WorkStatisticalDesign.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 WorkStatisticalDesign : LYFZ.Software.UI.StatisticalEmployeeWork.WorkStatisticalDesign
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. public WorkStatisticalDesign()
  15. {
  16. this.Load += WorkStatisticalDesign_Load;
  17. this.Shown += WorkStatisticalDesign_Shown;
  18. this.dtDataTimeStart.Leave += dtDataTimeStart_Leave;
  19. this.btnQuery.Click += btnQuery_Click;
  20. this.btnExport.Click += btnExport_Click;
  21. this.btnClose.Click += btnClose_Click;
  22. }
  23. /// <summary>
  24. /// 窗体加载事件
  25. /// </summary>
  26. /// <param name="sender"></param>
  27. /// <param name="e"></param>
  28. void WorkStatisticalDesign_Load(object sender, EventArgs e)
  29. {
  30. this.dtDataTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM") + "-01";
  31. this.dtDataTimeEnd.DateValue = Convert.ToDateTime(this.dtDataTimeStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
  32. }
  33. /// <summary>
  34. /// 窗体加载事件
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="e"></param>
  38. void WorkStatisticalDesign_Shown(object sender, EventArgs e)
  39. {
  40. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbtreevperson, true, IsFirstNodeName: "全部", IsShowResign: false);
  41. cmbtreevperson.IsNodeMouseClick = true;
  42. cmbtreevperson.IsSelectParentNode = true;
  43. this.cmbtreevperson.TextFindTag("全部");
  44. this.btnQuery_Click(this, null);
  45. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.工作统计);
  46. if (!b)
  47. {
  48. this.Close();
  49. }
  50. }
  51. /// <summary>
  52. /// 开始日期离开事件
  53. /// </summary>
  54. /// <param name="sender"></param>
  55. /// <param name="e"></param>
  56. void dtDataTimeStart_Leave(object sender, EventArgs e)
  57. {
  58. this.dtDataTimeEnd.DateValue = Convert.ToDateTime(this.dtDataTimeStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
  59. }
  60. /// <summary>
  61. /// 获取员工编号
  62. /// </summary>
  63. /// <returns></returns>
  64. string GetEmployeeDataInfo()
  65. {
  66. string strWhere = "";
  67. TreeNode tBode = this.cmbtreevperson.SelectedNode;
  68. if (tBode.Name == "StoreName")
  69. {
  70. if (tBode.Nodes.Count > 0)
  71. {
  72. foreach (TreeNode node in tBode.Nodes)
  73. {
  74. if (node.Nodes.Count > 0)
  75. {
  76. foreach (TreeNode userNode in node.Nodes)
  77. {
  78. if (strWhere != "")
  79. {
  80. strWhere += " or ";
  81. }
  82. strWhere += " Ordv_DesignerName like '%" + userNode.Tag + "%'";
  83. }
  84. }
  85. }
  86. }
  87. }
  88. else if (tBode.Name == "Department")
  89. {
  90. if (tBode.Nodes.Count > 0)
  91. {
  92. foreach (TreeNode userNode in tBode.Nodes)
  93. {
  94. if (strWhere != "")
  95. {
  96. strWhere += " or ";
  97. }
  98. strWhere += " Ordv_DesignerName like '%" + userNode.Tag + "%'";
  99. }
  100. }
  101. }
  102. else if (tBode.Name == "User")
  103. {
  104. if (strWhere != "")
  105. {
  106. strWhere += " or ";
  107. }
  108. strWhere += " Ordv_DesignerName like '%" + tBode.Tag + "%'";
  109. //strWhere += tBode.Tag ;
  110. }
  111. if (string.IsNullOrEmpty(strWhere))
  112. {
  113. strWhere = " Ordv_DesignerName = '-1'";
  114. }
  115. //strDepartment = "'" + string.Join("','", department.ToArray()) + "'";
  116. return strWhere;
  117. }
  118. /// <summary>
  119. /// 查询
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. void btnQuery_Click(object sender, EventArgs e)
  124. {
  125. if (string.IsNullOrEmpty(this.dtDataTimeStart.DateValue.Trim()) && string.IsNullOrEmpty(this.dtDataTimeEnd.DateValue.Trim()))
  126. { MessageBoxCustom.Show("日期段不能为空"); return; }
  127. if (Convert.ToDateTime(this.dtDataTimeEnd.DateValue) < Convert.ToDateTime(this.dtDataTimeStart.DateValue))
  128. { MessageBoxCustom.Show("开始日期不能大于结束日期"); return; }
  129. if (string.IsNullOrEmpty(this.cmbtreevperson.Text.Trim()))
  130. { MessageBoxCustom.Show("设计师不能为空!"); return; }
  131. string StrWhere = "Ordv_DesignerStatus = '2' And Ordv_DesignerName != ''";
  132. StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Ordv_DesignerTime", this.dtDataTimeStart.DateValue.Trim(), this.dtDataTimeEnd.DateValue.Trim());
  133. if (this.cmbtreevperson.Text.Trim() != "全部")
  134. { StrWhere += " And ("+ GetEmployeeDataInfo() + ") "; }
  135. DAL.DAL_ErpOrdersPhotography bLLErpOrdersPhotography = new DAL.DAL_ErpOrdersPhotography();
  136. DataTable dt = bLLErpOrdersPhotography.GetStatisticalRepairPieceData(StrWhere, "dbo.fn_CheckUserIDGetUserName(Ordv_DesignerName) AS 设计师" +
  137. ",dbo.fn_CheckDateTime(Ordv_DesignerTime) AS 设计日期" +
  138. ",dbo.fn_CheckOrderEarlyRepairStatus(Ordv_DesignerStatus) AS 设计状态");
  139. if (dt.Rows.Count > 0)
  140. {
  141. dt = dt.AsEnumerable().OrderByDescending(p => p.Field<string>("设计日期")).CopyToDataTable();
  142. }
  143. /*string StrTableName = "tb_ErpOrderDigital Left Join dbo.tb_ErpOrder on Ord_Number = Ordv_Number Left Join tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber " +
  144. "Left Join dbo.BView_OrderAmount on Order_Number = Ord_Number Left Join tb_ErpOrderDigitalStatus on Ords_ViceNumber = Ordv_ViceNumber";
  145. string StrColumnName = "Ord_SinceOrderNumber AS 订单号" +
  146. ",dbo.fn_CheckOrderType(Ord_Type) AS 订单类型" +
  147. ",Cus_Name AS 客户姓名" +
  148. ",Cus_Sex_cs AS 客户性别" +
  149. ",Cus_Telephone AS 客户电话" +
  150. ",Ord_OrderPersonName AS 接单人" +
  151. ",Ord_SeriesName AS 套系名称" +
  152. ",Ord_SeriesPrice AS 套系价格" +
  153. ",dbo.fn_CheckUserIDGetUserName(Ordv_DesignerName) AS 设计师" +
  154. ",dbo.fn_CheckDateTime(Ordv_DesignerTime) AS 设计日期" +
  155. ",Ords_SightsName AS 拍摄名称" +
  156. ",dbo.fn_CheckOrderDesignerStatus(Ordv_DesignerStatus) AS 设计状态" +
  157. ",(套系金额 + isnull(加挑金额,0) - isnull(收款金额,0)) AS 欠款";
  158. DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: StrWhere, ShowColumnName: StrColumnName).Tables[0];*/
  159. this.dgvData.DataSource(dt, strHideField: "Ordv_ViceNumber");
  160. this.dgvData.Columns["客户电话"].Width = 180;
  161. this.dgvData.Columns["拍摄名称"].Width = 200;
  162. this.dgvData.Columns["设计日期"].Width = 110;
  163. this.dgvData.FillLastColumn(isAddNullColumns: true);
  164. string StrStatisticalText = "总数量:" + dt.Rows.Count;
  165. DataRow[] dtRow1 = dt.Select("订单类型 = '婚纱订单'");
  166. if (dtRow1.Length > 0)
  167. { StrStatisticalText += " 婚纱订单:" + dtRow1.Length; }
  168. DataRow[] dtRow2 = dt.Select("订单类型 = '儿童订单'");
  169. if (dtRow2.Length > 0)
  170. { StrStatisticalText += " 儿童订单:" + dtRow2.Length; }
  171. DataRow[] dtRow3 = dt.Select("订单类型 = '写真订单'");
  172. if (dtRow3.Length > 0)
  173. { StrStatisticalText += " 写真订单:" + dtRow3.Length; }
  174. // 套系价格列求和;
  175. try
  176. {
  177. double sumObject = Convert.ToDouble(dt.Compute("sum(套系价格)", "true"));
  178. StrStatisticalText += string.Format(" 套系总价:{0:N2}, 套系平均价:{1:N2}", sumObject, sumObject / dt.Rows.Count);
  179. }
  180. catch { }
  181. this.txtStatisticalText.Text = StrStatisticalText;
  182. }
  183. /// <summary>
  184. /// 导出
  185. /// </summary>
  186. /// <param name="sender"></param>
  187. /// <param name="e"></param>
  188. void btnExport_Click(object sender, EventArgs e)
  189. {
  190. this.dgvData.ExportDataTable(this.UcNavigationTool.LabTitle);
  191. }
  192. /// <summary>
  193. /// 关闭
  194. /// </summary>
  195. /// <param name="sender"></param>
  196. /// <param name="e"></param>
  197. void btnClose_Click(object sender, EventArgs e)
  198. {
  199. this.Close();
  200. }
  201. }
  202. }