123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.FlowStatistic
- {
- public class frmFlowStatistic : LYFZ.Software.FlowStatistic.frmFlowStatistic
- {
- #if DEBUG
- private const string url = "http://127.0.0.1?id1={0}&id2={1}&begin={2}&end={3}";
- #else
- private const string url = "http://statistic.lyfz.net:5080?id1={0}&id2={1}&begin={2}&end={3}";
- #endif
- // 企业id;
- static string strEnterpriseId = "";
- // 传片分店id;
- static string strTransBranchId = "";
- public frmFlowStatistic()
- {
- this.Load += frmFlowStatistic_Load;
- this.btn_Query.Click += btn_Query_Click;
- this.ck_QueryTime.CheckedChanged += ck_QueryTime_CheckedChanged;
- }
- void ck_QueryTime_CheckedChanged(object sender, EventArgs e)
- {
- if ( this.ck_QueryTime.Checked == true )
- {
- this.dt_StartTime.Enabled = true;
- this.dt_EndofTime.Enabled = true;
- this.btn_Query.Enabled = true;
- }
- else
- {
- this.dt_StartTime.Enabled = false;
- this.dt_EndofTime.Enabled = false;
- this.btn_Query.Enabled = false;
- }
- }
- void btn_Query_Click(object sender, EventArgs e)
- {
- System.DateTime dtStart = dt_StartTime.Value, dtEnding = dt_EndofTime.Value;
- if (dtStart.DayOfYear > dtEnding.DayOfYear)
- {
- MessageBoxCustom.Show("开始时间不能大于结束时间,请重新选择日期","提示");
- return;
- }
- LYFZ.Model.ReturnStatisticJson returnStatistic = null;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- try
- {
- string strJson = LYFZ.WinAPI.HttpClientHelper.GetResponse(string.Format(url, strEnterpriseId, strTransBranchId, string.Format("{0:D}", dtStart), string.Format("{0:D}", dtEnding)));
- returnStatistic = Newtonsoft.Json.JsonConvert.DeserializeObject<LYFZ.Model.ReturnStatisticJson>(strJson);
- }
- catch (Exception ex)
- {
- }
- });
- if (returnStatistic != null)
- FillDataGridView(returnStatistic.ListRecord);
- }
- void frmFlowStatistic_Load(object sender, EventArgs e)
- {
- #region 获取本机的企业id和云传片id;
- LYFZ.BLL.BLL_ErpSystemConfigure sysConfigBll = new BLL.BLL_ErpSystemConfigure();
- strEnterpriseId = sysConfigBll.GetModelAPPInterface().AppEnId;
- string branchId;
- LYFZ.Network.PlatinumClientProcess.GetOssBranchId(out branchId);
- strTransBranchId = branchId;
- #endregion
- #region 若存在则直接获取
- LYFZ.Model.ReturnStatisticJson returnStatistic = null;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- try
- {
- System.DateTime dtStart = System.DateTime.Now.Subtract(new TimeSpan(365, 0, 0, 0)), dtEnding = System.DateTime.Now;
- string strJson = LYFZ.WinAPI.HttpClientHelper.GetResponse(string.Format(url, strEnterpriseId, strTransBranchId, string.Format("{0:D}", dtStart), string.Format("{0:D}", dtEnding)));
- returnStatistic = Newtonsoft.Json.JsonConvert.DeserializeObject<LYFZ.Model.ReturnStatisticJson>(strJson);
- }
- catch (Exception ex)
- {
- }
- });
- if ( returnStatistic != null)
- FillDataGridView(returnStatistic.ListRecord);
- // 年费;
- tx_AnnualFee.Text = returnStatistic.AnnualFee.ToString();
- tx_Balance.Text = returnStatistic.Balance.ToString();
- tx_TransBalance.Text = returnStatistic.TransBalance.ToString();
- tx_Trans_Expire_Date.Text = returnStatistic.TransExpireDate.ToString();
- #endregion
- // 设置默认时间,最后一天不能超过28号(2月最小号28号);
- dt_StartTime.Value = LYFZ.SDateTime.FirstDayOfMonth(DateTime.Now);
- dt_EndofTime.Value = LYFZ.SDateTime.FirstDayOfMonth(DateTime.Now);
- #region 禁用按钮
- this.ck_QueryTime.Checked = false;
- this.dt_StartTime.Enabled = false;
- this.dt_EndofTime.Enabled = false;
- this.btn_Query.Enabled = false;
- #endregion
- // 初始化时间控件的显示格式;
- dt_StartTime.Format = DateTimePickerFormat.Custom;
- dt_EndofTime.Format = DateTimePickerFormat.Custom;
- dt_StartTime.CustomFormat = "yyyy年MM月";
- dt_EndofTime.CustomFormat = "yyyy年MM月";
- }
- public void FillDataGridView(List<LYFZ.Model.StatisticFlow> listRecord)
- {
- if ( listRecord != null)
- {
- // 清空列表;
- this.dgv_Statistic.Rows.Clear();
- foreach (LYFZ.Model.StatisticFlow sf in listRecord)
- {
- DataGridViewRow dgvRow = new DataGridViewRow();
- dgvRow.CreateCells(this.dgv_Statistic);
- dgvRow.Tag = sf;
- dgvRow.Cells[0].Value = sf.ErpFlows;
- dgvRow.Cells[1].Value = sf.MobileFlows;
- dgvRow.Cells[2].Value = sf.TransFlows;
- dgvRow.Cells[3].Value = sf.StatisticDate;
- this.dgv_Statistic.Rows.Add(dgvRow);
- }
- }
- }
- }
- }
|