frmJBZKZH.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using Core.Mes.ClientFrameWork;
  7. using Core.Mes.IBaseInterface;
  8. using System.Data;
  9. using Infragistics.Excel;
  10. using Infragistics.Win.UltraWinGrid;
  11. using Infragistics.Win.UltraWinGrid.ExcelExport;
  12. using Infragistics.Shared;
  13. using Infragistics.Win;
  14. namespace Core.XgMes.Client.JGKC.RollManager
  15. {
  16. public partial class frmJBZKZH : Mes.ClientFrameWork.FrmBase
  17. {
  18. public frmJBZKZH()
  19. {
  20. InitializeComponent();
  21. }
  22. private string sqlWhereForBJYiYuChuLi;
  23. DataSet ds = new DataSet();
  24. private string sqlWhereForBJYiYuChuLi1;
  25. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  26. {
  27. try
  28. {
  29. switch (e.Tool.Key)
  30. {
  31. case "btnQuery":
  32. sqlWhereForBJYiYuChuLi = " ";
  33. sqlWhereForBJYiYuChuLi1 = " ";
  34. if (consql())
  35. displayBJZH();
  36. break;
  37. case "btnExcel":
  38. ExcelForBJYCL();
  39. break;
  40. case "btnExit":
  41. this.Close();
  42. break;
  43. default:
  44. break;
  45. }
  46. }
  47. catch (Exception err)
  48. {
  49. System.Diagnostics.Debug.WriteLine(err.ToString());
  50. }
  51. }
  52. private void displayBJZH()
  53. {
  54. string strOut = "";
  55. try
  56. {
  57. object obj = Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("BJZWJBStuff", "Core.XgMes.Server.JGKC.RollManager.TurnoReport",
  58. "getBJZHForQuery",
  59. new object[] { sqlWhereForBJYiYuChuLi, sqlWhereForBJYiYuChuLi1 },
  60. out strOut) as DataSet;
  61. if (strOut != "")
  62. {
  63. MessageBox.Show(strOut);
  64. return;
  65. }
  66. ds=(DataSet)obj;
  67. this.ultraGrid1.DataSource = (DataSet)obj;/*ds*/
  68. this.ultraGrid1.UpdateData();
  69. //this.InitGridSummery(this.ultraGrid1);
  70. }
  71. catch (Exception ex)
  72. {
  73. System.Diagnostics.Debug.WriteLine(ex.ToString());
  74. }
  75. }
  76. private void InitGridSummery(Infragistics.Win.UltraWinGrid.UltraGrid uGrid)
  77. {
  78. if (uGrid.Rows.FilteredInRowCount > 0)// && CheckHZ.Checked)
  79. {
  80. for (int i = 0; i < uGrid.DisplayLayout.Bands[0].Summaries.Count; i++)
  81. {
  82. if (uGrid.DisplayLayout.Bands[0].Summaries[i].SummaryType == SummaryType.Sum)
  83. uGrid.DisplayLayout.Bands[0].Summaries[i].SummaryDisplayArea =
  84. SummaryDisplayAreas.BottomFixed | SummaryDisplayAreas.InGroupByRows;
  85. else
  86. uGrid.DisplayLayout.Bands[0].Summaries[i].SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  87. }
  88. }
  89. else
  90. {
  91. for (int i = 0; i < uGrid.DisplayLayout.Bands[0].Summaries.Count; i++)
  92. {
  93. uGrid.DisplayLayout.Bands[0].Summaries[i].SummaryDisplayArea = SummaryDisplayAreas.None;
  94. }
  95. }
  96. }
  97. private void frmJBZKZH_Load(object sender, EventArgs e)
  98. {
  99. try
  100. {
  101. //this.Cmb_DateType.Value = "交货日期";
  102. //((Infragistics.Win.UltraWinGrid.UltraCombo)Cmb_DateType).DisplayLayout.Bands[0].Columns[0].Band.ColHeadersVisible = false;
  103. //this.InitGridSummery(this.ultraGrid1);
  104. }
  105. catch (Exception ex)
  106. {
  107. Console.Write(ex.Message);
  108. }
  109. }
  110. private void uCkEditorForTaskNo_CheckedChanged(object sender, EventArgs e)
  111. {
  112. this.uEditorForTaskNo.Enabled = this.uCkEditorForTaskNo.Checked;
  113. }
  114. private void uEYCLDate_CheckedChanged(object sender, EventArgs e)
  115. {
  116. Cmb_DateType.Enabled = this.uEYCLDate.Checked;
  117. uDateEndTime.Enabled = this.uEYCLDate.Checked;
  118. uDateStartTime.Enabled = this.uEYCLDate.Checked;
  119. }
  120. private void uCkEditorForGroupBy_CheckedChanged(object sender, EventArgs e)
  121. {
  122. if (this.uCkEditorForGroupBy.Checked)
  123. {
  124. this.ultraGrid1.DisplayLayout.GroupByBox.Hidden = false;
  125. }
  126. else
  127. {
  128. this.ultraGrid1.DisplayLayout.GroupByBox.Hidden = true;
  129. this.ultraGrid1.DisplayLayout.Bands[0].SortedColumns.Clear();
  130. }
  131. }
  132. private void uCkEditorForFilter_CheckedChanged(object sender, EventArgs e)
  133. {
  134. if (this.uCkEditorForFilter.Checked)
  135. {
  136. this.ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;
  137. }
  138. else
  139. {
  140. this.ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
  141. }
  142. }
  143. private bool consql()
  144. {
  145. if (this.uCkEditorForTaskNo.Checked == true)
  146. {
  147. if (this.uEditorForTaskNo.Text.Trim() == "")
  148. {
  149. MessageBox.Show("合同号不能为空", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  150. return false;
  151. }
  152. else
  153. {
  154. this.sqlWhereForBJYiYuChuLi = this.sqlWhereForBJYiYuChuLi + " AND A.ORD_NO LIKE '" + this.uEditorForTaskNo.Text.Trim() + "%'";
  155. sqlWhereForBJYiYuChuLi1 = this.sqlWhereForBJYiYuChuLi1 + " AND B.ORD_NO LIKE '" + this.uEditorForTaskNo.Text.Trim() + "%'";
  156. }
  157. }
  158. if (this.uEYCLDate.Checked == true)
  159. {
  160. if (this.uDateStartTime.DateTime.CompareTo(this.uDateEndTime.DateTime) > 0)
  161. {
  162. MessageBox.Show("开始时间大于结束时间", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  163. return false;
  164. }
  165. else
  166. {
  167. string col = "a.ORD_DEVLMT_DATE";
  168. this.sqlWhereForBJYiYuChuLi = "AND " + col + " >= '"
  169. + this.uDateStartTime.DateTime.ToString("yyyyMMdd") + "' AND a.ORD_DEVLMT_DATE <= '"
  170. + this.uDateEndTime.DateTime.ToString("yyyyMMdd") + "'";
  171. string col1 = "B.DEVLMT_DTIME";
  172. this.sqlWhereForBJYiYuChuLi1 = "AND " + col1 + " >= '"
  173. + this.uDateStartTime.DateTime.ToString("yyyyMMdd") + "' AND B.DEVLMT_DTIME <= '"
  174. + this.uDateEndTime.DateTime.ToString("yyyyMMdd") + "'";
  175. }
  176. }
  177. return true;
  178. }
  179. private void ExcelForBJYCL()
  180. {
  181. if (this.ultraGrid1.Rows.Count == 0)
  182. {
  183. MessageBox.Show("没有数据,不能导出", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  184. }
  185. else
  186. {
  187. DoExc();
  188. }
  189. }
  190. private void DoExc()
  191. {
  192. string strFileName = @"c:\" + this.Text + System.DateTime.Today.ToString("yyMMdd") + ".xls";
  193. System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog();
  194. sfd.Filter = "Microsoft Office Excel 工作簿 (*.xls)|*.xls";
  195. sfd.Title = "导出到Excel文件";
  196. sfd.FileName = strFileName;
  197. if (sfd.ShowDialog() == DialogResult.OK)
  198. {
  199. strFileName = sfd.FileName;
  200. Infragistics.Excel.Workbook wb = new Infragistics.Excel.Workbook();
  201. Infragistics.Excel.Worksheet ws2 = wb.Worksheets.Add("Sheet1");
  202. ws2.Rows[0].Cells[0].Value = this.ultraGrid1.Text;
  203. ws2.MergedCellsRegions.Add(0, 0, 0, 29);
  204. ws2.Rows[0].Cells[0].CellFormat.Alignment = Infragistics.Excel.HorizontalCellAlignment.Center;
  205. ws2.Rows[0].Cells[0].CellFormat.VerticalAlignment = Infragistics.Excel.VerticalCellAlignment.Center;
  206. ws2.Rows[0].Cells[0].CellFormat.WrapText = Infragistics.Excel.ExcelDefaultableBoolean.True;
  207. ws2.Rows[0].Cells[0].CellFormat.Font.Height = 300;
  208. ws2.Rows[0].Cells[0].CellFormat.Font.UnderlineStyle = Infragistics.Excel.FontUnderlineStyle.Single;
  209. ws2.Rows[0].Height = 510;
  210. int int_index = 0;
  211. try
  212. {
  213. for (int i = 0; i < this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count; i++)
  214. {
  215. if (this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].Hidden == false)
  216. {
  217. ws2.Rows[1 + this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.OriginY].Cells[this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.OriginX].Value = this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].Header.Caption;
  218. ws2.MergedCellsRegions.Add(1 + this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.OriginY,
  219. this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.OriginX,
  220. 1 + this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.OriginY +
  221. this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.SpanY - 1,
  222. this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.OriginX +
  223. this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.SpanX - 1);
  224. int_index += this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].RowLayoutColumnInfo.SpanX;
  225. }
  226. }
  227. }
  228. catch (Exception ex)
  229. { }
  230. for (int i = 0; i <= 29; i++)
  231. {
  232. for (int j = 1; j <= 2; j++)
  233. {
  234. ws2.Rows[j].Cells[i].CellFormat.Alignment = Infragistics.Excel.HorizontalCellAlignment.Center;
  235. ws2.Rows[j].Cells[i].CellFormat.VerticalAlignment = Infragistics.Excel.VerticalCellAlignment.Center;
  236. ws2.Rows[j].Cells[i].CellFormat.WrapText = Infragistics.Excel.ExcelDefaultableBoolean.True;
  237. ws2.Rows[j].Cells[i].CellFormat.FillPatternBackgroundColor = Color.LightSteelBlue;
  238. ws2.Rows[j].Cells[i].CellFormat.FillPatternForegroundColor = Color.LightSteelBlue;
  239. ws2.Rows[j].Cells[i].CellFormat.TopBorderColor = Color.Black;
  240. ws2.Rows[j].Cells[i].CellFormat.BottomBorderColor = Color.Black;
  241. ws2.Rows[j].Cells[i].CellFormat.LeftBorderColor = Color.Black;
  242. ws2.Rows[j].Cells[i].CellFormat.RightBorderColor = Color.Black;
  243. }
  244. }
  245. for (int i = 0; i < this.ultraGrid1.Rows.Count; i++)
  246. {
  247. for (int j = 0; j < this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count; j++)
  248. {
  249. if (this.ultraGrid1.Rows[i].Cells[j].Hidden == false && this.ultraGrid1.DisplayLayout.Bands[0].Columns[j].RowLayoutColumnInfo.LabelPosition != LabelPosition.LabelOnly)
  250. {
  251. ws2.Rows[3 + i].Cells[this.ultraGrid1.DisplayLayout.Bands[0].Columns[j].RowLayoutColumnInfo.OriginX].Value = this.ultraGrid1.Rows[i].Cells[j].Value;
  252. ws2.Rows[3 + i].Cells[this.ultraGrid1.DisplayLayout.Bands[0].Columns[j].RowLayoutColumnInfo.OriginX].CellFormat.VerticalAlignment = Infragistics.Excel.VerticalCellAlignment.Center;
  253. if (this.ultraGrid1.DisplayLayout.Bands[0].Columns[j].DataType == typeof(System.Decimal))
  254. {
  255. ws2.Rows[3 + i].Cells[this.ultraGrid1.DisplayLayout.Bands[0].Columns[j].RowLayoutColumnInfo.OriginX].CellFormat.Alignment = Infragistics.Excel.HorizontalCellAlignment.Right;
  256. }
  257. }
  258. }
  259. }
  260. Infragistics.Excel.BIFF8Writer.WriteWorkbookToFile(wb, strFileName);
  261. }
  262. }
  263. private void ultraCheckEditor6_CheckedChanged(object sender, EventArgs e)
  264. {
  265. try
  266. {
  267. string RowFilter = "";
  268. if (ultraCheckEditor5.Checked)
  269. RowFilter = "SENDWEIGHT>=WEIGHT-0.1 ";
  270. if (ultraCheckEditor10.Checked)
  271. {
  272. if (RowFilter.Length > 0)
  273. RowFilter = RowFilter + " AND ZL_WEIGHT >= WEIGHT-0.1 and SENDWEIGHT<WEIGHT-0.1 ";
  274. else
  275. RowFilter = "ZL_WEIGHT >= WEIGHT-0.1 and SENDWEIGHT<WEIGHT-0.1 ";
  276. }
  277. if (ultraCheckEditor6.Checked)
  278. {
  279. if (RowFilter.Length > 0)
  280. RowFilter = RowFilter + " AND CL_WEIGHT<-0.1 and ZL_WEIGHT<WEIGHT-0.1 ";
  281. else
  282. RowFilter = "CL_WEIGHT<-0.1 and ZL_WEIGHT<WEIGHT-0.1 ";
  283. }
  284. ds.Tables[0].DefaultView.RowFilter = RowFilter;
  285. SetColor();
  286. }
  287. catch (Exception err)
  288. {
  289. System.Diagnostics.Debug.WriteLine(err.ToString());
  290. }
  291. }
  292. private void ultraCheckEditor5_CheckedChanged(object sender, EventArgs e)
  293. {
  294. try
  295. {
  296. string RowFilter = "";
  297. if (ultraCheckEditor6.Checked)
  298. RowFilter = "CL_WEIGHT<-0.1 and ZL_WEIGHT<WEIGHT-0.1 ";
  299. if (ultraCheckEditor10.Checked)
  300. {
  301. if (RowFilter.Length > 0)
  302. RowFilter = RowFilter + "AND ZL_WEIGHT >= WEIGHT-0.1 and SENDWEIGHT<WEIGHT-0.1 ";
  303. else
  304. RowFilter = "ZL_WEIGHT >= WEIGHT-0.1 and SENDWEIGHT<WEIGHT-0.1 ";
  305. }
  306. if (ultraCheckEditor5.Checked)
  307. {
  308. if (RowFilter.Length > 0)
  309. RowFilter = RowFilter + "and SENDWEIGHT>=WEIGHT-0.1 ";
  310. else
  311. RowFilter = "SENDWEIGHT>=WEIGHT-0.1 ";
  312. }
  313. ds.Tables[0].DefaultView.RowFilter = RowFilter;
  314. SetColor();
  315. }
  316. catch (Exception err)
  317. {
  318. System.Diagnostics.Debug.WriteLine(err.ToString());
  319. }
  320. }
  321. private void ultraCheckEditor10_CheckedChanged(object sender, EventArgs e)
  322. {
  323. try
  324. {
  325. string RowFilter = "";
  326. if (ultraCheckEditor5.Checked)
  327. RowFilter = "SENDWEIGHT>=WEIGHT-0.1";
  328. if (ultraCheckEditor6.Checked)
  329. {
  330. if (RowFilter.Length > 0)
  331. RowFilter = RowFilter + "CL_WEIGHT<-0.1 and ZL_WEIGHT<WEIGHT-0.1 ";
  332. else
  333. RowFilter = "CL_WEIGHT<-0.1 and ZL_WEIGHT<WEIGHT-0.1 ";
  334. }
  335. if (ultraCheckEditor10.Checked)
  336. {
  337. if (RowFilter.Length > 0)
  338. RowFilter = RowFilter + "AND ZL_WEIGHT >= WEIGHT-0.1 and SENDWEIGHT<WEIGHT-0.1 ";
  339. else
  340. RowFilter = "ZL_WEIGHT >= WEIGHT-0.1 and SENDWEIGHT<WEIGHT-0.1 ";
  341. }
  342. ds.Tables[0].DefaultView.RowFilter = RowFilter;
  343. SetColor();
  344. }
  345. catch (Exception err)
  346. {
  347. Console.WriteLine(err.ToString());
  348. }
  349. }
  350. private void SetColor()
  351. {
  352. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow Row in this.ultraGrid1.Rows)
  353. {
  354. if (Convert.ToDouble(Row.Cells["CL_WEIGHT"].Value) < -0.1)
  355. {
  356. Row.Appearance.ForeColor = Color.DarkGreen;
  357. }
  358. if (Convert.ToDouble(Row.Cells["ZL_WEIGHT"].Value) - Convert.ToDouble(Row.Cells["WEIGHT"].Value) >= -0.1)
  359. {
  360. Row.Appearance.ForeColor = Color.Red;
  361. }
  362. if (Convert.ToDouble(Row.Cells["SENDWEIGHT"].Value) - Convert.ToDouble(Row.Cells["WEIGHT"].Value) >= -0.1)
  363. {
  364. Row.Appearance.ForeColor = Color.Blue;
  365. }
  366. }
  367. }
  368. }
  369. }