WorkStatisticalDayFilmSelectionToProductComplete.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.StatisticalEmployeeWork
  10. {
  11. public partial class WorkStatisticalDayFilmSelectionToProductComplete : LYFZ.Software.UI.StatisticalEmployeeWork.WorkStatisticalDayFilmSelectionToProductComplete
  12. {
  13. public WorkStatisticalDayFilmSelectionToProductComplete()
  14. {
  15. this.Load += WorkStatisticalDayFilmSelectionToProductComplete_Load;
  16. this.btnQuery.Click += btnQuery_Click;
  17. this.btnClose.Click += btnClose_Click;
  18. this.dgvData.ColumnHeaderMouseClick += dgvData_ColumnHeaderMouseClick;
  19. }
  20. /// <summary>
  21. /// 员工编号
  22. /// </summary>
  23. string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  24. /// <summary>
  25. /// 窗体加载事件
  26. /// </summary>
  27. /// <param name="sender"></param>
  28. /// <param name="e"></param>
  29. void WorkStatisticalDayFilmSelectionToProductComplete_Load(object sender, EventArgs e)
  30. {
  31. this.dtDateTimeEnd.DateValue = SDateTime.Now.ToString("yyyy-MM-dd");
  32. this.dtDateTimeStart.DateValue = Convert.ToDateTime(this.dtDateTimeEnd.DateValue).AddMonths(-3).ToString("yyyy-MM-01");
  33. // 部门人员绑定
  34. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cbxTreeViewDepartment, IsFirstNodeNull: true, IsFirstNodeName: "全部", IsShowResign: false, IsShowAdmin: true, tb_User: LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable);
  35. this.cbxTreeViewDepartment.TextFindTag("全部");
  36. this.PublicFunctionRows();
  37. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.工作统计);
  38. if (!b)
  39. {
  40. this.Close();
  41. }
  42. }
  43. /// <summary>
  44. /// 查询
  45. /// </summary>
  46. /// <param name="sender"></param>
  47. /// <param name="e"></param>
  48. void btnQuery_Click(object sender, EventArgs e)
  49. {
  50. this.PublicFunctionRows();
  51. }
  52. /// <summary>
  53. /// 关闭
  54. /// </summary>
  55. /// <param name="sender"></param>
  56. /// <param name="e"></param>
  57. void btnClose_Click(object sender, EventArgs e)
  58. {
  59. this.Close();
  60. }
  61. /// <summary>
  62. /// 列表标题的点击事件
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. void dgvData_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  67. {
  68. string StrColumnName = this.dgvData.Columns[e.ColumnIndex].Name.Trim();
  69. if (StrColumnName == this.StrCurrentClickField || string.IsNullOrEmpty(this.StrCurrentClickField))
  70. {
  71. if (this.StrSortOrder == "ASC")
  72. {
  73. this.StrSortOrder = "DESC";
  74. }
  75. else
  76. {
  77. this.StrSortOrder = "ASC";
  78. }
  79. }
  80. else
  81. {
  82. this.StrSortOrder = "DESC";
  83. }
  84. this.StrSortField = StrColumnName + " " + this.StrSortOrder + "";
  85. this.StrCurrentClickField = StrColumnName;
  86. DataRow[] dtRows = this.newTable.Select("1 = 1", StrColumnName + " " + StrSortOrder);
  87. this.PublicFunctionRows(dtRows);
  88. }
  89. /// <summary>
  90. /// 当前点击的字段
  91. /// </summary>
  92. string StrCurrentClickField = "";
  93. /// <summary>
  94. /// 排序字段
  95. /// </summary>
  96. string StrSortField = "DATEDIFF(day, Ordv_FilmSelectionTime, Ords_ProductCompletedTime) DESC";
  97. /// <summary>
  98. /// 排序顺序
  99. /// </summary>
  100. string StrSortOrder = "DESC";
  101. DataTable newTable = new DataTable();
  102. /// <summary>
  103. /// 创建行
  104. /// </summary>
  105. void PublicFunctionRows()
  106. {
  107. if (string.IsNullOrEmpty(this.dtDateTimeStart.DateValue.Trim()) && string.IsNullOrEmpty(this.dtDateTimeEnd.DateValue.Trim()))
  108. {
  109. MessageBoxCustom.Show("日期段不能为空"); return;
  110. }
  111. if (Convert.ToDateTime(this.dtDateTimeEnd.DateValue) < Convert.ToDateTime(this.dtDateTimeStart.DateValue))
  112. {
  113. MessageBoxCustom.Show("开始日期不能大于结束日期"); return;
  114. }
  115. this.dgvData.dgvCurrentColumnOriginalSet = "Ord_Number,Ordv_ViceNumber,订单号,订单类型,客户姓名,客户性别,客户电话,套系名称,套系价格,拍摄名称,选片师,选片时间,选片状态,商品完成时间,用时(天)";
  116. string StrGuidName = LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0007.ToString().Trim();
  117. this.dgvData.dgvFixedHideColumn = "Ord_Number,Ordv_ViceNumber";
  118. this.dgvData.dgvGuidName = StrGuidName;
  119. this.dgvData.dgvUserEmployeeID = this.StrUserID;
  120. this.dgvData.StrValueNullColumn = "订单号,客户姓名,客户性别,客户电话,订单类型,接单人,套系名称,套系价格,会员卡号";
  121. this.dgvData.StrSecondStageNull = "加急,加急日期,拍摄名称,拍照状态,设计状态,设计师,设计日期,看版状态,看版师,看版日期,取件状态";
  122. Dictionary<string, string> dictColumns = LYFZ.DAL.DAL_GridViewDisplayIndex.GetdictColumns(this.dgvData.dgvCurrentColumnOriginalSet);
  123. this.dgvData.dictShowColumName = dictColumns;
  124. string StrQueryCondition = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Ords_ProductCompletedTime", this.dtDateTimeStart.DateValue.Trim(), this.dtDateTimeEnd.DateValue.Trim());
  125. ItemValue itemValue = GetCompanyDataInfo();
  126. int intTopCount = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();
  127. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  128. {
  129. this.newTable = LYFZ.BLL.BLL_ErpOrderView.GetData_WorkStatistical_FilmSelectionToProductComplete(dictColumns, StrQueryCondition, "Order By " + this.StrSortField, itemValue.Text, itemValue.Value.ToString_s());
  130. });
  131. if (this.newTable.Rows.Count > 0)
  132. {
  133. this.PublicFunctionRows(this.newTable.Select());
  134. }
  135. else
  136. {
  137. this.dgvData.DataColumns(this.dgvData.dgvCurrentColumnOriginalSet, strHideField: this.dgvData.dgvFixedHideColumn);
  138. }
  139. string strText = string.Format("订单数量:{0} ", this.newTable.Rows.Count);
  140. // 套系价格列求和;
  141. try
  142. {
  143. double sumObject = 0.0f;// Convert.ToDouble(this.newTable.Compute("sum(cast('套系价格' as float))", "true"));
  144. foreach ( DataRow dr in this.newTable.Rows )
  145. {
  146. sumObject += Convert.ToDouble(dr["套系价格"].ToString());
  147. }
  148. strText += string.Format(" 套系总价:{0:N2}, 套系平均价:{1:N2}", sumObject, sumObject / this.newTable.Rows.Count);
  149. }
  150. catch (Exception e) {
  151. }
  152. this.txtStatisticalText.Text = strText;
  153. }
  154. /// <summary>
  155. /// 处理数据
  156. /// </summary>
  157. /// <param name="dtRows"></param>
  158. void PublicFunctionRows(DataRow[] dtRows)
  159. {
  160. this.dgvData.DataColumns(this.newTable.Columns, strHideField: this.dgvData.dgvFixedHideColumn);
  161. this.dgvData.FillLastColumn();
  162. DataGridViewRow dgvr = null;
  163. DataGridViewCell cell = null;
  164. for (int i = 0; i < dtRows.Length; i++)
  165. {
  166. dgvr = new DataGridViewRow();
  167. for (int j = 0; j < this.newTable.Columns.Count; j++)
  168. {
  169. cell = new DataGridViewTextBoxCell();
  170. cell.Value = dtRows[i][this.newTable.Columns[j].ColumnName.Trim()].ToString().Trim();
  171. dgvr.Cells.Add(cell);
  172. }
  173. this.dgvData.Rows.Add(dgvr);
  174. }
  175. this.dgvData.Columns["客户姓名"].Frozen = true;
  176. this.dgvData.Columns["套系名称"].Width = 180;
  177. this.dgvData.Columns["选片时间"].Width = 120;
  178. this.dgvData.Columns["商品完成时间"].Width = 120;
  179. this.dgvData.ClearSelection();
  180. }
  181. /// <summary>
  182. /// 获取数据
  183. /// </summary>
  184. /// <returns></returns>
  185. ItemValue GetCompanyDataInfo()
  186. {
  187. ItemValue itemValue = new ItemValue("", "");
  188. if (this.cbxTreeViewDepartment.Tag != null && this.cbxTreeViewDepartment.TreeView.SelectedNode != null)
  189. {
  190. string dataValue = this.cbxTreeViewDepartment.Tag.ToString();
  191. string dataType = this.cbxTreeViewDepartment.StrGetName.Trim();
  192. itemValue.Text = dataType;
  193. itemValue.Value = dataValue;
  194. if (dataType.Length > 0)
  195. {
  196. switch (dataType.ToLower())
  197. {
  198. case "storename":
  199. break;
  200. case "department":
  201. itemValue.Value = dataValue ;
  202. break;
  203. case "user":
  204. itemValue.Value = dataValue ;
  205. break;
  206. }
  207. }
  208. }
  209. return itemValue;
  210. }
  211. }
  212. }