FrmJGMatReport.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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 Core.Mes.Client.Comm.Server;
  10. using CoreFS.CA06;
  11. using System.Collections;
  12. using Core.Mes.Client.Comm.Control;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Core.Mes.Client.Comm.Tool;
  15. using Core.StlMes.Client.Mcp.Control;
  16. using com.steering.mes.mcp.entity;
  17. using Core.Mes.Client.Comm.Format;
  18. using Core.StlMes.Client.Mcp.Control.Base;
  19. using Infragistics.Win;
  20. namespace Core.StlMes.Client.Mcp.Report
  21. {
  22. public partial class FrmJGMatReport : FrmBase
  23. {
  24. public FrmJGMatReport()
  25. {
  26. InitializeComponent();
  27. this.IsLoadUserView = true;
  28. }
  29. private void FrmJGMatReport_Load(object sender, EventArgs e)
  30. {
  31. EntityHelper.ShowGridCaption<CouplingMatButtressEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  32. EntityHelper.ShowGridCaption<CouplingMatButtressEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  33. EntityHelper.ShowGridCaption<CouplingMatButtressEntity>(ultraGrid4.DisplayLayout.Bands[0]);
  34. EntityHelper.ShowGridCaption<CouplingMatButtressEntity>(ultraGrid5.DisplayLayout.Bands[0]);
  35. EntityHelper.ShowGridCaption<PlnZyJgMiddleEntity>(ultraGrid3.DisplayLayout.Bands[0]);
  36. DateTime t = DateTime.Now;
  37. DateTime t1 = new DateTime(t.Year, t.Month, 1);
  38. RegStartTime.Value = DateTime.Parse(t1.ToString("yyyy-MM-dd 00:00:00"));
  39. RegEndTime.Value = DateTime.Parse(t1.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
  40. //框号
  41. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmJGMatNoReport.getKepNo", null, this.ob);
  42. cmbMaterial.DataSource = dt;
  43. cmbMaterial.DisplayMember = "KEP_NO";
  44. PipeManageClass.SetComboItemHeight(cmbMaterial);
  45. String[] str = this.ValidDataPurviewIds;
  46. ArrayList arList = new ArrayList();
  47. //获取用户对应科室ID
  48. string User = this.UserInfo.GetDeptid();
  49. string StorageType = "";//根据传递的参数获取仓库类别
  50. string StorageAttr = "";////根据传递的参数获取仓库类型
  51. if (CustomInfo != "")
  52. {
  53. string[] strflg = CustomInfo.ToString().Split(new char[] { ',' });
  54. StorageType = strflg[0];
  55. StorageAttr = strflg[1];
  56. }
  57. DataTable dt1 = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getStoreNo", new object[] { StorageType, StorageAttr, str }, this.ob);
  58. cmbWarehous.DataSource = dt1;
  59. cmbWarehous.DisplayMember = "STORAGE_NAME";
  60. cmbWarehous.ValueMember = "STORAGE_NO";
  61. PipeManageClass.SetComboItemHeight(cmbWarehous);
  62. }
  63. public override void ToolBar_Click(object sender, string ToolbarKey)
  64. {
  65. switch (ToolbarKey)
  66. {
  67. case "Query":
  68. doQuery();
  69. break;
  70. case "Extinction":
  71. Extinction();
  72. break;
  73. case "doUpdate":
  74. doUpdate();
  75. break;
  76. case "Export":
  77. if (ultraTabControl1.SelectedTab.Key.Equals("0"))
  78. {
  79. GridHelper.ulGridToExcel(ultraGrid4, "库存信息");
  80. }
  81. else if (ultraTabControl1.SelectedTab.Key.Equals("1"))
  82. {
  83. GridHelper.ulGridToExcel(ultraGrid1, "库存信息");
  84. }
  85. else if (ultraTabControl1.SelectedTab.Key.Equals("2"))
  86. {
  87. GridHelper.ulGridToExcel(ultraGrid5, "库存信息");
  88. }
  89. break;
  90. case "Close":
  91. this.Close();
  92. break;
  93. }
  94. }
  95. /// <summary>
  96. /// 消亡
  97. /// </summary>
  98. private void Extinction()
  99. {
  100. this.ultraGrid1.UpdateData();
  101. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  102. if (checkMagRows.Count() == 0)
  103. {
  104. MessageUtil.ShowTips("请选择需要消亡的信息!");
  105. return;
  106. }
  107. ArrayList parm = new ArrayList();
  108. foreach (UltraGridRow uRow in checkMagRows)
  109. {
  110. CouplingMatButtressEntity matButtress = (CouplingMatButtressEntity)uRow.ListObject;
  111. string matButtressTity = JSONFormat.Format(matButtress);
  112. parm.Add(matButtressTity);
  113. }
  114. CoreClientParam ccp = new CoreClientParam();
  115. ccp.ServerName = "com.steering.mes.mcp.Report.FrmJGMatNoReport";
  116. ccp.MethodName = "Extinction";
  117. ccp.ServerParams = new object[] { parm, UserInfo.GetUserName()};
  118. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  119. if (ccp.ReturnCode != -1)
  120. {
  121. if (ccp.ReturnInfo.Equals("消亡成功!"))
  122. {
  123. doQuery();
  124. MessageUtil.ShowTips(ccp.ReturnInfo);
  125. }
  126. else
  127. {
  128. MessageUtil.ShowTips(ccp.ReturnInfo);
  129. }
  130. }
  131. }
  132. /// <summary>
  133. /// 修改物料
  134. /// </summary>
  135. private void doUpdate()
  136. {
  137. this.ultraGrid1.UpdateData();
  138. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  139. if (checkMagRows.Count() == 0)
  140. {
  141. MessageUtil.ShowTips("请选择需要修改物料的信息!");
  142. return;
  143. }
  144. ArrayList parm = new ArrayList();
  145. foreach (UltraGridRow uRow in checkMagRows)
  146. {
  147. CouplingMatButtressEntity matButtress = (CouplingMatButtressEntity)uRow.ListObject;
  148. string matButtressTity = JSONFormat.Format(matButtress);
  149. parm.Add(matButtressTity);
  150. }
  151. CoreClientParam ccp = new CoreClientParam();
  152. ccp.ServerName = "com.steering.mes.mcp.Report.FrmJGMatNoReport";
  153. ccp.MethodName = "doUpdate";
  154. ccp.ServerParams = new object[] { parm };
  155. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  156. if (ccp.ReturnCode != -1)
  157. {
  158. if (ccp.ReturnInfo.Equals("修改成功!"))
  159. {
  160. doQuery();
  161. MessageUtil.ShowTips(ccp.ReturnInfo);
  162. }
  163. else
  164. {
  165. MessageUtil.ShowTips(ccp.ReturnInfo);
  166. }
  167. }
  168. }
  169. /// <summary>
  170. /// 查询
  171. /// </summary>
  172. private void doQuery()
  173. {
  174. if (!CheckQuery()) return;
  175. string strRegStart = "";
  176. string strRegEnd = "";
  177. string strWare = "";//仓库号
  178. //string strMat = "";//框号
  179. string strFurnace = "";//炉号
  180. string strBatch = "";//批号
  181. string strWoid = "";//工单号
  182. string qcmStaus = ""; //交货状态
  183. ArrayList pram = new ArrayList();
  184. if (chkWarehous.Checked)
  185. {
  186. strWare = cmbWarehous.Value.ToString();
  187. }
  188. //if (chkMaterial.Checked)
  189. //{
  190. // strMat = cmbMaterial.Value.ToString();
  191. //}
  192. if (chkRegTime.Checked)
  193. {
  194. strRegStart = RegStartTime.Value.ToString();
  195. strRegEnd = RegEndTime.Value.ToString();
  196. }
  197. else
  198. {
  199. strRegStart = "1";
  200. }
  201. if (chkFurnace.Checked)
  202. {
  203. strFurnace = txtFurnace.Text.Trim();
  204. }
  205. if (chkBatch.Checked)
  206. {
  207. strBatch = txtBatch.Text.Trim();
  208. }
  209. if (chkQcmStaus.Checked)
  210. {
  211. qcmStaus = cmbQcmStaus.Text.Trim();
  212. }
  213. pram.Add(strWare);
  214. pram.Add("");
  215. pram.Add(strFurnace);
  216. pram.Add(strRegStart);
  217. pram.Add(strRegStart);
  218. pram.Add(strRegStart);
  219. pram.Add(strRegEnd);
  220. pram.Add(strRegEnd);
  221. pram.Add(strBatch);
  222. pram.Add(qcmStaus);
  223. //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmJGMatNoReport.doQueryInfoResult", new object[] { pram }, ob);
  224. //GridHelper.CopyDataToDatatable(dt, this.dateMat, true);
  225. List<CouplingMatButtressEntity> listSource = EntityHelper.GetData<CouplingMatButtressEntity>
  226. ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryCouplingMatTogether", new object[] { pram }, this.ob);
  227. bindingSource1.DataSource = listSource;
  228. GridHelper.RefreshAndAutoSize(ultraGrid4);
  229. List<CouplingMatButtressEntity> listSource1 = EntityHelper.GetData<CouplingMatButtressEntity>
  230. ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryCouplingMat", new object[] { pram }, this.ob);
  231. CouplingMatButtEntitybindingSource1.DataSource = listSource1;
  232. GridHelper.RefreshAndAutoSize(ultraGrid1);
  233. List<CouplingMatButtressEntity> listSource2 = EntityHelper.GetData<CouplingMatButtressEntity>
  234. ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryCouplingMat2", new object[] { pram }, this.ob);
  235. bindingSource2.DataSource = listSource2;
  236. GridHelper.RefreshAndAutoSize(ultraGrid5);
  237. }
  238. private void chkRegTime_CheckedChanged(object sender, EventArgs e)
  239. {
  240. if (chkBatch.Checked) { txtBatch.Enabled = true; } else { txtBatch.Enabled = false; }
  241. if (chkWarehous.Checked) { cmbWarehous.Enabled = true; } else { cmbWarehous.Enabled = false; }
  242. if (chkMaterial.Checked) { cmbMaterial.Enabled = true; } else { cmbMaterial.Enabled = false; }
  243. if (chkFurnace.Checked) { txtFurnace.Enabled = true; } else { txtFurnace.Enabled = false; }
  244. if (chkRegTime.Checked) { RegStartTime.Enabled = true; RegEndTime.Enabled = true; }
  245. else
  246. {
  247. RegStartTime.Enabled = false; RegEndTime.Enabled = false;
  248. }
  249. }
  250. ///查询时验证必填项
  251. private bool CheckQuery()
  252. {
  253. if (DataTimeUtil.JudgeTime(DateTime.Parse(RegStartTime.Value.ToString()), DateTime.Parse(RegEndTime.Value.ToString())) == 0)
  254. {
  255. MessageUtil.ShowTips("开始时间不能大于结束时间!");
  256. return false;
  257. }
  258. if (chkFurnace.Checked && string.IsNullOrEmpty(txtFurnace.Text.Trim()))
  259. {
  260. MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  261. return false;
  262. }
  263. if (chkBatch.Checked && string.IsNullOrEmpty(txtBatch.Text.Trim()))
  264. {
  265. MessageBox.Show("请输入批号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  266. return false;
  267. }
  268. if (chkWarehous.Checked && string.IsNullOrEmpty(cmbWarehous.Text.Trim()))
  269. {
  270. MessageBox.Show("请选择仓库号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  271. return false;
  272. }
  273. if (chkMaterial.Checked && string.IsNullOrEmpty(cmbMaterial.Text.Trim()))
  274. {
  275. MessageBox.Show("请选择框号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  276. return false;
  277. }
  278. return true;
  279. }
  280. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  281. {
  282. UltraGridRow urg = ultraGrid1.ActiveRow;
  283. if (urg == null) return;
  284. string woid = urg.Cells["WoId"].Text;
  285. string matNo = urg.Cells["MatNo"].Text;
  286. string judgeNo = urg.Cells["JudgeStoveNo"].Text;
  287. //查询框号信息
  288. getQueryLocation(matNo);
  289. //查询合同相关信息
  290. getQueryOrder(woid,judgeNo);
  291. }
  292. //查询框号信息
  293. public void getQueryLocation(string matNo)
  294. {
  295. List<CouplingMatButtressEntity> listSource1 = EntityHelper.GetData<CouplingMatButtressEntity>
  296. ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryLocation", new object[] { matNo }, this.ob);
  297. CouplingButtbindingSource1.DataSource = listSource1;
  298. GridHelper.RefreshAndAutoSize(ultraGrid2);
  299. }
  300. //查询合同相关信息
  301. public void getQueryOrder(string woid,string judgeNo)
  302. {
  303. List<PlnZyJgMiddleEntity> listSource1 = EntityHelper.GetData<PlnZyJgMiddleEntity>
  304. ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryOrder", new object[] { woid,judgeNo }, this.ob);
  305. PlnZyJgMiddlebindingSource1.DataSource = listSource1;
  306. GridHelper.RefreshAndAutoSize(ultraGrid3);
  307. }
  308. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  309. {
  310. foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows)
  311. {
  312. if (uRow.GetType() != typeof(UltraGridGroupByRow))
  313. {
  314. uRow.Cells["CHK"].Value = true;
  315. }
  316. }
  317. }
  318. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  319. {
  320. this.ultraGrid1.UpdateData();
  321. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmJGMatNoReport.getBaseMaterialForChoose",
  322. new object[] { }, ob);
  323. dt.Columns["BASENAME"].Caption = "物料名称";
  324. BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "BASENAME", "BASECODE");
  325. baseInfo.Shown += new EventHandler((a, b) =>
  326. {
  327. var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where(
  328. c => c.GetValue("BASECODE") == this.cmbMaterial.Tag.ToString2()).FirstOrDefault();
  329. if (actRow != null) actRow.Activate();
  330. });
  331. if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  332. {
  333. //cmbLocationNo.Tag = baseInfo.ChoicedRow.GetValue("LOCATION_NO");
  334. //cmbLocationNo.Text = baseInfo.ChoicedRow.GetValue("LOCATION_NAME");
  335. this.ultraGrid1.ActiveCell.Value = baseInfo.ChoicedRow.GetValue("BASENAME");
  336. this.ultraGrid1.ActiveCell.Row.Cells["BlWlId"].Value = baseInfo.ChoicedRow.GetValue("BASECODE");
  337. }
  338. }
  339. private void FrmJGMatReport_Shown(object sender, EventArgs e)
  340. {
  341. toolMenu.Toolbars[0].Tools["Extinction"].InstanceProps.Visible = DefaultableBoolean.False;
  342. toolMenu.Toolbars[0].Tools["doUpdate"].InstanceProps.Visible = DefaultableBoolean.False;
  343. }
  344. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  345. {
  346. if (toolMenu == null) return;
  347. if (ultraTabControl1.SelectedTab.Key.Equals("0"))
  348. {
  349. toolMenu.Toolbars[0].Tools["Extinction"].InstanceProps.Visible = DefaultableBoolean.False;
  350. toolMenu.Toolbars[0].Tools["doUpdate"].InstanceProps.Visible = DefaultableBoolean.False;
  351. }
  352. if (ultraTabControl1.SelectedTab.Key.Equals("1"))
  353. {
  354. toolMenu.Toolbars[0].Tools["Extinction"].InstanceProps.Visible = DefaultableBoolean.True;
  355. toolMenu.Toolbars[0].Tools["doUpdate"].InstanceProps.Visible = DefaultableBoolean.True;
  356. }
  357. if (ultraTabControl1.SelectedTab.Key.Equals("2"))
  358. {
  359. toolMenu.Toolbars[0].Tools["Extinction"].InstanceProps.Visible = DefaultableBoolean.False;
  360. toolMenu.Toolbars[0].Tools["doUpdate"].InstanceProps.Visible = DefaultableBoolean.False;
  361. }
  362. }
  363. }
  364. }