OrderControlFormMain.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.CameraControlBook
  11. {
  12. public partial class OrderControlFormMain : LYFZ.Software.UI.CameraControlBook.OrderControlFormMain
  13. {
  14. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  15. public OrderControlFormMain()
  16. {
  17. this.Load += OrderControlFormMain_Load;
  18. this.Shown += OrderControlFormMain_Shown;
  19. this.btnQuery.Click += btnQuery_Click;
  20. this.btnExport.Click += btnExport_Click;
  21. this.btnCloses.Click += btnCloses_Click;
  22. this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
  23. this.dgvData.EventRowExpandCollapse += dgvData_EventRowExpandCollapse;
  24. }
  25. /// <summary>
  26. /// 窗体加载事件
  27. /// </summary>
  28. /// <param name="sender"></param>
  29. /// <param name="e"></param>
  30. void OrderControlFormMain_Load(object sender, EventArgs e)
  31. {
  32. string StrColumnName = "订单号,订单类型,分店,客户姓名,客户拼音,客户性别,客户电话,预约拍照日期,完成状态,取件状态";
  33. this.dgvData.DataColumns(StrColumns: StrColumnName);
  34. }
  35. /// <summary>
  36. /// 窗体加载事件
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="e"></param>
  40. void OrderControlFormMain_Shown(object sender, EventArgs e)
  41. {
  42. this.PublicFunctionRows();
  43. }
  44. /// <summary>
  45. /// 查询
  46. /// </summary>
  47. /// <param name="sender"></param>
  48. /// <param name="e"></param>
  49. void btnQuery_Click(object sender, EventArgs e)
  50. {
  51. this.PublicFunctionRows();
  52. }
  53. /// <summary>
  54. ///
  55. /// </summary>
  56. /// <param name="sender"></param>
  57. /// <param name="e"></param>
  58. void btnExport_Click(object sender, EventArgs e)
  59. {
  60. if (this.dgvData.Rows.Count > 0)
  61. {
  62. string StrtableName = this.tabControlEx1.SelectedTab.Text.Trim();
  63. this.dgvData.ExportDataTable(StrtableName);
  64. }
  65. }
  66. /// <summary>
  67. /// 关闭
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. void btnCloses_Click(object sender, EventArgs e)
  72. {
  73. this.Close();
  74. }
  75. /// <summary>
  76. /// 选项卡选择事件
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="e"></param>
  80. void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
  81. {
  82. this.PublicFunctionRows();
  83. }
  84. /// <summary>
  85. /// 分页前数据,便于展开时用来查询订单的子数据
  86. /// </summary>
  87. DataTable tblMianSelectData = new DataTable();
  88. /// <summary>
  89. /// 创建行
  90. /// </summary>
  91. void PublicFunctionRows()
  92. {
  93. int intViceCount = 1;
  94. switch (this.tabControlEx1.SelectedTab.Name.Trim())
  95. {
  96. case "tabPage_ExpiredReservationPhotographyNotPhotography":
  97. intViceCount = 2;
  98. break;
  99. }
  100. tblMianSelectData = new DataTable();
  101. tblMianSelectData = orbll.GetView_Custom(this.GetTableName()).Tables[0];
  102. this.dgvData.ViceCount = intViceCount;
  103. this.dgvData.DataSourceMain(tblMianSelectData, strHideField: "PID,Ord_Number,Ord_ViceOrderCount");
  104. this.dgvData.FillLastColumn(isAddNullColumns: true);
  105. Hashtable htData = new Hashtable();
  106. for (int i = 0; i < tblMianSelectData.Rows.Count; i++)
  107. { htData[tblMianSelectData.Rows[i]["Ord_Number"].ToString().Trim()] = tblMianSelectData.Rows[i]["Ord_Number"].ToString().Trim(); }
  108. this.dataGridViewStatisticsCount1.LocationX = this.dgvData.RowHeadersWidth;
  109. this.dataGridViewStatisticsCount1.CurrenQuantity = htData.Count;
  110. this.dataGridViewStatisticsCount1.TotalQuantity = htData.Count;
  111. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.客服中心已过预约把控);
  112. if (!b)
  113. {
  114. this.Close();
  115. }
  116. }
  117. /// <summary>
  118. /// 获取视图表
  119. /// </summary>
  120. /// <returns></returns>
  121. string GetTableName()
  122. {
  123. string StrWhere = "";
  124. string StrTableName = "";
  125. if (!string.IsNullOrEmpty(this.txtQuery.Text.Trim()))
  126. { StrWhere = "Where (订单号 like '%" + this.txtQuery.Text.Trim() + "%' or 客户姓名 like '%" + this.txtQuery.Text.Trim() + "%' or 客户拼音 like '%" + this.txtQuery.Text.Trim() + "%' or 客户电话 like '%" + this.txtQuery.Text.Trim() + "%')"; }
  127. switch (this.tabControlEx1.SelectedTab.Name.Trim())
  128. {
  129. case "tabPage_ExpiredReservationPhotographyNotPhotography":
  130. StrTableName = "with t AS ( " +
  131. "select Max(ID) AS PID,Ordpg_Number,Ordpg_ViceNumber,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS Ordpg_ReservationPhotographyTime,Ordpg_PhotographyStatus " +
  132. "from tb_ErpOrdersPhotography " +
  133. "where Ordpg_PhotographyStatus != '1' And Ordpg_ReservationPhotographyTime is not null And Ordpg_ViceNumber != '' " +
  134. "Group By Ordpg_Number,Ordpg_ViceNumber,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)),Ordpg_PhotographyStatus " +
  135. ") " +
  136. ", t1 AS( " +
  137. "select PID,Ord_Number,Ordpg_ViceNumber,Ord_DividedShop, " +
  138. "CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号, " +
  139. "dbo.fn_CheckOrderType(Ord_Type) AS 订单类型, " +
  140. "Company_Name AS 分店, " +
  141. "Cus_Name AS 客户姓名, " +
  142. "Cus_Name_py AS 客户拼音, " +
  143. "Cus_Sex_cs AS 客户性别, " +
  144. "Cus_Telephone AS 客户电话, " +
  145. "Ordpg_ReservationPhotographyTime AS 预约拍照日期, " +
  146. "dbo.fn_CheckOrderPhotographyStatus(t.Ordpg_PhotographyStatus) AS 拍摄状态, " +
  147. "(SELECT Count(Ordpg_ViceNumber) AS CountID FROM t AS tt WHERE tt.Ordpg_ViceNumber = t.Ordpg_ViceNumber) AS Ord_ViceOrderCount " +
  148. "from t " +
  149. "Left Join tb_ErpOrder on Ord_Number = t.Ordpg_Number " +
  150. "Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
  151. "Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
  152. "where Ord_Number is not null And convert(datetime,Ordpg_ReservationPhotographyTime,120) < GETDATE() " +
  153. ") " +
  154. "select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约拍照日期,拍摄状态,Ord_ViceOrderCount " +
  155. "from t1 " + StrWhere + " " +
  156. "order by Ordpg_ViceNumber,预约拍照日期";
  157. break;
  158. case "tabPage_ExpiredReservationLookDesignNotLookDesign":
  159. StrTableName = "with t AS( " +
  160. "select tb_ErpOrderDigital.ID AS PID, " +
  161. "Ord_Number, " +
  162. "Ordv_ViceNumber, " +
  163. "Ord_DividedShop, " +
  164. "CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号, " +
  165. "dbo.fn_CheckOrderType(Ord_Type) AS 订单类型, " +
  166. "Company_Name AS 分店, " +
  167. "Cus_Name AS 客户姓名, " +
  168. "Cus_Name_py AS 客户拼音, " +
  169. "Cus_Sex_cs AS 客户性别, " +
  170. "Cus_Telephone AS 客户电话, " +
  171. "dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationLookDesignTime)) AS 预约看版日期, " +
  172. "dbo.fn_CheckOrderLookDesignStatus(Ordv_LookDesignStatus) AS 看版状态, " +
  173. "(SELECT Count(Ordv_ViceNumber) AS CountID FROM tb_ErpOrderDigital AS tt WHERE tt.Ordv_ViceNumber = tb_ErpOrderDigital.Ordv_ViceNumber) AS Ord_ViceOrderCount " +
  174. "from tb_ErpOrderDigital " +
  175. "Left Join tb_ErpOrder on Ord_Number = Ordv_Number " +
  176. "Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
  177. "Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
  178. "where Ord_Number is not null And Ordv_LookDesignStatus != '1' And convert(datetime,Ordv_ReservationLookDesignTime,120) < GETDATE() " +
  179. ") " +
  180. "select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约看版日期,看版状态,Ord_ViceOrderCount " +
  181. "from t " + StrWhere + " " +
  182. "order by Ordv_ViceNumber,预约看版日期";
  183. break;
  184. case "tabPage_ExpiredReservationPickupNotComplete":
  185. StrTableName = "with t AS " +
  186. "(" +
  187. "select " +
  188. "Max(ID) AS PID," +
  189. "OPlist_ViceNumber," +
  190. "dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS OPlist_ReservationTakeTime," +
  191. "OPlist_CompletedStatus," +
  192. "OPlist_PickupStatus " +
  193. "from tb_ErpOrderProductList " +
  194. "where OPlist_Type = '2' And OPlist_ReservationTakeTime is not null And OPlist_PickupStatus = '0' And OPlist_CompletedStatus = '0' And OPlist_ViceNumber != '' " +
  195. "Group By OPlist_ViceNumber,OPlist_CompletedStatus,OPlist_PickupStatus,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime))" +
  196. ")" +
  197. ", t1 AS " +
  198. "(" +
  199. "select " +
  200. "PID," +
  201. "Ord_Number," +
  202. "Ordv_ViceNumber," +
  203. "Ord_DividedShop," +
  204. "CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号," +
  205. "dbo.fn_CheckOrderType(Ord_Type) AS 订单类型," +
  206. "Company_Name AS 分店," +
  207. "Cus_Name AS 客户姓名," +
  208. "Cus_Name_py AS 客户拼音," +
  209. "Cus_Sex_cs AS 客户性别," +
  210. "Cus_Telephone AS 客户电话," +
  211. "OPlist_ReservationTakeTime AS 预约取件日期," +
  212. "dbo.fn_CheckProductCompletedStatus(t.OPlist_CompletedStatus) AS 完成状态," +
  213. "dbo.fn_CheckProductTakePiecesStatus(t.OPlist_PickupStatus) AS 取件状态," +
  214. "(SELECT Count(OPlist_ViceNumber) AS CountID FROM t AS tt WHERE tt.OPlist_ViceNumber = Ordv_ViceNumber) AS Ord_ViceOrderCount " +// tt.OPlist_ReservationTakeTime = t.OPlist_ReservationTakeTime
  215. "from t " +
  216. "Left Join tb_ErpOrderDigital on Ordv_ViceNumber = OPlist_ViceNumber " +
  217. "Left Join tb_ErpOrder on Ord_Number = Ordv_Number " +
  218. "Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
  219. "Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
  220. "where Ord_Number is not null And convert(datetime,OPlist_ReservationTakeTime,120) < GETDATE() " +
  221. ")" +
  222. "select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约取件日期,完成状态,取件状态,Ord_ViceOrderCount from t1 " + StrWhere + " " +
  223. "order by Ordv_ViceNumber,预约取件日期";
  224. break;
  225. case "tabPage_ExpiredReservationPickupNotPickup":
  226. StrTableName = "with t AS " +
  227. "(" +
  228. "select " +
  229. "Max(ID) AS PID," +
  230. "OPlist_ViceNumber," +
  231. "dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS OPlist_ReservationTakeTime," +
  232. "OPlist_CompletedStatus," +
  233. "OPlist_PickupStatus " +
  234. "from tb_ErpOrderProductList " +
  235. "where OPlist_Type = '2' And OPlist_ReservationTakeTime is not null And OPlist_PickupStatus = '0' And OPlist_ViceNumber != '' " +
  236. "Group By OPlist_ViceNumber,OPlist_CompletedStatus,OPlist_PickupStatus,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime))" +
  237. ")" +
  238. ", t1 AS" +
  239. "(" +
  240. "select " +
  241. "PID," +
  242. "Ord_Number," +
  243. "Ordv_ViceNumber," +
  244. "Ord_DividedShop," +
  245. "CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号," +
  246. "dbo.fn_CheckOrderType(Ord_Type) AS 订单类型," +
  247. "Company_Name AS 分店," +
  248. "Cus_Name AS 客户姓名," +
  249. "Cus_Name_py AS 客户拼音," +
  250. "Cus_Sex_cs AS 客户性别," +
  251. "Cus_Telephone AS 客户电话," +
  252. "OPlist_ReservationTakeTime AS 预约取件日期," +
  253. "dbo.fn_CheckProductCompletedStatus(t.OPlist_CompletedStatus) AS 完成状态," +
  254. "dbo.fn_CheckProductTakePiecesStatus(t.OPlist_PickupStatus) AS 取件状态," +
  255. "(SELECT Count(OPlist_ViceNumber) AS CountID FROM t AS tt WHERE tt.OPlist_ViceNumber = Ordv_ViceNumber) AS Ord_ViceOrderCount " +// And tt.OPlist_ReservationTakeTime = t.OPlist_ReservationTakeTime
  256. "from t " +
  257. "Left Join tb_ErpOrderDigital on Ordv_ViceNumber = OPlist_ViceNumber " +
  258. "Left Join tb_ErpOrder on Ord_Number = Ordv_Number " +
  259. "Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
  260. "Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
  261. "where Ord_Number is not null And convert(datetime,OPlist_ReservationTakeTime,120) < GETDATE() " +
  262. ")" +
  263. "select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约取件日期,完成状态,取件状态,Ord_ViceOrderCount from t1 " + StrWhere + " " +
  264. "order by Ordv_ViceNumber,预约取件日期";
  265. break;
  266. case "tabPage_ExpireReservationSelect":
  267. StrTableName = "with t AS( " +
  268. "select tb_ErpOrderDigital.ID AS PID, " +
  269. "Ord_Number, " +
  270. "Ordv_ViceNumber, " +
  271. "Ord_DividedShop, " +
  272. "CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号, " +
  273. "dbo.fn_CheckOrderType(Ord_Type) AS 订单类型, " +
  274. "Company_Name AS 分店, " +
  275. "Cus_Name AS 客户姓名, " +
  276. "Cus_Name_py AS 客户拼音, " +
  277. "Cus_Sex_cs AS 客户性别, " +
  278. "Cus_Telephone AS 客户电话, " +
  279. "dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationFilmSelectionTime)) AS 预约选样日期, " +
  280. "dbo.fn_CheckOrderFilmSelectionStatus(Ordv_FilmSelectionStatus) AS 选样状态, " +
  281. "(SELECT Count(Ordv_ViceNumber) AS CountID FROM tb_ErpOrderDigital AS tt WHERE tt.Ordv_ViceNumber = tb_ErpOrderDigital.Ordv_ViceNumber) AS Ord_ViceOrderCount " +
  282. "from tb_ErpOrderDigital " +
  283. "Left Join tb_ErpOrder on Ord_Number = Ordv_Number " +
  284. "Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
  285. "Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
  286. "where Ord_Number is not null And Ordv_FilmSelectionStatus != '1' And convert(datetime,Ordv_ReservationFilmSelectionTime,120) < GETDATE() " +
  287. ") " +
  288. "select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约选样日期,选样状态,Ord_ViceOrderCount " +
  289. "from t " + StrWhere + " " +
  290. "order by Ordv_ViceNumber,预约选样日期";
  291. break;
  292. }
  293. return StrTableName;
  294. }
  295. /// <summary>
  296. /// 展开副级
  297. /// </summary>
  298. /// <param name="e"></param>
  299. void dgvData_EventRowExpandCollapse(ComponentLibrary.DataGridViewEc.EventExpandCollapse e)
  300. {
  301. //现再为展开
  302. if (e.ExpandOrCollapse)
  303. {
  304. if (tblMianSelectData.Rows.Count > 0)
  305. {
  306. string StrOrderBy = "";
  307. switch (this.tabControlEx1.SelectedTab.Name.Trim())
  308. {
  309. case "tabPage_ExpiredReservationPhotographyNotPhotography":
  310. StrOrderBy = "预约拍照日期";
  311. break;
  312. case "tabPage_ExpiredReservationLookDesignNotLookDesign":
  313. StrOrderBy = "预约看版日期";
  314. break;
  315. case "tabPage_ExpiredReservationPickupNotComplete":
  316. case "tabPage_ExpiredReservationPickupNotPickup":
  317. StrOrderBy = "预约取件日期";
  318. break;
  319. }
  320. DataRow[] dtRow = this.tblMianSelectData.Select("Ord_Number = '" + this.dgvData.CurrentRow.Cells["Ord_Number"].Value.ToString().Trim() + "' and PID <> '" + this.dgvData.CurrentRow.Cells["PID"].Value.ToString().Trim() + "'", StrOrderBy);
  321. this.dgvData.DgvValueFiledNull = this.dgvData.StrValueNullColumn + ",订单号,订单类型,分店";
  322. this.dgvData.DataSourceViceRow(dtRow);
  323. }
  324. }
  325. //现再为折叠
  326. else { }
  327. }
  328. }
  329. }