F_MST_0407.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /*******************************************************************************
  2. * Copyright(c) 2014 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0407.cs
  5. * 2.功能描述:产品缺陷
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 任海 2014/09/10 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.Basics.Library;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. namespace Dongke.IBOSS.PRD.Client.SystemModule
  20. {
  21. /// <summary>
  22. /// 产品缺陷
  23. /// </summary>
  24. public partial class F_MST_0407 : FormBase
  25. {
  26. #region 成员变量
  27. // 窗体的单例模式
  28. private static F_MST_0407 _instance;
  29. // 产品缺陷数据源
  30. private DataTable _dtSourse;
  31. // 缺陷类别
  32. private int _DefectTypeId = Constant.INT_IS_ZERO;
  33. #endregion
  34. #region 构造函数
  35. /// <summary>
  36. /// 构造函数
  37. /// </summary>
  38. public F_MST_0407()
  39. {
  40. InitializeComponent();
  41. // 窗口标题
  42. this.Text = FormTitles.F_MST_0407;
  43. // 按钮
  44. this.btnSave.Text = ButtonText.BTN_SAVE;
  45. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  46. }
  47. #endregion
  48. #region 单例模式
  49. /// <summary>
  50. /// 单例模式,防止重复创建窗体
  51. /// </summary>
  52. public static F_MST_0407 Instance
  53. {
  54. get
  55. {
  56. if (_instance == null)
  57. {
  58. _instance = new F_MST_0407();
  59. }
  60. return _instance;
  61. }
  62. }
  63. #endregion
  64. #region 事件
  65. /// <summary>
  66. /// 窗体加载
  67. /// </summary>
  68. /// <param name="sender"></param>
  69. /// <param name="e"></param>
  70. private void F_MST_0407_Load(object sender, System.EventArgs e)
  71. {
  72. try
  73. {
  74. // 设置datagridview不自动创建列
  75. this.dgvDataDefect.AutoGenerateColumns = false;
  76. // 加载产品缺陷管理数据
  77. // 窗体启动立即加载全部产品缺陷信息
  78. this.GetAllDefect();
  79. this.RefreshDataGridViewData();
  80. this.dgvDataDefect.IsSetInputColumnsColor = true;
  81. // 绑定缺陷类型数据
  82. DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  83. {
  84. return SystemModuleProxy.Service.GetAllDefectTypeInfo();
  85. }));
  86. DataView dv = dsResultAccount.Tables[0].DefaultView;
  87. dv.RowFilter = "valueflag=1";
  88. DataTable dtDefectType = dv.ToTable();
  89. this.DefectTypeID.ValueMember = "DefectTypeID";
  90. this.DefectTypeID.DisplayMember = "DefectTypeName";
  91. this.DefectTypeID.DataSource = dtDefectType;
  92. //把第一条数据绑定给窑炉类型
  93. if (dtDefectType != null && dtDefectType.Rows.Count > Constant.INT_IS_ZERO)
  94. {
  95. this._DefectTypeId = Convert.ToInt32(dtDefectType.Rows[0]["DefectTypeID"]);
  96. }
  97. //权限控制
  98. FormPermissionManager.FormPermissionControl(this.Name, this,
  99. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  100. this.dgvDataDefect.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
  101. }
  102. catch (Exception ex)
  103. {
  104. // 对异常进行共通处理
  105. ExceptionManager.HandleEventException(this.ToString(),
  106. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  107. }
  108. }
  109. /// <summary>
  110. /// 点击右上角关闭按钮
  111. /// </summary>
  112. /// <param name="sender"></param>
  113. /// <param name="e"></param>
  114. private void F_MST_0407_FormClosing(object sender, FormClosingEventArgs e)
  115. {
  116. try
  117. {
  118. // 关闭的时候需要判断是否有数据变化
  119. if (DataJudge.IsChange((DataTable)this.dgvDataDefect.DataSource))
  120. {
  121. DialogResult dialogResult = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  122. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  123. // 保存改变的数据
  124. if (dialogResult == DialogResult.Yes)
  125. {
  126. DataGridViewRow row = dgvDataDefect.CurrentRow;
  127. if (!row.IsNewRow)
  128. {
  129. // 判断产品缺陷编码不能为空
  130. if (row.Cells["DefectCode"].Value == null
  131. || string.IsNullOrEmpty(row.Cells["DefectCode"].Value + string.Empty))
  132. {
  133. // 错误消息
  134. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品缺陷编码"),
  135. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  136. e.Cancel = true;
  137. this.btnSave.Enabled = false;
  138. return;
  139. }
  140. // 判断产品缺陷名称不能为空
  141. if (row.Cells["DefectName"].Value == null
  142. || string.IsNullOrEmpty(row.Cells["DefectName"].Value + string.Empty))
  143. {
  144. // 单元格的错误消息
  145. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品缺陷名称"),
  146. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  147. e.Cancel = true;
  148. this.btnSave.Enabled = false;
  149. return;
  150. }
  151. // 判断缺陷类别不能为空
  152. if (row.Cells["DefectTypeID"].Value == null
  153. || string.IsNullOrEmpty(row.Cells["DefectTypeID"].Value + string.Empty))
  154. {
  155. // 单元格的错误消息
  156. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "缺陷类别"),
  157. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  158. e.Cancel = true;
  159. this.btnSave.Enabled = false;
  160. return;
  161. }
  162. }
  163. // 异步处理
  164. object result = DoAsync(new BaseAsyncMethod(SaveDefectData));
  165. if (result.Equals(Constant.INT_IS_ONE))
  166. {
  167. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "产品缺陷编码"),
  168. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  169. e.Cancel = true;
  170. this.btnSave.Enabled = false;
  171. return;
  172. }
  173. // 保存成功,不关闭窗体
  174. if (Convert.ToInt32(result) > Constant.INT_IS_ZERO)
  175. {
  176. e.Cancel = true;
  177. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "产品缺陷管理", "保存"),
  178. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  179. this.btnSave.Enabled = false;
  180. // 加载产品缺陷管理数据
  181. this._dtSourse.AcceptChanges();
  182. }
  183. else if (Convert.ToInt32(result) == (int)Constant.RETURN_IS_EXIST)
  184. {
  185. e.Cancel = true;
  186. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "产品缺陷名称"),
  187. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  188. }
  189. else
  190. {
  191. e.Cancel = true;
  192. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "产品缺陷管理", "保存"),
  193. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  194. }
  195. }
  196. else if (dialogResult == DialogResult.Cancel)
  197. {
  198. e.Cancel = true;
  199. }
  200. }
  201. }
  202. catch (Exception ex)
  203. {
  204. // 对异常进行共通处理
  205. ExceptionManager.HandleEventException(this.ToString(),
  206. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  207. }
  208. }
  209. /// <summary>
  210. /// 窗体关闭后,释放单例资源
  211. /// </summary>
  212. /// <param name="sender"></param>
  213. /// <param name="e"></param>
  214. private void F_MST_0407_FormClosed(object sender, FormClosedEventArgs e)
  215. {
  216. _instance = null;
  217. }
  218. /// <summary>
  219. /// 选中新行时,设置默认值
  220. /// </summary>
  221. /// <param name="sender"></param>
  222. /// <param name="e"></param>
  223. private void dgvDataDefect_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
  224. {
  225. // 设置有效属性为选中状态
  226. e.Row.Cells["ValueFlag"].Value = Constant.INT_IS_ONE;
  227. if (_DefectTypeId > 0)
  228. {
  229. e.Row.Cells["DefectTypeID"].Value = _DefectTypeId;
  230. }
  231. e.Row.Cells["DisplayNo"].Value = e.Row.Index + 1;
  232. }
  233. /// <summary>
  234. /// 产品缺陷管理信息输入格式控制
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. private void dgvDataDefect_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  239. {
  240. try
  241. {
  242. // 只对文本框做控制
  243. //if (e.Control is DataGridViewTextBoxEditingControl)
  244. //{
  245. // DataGridViewTextBoxEditingControl EditingControl = (DataGridViewTextBoxEditingControl)e.Control;
  246. //}
  247. TextBox tb = (e.Control as TextBox);
  248. if (tb != null)
  249. {
  250. if ("DefectCode" == this.dgvDataDefect.Columns[this.dgvDataDefect.CurrentCell.ColumnIndex].Name)
  251. {
  252. tb.CharacterCasing = CharacterCasing.Upper;
  253. }
  254. else
  255. {
  256. tb.CharacterCasing = CharacterCasing.Normal;
  257. }
  258. }
  259. }
  260. catch (Exception ex)
  261. {
  262. // 对异常进行共通处理
  263. ExceptionManager.HandleEventException(this.ToString(),
  264. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  265. }
  266. }
  267. /// <summary>
  268. /// 单元格验证,检查
  269. /// </summary>
  270. /// <param name="sender"></param>
  271. /// <param name="e"></param>
  272. private void dgvDataDefect_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  273. {
  274. try
  275. {
  276. if (this.ActiveControl != null && "btnClose".Equals(this.ActiveControl.Name))
  277. {
  278. return;
  279. }
  280. if (!dgvDataDefect.CurrentRow.IsNewRow)
  281. {
  282. DataGridViewRow rowItem = dgvDataDefect.Rows[e.RowIndex];
  283. DataGridViewColumn columnItem = dgvDataDefect.Columns[e.ColumnIndex];
  284. object columnvalue = rowItem.Cells[columnItem.Name].EditedFormattedValue;
  285. // 产品缺陷编码
  286. if ("DefectCode".Equals(columnItem.Name))
  287. {
  288. if (columnvalue != null && !string.IsNullOrEmpty(columnvalue + string.Empty))
  289. {
  290. if (!Utility.IsUnique(columnvalue.ToString(),
  291. dgvDataDefect.CurrentRow.Index, this.dgvDataDefect, "DefectCode"))
  292. {
  293. // 单元格的错误消息
  294. this.dgvDataDefect.CurrentRow.ErrorText = string.Format(
  295. Messages.MSG_CMN_W006, "产品缺陷编码");
  296. e.Cancel = true;
  297. this.btnSave.Enabled = false;
  298. return;
  299. }
  300. }
  301. }
  302. // 清除单元格的错误消息
  303. this.dgvDataDefect.CurrentRow.ErrorText = string.Empty;
  304. }
  305. }
  306. catch (Exception ex)
  307. {
  308. // 对异常进行共通处理
  309. ExceptionManager.HandleEventException(this.ToString(),
  310. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  311. }
  312. }
  313. /// <summary>
  314. /// 根据数据是否变化,设置保存按钮的可用状态
  315. /// </summary>
  316. /// <param name="sender"></param>
  317. /// <param name="e"></param>
  318. private void dgvDataDefect_CellValidated(object sender, DataGridViewCellEventArgs e)
  319. {
  320. try
  321. {
  322. this.SetSaveBtnStatus();
  323. }
  324. catch (Exception ex)
  325. {
  326. // 对异常进行共通处理
  327. ExceptionManager.HandleEventException(this.ToString(),
  328. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  329. }
  330. }
  331. /// <summary>
  332. /// 行校验
  333. /// </summary>
  334. /// <param name="sender"></param>
  335. /// <param name="e"></param>
  336. private void dgvDataDefect_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
  337. {
  338. try
  339. {
  340. // 按Esc键时不校验
  341. if (!dgvDataDefect.IsCurrentRowDirty)
  342. {
  343. this.dgvDataDefect.IsSetInputColumnsColor = true;
  344. return;
  345. }
  346. if (this.ActiveControl != null && "btnClose".Equals(this.ActiveControl.Name))
  347. {
  348. // 清除单元格的错误消息
  349. this.dgvDataDefect.CurrentRow.ErrorText = string.Empty;
  350. return;
  351. }
  352. DataGridViewRow row = dgvDataDefect.CurrentRow;
  353. if (!row.IsNewRow)
  354. {
  355. // 判断产品缺陷编码能为空
  356. if (row.Cells["DefectCode"].Value == null
  357. || string.IsNullOrEmpty(row.Cells["DefectCode"].Value + string.Empty))
  358. {
  359. // 单元格的错误消息
  360. this.dgvDataDefect.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "产品缺陷编码");
  361. e.Cancel = true;
  362. this.btnSave.Enabled = false;
  363. return;
  364. }
  365. // 判断产品缺陷名称不能为空
  366. if (row.Cells["DefectName"].Value == null
  367. || string.IsNullOrEmpty(row.Cells["DefectName"].Value + string.Empty))
  368. {
  369. // 单元格的错误消息
  370. this.dgvDataDefect.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "产品缺陷名称");
  371. e.Cancel = true;
  372. this.btnSave.Enabled = false;
  373. return;
  374. }
  375. // 判断窑炉类别不能为空
  376. if (row.Cells["DefectTypeID"].Value == null
  377. || string.IsNullOrEmpty(row.Cells["DefectTypeID"].Value + string.Empty))
  378. {
  379. // 单元格的错误消息
  380. this.dgvDataDefect.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "缺陷类别");
  381. e.Cancel = true;
  382. this.btnSave.Enabled = false;
  383. return;
  384. }
  385. // 清除单元格的错误消息
  386. this.dgvDataDefect.CurrentRow.ErrorText = string.Empty;
  387. }
  388. }
  389. catch (Exception ex)
  390. {
  391. // 对异常进行共通处理
  392. ExceptionManager.HandleEventException(this.ToString(),
  393. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  394. }
  395. }
  396. /// <summary>
  397. /// 根据数据是否变化,设置保存按钮的可用状态
  398. /// </summary>
  399. /// <param name="sender"></param>
  400. /// <param name="e"></param>
  401. private void dgvDataDefect_RowValidated(object sender, DataGridViewCellEventArgs e)
  402. {
  403. try
  404. {
  405. this.SetSaveBtnStatus();
  406. }
  407. catch (Exception ex)
  408. {
  409. // 对异常进行共通处理
  410. ExceptionManager.HandleEventException(this.ToString(),
  411. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  412. }
  413. }
  414. /// <summary>
  415. /// 根据是否选中停用数据,加载数据
  416. /// </summary>
  417. /// <param name="sender"></param>
  418. /// <param name="e"></param>
  419. private void chkDisplayDisabledData_CheckedChanged(object sender, EventArgs e)
  420. {
  421. try
  422. {
  423. this.RefreshDataGridViewData();
  424. this.SetSaveBtnStatus();
  425. this.dgvDataDefect.IsSetInputColumnsColor = true;
  426. }
  427. catch (Exception ex)
  428. {
  429. // 对异常进行共通处理
  430. ExceptionManager.HandleEventException(this.ToString(),
  431. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  432. }
  433. }
  434. /// <summary>
  435. /// 单元格输入时,给自动生成的行设置颜色
  436. /// </summary>
  437. /// <param name="sender"></param>
  438. /// <param name="e"></param>
  439. private void dgvDataDefect_UserAddedRow(object sender, DataGridViewRowEventArgs e)
  440. {
  441. this.dgvDataDefect.IsSetInputColumnsColor = true;
  442. }
  443. /// <summary>
  444. /// 设置排序时列表的颜色
  445. /// </summary>
  446. private void dgvDataDefect_Sorted(object sender, EventArgs e)
  447. {
  448. this.dgvDataDefect.IsSetInputColumnsColor = true;
  449. }
  450. /// <summary>
  451. /// 保存产品缺陷数据
  452. /// </summary>
  453. /// <param name="sender"></param>
  454. /// <param name="e"></param>
  455. private void btnSave_Click(object sender, EventArgs e)
  456. {
  457. try
  458. {
  459. int results = Conservation();
  460. //判断单元格必输项不能为空
  461. if (results == Constant.INT_IS_ONE)
  462. {
  463. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品缺陷编码"),
  464. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  465. this.btnSave.Enabled = false;
  466. return;
  467. }
  468. if (results == Constant.INT_IS_TWO)
  469. {
  470. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品缺陷名称"),
  471. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  472. this.btnSave.Enabled = false;
  473. return;
  474. }
  475. if (results == Constant.INT_IS_THREE)
  476. {
  477. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "缺陷类别"),
  478. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  479. this.btnSave.Enabled = false;
  480. return;
  481. }
  482. // 异步处理
  483. this.btnSave.Enabled = false;
  484. this.btnCancel.Enabled = false;
  485. int result = (int)DoAsync(new BaseAsyncMethod(SaveDefectData));
  486. this.btnSave.Enabled = true;
  487. this.btnCancel.Enabled = true;
  488. // 产品缺陷数据保存成功
  489. if (result == Constant.INT_IS_TWO)
  490. {
  491. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "产品缺陷管理", "保存"),
  492. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  493. // 加载产品缺陷管理数据
  494. this._dtSourse.AcceptChanges();
  495. this.btnSave.Enabled = false;
  496. }
  497. else if (result == Constant.INT_IS_ONE)
  498. {
  499. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "产品缺陷编码"),
  500. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  501. return;
  502. }
  503. else
  504. {
  505. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "产品缺陷管理", "保存"),
  506. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  507. }
  508. this.dgvDataDefect.IsSetInputColumnsColor = true;
  509. }
  510. catch (Exception ex)
  511. {
  512. this.btnSave.Enabled = true;
  513. this.btnCancel.Enabled = true;
  514. // 对异常进行共通处理
  515. ExceptionManager.HandleEventException(this.ToString(),
  516. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  517. }
  518. }
  519. /// <summary>
  520. /// 点击关闭按钮
  521. /// </summary>
  522. /// <param name="sender"></param>
  523. /// <param name="e"></param>
  524. private void btnCancel_Click(object sender, EventArgs e)
  525. {
  526. this.Close();
  527. }
  528. #endregion
  529. #region 私有方法
  530. /// <summary>
  531. /// 加载产品缺陷管理数据
  532. /// </summary>
  533. /// <returns></returns>
  534. private DataSet GetDefectData()
  535. {
  536. try
  537. {
  538. byte valueFlag = Convert.ToByte(chkDisplayDisabledData.Checked);
  539. return SystemModuleProxy.Service.GetDefectData(valueFlag);
  540. }
  541. catch (Exception ex)
  542. {
  543. throw ex;
  544. }
  545. }
  546. /// <summary>
  547. /// 获取产品缺陷管理的全部数据
  548. /// </summary>
  549. /// <param name="sUserInfo">用户信息</param>
  550. /// <returns></returns>
  551. /// <remarks>
  552. /// 2014.10.30 任海 新建
  553. /// </remarks>
  554. private void GetAllDefect()
  555. {
  556. try
  557. {
  558. DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  559. {
  560. return SystemModuleProxy.Service.GetAllDefectInfo();
  561. }));
  562. this._dtSourse = dsResultAccount.Tables[0];
  563. }
  564. catch (Exception ex)
  565. {
  566. throw ex;
  567. }
  568. }
  569. /// <summary>
  570. /// 得到产品缺陷信息
  571. /// </summary>
  572. /// <returns></returns>
  573. private void RefreshDataGridViewData()
  574. {
  575. try
  576. {
  577. if (this.chkDisplayDisabledData.Checked == false)
  578. {
  579. this._dtSourse.DefaultView.RowFilter = "ValueFlag=1";
  580. }
  581. else
  582. {
  583. this._dtSourse.DefaultView.RowFilter = null;
  584. }
  585. this.dgvDataDefect.DataSource = _dtSourse;
  586. this.btnSave.Enabled = false;
  587. }
  588. catch (Exception ex)
  589. {
  590. throw ex;
  591. }
  592. }
  593. /// <summary>
  594. /// 保存产品缺陷数据
  595. /// </summary>
  596. /// <returns>是否成功</returns>
  597. private object SaveDefectData()
  598. {
  599. try
  600. {
  601. // 获取当前dataDefectData数据源
  602. DataTable dataDefectData = (DataTable)this.dgvDataDefect.DataSource;
  603. int result = SystemModuleProxy.Service.SaveDefectData(dataDefectData);
  604. return result;
  605. }
  606. catch (Exception ex)
  607. {
  608. throw ex;
  609. }
  610. }
  611. /// <summary>
  612. /// 设置保存按钮的可用状态
  613. /// </summary>
  614. private void SetSaveBtnStatus()
  615. {
  616. if (DataJudge.IsChange((DataTable)this.dgvDataDefect.DataSource))
  617. {
  618. this.btnSave.Enabled = true;
  619. }
  620. else
  621. {
  622. this.btnSave.Enabled = false;
  623. }
  624. }
  625. /// <summary>
  626. /// 保存时单元格必输项不能为空
  627. /// </summary>
  628. private int Conservation()
  629. {
  630. int isConservation = Constant.INT_IS_ZERO;
  631. DataTable dataDefectData = (DataTable)this.dgvDataDefect.DataSource;
  632. foreach (DataRow drproductionData in dataDefectData.Rows)
  633. {
  634. //判断必输项是否为空
  635. if (drproductionData["DefectCode"].ToString() == string.Empty)
  636. {
  637. isConservation = Constant.INT_IS_ONE;
  638. break;
  639. }
  640. if (drproductionData["DefectName"].ToString() == string.Empty)
  641. {
  642. isConservation = Constant.INT_IS_TWO;
  643. break;
  644. }
  645. if (drproductionData["DefectTypeID"].ToString() == string.Empty)
  646. {
  647. isConservation = Constant.INT_IS_THREE;
  648. break;
  649. }
  650. }
  651. return isConservation;
  652. }
  653. #endregion
  654. }
  655. }