UIM030500.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. using CoreFS.CA06;
  10. using System.Collections;
  11. using Infragistics.Win.UltraWinGrid;
  12. namespace Core.LZMes.Client.UIM.UIM03
  13. {
  14. public partial class UIM030500 : FrmBase
  15. {
  16. public UIM030500()
  17. {
  18. InitializeComponent();
  19. }
  20. public override void ToolBar_Click(object sender, string ToolbarKey)
  21. {
  22. switch (ToolbarKey)
  23. {
  24. case "Query":
  25. this.DoQuery();
  26. break;
  27. case "Export":
  28. this.DoExport();
  29. break;
  30. case "Exit":
  31. this.Close();
  32. break;
  33. }
  34. }
  35. private void DoQuery()
  36. {
  37. try
  38. {
  39. this.dataSet1.Tables[0].Clear();
  40. string queryDate = this.ultraDateTimeEditor1.Value == null ? "" : this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
  41. string queryDate1 = this.ultraDateTimeEditor2.Value == null ? "" : this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd");
  42. if (queryDate1.Substring(0, 6) != queryDate.Substring(0, 6))
  43. {
  44. MessageBox.Show("请确保两个查询日期在同一月份", "错误");
  45. return;
  46. }
  47. string queryDate2 = "";//月累统计截止日期
  48. if (queryDate.Substring(0, 6) == DateTime.Today.ToString("yyyyMM"))//查询日期为当月
  49. queryDate2 = DateTime.Today.ToString("yyyyMMdd");
  50. else
  51. {
  52. DateTime date = ultraDateTimeEditor2.DateTime;
  53. queryDate2 = date.AddDays(1 - date.Day).AddMonths(1).AddDays(-1).ToString("yyyyMMdd");
  54. }
  55. if (CustomInfo == "2" || CustomInfo == "1" || CustomInfo == "3" || CustomInfo == "4" || CustomInfo == "5" || CustomInfo == "6" || CustomInfo == "7" || CustomInfo == "8")
  56. {
  57. CoreClientParam ccp1 = null;
  58. ccp1 = new CoreClientParam();
  59. Hashtable ht = new Hashtable();
  60. ht.Add("i1", this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"));
  61. ht.Add("i2", this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd"));
  62. ht.Add("o3", "");
  63. //规格明细统计
  64. ccp1.ServerName = "UIB.COM.ComDBProcedure";
  65. ccp1.MethodName = "doXmlProcedure";
  66. if (CustomInfo == "1")
  67. ccp1.ServerParams = new object[] { "UIM020010_01.CALL", ht };
  68. else if (CustomInfo == "2")
  69. ccp1.ServerParams = new object[] { "UIM020010_02.CALL", ht };
  70. else if (CustomInfo == "3")
  71. ccp1.ServerParams = new object[] { "UIM020010_03.CALL", ht };
  72. else if (CustomInfo == "4")
  73. ccp1.ServerParams = new object[] { "UIM020010_04.CALL", ht };
  74. else if (CustomInfo == "5")
  75. ccp1.ServerParams = new object[] { "UIM020010_05.CALL", ht };
  76. else if (CustomInfo == "6")
  77. ccp1.ServerParams = new object[] { "UIM020010_06.CALL", ht };
  78. else if (CustomInfo == "7")
  79. ccp1.ServerParams = new object[] { "UIM020010_07.CALL", ht };
  80. else if (CustomInfo == "8")
  81. ccp1.ServerParams = new object[] { "UIM020010_08.CALL", ht };
  82. this.ExecuteNonQuery(ccp1, CoreInvokeType.Internal);
  83. //规格明细查询
  84. CoreClientParam ccp = new CoreClientParam();
  85. ccp.ServerName = "UIM.UIM02.UIM020010";
  86. if (CustomInfo == "1")
  87. ccp.MethodName = "queryPltcmSizeDetail";
  88. else if (CustomInfo == "2")
  89. ccp.MethodName = "queryCalSizeDetail";
  90. else if (CustomInfo == "3")
  91. ccp.MethodName = "queryRclSizeDetail";
  92. else if (CustomInfo == "4")
  93. ccp.MethodName = "queryINYARDSizeDetail";
  94. else if (CustomInfo == "5")
  95. ccp.MethodName = "querySuanXiSizeDetail";
  96. else if (CustomInfo == "6")
  97. ccp.MethodName = "querySuanXiSizeDetail";
  98. else if (CustomInfo == "7")
  99. ccp.MethodName = "queryPltcmSizeDetail";
  100. else if (CustomInfo == "8")
  101. ccp.MethodName = "queryINYARDSizeDetail";
  102. ccp.ServerParams = null;
  103. ccp.SourceDataTable = this.dataSet1.Tables[0];
  104. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  105. //合计成材率的计算
  106. #region
  107. if (ultraGrid1.Rows.Count > 0)
  108. {
  109. UltraGridRow ur1 = null;
  110. UltraGridRow ur2 = null;
  111. UltraGridRow ur3 = null;
  112. int n = 0;
  113. foreach (UltraGridRow ur in ultraGrid1.Rows)
  114. {
  115. if (ur.Cells["SPEC_STL_GRD"].Text == "合计" && ur.Cells["PRODUCT_NAME"].Text == "原料")
  116. {
  117. ur1 = ur;
  118. n++;
  119. }
  120. else if (ur.Cells["SPEC_STL_GRD"].Text == "合计" && ur.Cells["PRODUCT_NAME"].Text == "产量")
  121. {
  122. ur2 = ur;
  123. n++;
  124. }
  125. else if (ur.Cells["SPEC_STL_GRD"].Text == "合计" && ur.Cells["PRODUCT_NAME"].Text == "成材率")
  126. {
  127. ur3 = ur;
  128. n++;
  129. }
  130. if (n == 3)
  131. break;
  132. }
  133. //ACT_WGT1
  134. if (double.Parse(ur2.Cells["ACT_WGT1"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT1"].Value.ToString())==0)
  135. ur3.Cells["ACT_WGT1"].Value = 0;
  136. else
  137. {
  138. double n1 = double.Parse(ur2.Cells["ACT_WGT1"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT1"].Value.ToString()) * 100;
  139. n1 = Math.Round(n1, 2);
  140. ur3.Cells["ACT_WGT1"].Value = n1.ToString();
  141. }
  142. //ACT_WGT2
  143. if (double.Parse(ur2.Cells["ACT_WGT2"].Value.ToString())==0 || double.Parse(ur1.Cells["ACT_WGT2"].Value.ToString())==0)
  144. ur3.Cells["ACT_WGT2"].Value = 0;
  145. else
  146. {
  147. double n1 = double.Parse(ur2.Cells["ACT_WGT2"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT2"].Value.ToString()) * 100;
  148. n1 = Math.Round(n1, 2);
  149. ur3.Cells["ACT_WGT2"].Value = n1.ToString();
  150. }
  151. //ACT_WGT2_3
  152. if (double.Parse(ur2.Cells["ACT_WGT2_3"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT2_3"].Value.ToString()) == 0)
  153. ur3.Cells["ACT_WGT2_3"].Value = 0;
  154. else
  155. {
  156. double n1 = double.Parse(ur2.Cells["ACT_WGT2_3"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT2_3"].Value.ToString()) * 100;
  157. n1 = Math.Round(n1, 2);
  158. ur3.Cells["ACT_WGT2_3"].Value = n1.ToString();
  159. }
  160. //ACT_WGT3
  161. if (double.Parse(ur2.Cells["ACT_WGT3"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT3"].Value.ToString()) == 0)
  162. ur3.Cells["ACT_WGT3"].Value = 0;
  163. else
  164. {
  165. double n1 = double.Parse(ur2.Cells["ACT_WGT3"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT3"].Value.ToString()) * 100;
  166. n1 = Math.Round(n1, 2);
  167. ur3.Cells["ACT_WGT3"].Value = n1.ToString();
  168. }
  169. //ACT_WGT4
  170. if (double.Parse(ur2.Cells["ACT_WGT4"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT4"].Value.ToString()) == 0)
  171. ur3.Cells["ACT_WGT4"].Value = 0;
  172. else
  173. {
  174. double n1 = double.Parse(ur2.Cells["ACT_WGT4"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT4"].Value.ToString()) * 100;
  175. n1 = Math.Round(n1, 2);
  176. ur3.Cells["ACT_WGT4"].Value = n1.ToString();
  177. }
  178. //ACT_WGT5判断是否为空
  179. if (string.IsNullOrEmpty(ur2.Cells["ACT_WGT5"].Value.ToString()) || string.IsNullOrEmpty(ur1.Cells["ACT_WGT5"].Value.ToString()))
  180. {
  181. ur3.Cells["ACT_WGT5"].Value = 0;
  182. }
  183. else if (double.Parse(ur2.Cells["ACT_WGT5"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT5"].Value.ToString()) == 0)
  184. {
  185. ur3.Cells["ACT_WGT5"].Value = 0;
  186. }
  187. else
  188. {
  189. double n1 = double.Parse(ur2.Cells["ACT_WGT5"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT5"].Value.ToString()) * 100;
  190. n1 = Math.Round(n1, 2);
  191. ur3.Cells["ACT_WGT5"].Value = n1.ToString();
  192. }
  193. //ACT_WGT
  194. if (double.Parse(ur2.Cells["ACT_WGT"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT"].Value.ToString()) == 0)
  195. ur3.Cells["ACT_WGT"].Value = 0;
  196. else
  197. {
  198. double n1 = double.Parse(ur2.Cells["ACT_WGT"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT"].Value.ToString()) * 100;
  199. n1 = Math.Round(n1, 2);
  200. ur3.Cells["ACT_WGT"].Value = n1.ToString();
  201. }
  202. //SUMACT_WGT1
  203. if (double.Parse(ur2.Cells["SUMACT_WGT1"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT1"].Value.ToString()) == 0)
  204. ur3.Cells["SUMACT_WGT1"].Value = 0;
  205. else
  206. {
  207. double n1 = double.Parse(ur2.Cells["SUMACT_WGT1"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT1"].Value.ToString()) * 100;
  208. n1 = Math.Round(n1, 2);
  209. ur3.Cells["SUMACT_WGT1"].Value = n1.ToString();
  210. }
  211. //SUMACT_WGT2
  212. if (double.Parse(ur2.Cells["SUMACT_WGT2"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT2"].Value.ToString()) == 0)
  213. ur3.Cells["SUMACT_WGT2"].Value = 0;
  214. else
  215. {
  216. double n1 = double.Parse(ur2.Cells["SUMACT_WGT2"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT2"].Value.ToString()) * 100;
  217. n1 = Math.Round(n1, 2);
  218. ur3.Cells["SUMACT_WGT2"].Value = n1.ToString();
  219. }
  220. //SUMACT_WGT2_3
  221. if (double.Parse(ur2.Cells["SUMACT_WGT2_3"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT2_3"].Value.ToString()) == 0)
  222. ur3.Cells["SUMACT_WGT2_3"].Value = 0;
  223. else
  224. {
  225. double n1 = double.Parse(ur2.Cells["SUMACT_WGT2_3"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT2_3"].Value.ToString()) * 100;
  226. n1 = Math.Round(n1, 2);
  227. ur3.Cells["SUMACT_WGT2_3"].Value = n1.ToString();
  228. }
  229. //SUMACT_WGT3
  230. if (double.Parse(ur2.Cells["SUMACT_WGT3"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT3"].Value.ToString()) == 0)
  231. ur3.Cells["SUMACT_WGT3"].Value = 0;
  232. else
  233. {
  234. double n1 = double.Parse(ur2.Cells["SUMACT_WGT3"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT3"].Value.ToString()) * 100;
  235. n1 = Math.Round(n1, 2);
  236. ur3.Cells["SUMACT_WGT3"].Value = n1.ToString();
  237. }
  238. //SUMACT_WGT4
  239. if (double.Parse(ur2.Cells["SUMACT_WGT4"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT4"].Value.ToString()) == 0)
  240. ur3.Cells["SUMACT_WGT4"].Value = 0;
  241. else
  242. {
  243. double n1 = double.Parse(ur2.Cells["SUMACT_WGT4"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT4"].Value.ToString()) * 100;
  244. n1 = Math.Round(n1, 2);
  245. ur3.Cells["SUMACT_WGT4"].Value = n1.ToString();
  246. }
  247. //SUMACT_WGT5判断是否为空
  248. if (string.IsNullOrEmpty(ur2.Cells["SUMACT_WGT5"].Value.ToString()) || string.IsNullOrEmpty(ur1.Cells["SUMACT_WGT5"].Value.ToString()))
  249. {
  250. ur3.Cells["SUMACT_WGT5"].Value = 0;
  251. }
  252. else if (double.Parse(ur2.Cells["SUMACT_WGT5"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT5"].Value.ToString()) == 0)
  253. ur3.Cells["SUMACT_WGT5"].Value = 0;
  254. else
  255. {
  256. double n1 = double.Parse(ur2.Cells["SUMACT_WGT5"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT5"].Value.ToString()) * 100;
  257. n1 = Math.Round(n1, 2);
  258. ur3.Cells["SUMACT_WGT5"].Value = n1.ToString();
  259. }
  260. //SUMACT_WGT
  261. if (double.Parse(ur2.Cells["SUMACT_WGT"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT"].Value.ToString()) == 0)
  262. ur3.Cells["SUMACT_WGT"].Value = 0;
  263. else
  264. {
  265. double n1 = double.Parse(ur2.Cells["SUMACT_WGT"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT"].Value.ToString()) * 100;
  266. n1 = Math.Round(n1, 2);
  267. ur3.Cells["SUMACT_WGT"].Value = n1.ToString();
  268. }
  269. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  270. {
  271. if (ultraGrid1.Rows[i].Cells["SPEC_STL_GRD"].Text == "合计" && ultraGrid1.Rows[i].Cells["PRODUCT_NAME"].Text == "成材率")
  272. {
  273. ultraGrid1.Rows[i].Cells["SUMACT_WGT1"].Value = ur3.Cells["SUMACT_WGT1"].Value;
  274. ultraGrid1.Rows[i].Cells["SUMACT_WGT2"].Value = ur3.Cells["SUMACT_WGT2"].Value;
  275. ultraGrid1.Rows[i].Cells["SUMACT_WGT2_3"].Value = ur3.Cells["SUMACT_WGT2_3"].Value;
  276. ultraGrid1.Rows[i].Cells["SUMACT_WGT3"].Value = ur3.Cells["SUMACT_WGT3"].Value;
  277. ultraGrid1.Rows[i].Cells["SUMACT_WGT4"].Value = ur3.Cells["SUMACT_WGT4"].Value;
  278. ultraGrid1.Rows[i].Cells["SUMACT_WGT5"].Value = ur3.Cells["SUMACT_WGT5"].Value;
  279. ultraGrid1.Rows[i].Cells["SUMACT_WGT"].Value = ur3.Cells["SUMACT_WGT"].Value;
  280. ultraGrid1.Rows[i].Cells["ACT_WGT1"].Value = ur3.Cells["ACT_WGT1"].Value;
  281. ultraGrid1.Rows[i].Cells["ACT_WGT2"].Value = ur3.Cells["ACT_WGT2"].Value;
  282. ultraGrid1.Rows[i].Cells["ACT_WGT2_3"].Value = ur3.Cells["ACT_WGT2_3"].Value;
  283. ultraGrid1.Rows[i].Cells["ACT_WGT3"].Value = ur3.Cells["ACT_WGT3"].Value;
  284. ultraGrid1.Rows[i].Cells["ACT_WGT4"].Value = ur3.Cells["ACT_WGT4"].Value;
  285. ultraGrid1.Rows[i].Cells["ACT_WGT5"].Value = ur3.Cells["ACT_WGT5"].Value;
  286. ultraGrid1.Rows[i].Cells["ACT_WGT"].Value = ur3.Cells["ACT_WGT"].Value;
  287. ultraGrid1.Update();
  288. break;
  289. }
  290. }
  291. }
  292. #endregion
  293. }
  294. //else if (CustomInfo == "3")
  295. //{
  296. // //规格明细查询
  297. // CoreClientParam ccp = new CoreClientParam();
  298. // ccp.ServerName = "UIM.UIM02.UIM020010";
  299. // ccp.MethodName = "queryRclSizeDetail";
  300. // ccp.ServerParams = new object[] { queryDate, queryDate1, queryDate2 };
  301. // ccp.SourceDataTable = this.dataSet1.Tables[0];
  302. // this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  303. //}
  304. }
  305. catch (Exception EX)
  306. {
  307. MessageBox.Show(EX.ToString());
  308. }
  309. }
  310. private void DoExport()
  311. {
  312. try
  313. {
  314. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  315. {
  316. string fileName = this.saveFileDialog1.FileName;
  317. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  318. System.Diagnostics.Process.Start(fileName);
  319. }
  320. }
  321. catch (Exception EX)
  322. {
  323. MessageBox.Show(EX.ToString());
  324. }
  325. }
  326. private void UIM030500_Load(object sender, EventArgs e)
  327. {
  328. if (CustomInfo == "7")
  329. {
  330. this.ultraGrid1.DisplayLayout.Bands[0].RowLayoutStyle = RowLayoutStyle.GroupLayout;
  331. modifyColumn("UnboundColumn2", "厚度≤3mm", 0, 0, 2, 1);
  332. modifyColumn("UnboundColumn3", "3<厚度≤4mm", 0, 0, 2, 1);
  333. modifyColumn("UnboundColumn4", "4<厚度≤5mm", 0, 0, 2, 1);
  334. modifyColumn("UnboundColumn8", "5<厚度≤6mm", 0, 0, 2, 1);
  335. modifyColumn("UnboundColumn5", "6<厚度", 0, 0, 2, 1);
  336. }
  337. }
  338. private void modifyColumn(string columnName, string caption, int x, int y, int spanX, int spanY)
  339. {
  340. //this.ultraGrid1.DisplayLayout.Bands[0].Columns.Add(columnName);
  341. UltraGridColumn GridColumn = this.ultraGrid1.DisplayLayout.Bands[0].Columns[columnName];
  342. GridColumn.Header.Caption = caption;
  343. //GridColumn.Header.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
  344. //GridColumn.Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Center;
  345. //GridColumn.RowLayoutColumnInfo.OriginX = x;
  346. //GridColumn.RowLayoutColumnInfo.OriginY = y;
  347. //GridColumn.RowLayoutColumnInfo.SpanX = spanX;
  348. //GridColumn.RowLayoutColumnInfo.SpanY = spanY;
  349. ////GridColumn.CellActivation = Activation.Disabled;
  350. //GridColumn.RowLayoutColumnInfo.AllowCellSizing = RowLayoutSizing.None;
  351. //GridColumn.SortIndicator = SortIndicator.Disabled;
  352. }
  353. }
  354. }