FrmBaseMatStdManage.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. using System.Data;
  2. using System.Drawing;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. using CoreFS.CA03;
  7. using CoreFS.CA04;
  8. using CoreFS.CA06;
  9. using System.Collections;
  10. using Infragistics.Win.UltraWinGrid;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.Mes.Client.Comm.Control;
  13. using Core.Mes.Client.Comm.Tool;
  14. using System;
  15. namespace Core.StlMes.Client.Lims.Data.Mat
  16. {
  17. public partial class FrmBaseMatStdManage : FrmBase
  18. {
  19. public FrmBaseMatStdManage()
  20. {
  21. InitializeComponent();
  22. }
  23. protected override void OnLoad(EventArgs e)
  24. {
  25. base.OnLoad(e);
  26. ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
  27. }
  28. private void FrmBaseMatStdManage_Load(object sender, EventArgs e)
  29. {
  30. InitColumns();
  31. }
  32. private void InitColumns()
  33. {
  34. string[] arrColumnsBase = new string[] { "STD_TYPE_CODE", "STD_TYPE", "STANDARDS_ID", "STANDARDS_NO", "STANDARDS_CODE", "STANDARDS_DESC", "VERSION_NO", "STD_FALG", "START_TIME", "VALID_TIME", "REMARK", "FILE_POSITION", "VALIDFLAG", "VALIDFLAG_DESC", "CREATE_NAME", "CREATE_TIME", "UPDATE_NAME", "UPDATE_TIME" };
  35. string[] arrCaptionBase = new string[] { "标准类型", "标准类型", "标准ID", "标准组号", "标准代码", "标准名称", "版本号", "状态", "生效日期", "有效日期", "备注", "文件位置", "是否有效", "是否有效", "创建人", "创建时间", "修改人", "修改时间" };
  36. PublicMat.InitColumns(arrColumnsBase, arrCaptionBase, dataTable1, ultraGrid1, new string[] { "STD_TYPE_CODE", "VALIDFLAG" }, false, null);
  37. BindComBoxData();
  38. }
  39. private void BindComBoxData()
  40. {
  41. try
  42. {
  43. DataTable dt = PublicServer.GetData("com.steering.lims.data.base.FrmBaseSelectItems.GetBaseData", new Object[] { "4092" }, ob);
  44. if (dt == null || dt.Rows.Count == 0)
  45. {
  46. return;
  47. }
  48. ultraQuerySTD_TYPE.DataSource = dt;
  49. ultraQuerySTD_TYPE.ValueMember = "BASECODE";
  50. ultraQuerySTD_TYPE.DisplayMember = "BASENAME";
  51. ultraSTD_TYPE.DataSource = dt;
  52. ultraSTD_TYPE.ValueMember = "BASECODE";
  53. ultraSTD_TYPE.DisplayMember = "BASENAME";
  54. }
  55. catch (Exception ex)
  56. {
  57. MessageUtil.ShowError(ex.Message);
  58. }
  59. }
  60. /// <summary>
  61. /// 重写基类方法
  62. /// </summary>
  63. /// <param name="sender"></param>
  64. /// <param name="ToolbarKey"></param>
  65. public override void ToolBar_Click(object sender, string ToolbarKey)
  66. {
  67. //新增修改删除退出
  68. switch (ToolbarKey)
  69. {
  70. case "Query":
  71. QueryMatStdManageBase();
  72. break;
  73. //case "Refresh":
  74. // BindStdSteelData();
  75. // break;
  76. case "Add":
  77. AddMatStdManageBase();
  78. break;
  79. case "Update":
  80. UpdateMatStdManageBase();
  81. break;
  82. case "Delete":
  83. DeleteMatStdManageBase();
  84. break;
  85. case "Recover":
  86. if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Text.Trim() != "0")
  87. {
  88. MessageUtil.ShowWarning("请选择一条需要恢复且状态为无效的记录!");
  89. return;
  90. }
  91. ChangeMatStdManageBase("恢复", "1");
  92. break;
  93. case "Cancel":
  94. if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Text.Trim() != "1")
  95. {
  96. MessageUtil.ShowWarning("请选择一条需要作废且状态为有效的记录!");
  97. return;
  98. }
  99. ChangeMatStdManageBase("作废", "0");
  100. break;
  101. case "Clear":
  102. if (MessageUtil.ShowYesNoAndQuestion("是否确认清空?") == DialogResult.Yes)
  103. {
  104. ClearMatStdManageBase();
  105. }
  106. break;
  107. case "Close":
  108. if (MessageUtil.ShowYesNoAndQuestion("是否确认关闭页面?") == DialogResult.Yes)
  109. {
  110. this.Close();
  111. }
  112. break;
  113. }
  114. }
  115. private void QueryMatStdManageBase()
  116. {
  117. try
  118. {
  119. ArrayList arrayList = new ArrayList();
  120. if (chkVALIDFLAG.Checked)
  121. {
  122. arrayList.Add("");
  123. arrayList.Add("");
  124. arrayList.Add("");
  125. }
  126. else
  127. {
  128. arrayList.Add("1");
  129. arrayList.Add("1");
  130. arrayList.Add("1");
  131. }
  132. if (UserInfo.ParentDepartment == "供应部")
  133. {
  134. //供应部只维护临时协议标准
  135. arrayList.Add("409205");//临时协议标准
  136. arrayList.Add("409205");//临时协议标准
  137. arrayList.Add("409205");//临时协议标准
  138. }
  139. else
  140. {
  141. if (chKSTD_TYPE.Checked && ultraQuerySTD_TYPE.Value != null)
  142. {
  143. arrayList.Add(ultraQuerySTD_TYPE.Value.ToString());
  144. arrayList.Add(ultraQuerySTD_TYPE.Value.ToString());
  145. arrayList.Add(ultraQuerySTD_TYPE.Value.ToString());
  146. }
  147. else
  148. {
  149. arrayList.Add("");
  150. arrayList.Add("");
  151. arrayList.Add("");
  152. }
  153. }
  154. if (chkSTANDARDS_CODE.Checked && ultraQuerySTANDARDS_CODE.Value != null)
  155. {
  156. arrayList.Add(ultraQuerySTANDARDS_CODE.Value.ToString());
  157. arrayList.Add(ultraQuerySTANDARDS_CODE.Value.ToString());
  158. arrayList.Add(ultraQuerySTANDARDS_CODE.Value.ToString());
  159. }
  160. else
  161. {
  162. arrayList.Add("");
  163. arrayList.Add("");
  164. arrayList.Add("");
  165. }
  166. DataTable dt = PublicServer.GetData("com.steering.lims.data.base.FrmBaseMatStdManage.QueryMatStdManageBase",
  167. new Object[] { arrayList }, ob);
  168. if (dt == null || dt.Rows.Count == 0)
  169. {
  170. ClearMatStdManageBase();
  171. dataTable1.Rows.Clear();
  172. MessageUtil.ShowTips("没有维护标准基础数据!");
  173. return;
  174. }
  175. GridHelper.CopyDataToDatatable(dt, dataTable1, true);//把dt复制给dataTable1
  176. GridHelper.RefreshAndAutoSize(ultraGrid1);
  177. }
  178. catch (Exception e)
  179. {
  180. MessageUtil.ShowWarning(e.Message);
  181. return;
  182. }
  183. }
  184. private void AddMatStdManageBase()
  185. {
  186. try
  187. {
  188. if (ultraSTD_TYPE.Text.Trim() == "")
  189. {
  190. MessageUtil.ShowWarning("标准类型不能为空!");
  191. return;
  192. }
  193. if (txtSTANDARDS_CODE.Text.Trim() == "")
  194. {
  195. MessageUtil.ShowWarning("标准代码不能为空!");
  196. return;
  197. }
  198. if (ultraSTD_FALG.Text == "换版" && ultraGrid1.ActiveRow == null)
  199. {
  200. MessageUtil.ShowWarning("换版的标准新增必选点击选择上一个版本!");
  201. return;
  202. }
  203. if (MessageUtil.ShowYesNoAndQuestion("是否确认新增?") == DialogResult.Yes)
  204. {
  205. string strSTANDARDS_CODE = txtSTANDARDS_CODE.Text;
  206. ArrayList arrayList = new ArrayList();
  207. arrayList.Add(ultraSTD_TYPE.Value.ToString());
  208. arrayList.Add(ultraSTD_TYPE.Text.Trim());
  209. if (ultraSTD_FALG.Text == "换版")
  210. {
  211. arrayList.Add(ultraGrid1.ActiveRow.Cells["STANDARDS_NO"].Text.Trim());//标准组号
  212. arrayList.Add(ultraGrid1.ActiveRow.Cells["STANDARDS_NO"].Text.Trim());
  213. }
  214. else
  215. {
  216. arrayList.Add("");
  217. arrayList.Add("");
  218. }
  219. arrayList.Add(txtSTANDARDS_CODE.Text.Trim());
  220. arrayList.Add(txtSTANDARDS_DESC.Text.Trim());
  221. arrayList.Add(txtVERSION_NO.Text.Trim());
  222. arrayList.Add(ultraSTD_FALG.Text.Trim());
  223. arrayList.Add(START_TIME.Text.Trim());
  224. arrayList.Add(VALID_TIME.Text.Trim());
  225. arrayList.Add(txtREMARK.Text.Trim());
  226. arrayList.Add(UserInfo.GetUserName());
  227. PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatStdManage.AddMatStdManageBase",
  228. new Object[] { strSTANDARDS_CODE, arrayList }, this.ob);
  229. QueryMatStdManageBase();
  230. PublicMat.ActiveOperateRow(ultraGrid1, "STANDARDS_CODE", strSTANDARDS_CODE);//定位保存的行
  231. MessageUtil.ShowTips("新增成功!");
  232. }
  233. }
  234. catch (Exception e)
  235. {
  236. MessageUtil.ShowWarning(e.Message);
  237. return;
  238. }
  239. }
  240. private void UpdateMatStdManageBase()
  241. {
  242. try
  243. {
  244. if (ultraGrid1.ActiveRow == null)
  245. {
  246. MessageUtil.ShowWarning("请选择一条需要修改的记录!");
  247. return;
  248. }
  249. if (ultraSTD_TYPE.Text.Trim() == "")
  250. {
  251. MessageUtil.ShowWarning("标准类型不能为空!");
  252. return;
  253. }
  254. if (MessageUtil.ShowYesNoAndQuestion("是否确认修改?") == DialogResult.Yes)
  255. {
  256. string strSTANDARDS_ID = txtSTANDARDS_ID.Text;
  257. ArrayList arrayList = new ArrayList();
  258. arrayList.Add(ultraSTD_TYPE.Value.ToString());
  259. arrayList.Add(ultraSTD_TYPE.Text.Trim());
  260. arrayList.Add(txtSTANDARDS_CODE.Text.Trim());
  261. arrayList.Add(txtSTANDARDS_DESC.Text.Trim());
  262. arrayList.Add(txtVERSION_NO.Text.Trim());
  263. arrayList.Add(ultraSTD_FALG.Text.Trim());
  264. arrayList.Add(START_TIME.Text.Trim());
  265. arrayList.Add(VALID_TIME.Text.Trim());
  266. arrayList.Add(txtREMARK.Text.Trim());
  267. arrayList.Add(UserInfo.GetUserName());
  268. arrayList.Add(strSTANDARDS_ID);
  269. PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatStdManage.UpdateMatStdManageBase",
  270. new Object[] { txtSTANDARDS_CODE.Text.Trim(), strSTANDARDS_ID, arrayList }, this.ob);
  271. QueryMatStdManageBase();
  272. PublicMat.ActiveOperateRow(ultraGrid1, "STANDARDS_ID", strSTANDARDS_ID);//定位保存的行
  273. MessageUtil.ShowTips("修改成功!");
  274. }
  275. }
  276. catch (Exception e)
  277. {
  278. MessageUtil.ShowWarning(e.Message);
  279. return;
  280. }
  281. }
  282. private void DeleteMatStdManageBase()
  283. {
  284. try
  285. {
  286. if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Text.Trim() != "1")
  287. {
  288. MessageUtil.ShowWarning("请选择一条需要删除且状态为有效的记录!");
  289. return;
  290. }
  291. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.Yes)
  292. {
  293. string strSTANDARDS_ID = txtSTANDARDS_ID.Text;
  294. ArrayList arrayList = new ArrayList();
  295. arrayList.Add(strSTANDARDS_ID);
  296. PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatStdManage.DeleteMatStdManageBase",
  297. new Object[] { arrayList }, this.ob);
  298. QueryMatStdManageBase();
  299. MessageUtil.ShowTips("删除成功!");
  300. }
  301. }
  302. catch (Exception e)
  303. {
  304. MessageUtil.ShowWarning(e.Message);
  305. return;
  306. }
  307. }
  308. private void ChangeMatStdManageBase(string strOper, string flag)
  309. {
  310. try
  311. {
  312. if (MessageUtil.ShowYesNoAndQuestion("是否确认" + strOper + "?") == DialogResult.Yes)
  313. {
  314. string strSTANDARDS_ID = txtSTANDARDS_ID.Text;
  315. ArrayList arrayList = new ArrayList();
  316. arrayList.Add(flag);
  317. arrayList.Add(strSTANDARDS_ID);
  318. PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatStdManage.ChangeMatStdManageBase",
  319. new Object[] { arrayList }, this.ob);
  320. QueryMatStdManageBase();
  321. MessageUtil.ShowTips(strOper + "成功!");
  322. }
  323. }
  324. catch (Exception e)
  325. {
  326. MessageUtil.ShowWarning(e.Message);
  327. return;
  328. }
  329. }
  330. private void ClearMatStdManageBase()
  331. {
  332. ultraSTD_TYPE.Text = "";
  333. txtSTANDARDS_ID.Text = "";
  334. txtSTANDARDS_CODE.Text = "";
  335. txtVERSION_NO.Text = "";
  336. txtSTANDARDS_DESC.Text = "";
  337. START_TIME.Value = DateTime.Now;
  338. VALID_TIME.Value = DateTime.Now;
  339. ultraSTD_FALG.Text = "";
  340. txtFILE_POSITION.Text = "";
  341. txtREMARK.Text = "";
  342. }
  343. private void View_Click(object sender, EventArgs e)
  344. {
  345. UltraGridRow ur = ultraGrid1.ActiveRow;
  346. if (ur == null)
  347. {
  348. MessageUtil.ShowWarning("请选择一条需要查看上传文件的记录!");
  349. return;
  350. }
  351. if (txtFILE_POSITION.Text == "")
  352. {
  353. MessageUtil.ShowWarning("请先上传再查看!");
  354. return;
  355. }
  356. string strTableName = "BASE_MAT_STD_MANAGE";
  357. string strId = ur.Cells["STANDARDS_ID"].Text.Trim();
  358. string path = "Lims/data/base/" + this.Name + "/" + ur.Cells["STANDARDS_ID"].Text.Trim() + "/";
  359. if (PublicMat.ViewFilePosition(this.ob, path) == false)
  360. {
  361. PublicMat.UpdateFilePosition(strTableName, "", "STANDARDS_ID", strId, this.ob);//更改数据库存储路径
  362. QueryMatStdManageBase();
  363. PublicMat.ActiveOperateRow(ultraGrid1, "STANDARDS_ID", strId);//定位保存的行
  364. }
  365. }
  366. private void Upload_Click(object sender, EventArgs e)
  367. {
  368. //if (txtCER_BOOK.Text != "")
  369. //{
  370. // MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!");
  371. // return;
  372. //}
  373. UltraGridRow ur = ultraGrid1.ActiveRow;
  374. if (ur == null)
  375. {
  376. MessageUtil.ShowWarning("请选择一条需要上传文件的记录!");
  377. return;
  378. }
  379. string strTableName = "BASE_MAT_STD_MANAGE";
  380. string strId = ur.Cells["STANDARDS_ID"].Text.Trim();
  381. string path = "Lims/data/base/" + this.Name + "/" + strId + "/";
  382. if (PublicMat.UploadFilePosition(this.ob, path))
  383. {
  384. PublicMat.UpdateFilePosition(strTableName, path, "STANDARDS_ID", strId, this.ob);//更改数据库存储路径
  385. QueryMatStdManageBase();
  386. PublicMat.ActiveOperateRow(ultraGrid1, "STANDARDS_ID", strId);
  387. }
  388. }
  389. private void chKSTD_TYPE_CheckedChanged(object sender, EventArgs e)
  390. {
  391. ultraQuerySTD_TYPE.Enabled = chKSTD_TYPE.Checked;
  392. }
  393. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  394. {
  395. setValue();
  396. }
  397. private void setValue()
  398. {
  399. ultraSTD_TYPE.Text = ultraGrid1.ActiveRow.Cells["STD_TYPE"].Text.Trim();
  400. txtSTANDARDS_ID.Text = ultraGrid1.ActiveRow.Cells["STANDARDS_ID"].Text.Trim();
  401. txtSTANDARDS_CODE.Text = ultraGrid1.ActiveRow.Cells["STANDARDS_CODE"].Text.Trim();
  402. txtVERSION_NO.Text = ultraGrid1.ActiveRow.Cells["VERSION_NO"].Text.Trim();
  403. txtSTANDARDS_DESC.Text = ultraGrid1.ActiveRow.Cells["STANDARDS_DESC"].Text.Trim();
  404. START_TIME.Text = ultraGrid1.ActiveRow.Cells["START_TIME"].Text.Trim();
  405. VALID_TIME.Text = ultraGrid1.ActiveRow.Cells["VALID_TIME"].Text.Trim();
  406. ultraSTD_FALG.Text = ultraGrid1.ActiveRow.Cells["STD_FALG"].Text.Trim();
  407. txtFILE_POSITION.Text = ultraGrid1.ActiveRow.Cells["FILE_POSITION"].Text.Trim();
  408. txtREMARK.Text = ultraGrid1.ActiveRow.Cells["REMARK"].Text.Trim();
  409. }
  410. private void chkSTANDARDS_CODE_CheckedChanged(object sender, EventArgs e)
  411. {
  412. ultraQuerySTANDARDS_CODE.Enabled = chkSTANDARDS_CODE.Checked;
  413. }
  414. }
  415. }