F_PM_0103.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0103.cs
  5. * 2.功能描述:注浆明细条码绑定
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2015/04/03 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Reflection;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. using Dongke.IBOSS.PRD.Basics.BaseControls;
  17. using Dongke.IBOSS.PRD.Basics.BaseResources;
  18. using Dongke.IBOSS.PRD.Client.CommonModule;
  19. using Dongke.IBOSS.PRD.Client.Controls;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. namespace Dongke.IBOSS.PRD.Client.PMModule
  23. {
  24. /// <summary>
  25. /// 注浆明细条码绑定
  26. /// </summary>
  27. public partial class F_PM_0103 : DKFormBase
  28. {
  29. #region 成员变量
  30. // 注浆日报ID
  31. private int _dailyId;
  32. // 注浆日期
  33. private DateTime _groutingDate = DateTime.Now.Date;
  34. private bool _canEdit = true;
  35. #endregion
  36. #region 构造函数
  37. /// <summary>
  38. /// 构造函数
  39. /// </summary>
  40. public F_PM_0103()
  41. :this(0)
  42. {
  43. }
  44. /// <summary>
  45. /// 构造函数
  46. /// </summary>
  47. /// <param name="dailyID">注浆日报ID</param>
  48. public F_PM_0103(int dailyID)
  49. {
  50. this.InitializeComponent();
  51. this._dailyId = dailyID;
  52. this.InitializeControls();
  53. }
  54. #endregion
  55. #region 属性
  56. /// <summary>
  57. /// 注浆登记ID
  58. /// </summary>
  59. public List<int> GroutingDailyIDs
  60. {
  61. get;
  62. private set;
  63. }
  64. #endregion
  65. #region 事件
  66. /// <summary>
  67. /// 窗体加载
  68. /// </summary>
  69. private void F_PM_0103_Load(object sender, EventArgs e)
  70. {
  71. try
  72. {
  73. this.lblGroutingDateValue.Text = string.Empty;
  74. DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
  75. if (logoInfo != null && logoInfo.Tables.Count > 0)
  76. {
  77. this.cmbLogo.DataSource = logoInfo.Tables[0];
  78. this.cmbLogo.DisplayMember = "LogoNameCode";
  79. this.cmbLogo.ValueMember = "LogoID";
  80. this.collogo.DataSource = logoInfo.Tables[0].Copy();
  81. this.collogo.DisplayMember = "LogoNameCode";
  82. this.collogo.ValueMember = "LogoID";
  83. }
  84. // 设置列表未注浆原因选项数据源
  85. this.InitializeData();
  86. }
  87. catch (Exception ex)
  88. {
  89. // 对异常进行共通处理
  90. ExceptionManager.HandleEventException(this.ToString(),
  91. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  92. }
  93. }
  94. /// <summary>
  95. /// 选择注浆登记信息
  96. /// </summary>
  97. /// <param name="sender"></param>
  98. /// <param name="e"></param>
  99. private void tsbtnGrouting_Click(object sender, EventArgs e)
  100. {
  101. try
  102. {
  103. F_PM_0105 frmPM0105 = new F_PM_0105();
  104. //frmPM0105.GroutingDate = this._groutingDate;
  105. DialogResult dialogResult = frmPM0105.ShowDialog();
  106. if (dialogResult != DialogResult.OK)
  107. {
  108. return;
  109. }
  110. this._dailyId = frmPM0105.GroutingDailyID;
  111. this.InitializeData();
  112. }
  113. catch (Exception ex)
  114. {
  115. // 对异常进行共通处理
  116. ExceptionManager.HandleEventException(this.ToString(),
  117. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  118. }
  119. }
  120. /// <summary>
  121. /// 提交选择列内容的修改
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. private void dgvDetail_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  126. {
  127. try
  128. {
  129. if (this.dgvDetail.CurrentRow != null && this.dgvDetail.IsCurrentCellDirty)
  130. {
  131. if ("ScrapFlag".Equals(this.dgvDetail.Columns
  132. [this.dgvDetail.CurrentCell.ColumnIndex].Name))
  133. {
  134. this.dgvDetail.CommitEdit(DataGridViewDataErrorContexts.Commit);
  135. }
  136. //else if ("BarCode".Equals(this.dgvDetail.Columns
  137. // [this.dgvDetail.CurrentCell.ColumnIndex].Name))
  138. //{
  139. // this.dgvDetail.CommitEdit(DataGridViewDataErrorContexts.Commit);
  140. //}
  141. }
  142. }
  143. catch (Exception ex)
  144. {
  145. // 对异常进行共通处理
  146. ExceptionManager.HandleEventException(this.ToString(),
  147. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  148. }
  149. }
  150. /// <summary>
  151. /// 损坯时,不能绑定条码
  152. /// </summary>
  153. private void dgvDetail_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  154. {
  155. if (e.RowIndex < 0)
  156. {
  157. return;
  158. }
  159. try
  160. {
  161. DataGridViewRow dataGridViewRow = this.dgvDetail.Rows[e.RowIndex];
  162. if ("ScrapFlag".Equals(this.dgvDetail.Columns[e.ColumnIndex].Name))
  163. {
  164. // 未绑定时,如果是改变了损坯标识,则对绑定条码进行控制输入
  165. object obarCode = dataGridViewRow.Cells["colOBarCode"].Value;
  166. if (obarCode == null || obarCode == DBNull.Value || string.IsNullOrWhiteSpace(obarCode.ToString()))
  167. {
  168. // 选择了损坯
  169. if (((int)Constant.GroutingScrapFlag.Yes).ToString() ==
  170. dataGridViewRow.Cells["ScrapFlag"].Value.ToString())
  171. {
  172. dataGridViewRow.Cells["BarCode"].ReadOnly = true;
  173. dataGridViewRow.Cells["BarCode"].Value = DBNull.Value;
  174. }
  175. else
  176. {
  177. if (_canEdit)
  178. {
  179. dataGridViewRow.Cells["BarCode"].ReadOnly = false;
  180. }
  181. else
  182. {
  183. dataGridViewRow.Cells["BarCode"].ReadOnly = true;
  184. }
  185. }
  186. this.dgvDetail.IsSetInputColumnsColor = true;
  187. }
  188. }
  189. if ("BarCode".Equals(this.dgvDetail.Columns[e.ColumnIndex].Name))
  190. {
  191. object obarCode = dataGridViewRow.Cells["colOBarCode"].Value;
  192. if (obarCode == null || obarCode == DBNull.Value || string.IsNullOrWhiteSpace(obarCode.ToString()))
  193. {
  194. // 选择了损坯
  195. if (dataGridViewRow.Cells["BarCode"].Value!=null && dataGridViewRow.Cells["BarCode"].Value.ToString()!="")
  196. {
  197. dataGridViewRow.Cells["ScrapFlag"].ReadOnly = true;
  198. dataGridViewRow.Cells["ScrapFlag"].Value = DBNull.Value;
  199. }
  200. else
  201. {
  202. if (_canEdit)
  203. {
  204. dataGridViewRow.Cells["ScrapFlag"].ReadOnly = false;
  205. }
  206. else
  207. {
  208. dataGridViewRow.Cells["ScrapFlag"].ReadOnly = true;
  209. }
  210. }
  211. this.dgvDetail.IsSetInputColumnsColor = true;
  212. }
  213. }
  214. }
  215. catch (Exception ex)
  216. {
  217. // 对异常进行共通处理
  218. ExceptionManager.HandleEventException(this.ToString(),
  219. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  220. }
  221. }
  222. /// <summary>
  223. /// 排序后设置Grid状态
  224. /// </summary>
  225. /// <param name="sender"></param>
  226. /// <param name="e"></param>
  227. private void dgvDetail_Sorted(object sender, EventArgs e)
  228. {
  229. this.SetEditGrid();
  230. }
  231. /// <summary>
  232. /// 自动列宽
  233. /// </summary>
  234. /// <param name="sender"></param>
  235. /// <param name="e"></param>
  236. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  237. {
  238. this.dgvDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  239. }
  240. /// <summary>
  241. /// 页面关闭
  242. /// </summary>
  243. /// <param name="sender"></param>
  244. /// <param name="e"></param>
  245. private void tsbtnClose_Click(object sender, EventArgs e)
  246. {
  247. this.DialogResult = DialogResult.Cancel;
  248. this.Close();
  249. }
  250. /// <summary>
  251. /// 绑定条码
  252. /// </summary>
  253. /// <param name="sender"></param>
  254. /// <param name="e"></param>
  255. private void txtBarCodeStart_KeyPress(object sender, KeyPressEventArgs e)
  256. {
  257. if (txtBarCodeStart.ReadOnly || !_canEdit)
  258. {
  259. return;
  260. }
  261. if (e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE)
  262. {
  263. this.btnBindBarCode_Click(sender, e);
  264. }
  265. }
  266. /// <summary>
  267. /// 绑定条码
  268. /// </summary>
  269. /// <param name="sender"></param>
  270. /// <param name="e"></param>
  271. private void btnBindBarCode_Click(object sender, EventArgs e)
  272. {
  273. if (!_canEdit)
  274. {
  275. return;
  276. }
  277. try
  278. {
  279. string barcodeBegin = this.txtBarCodeStart.Text.Trim();
  280. if (barcodeBegin.Length <= 0)
  281. {
  282. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_003, this.lblBarCodeStart.Text);
  283. this.txtBarCodeStart.Focus();
  284. return;
  285. }
  286. if (barcodeBegin.Length != 11)
  287. {
  288. MessageBox.Show(this, "起始条码需要11位", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  289. this.txtBarCodeStart.Focus();
  290. return;
  291. }
  292. System.Text.RegularExpressions.Match mc =
  293. System.Text.RegularExpressions.Regex.Match(barcodeBegin, @"^([a-zA-Z]*|[a-zA-Z0-9]*[a-zA-Z]+)([0-9]{10,})$");
  294. if (!mc.Success)
  295. {
  296. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_005, barcodeBegin);
  297. this.txtBarCodeStart.Focus();
  298. return;
  299. }
  300. string strLetter = mc.Groups[1].Value;
  301. string strDigit = mc.Groups[2].Value;
  302. decimal digit = Convert.ToDecimal(strDigit);
  303. int len = strDigit.Length;
  304. foreach (DataGridViewRow row in this.dgvDetail.Rows)
  305. {
  306. object sf = row.Cells["ScrapFlag"].Value;
  307. if (row.Cells["BarCode"].ReadOnly || sf == null || "1" == sf.ToString())
  308. {
  309. continue;
  310. }
  311. string barcode = strLetter + (digit++).ToString().PadLeft(len, '0');
  312. row.Cells["BarCode"].Value = barcode;
  313. DataRowView dataRow = row.DataBoundItem as DataRowView;
  314. if (dataRow != null)
  315. {
  316. dataRow.EndEdit();
  317. }
  318. }
  319. }
  320. catch (Exception ex)
  321. {
  322. // 对异常进行共通处理
  323. ExceptionManager.HandleEventException(this.ToString(),
  324. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  325. }
  326. }
  327. /// <summary>
  328. /// 清空条码
  329. /// </summary>
  330. /// <param name="sender"></param>
  331. /// <param name="e"></param>
  332. private void btnClearBarCode_Click(object sender, EventArgs e)
  333. {
  334. try
  335. {
  336. this.txtBarCodeStart.Clear();
  337. foreach (DataGridViewRow row in this.dgvDetail.Rows)
  338. {
  339. if (!row.Cells["BarCode"].ReadOnly)
  340. {
  341. row.Cells["BarCode"].Value = DBNull.Value;
  342. }
  343. }
  344. }
  345. catch (Exception ex)
  346. {
  347. // 对异常进行共通处理
  348. ExceptionManager.HandleEventException(this.ToString(),
  349. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  350. }
  351. }
  352. /// <summary>
  353. /// 保存数据
  354. /// </summary>
  355. private void btnSave_Click(object sender, EventArgs e)
  356. {
  357. // 没有注浆数据
  358. if (this.DataSource == null || this._dailyId <= 0)
  359. {
  360. return;
  361. }
  362. try
  363. {
  364. // 验证条码重复
  365. DataTable dtGROUTINGDAILYDETAIL =this.DataSource.Tables[1];
  366. foreach (DataRow row in dtGROUTINGDAILYDETAIL.Rows)
  367. {
  368. if (string.IsNullOrWhiteSpace(row["ScrapFlag"].ToString()) || row["ScrapFlag"].ToString() == "")
  369. {
  370. row["ScrapFlag"] = 0;
  371. }
  372. string barcode = row["Barcode"].ToString().Trim();
  373. if (!string.IsNullOrEmpty(barcode) && barcode.Length != 11)
  374. {
  375. MessageBox.Show("注浆信息中有非11位的条码",
  376. this.Text,
  377. MessageBoxButtons.OK,
  378. MessageBoxIcon.Warning);
  379. return;
  380. }
  381. if (string.IsNullOrWhiteSpace(barcode))
  382. {
  383. row["Barcode"] = DBNull.Value;
  384. continue;
  385. }
  386. else
  387. {
  388. row["Barcode"] = barcode;
  389. }
  390. DataRow[] drs = dtGROUTINGDAILYDETAIL.Select("Barcode = '" + barcode
  391. + "' AND GROUTINGDAILYDETAILID <> "+row["GROUTINGDAILYDETAILID"]);
  392. if (drs != null && drs.Length > 0)
  393. {
  394. MessageBox.Show("注浆信息中有重复条码【" + barcode + "】",
  395. this.Text,
  396. MessageBoxButtons.OK,
  397. MessageBoxIcon.Warning);
  398. return;
  399. }
  400. }
  401. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  402. {
  403. return PMModuleProxyNew.Service.SetFPM0103Data(this.DataSource);
  404. }
  405. );
  406. if (sre.Status == Constant.ServiceResultStatus.Success)
  407. {
  408. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  409. if (this.GroutingDailyIDs == null)
  410. {
  411. this.GroutingDailyIDs = new List<int>();
  412. }
  413. this.GroutingDailyIDs.Add(this._dailyId);
  414. //this.DialogResult = DialogResult.OK;
  415. //this.Close();
  416. this._dailyId = 0;
  417. this.lblGroutingDateValue.Text = string.Empty;
  418. //this.txtGrouting.Clear();
  419. this.txtGrouting.Text = null;
  420. this.txtBarCodeStart.Clear();
  421. this.dgvDetail.DataSource = null;
  422. this.btnSave.Enabled = false;
  423. return;
  424. }
  425. if (sre.Status == Constant.ServiceResultStatus.Other)
  426. {
  427. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  428. }
  429. this.SetEditGrid();
  430. }
  431. catch (Exception ex)
  432. {
  433. this.SetEditGrid();
  434. // 对异常进行共通处理
  435. ExceptionManager.HandleEventException(this.ToString(),
  436. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  437. }
  438. }
  439. /// <summary>
  440. /// 关闭窗体
  441. /// </summary>
  442. private void btnCancel_Click(object sender, EventArgs e)
  443. {
  444. this.DialogResult = DialogResult.Cancel;
  445. this.Close();
  446. }
  447. #endregion
  448. #region 私有方法
  449. /// <summary>
  450. /// 初始化控件
  451. /// </summary>
  452. private void InitializeControls()
  453. {
  454. this.Text = FormTitles.F_PM_0103;
  455. // 功能按钮文本赋值
  456. //this.tsbtnGrouting.Text = ButtonText.TSBTN_;
  457. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  458. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  459. this.btnSave.Text = ButtonText.BTN_SAVE;
  460. this.btnClose.Text = ButtonText.BTN_CLOSE;
  461. this.dgvDetail.AutoGenerateColumns = false;
  462. this.lblGroutingDateValue.Text = string.Empty;
  463. this.btnBindBarCode.Text = ButtonText.BTN_BINDBARCODE;
  464. this.btnClearBarCode.Text = ButtonText.BTN_CLEARBARCODE;
  465. this.txtBarCodeStart.ReadOnly = true;
  466. this.btnBindBarCode.Enabled = false;
  467. this.btnBindss.Enabled = false;
  468. this.btnClearBarCode.Enabled = false;
  469. }
  470. /// <summary>
  471. /// 取得注浆日报信息
  472. /// </summary>
  473. private void InitializeData()
  474. {
  475. try
  476. {
  477. if (this._dailyId > 0)
  478. {
  479. this.DataSource = null;
  480. this.dgvDetail.DataSource = null;
  481. this.txtBarCodeStart.Clear();
  482. //this.txtGrouting.Clear();
  483. this.txtGrouting.Text = null;
  484. // 获取成型线类型数据并绑定到控件上
  485. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  486. {
  487. return PMModuleProxyNew.Service.GetFPM0103Data(this._dailyId);
  488. }
  489. );
  490. if (sre.Status == Constant.ServiceResultStatus.Other)
  491. {
  492. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  493. return;
  494. }
  495. if (sre.Status != Constant.ServiceResultStatus.Success)
  496. {
  497. return;
  498. }
  499. _canEdit = ((int)sre.Result == 1);
  500. this.DataSource = sre.Data;
  501. DataRow lineDataRow = sre.Data.Tables[0].Rows[0];
  502. this._groutingDate = Convert.ToDateTime(lineDataRow["GroutingDate"]);
  503. this.lblGroutingDateValue.Text = this._groutingDate.ToString(Constant.S_DATE_YYYY_MM_DD);
  504. if (_canEdit)
  505. {
  506. this.txtGrouting.Text = string.Format("{0}({1})", lineDataRow["GroutingLineCode"], lineDataRow["MouldQuantity"]);
  507. this.txtGrouting.ForeColor = System.Drawing.Color.Black;
  508. }
  509. else
  510. {
  511. this.txtGrouting.Text = string.Format("{0}({1}) {2}", lineDataRow["GroutingLineCode"], lineDataRow["MouldQuantity"], sre.Message);
  512. this.txtGrouting.ForeColor = System.Drawing.Color.Red;
  513. }
  514. this.dgvDetail.DataSource = sre.Data.Tables[1];
  515. this.SetEditGrid();
  516. if (_canEdit)
  517. {
  518. this.btnBindBarCode.Enabled = true;
  519. this.btnBindss.Enabled = true;
  520. this.txtBarCodeStart.ReadOnly = false;
  521. }
  522. else
  523. {
  524. this.btnBindBarCode.Enabled = false;
  525. this.btnBindss.Enabled = false;
  526. this.txtBarCodeStart.ReadOnly = true;
  527. }
  528. this.btnClearBarCode.Enabled = true;
  529. this.btnSave.Enabled = true;
  530. this.txtBarCodeStart.Focus();
  531. }
  532. }
  533. catch (Exception ex)
  534. {
  535. throw ex;
  536. }
  537. }
  538. /// <summary>
  539. /// 编辑模式下设置Grid编辑状态
  540. /// </summary>
  541. private void SetEditGrid()
  542. {
  543. foreach (DataGridViewRow row in this.dgvDetail.Rows)
  544. {
  545. if (!_canEdit)
  546. {
  547. // 过期后不能撤销报损
  548. row.Cells["BarCode"].ReadOnly = true;
  549. row.Cells["ScrapFlag"].ReadOnly = true;
  550. }
  551. object sbarcode = row.Cells["BarCode"].Value;
  552. if (sbarcode != null && !string.IsNullOrWhiteSpace(sbarcode.ToString()))
  553. {
  554. row.Cells["ScrapFlag"].ReadOnly = true;
  555. }
  556. // 未注浆的,不能编辑
  557. object groutingFlag = row.Cells["GroutingFlag"].Value;
  558. if (groutingFlag == null || ((int)Constant.GroutingFlag.Yes).ToString() != groutingFlag.ToString())
  559. {
  560. row.Cells["BarCode"].ReadOnly = true;
  561. row.Cells["ScrapFlag"].ReadOnly = true;
  562. //row.Cells["Remarks"].ReadOnly = true;
  563. //row.Cells["colLogo"].ReadOnly = true;
  564. continue;
  565. }
  566. // 交坯后,不能编辑
  567. object deliverFlag = row.Cells["DeliverFlag"].Value;
  568. if (deliverFlag != null && "1" == deliverFlag.ToString())
  569. {
  570. row.Cells["BarCode"].ReadOnly = true;
  571. row.Cells["ScrapFlag"].ReadOnly = true;
  572. //row.Cells["Remarks"].ReadOnly = true;
  573. row.Cells["colLogo"].ReadOnly = true;
  574. continue;
  575. }
  576. // 绑定条码后,不能编辑条码
  577. object obarCode = row.Cells["colOBarCode"].Value;
  578. if (obarCode != null && !string.IsNullOrWhiteSpace(obarCode.ToString()))
  579. {
  580. row.Cells["BarCode"].ReadOnly = true;
  581. continue;
  582. }
  583. //绑定条码后 不能报损
  584. //object oscrapFlag = row.Cells["colOScrapFlag"].Value;
  585. //if (oscrapFlag != null && ((int)Constant.GroutingScrapFlag.Yes).ToString() == oscrapFlag.ToString())
  586. //{
  587. // row.ReadOnly = true;
  588. // row.Cells["Remarks"].ReadOnly = false;
  589. //}
  590. // 损坯后,不能编辑
  591. if (((int)Constant.GroutingScrapFlag.Yes).ToString() == row.Cells["ScrapFlag"].Value.ToString())
  592. {
  593. row.Cells["BarCode"].Value = DBNull.Value;
  594. row.Cells["BarCode"].ReadOnly = true;
  595. continue;
  596. }
  597. if (!_canEdit)
  598. {
  599. row.Cells["BarCode"].ReadOnly = true;
  600. row.Cells["ScrapFlag"].ReadOnly = true;
  601. continue;
  602. }
  603. row.Cells["BarCode"].ReadOnly = false;
  604. }
  605. this.dgvDetail.IsSetInputColumnsColor = true;
  606. }
  607. #endregion
  608. private void btnNGRSetting_Click(object sender, EventArgs e)
  609. {
  610. if (this.cmbLogo.SelectedIndex < 0)
  611. {
  612. return;
  613. }
  614. try
  615. {
  616. foreach (DataGridViewRow row in this.dgvDetail.Rows)
  617. {
  618. if (!row.Cells["colLogo"].ReadOnly)
  619. {
  620. row.Cells["colLogo"].Value = this.cmbLogo.SelectedValue;
  621. DataRowView dataRow = row.DataBoundItem as DataRowView;
  622. if (dataRow != null)
  623. {
  624. dataRow.EndEdit();
  625. }
  626. }
  627. }
  628. }
  629. catch (Exception ex)
  630. {
  631. // 对异常进行共通处理
  632. ExceptionManager.HandleEventException(this.ToString(),
  633. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  634. }
  635. }
  636. private void btnBindss_Click(object sender, EventArgs e)
  637. {
  638. if (!_canEdit)
  639. {
  640. return;
  641. }
  642. try
  643. {
  644. F_PM_0103_1 f = new F_PM_0103_1();
  645. f.BarCodeGrid = this.dgvDetail;
  646. if (f.ShowDialog() == DialogResult.OK)
  647. {
  648. List<string> error_list = f.ERROR_LIST;
  649. if (error_list?.Count > 0)
  650. {
  651. F_PM_0103_2 f2 = new F_PM_0103_2();
  652. f2.ERROR_TEXT = string.Join(Environment.NewLine, error_list);
  653. f2.Show();
  654. }
  655. }
  656. }
  657. catch (Exception ex)
  658. {
  659. // 对异常进行共通处理
  660. ExceptionManager.HandleEventException(this.ToString(),
  661. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  662. }
  663. }
  664. }
  665. }