WorkStatisticalRepairPiece.cs 12 KB

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