WorkStatisticalMakeupArtist.cs 9.6 KB

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