frmFlowStatistic.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. namespace LYFZ.Software.MainBusiness.FlowStatistic
  7. {
  8. public class frmFlowStatistic : LYFZ.Software.FlowStatistic.frmFlowStatistic
  9. {
  10. #if DEBUG
  11. private const string url = "http://127.0.0.1?id1={0}&id2={1}&begin={2}&end={3}";
  12. #else
  13. private const string url = "http://statistic.lyfz.net:5080?id1={0}&id2={1}&begin={2}&end={3}";
  14. #endif
  15. // 企业id;
  16. static string strEnterpriseId = "";
  17. // 传片分店id;
  18. static string strTransBranchId = "";
  19. public frmFlowStatistic()
  20. {
  21. this.Load += frmFlowStatistic_Load;
  22. this.btn_Query.Click += btn_Query_Click;
  23. this.ck_QueryTime.CheckedChanged += ck_QueryTime_CheckedChanged;
  24. }
  25. void ck_QueryTime_CheckedChanged(object sender, EventArgs e)
  26. {
  27. if ( this.ck_QueryTime.Checked == true )
  28. {
  29. this.dt_StartTime.Enabled = true;
  30. this.dt_EndofTime.Enabled = true;
  31. this.btn_Query.Enabled = true;
  32. }
  33. else
  34. {
  35. this.dt_StartTime.Enabled = false;
  36. this.dt_EndofTime.Enabled = false;
  37. this.btn_Query.Enabled = false;
  38. }
  39. }
  40. void btn_Query_Click(object sender, EventArgs e)
  41. {
  42. System.DateTime dtStart = dt_StartTime.Value, dtEnding = dt_EndofTime.Value;
  43. if (dtStart.DayOfYear > dtEnding.DayOfYear)
  44. {
  45. MessageBoxCustom.Show("开始时间不能大于结束时间,请重新选择日期","提示");
  46. return;
  47. }
  48. LYFZ.Model.ReturnStatisticJson returnStatistic = null;
  49. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  50. {
  51. try
  52. {
  53. string strJson = LYFZ.WinAPI.HttpClientHelper.GetResponse(string.Format(url, strEnterpriseId, strTransBranchId, string.Format("{0:D}", dtStart), string.Format("{0:D}", dtEnding)));
  54. returnStatistic = Newtonsoft.Json.JsonConvert.DeserializeObject<LYFZ.Model.ReturnStatisticJson>(strJson);
  55. }
  56. catch (Exception ex)
  57. {
  58. }
  59. });
  60. if (returnStatistic != null)
  61. FillDataGridView(returnStatistic.ListRecord);
  62. }
  63. void frmFlowStatistic_Load(object sender, EventArgs e)
  64. {
  65. #region 获取本机的企业id和云传片id;
  66. LYFZ.BLL.BLL_ErpSystemConfigure sysConfigBll = new BLL.BLL_ErpSystemConfigure();
  67. strEnterpriseId = sysConfigBll.GetModelAPPInterface().AppEnId;
  68. string branchId;
  69. LYFZ.Network.PlatinumClientProcess.GetOssBranchId(out branchId);
  70. strTransBranchId = branchId;
  71. #endregion
  72. #region 若存在则直接获取
  73. LYFZ.Model.ReturnStatisticJson returnStatistic = null;
  74. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  75. {
  76. try
  77. {
  78. System.DateTime dtStart = System.DateTime.Now.Subtract(new TimeSpan(365, 0, 0, 0)), dtEnding = System.DateTime.Now;
  79. string strJson = LYFZ.WinAPI.HttpClientHelper.GetResponse(string.Format(url, strEnterpriseId, strTransBranchId, string.Format("{0:D}", dtStart), string.Format("{0:D}", dtEnding)));
  80. returnStatistic = Newtonsoft.Json.JsonConvert.DeserializeObject<LYFZ.Model.ReturnStatisticJson>(strJson);
  81. }
  82. catch (Exception ex)
  83. {
  84. }
  85. });
  86. if ( returnStatistic != null)
  87. FillDataGridView(returnStatistic.ListRecord);
  88. // 年费;
  89. tx_AnnualFee.Text = returnStatistic.AnnualFee.ToString();
  90. tx_Balance.Text = returnStatistic.Balance.ToString();
  91. tx_TransBalance.Text = returnStatistic.TransBalance.ToString();
  92. tx_Trans_Expire_Date.Text = returnStatistic.TransExpireDate.ToString();
  93. #endregion
  94. // 设置默认时间,最后一天不能超过28号(2月最小号28号);
  95. dt_StartTime.Value = LYFZ.SDateTime.FirstDayOfMonth(DateTime.Now);
  96. dt_EndofTime.Value = LYFZ.SDateTime.FirstDayOfMonth(DateTime.Now);
  97. #region 禁用按钮
  98. this.ck_QueryTime.Checked = false;
  99. this.dt_StartTime.Enabled = false;
  100. this.dt_EndofTime.Enabled = false;
  101. this.btn_Query.Enabled = false;
  102. #endregion
  103. // 初始化时间控件的显示格式;
  104. dt_StartTime.Format = DateTimePickerFormat.Custom;
  105. dt_EndofTime.Format = DateTimePickerFormat.Custom;
  106. dt_StartTime.CustomFormat = "yyyy年MM月";
  107. dt_EndofTime.CustomFormat = "yyyy年MM月";
  108. }
  109. public void FillDataGridView(List<LYFZ.Model.StatisticFlow> listRecord)
  110. {
  111. if ( listRecord != null)
  112. {
  113. // 清空列表;
  114. this.dgv_Statistic.Rows.Clear();
  115. foreach (LYFZ.Model.StatisticFlow sf in listRecord)
  116. {
  117. DataGridViewRow dgvRow = new DataGridViewRow();
  118. dgvRow.CreateCells(this.dgv_Statistic);
  119. dgvRow.Tag = sf;
  120. dgvRow.Cells[0].Value = sf.ErpFlows;
  121. dgvRow.Cells[1].Value = sf.MobileFlows;
  122. dgvRow.Cells[2].Value = sf.TransFlows;
  123. dgvRow.Cells[3].Value = sf.StatisticDate;
  124. this.dgv_Statistic.Rows.Add(dgvRow);
  125. }
  126. }
  127. }
  128. }
  129. }