WorkStatisticalBootDivision.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 WorkStatisticalBootDivision : LYFZ.Software.UI.StatisticalEmployeeWork.WorkStatisticalBootDivision
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. public WorkStatisticalBootDivision()
  15. {
  16. this.Load += WorkStatisticalBootDivision_Load;
  17. this.Shown += WorkStatisticalBootDivision_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 WorkStatisticalBootDivision_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 WorkStatisticalBootDivision_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 += " Ords_BootDivision 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 += " Ords_BootDivision like '%" + userNode.Tag + "%'";
  99. }
  100. }
  101. }
  102. else if (tBode.Name == "User")
  103. {
  104. if (strWhere != "")
  105. {
  106. strWhere += " or ";
  107. }
  108. strWhere += " Ords_BootDivision like '%" + tBode.Tag + "%'";
  109. //strWhere += tBode.Tag ;
  110. }
  111. if (string.IsNullOrEmpty(strWhere))
  112. {
  113. strWhere = " Ords_BootDivision = '-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. {
  127. MessageBoxCustom.Show("日期段不能为空"); return;
  128. }
  129. if (Convert.ToDateTime(this.dtDataTimeEnd.DateValue) < Convert.ToDateTime(this.dtDataTimeStart.DateValue))
  130. {
  131. MessageBoxCustom.Show("开始日期不能大于结束日期"); return;
  132. }
  133. if (string.IsNullOrEmpty(this.cmbtreevperson.Text.Trim()))
  134. {
  135. MessageBoxCustom.Show("引导师不能为空!"); return;
  136. }
  137. string StrWhere = "Ords_PhotographStatus = '1'";
  138. StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Ords_PhotographMaxTime", this.dtDataTimeStart.DateValue.Trim(), this.dtDataTimeEnd.DateValue.Trim());
  139. if (this.cmbtreevperson.Text.Trim() != "全部")
  140. {
  141. StrWhere += " And ("+ GetEmployeeDataInfo() + ") ";
  142. }
  143. else
  144. {
  145. StrWhere += " And Ords_BootDivision != ''";
  146. }
  147. DAL.DAL_ErpOrdersPhotography bLLErpOrdersPhotography = new DAL.DAL_ErpOrdersPhotography();
  148. DataTable dt = bLLErpOrdersPhotography.GetStatisticalPhotographerData(StrWhere, " Ords_BootDivision as 引导师 ");
  149. DataTable useDt = new BLL.BLL_ErpUser().GetAllList().Tables[0];
  150. foreach (DataRow dr in dt.Rows)
  151. {
  152. List<DataRow> useDr = useDt.AsEnumerable().Where(p => p.Field<string>("User_EmployeeID") == dr["引导师"].ToString_s()).ToList();
  153. if (useDr.Count > 0)
  154. {
  155. dr["引导师"] = useDr[0]["User_Name"];
  156. }
  157. }
  158. if (dt.Rows.Count > 0)
  159. {
  160. dt = dt.AsEnumerable().OrderByDescending(p => p.Field<string>("拍摄日期")).CopyToDataTable();
  161. }
  162. /*string StrTableName = "tb_ErpOrderDigital Left Join dbo.tb_ErpOrder on Ord_Number = Ordv_Number Left Join tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber " +
  163. "Left Join dbo.BView_OrderAmount on Order_Number = Ord_Number Left Join tb_ErpOrderDigitalStatus on Ords_ViceNumber = Ordv_ViceNumber";
  164. string StrColumnName = "Ord_SinceOrderNumber AS 订单号," +
  165. "dbo.fn_CheckOrderType(Ord_Type) AS 订单类型," +
  166. "Cus_Name AS 客户姓名," +
  167. "Cus_Sex_cs AS 客户性别," +
  168. "Cus_Telephone AS 客户电话," +
  169. "Ord_OrderPersonName AS 接单人," +
  170. "Ord_SeriesName AS 套系名称," +
  171. "Ord_SeriesPrice AS 套系价格," +
  172. "Ords_BootDivision AS 引导师," +
  173. "dbo.fn_CheckDateTime(Ords_PhotographMaxTime) AS 拍摄日期," +
  174. "Ords_SightsName AS 拍摄名称," +
  175. "Ords_PhotographStatus AS 拍照状态," +
  176. "(套系金额 + isnull(加挑金额,0) - isnull(收款金额,0)) AS 欠款 ";
  177. DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: StrWhere, ShowColumnName: StrColumnName).Tables[0];*/
  178. this.dgvData.DataSource(dt, strHideField: "");
  179. this.dgvData.Columns["客户电话"].Width = 180;
  180. this.dgvData.Columns["拍摄名称"].Width = 200;
  181. this.dgvData.Columns["拍摄日期"].Width = 110;
  182. this.dgvData.FillLastColumn(isAddNullColumns: true);
  183. string StrStatisticalText = "总数量:" + dt.Rows.Count;
  184. DataRow[] dtRow1 = dt.Select("订单类型 = '婚纱订单'");
  185. if (dtRow1.Length > 0)
  186. {
  187. StrStatisticalText += " 婚纱订单:" + dtRow1.Length;
  188. }
  189. DataRow[] dtRow2 = dt.Select("订单类型 = '儿童订单'");
  190. if (dtRow2.Length > 0)
  191. {
  192. StrStatisticalText += " 儿童订单:" + dtRow2.Length;
  193. }
  194. DataRow[] dtRow3 = dt.Select("订单类型 = '写真订单'");
  195. if (dtRow3.Length > 0)
  196. {
  197. StrStatisticalText += " 写真订单:" + dtRow3.Length;
  198. }
  199. // 套系价格列求和;
  200. try
  201. {
  202. double sumObject = Convert.ToDouble(dt.Compute("sum(套系价格)", "true"));
  203. StrStatisticalText += string.Format(" 套系总价:{0:N2}, 套系平均价:{1:N2}", sumObject, sumObject / dt.Rows.Count);
  204. }
  205. catch { }
  206. this.txtStatisticalText.Text = StrStatisticalText;
  207. }
  208. /// <summary>
  209. /// 导出
  210. /// </summary>
  211. /// <param name="sender"></param>
  212. /// <param name="e"></param>
  213. void btnExport_Click(object sender, EventArgs e)
  214. {
  215. this.dgvData.ExportDataTable(this.UcNavigationTool.LabTitle);
  216. }
  217. /// <summary>
  218. /// 关闭
  219. /// </summary>
  220. /// <param name="sender"></param>
  221. /// <param name="e"></param>
  222. void btnClose_Click(object sender, EventArgs e)
  223. {
  224. this.Close();
  225. }
  226. }
  227. }