F_PM_0102.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0102.cs
  5. * 2.功能描述:注浆登记
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2015/03/25 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseControls;
  16. using Dongke.IBOSS.PRD.Basics.BaseResources;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 注浆登记新建和编辑页面
  25. /// </summary>
  26. public partial class F_PM_0102 : DKFormBase
  27. {
  28. #region 成员变量
  29. // 窗体模式ID
  30. private Constant.FormMode _formMode = Constant.FormMode.Add;
  31. // 未注浆原因,传给选择页面
  32. private DataTable _dtNotGroutingRreason;
  33. // 注浆日报ID
  34. private int _dailyId;
  35. // 注浆日期
  36. private DateTime _groutingDate = DateTime.Now.Date;
  37. // 账务日期
  38. private DateTime _accountDate = DateTime.Now.Date;
  39. //private decimal? _logoid = null;
  40. private bool _canEdit = true;
  41. #endregion
  42. #region 构造函数
  43. /// <summary>
  44. /// 构造函数
  45. /// </summary>
  46. public F_PM_0102()
  47. :this(0)
  48. {
  49. }
  50. /// <summary>
  51. /// 构造函数
  52. /// </summary>
  53. /// <param name="dailyID">注浆日报ID:新建时为0</param>
  54. public F_PM_0102(int dailyID)
  55. {
  56. this.InitializeComponent();
  57. this._dailyId = dailyID;
  58. this.InitializeControls();
  59. }
  60. #endregion
  61. #region 属性
  62. /// <summary>
  63. /// 注浆登记的ID(多个用【,】隔开)
  64. /// </summary>
  65. public string GroutingDailyIDs
  66. {
  67. get;
  68. private set;
  69. }
  70. #endregion
  71. #region 事件
  72. /// <summary>
  73. /// 窗体加载
  74. /// </summary>
  75. private void F_PM_0102_Load(object sender, EventArgs e)
  76. {
  77. try
  78. {
  79. this.lblGroutingDateValue.Text = string.Empty;
  80. DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
  81. if (logoInfo != null && logoInfo.Tables.Count > 0)
  82. {
  83. this.cmbLogo.DataSource = logoInfo.Tables[0];
  84. this.cmbLogo.DisplayMember = "LogoNameCode";
  85. this.cmbLogo.ValueMember = "LogoID";
  86. this.colLogo.DataSource = logoInfo.Tables[0].Copy();
  87. this.colLogo.DisplayMember = "LogoNameCode";
  88. this.colLogo.ValueMember = "LogoID";
  89. //if(logoInfo.Tables[0].Rows.Count > 0)
  90. //{
  91. // _logoid = Convert.ToDecimal(logoInfo.Tables[0].Rows[0]["LogoID"]);
  92. //}
  93. }
  94. // 设置列表未注浆原因选项数据源
  95. this.InitializeData();
  96. }
  97. catch (Exception ex)
  98. {
  99. // 对异常进行共通处理
  100. ExceptionManager.HandleEventException(this.ToString(),
  101. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  102. }
  103. }
  104. /// <summary>
  105. /// 全线注浆按钮按下,生成该成型班长的所有注浆信息
  106. /// </summary>
  107. /// <param name="sender"></param>
  108. /// <param name="e"></param>
  109. private void tsbtnAllGrouting_Click(object sender, EventArgs e)
  110. {
  111. try
  112. {
  113. // 获取登录用户所有的注浆信息,并绑定
  114. this.txtGrouting.Clear();
  115. this.dgvDetail.DataSource = null;
  116. this.DataSource = null;
  117. this.DataSource = this.GetGroutingDailyInfo(null, null);
  118. if (this.DataSource != null && this.DataSource.Tables.Count == 2)
  119. {
  120. StringBuilder groutingLines = new StringBuilder();
  121. foreach (DataRow row in this.DataSource.Tables[0].Rows)
  122. {
  123. if (groutingLines.Length > 0)
  124. {
  125. groutingLines.Append(", ");
  126. }
  127. groutingLines.Append(string.Format("{0}({1})", row["GroutingLineCode"], row["MouldQuantity"]));
  128. }
  129. this.DataSource.Tables[1].Columns.Add("NoGroutingRreason", typeof(decimal));
  130. this.DataSource.Tables[1].Columns.Add("Remarks", typeof(string));
  131. //DataColumn dc = new DataColumn("LogoID", typeof(decimal));
  132. //if (_logoid.HasValue)
  133. //{
  134. // dc.DefaultValue = _logoid.Value;
  135. //}
  136. //this.DataSource.Tables[1].Columns.Add(dc);
  137. this.txtGrouting.Text = groutingLines.ToString();
  138. this.dgvDetail.DataSource = this.DataSource.Tables[1];
  139. this.dgvDetail.IsSetInputColumnsColor = true;
  140. // 按钮状态
  141. this.tsbtnAllGrouting.Enabled = false;
  142. this.tsbtnGrouting.Enabled = false;
  143. this.tsbtnClearDetail.Enabled = true;
  144. this.tsbtnChangeGroutingUser.Enabled = true;
  145. this.btnSave.Enabled = true;
  146. }
  147. }
  148. catch (Exception ex)
  149. {
  150. // 对异常进行共通处理
  151. ExceptionManager.HandleEventException(this.ToString(),
  152. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  153. }
  154. }
  155. /// <summary>
  156. /// 部分注浆按钮按下,弹出选择成型线窗体
  157. /// </summary>
  158. /// <param name="sender"></param>
  159. /// <param name="e"></param>
  160. private void tsbtnGrouting_Click(object sender, EventArgs e)
  161. {
  162. try
  163. {
  164. // 打开选择成型线页面
  165. F_PM_0104_1 frmPM0104 = new F_PM_0104_1();
  166. frmPM0104.NotGroutingRreason = this._dtNotGroutingRreason;
  167. DialogResult dialogResult = frmPM0104.ShowDialog();
  168. if (DialogResult.OK == dialogResult && frmPM0104.GroutingInfo.Length > 0)
  169. {
  170. // 根据选择成型线页面返回成型线,取得注浆明细数据
  171. string groutingLineIDs = string.Empty;
  172. foreach (DataRow dataRow in frmPM0104.GroutingInfo)
  173. {
  174. if (groutingLineIDs.Length > 0)
  175. {
  176. groutingLineIDs += ",";
  177. }
  178. groutingLineIDs += dataRow["GroutingLineID"].ToString();
  179. }
  180. this.txtGrouting.Clear();
  181. this.dgvDetail.DataSource = null;
  182. this.DataSource = null;
  183. this.DataSource = this.GetGroutingDailyInfo(frmPM0104.GroutingDate, groutingLineIDs);
  184. // 组成页面的注浆日期、注浆成型线显示信息,并且绑定注浆信息的数据源
  185. if (this.DataSource != null && this.DataSource.Tables.Count == 2)
  186. {
  187. StringBuilder groutingLines = new StringBuilder();
  188. // 根据成型线选择注浆原因,控制注浆列表的未注浆选择列
  189. this.DataSource.Tables[1].Columns.Add("NoGroutingRreason", typeof(decimal));
  190. this.DataSource.Tables[1].Columns.Add("Remarks", typeof(string));
  191. //DataColumn dc = new DataColumn("LogoID", typeof(decimal));
  192. //if (_logoid.HasValue)
  193. //{
  194. // dc.DefaultValue = _logoid.Value;
  195. //}
  196. //this.DataSource.Tables[1].Columns.Add(dc);
  197. foreach (DataRow dataRow in frmPM0104.GroutingInfo)
  198. {
  199. string sqlWhere = "GroutingLineID = " + dataRow["GroutingLineID"].ToString();
  200. DataRow[] drLines = this.DataSource.Tables[0].Select(sqlWhere);
  201. if (drLines == null || drLines.Length == 0)
  202. {
  203. continue;
  204. }
  205. DataRow[] drs = this.DataSource.Tables[1].Select("GroutingLineID = " + dataRow["GroutingLineID"].ToString());
  206. if (drs == null || drs.Length == 0)
  207. {
  208. drLines[0].Delete();
  209. continue;
  210. }
  211. if (groutingLines.Length > 0)
  212. {
  213. groutingLines.Append(", ");
  214. }
  215. groutingLines.Append(string.Format("{0}({1})[{2}]", drLines[0]["GroutingLineCode"], drLines[0]["MouldQuantity"], drLines[0]["monitorcode"]));
  216. drLines[0]["UserID"] = dataRow["GroutingUserID"];
  217. drLines[0]["UserCode"] = dataRow["GroutingUserCode"];
  218. string canManyTimes = drLines[0]["CanManyTimes"].ToString();
  219. int num = System.Convert.ToInt32(dataRow["GroutingNum"]);
  220. int batchNo = System.Convert.ToInt32(drLines[0]["GroutingBatchNo"]);
  221. if (num > 1 && "1" == canManyTimes)
  222. {
  223. for (int i = 1; i < num; i++)
  224. {
  225. DataRow newRow = this.DataSource.Tables[0].Rows.Add(drLines[0].ItemArray);
  226. newRow["GroutingBatchNo"] = batchNo + i;
  227. }
  228. }
  229. foreach (DataRow detailDataRow in drs)
  230. {
  231. detailDataRow["GroutingUserID"] = dataRow["GroutingUserID"];
  232. detailDataRow["GroutingUserCode"] = dataRow["GroutingUserCode"];
  233. object NoGroutingRreason = dataRow["NoGroutingRreason"];
  234. if (NoGroutingRreason != null && NoGroutingRreason != DBNull.Value)
  235. {
  236. detailDataRow["GroutingFlag"] = (int)Constant.GroutingFlag.No;
  237. detailDataRow["NoGroutingRreason"] = dataRow["NoGroutingRreason"];
  238. }
  239. if (num > 1 && "1" == canManyTimes)
  240. {
  241. for (int i = 1; i < num; i++)
  242. {
  243. DataRow newRow = this.DataSource.Tables[1].Rows.Add(detailDataRow.ItemArray);
  244. newRow["GroutingBatchNo"] = batchNo + i;
  245. }
  246. }
  247. }
  248. }
  249. this.DataSource.AcceptChanges();
  250. this.DataSource.Tables[1].DefaultView.Sort = "GroutingLineCode, GroutingBatchNo, GroutingMouldCode";
  251. this.txtGrouting.Text = groutingLines.ToString();
  252. this.dgvDetail.DataSource = this.DataSource.Tables[1];
  253. this.dgvDetail.IsSetInputColumnsColor = true;
  254. // 按钮状态
  255. this.tsbtnAllGrouting.Enabled = false;
  256. this.tsbtnGrouting.Enabled = false;
  257. this.tsbtnClearDetail.Enabled = true;
  258. this.tsbtnChangeGroutingUser.Enabled = true;
  259. this.btnSave.Enabled = true;
  260. }
  261. }
  262. }
  263. catch (Exception ex)
  264. {
  265. // 对异常进行共通处理
  266. ExceptionManager.HandleEventException(this.ToString(),
  267. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  268. }
  269. }
  270. /// <summary>
  271. /// 更改成型工按钮按下,整个成型线更换成型工
  272. /// </summary>
  273. /// <param name="sender"></param>
  274. /// <param name="e"></param>
  275. private void tsbtnChangeGroutingUser_Click(object sender, EventArgs e)
  276. {
  277. try
  278. {
  279. }
  280. catch (Exception ex)
  281. {
  282. // 对异常进行共通处理
  283. ExceptionManager.HandleEventException(this.ToString(),
  284. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  285. }
  286. }
  287. /// <summary>
  288. /// 清空注浆明细按钮按钮,清空注浆信息,可以重新进行注浆
  289. /// </summary>
  290. /// <param name="sender"></param>
  291. /// <param name="e"></param>
  292. private void tsbtnClearDetail_Click(object sender, EventArgs e)
  293. {
  294. this.txtGrouting.Clear();
  295. this.dgvDetail.DataSource = null;
  296. this.DataSource = null;
  297. this.lblGroutingDateValue.Text = this._accountDate.Date.ToString(Constant.S_DATE_YYYY_MM_DD);
  298. // 清空注浆信息后,清空明细、更换成型工按钮不可用
  299. this.tsbtnAllGrouting.Enabled = true;
  300. this.tsbtnGrouting.Enabled = true;
  301. this.tsbtnClearDetail.Enabled = false;
  302. this.tsbtnChangeGroutingUser.Enabled = false;
  303. this.btnSave.Enabled = false;
  304. }
  305. /// <summary>
  306. /// 提交选择列内容的修改
  307. /// </summary>
  308. /// <param name="sender"></param>
  309. /// <param name="e"></param>
  310. private void dgvDetail_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  311. {
  312. try
  313. {
  314. if (this.dgvDetail.CurrentRow != null && this.dgvDetail.IsCurrentCellDirty)
  315. {
  316. if ("GroutingFlag".Equals(this.dgvDetail.Columns
  317. [this.dgvDetail.CurrentCell.ColumnIndex].Name))
  318. {
  319. this.dgvDetail.CommitEdit(DataGridViewDataErrorContexts.Commit);
  320. }
  321. }
  322. }
  323. catch (Exception ex)
  324. {
  325. // 对异常进行共通处理
  326. ExceptionManager.HandleEventException(this.ToString(),
  327. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  328. }
  329. }
  330. /// <summary>
  331. /// 未注浆时,未注浆原因才可以输入
  332. /// </summary>
  333. private void dgvDetail_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  334. {
  335. try
  336. {
  337. if (e.RowIndex != Constant.INT_IS_NEGATIE_ONE && this._canEdit)
  338. {
  339. DataGridViewRow dataGridViewRow = this.dgvDetail.Rows[e.RowIndex];
  340. // 如果是改变了注浆标识,则对未注浆原因进行控制输入
  341. if ( "GroutingFlag".Equals(this.dgvDetail.Columns[e.ColumnIndex].Name))
  342. {
  343. // 选择了未注浆
  344. if (((int)Constant.GroutingFlag.Yes).ToString() != dataGridViewRow.Cells["GroutingFlag"].Value.ToString())
  345. {
  346. dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = false;
  347. }
  348. else
  349. {
  350. dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = true;
  351. this.dgvDetail.Rows[e.RowIndex].Cells["NoGroutingRreason"].Value = DBNull.Value;
  352. }
  353. }
  354. }
  355. }
  356. catch (Exception ex)
  357. {
  358. // 对异常进行共通处理
  359. ExceptionManager.HandleEventException(this.ToString(),
  360. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  361. }
  362. }
  363. /// <summary>
  364. /// 排序后设置Grid状态
  365. /// </summary>
  366. /// <param name="sender"></param>
  367. /// <param name="e"></param>
  368. private void dgvDetail_Sorted(object sender, EventArgs e)
  369. {
  370. this.SetEditGrid();
  371. this.dgvDetail.IsSetInputColumnsColor = true;
  372. }
  373. /// <summary>
  374. /// 自动列宽
  375. /// </summary>
  376. /// <param name="sender"></param>
  377. /// <param name="e"></param>
  378. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  379. {
  380. this.dgvDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  381. }
  382. /// <summary>
  383. /// 页面关闭
  384. /// </summary>
  385. /// <param name="sender"></param>
  386. /// <param name="e"></param>
  387. private void tsbtnClose_Click(object sender, EventArgs e)
  388. {
  389. this.DialogResult = DialogResult.Cancel;
  390. this.Close();
  391. }
  392. /// <summary>
  393. /// 保存数据
  394. /// </summary>
  395. private void btnSave_Click(object sender, EventArgs e)
  396. {
  397. // 没有注浆数据
  398. if (this.DataSource == null || this.DataSource.Tables.Count != 2)
  399. {
  400. return;
  401. }
  402. try
  403. {
  404. DataRow[] noGroutingDataRow = this.DataSource.Tables[1].Select("GroutingFlag = 0 AND NoGroutingRreason IS NULL");
  405. if (noGroutingDataRow != null && noGroutingDataRow.Length > 0)
  406. {
  407. string mc = null;
  408. foreach (DataRow dataRow in noGroutingDataRow)
  409. {
  410. if (mc != null)
  411. {
  412. mc += ",";
  413. }
  414. mc += dataRow["GroutingMouldCode"].ToString();
  415. }
  416. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_006,
  417. "以下模具编号既没有注浆也没有未注浆原因" + Environment.NewLine + mc);
  418. return;
  419. }
  420. DateTime? date = null;
  421. if (this._formMode == Constant.FormMode.Add)
  422. {
  423. date = this._groutingDate;
  424. }
  425. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  426. {
  427. return PMModuleProxyNew.Service.SetFPM0102Data(date, this.DataSource);
  428. }
  429. );
  430. if (sre.Status == Constant.ServiceResultStatus.Success)
  431. {
  432. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  433. if (sre.Result != null)
  434. {
  435. this.GroutingDailyIDs = sre.Result.ToString();
  436. }
  437. this.DialogResult = DialogResult.OK;
  438. this.Close();
  439. return;
  440. }
  441. if (sre.Status == Constant.ServiceResultStatus.Other)
  442. {
  443. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  444. }
  445. this.SetEditGrid();
  446. }
  447. catch (Exception ex)
  448. {
  449. this.SetEditGrid();
  450. // 对异常进行共通处理
  451. ExceptionManager.HandleEventException(this.ToString(),
  452. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  453. }
  454. }
  455. /// <summary>
  456. /// 关闭窗体
  457. /// </summary>
  458. private void btnCancel_Click(object sender, EventArgs e)
  459. {
  460. this.DialogResult = DialogResult.Cancel;
  461. this.Close();
  462. }
  463. /// <summary>
  464. /// 设置注浆状态和未注浆原因
  465. /// </summary>
  466. /// <param name="sender"></param>
  467. /// <param name="e"></param>
  468. private void btnNGRSetting_Click(object sender, EventArgs e)
  469. {
  470. if (this.cboNoGroutingRreason.SelectedIndex < 0 || !this._canEdit)
  471. {
  472. return;
  473. }
  474. try
  475. {
  476. object noGroutingRreason = null;
  477. // 未注浆原因
  478. if (Constant.CBO_SELECT_ALL_VALUE.ToString() != this.cboNoGroutingRreason.SelectedValue.ToString())
  479. {
  480. noGroutingRreason = this.cboNoGroutingRreason.SelectedValue;
  481. }
  482. foreach (DataGridViewRow row in this.dgvDetail.Rows)
  483. {
  484. if (!row.Cells["GroutingFlag"].ReadOnly)
  485. {
  486. if (noGroutingRreason == null)
  487. {
  488. row.Cells["NoGroutingRreason"].Value = DBNull.Value;
  489. row.Cells["GroutingFlag"].Value = (int)Constant.GroutingFlag.Yes;
  490. }
  491. else
  492. {
  493. row.Cells["NoGroutingRreason"].Value = noGroutingRreason;
  494. row.Cells["GroutingFlag"].Value = (int)Constant.GroutingFlag.No;
  495. }
  496. DataRowView dataRow = row.DataBoundItem as DataRowView;
  497. if (dataRow != null)
  498. {
  499. dataRow.EndEdit();
  500. }
  501. }
  502. }
  503. }
  504. catch (Exception ex)
  505. {
  506. // 对异常进行共通处理
  507. ExceptionManager.HandleEventException(this.ToString(),
  508. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  509. }
  510. }
  511. #endregion
  512. #region 私有方法
  513. /// <summary>
  514. /// 初始化控件
  515. /// </summary>
  516. private void InitializeControls()
  517. {
  518. // 窗体名称赋值
  519. if (this._dailyId > 0)
  520. {
  521. this._formMode = Constant.FormMode.Edit;
  522. this.Text = FormTitles.F_PM_0102_EDIT;
  523. this.tsbtnAllGrouting.Enabled = false;
  524. this.tsbtnGrouting.Enabled = false;
  525. this.BarCode.Visible = true;
  526. this.ScrapFlag.Visible = true;
  527. }
  528. else
  529. {
  530. this._formMode = Constant.FormMode.Add;
  531. this.Text = FormTitles.F_PM_0102_ADD;
  532. this.BarCode.Visible = false;
  533. this.ScrapFlag.Visible = false;
  534. }
  535. // 功能按钮文本赋值
  536. this.tsbtnAllGrouting.Text = ButtonText.TSBTN_ALLGROUTING;
  537. this.tsbtnGrouting.Text = ButtonText.TSBTN_GROUTING;
  538. this.tsbtnClearDetail.Text = ButtonText.TSBTN_CLEARDETAIL;
  539. this.tsbtnChangeGroutingUser.Text = ButtonText.TSBTN_CHANGEGROUTINGUSER;
  540. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  541. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  542. this.btnSave.Text = ButtonText.BTN_SAVE;
  543. this.btnClose.Text = ButtonText.BTN_CLOSE;
  544. this.dgvDetail.AutoGenerateColumns = false;
  545. }
  546. /// <summary>
  547. /// 设置列表中未注浆原因的数据源
  548. /// </summary>
  549. private void InitializeData()
  550. {
  551. try
  552. {
  553. // 获取成型线类型数据并绑定到控件上
  554. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  555. {
  556. return PMModuleProxyNew.Service.GetFPM0102IData(this._dailyId);
  557. }
  558. );
  559. if (sre.Status == Constant.ServiceResultStatus.Other)
  560. {
  561. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  562. this.DialogResult = DialogResult.Cancel;
  563. this.Close();
  564. return;
  565. }
  566. if (sre.Status != Constant.ServiceResultStatus.Success)
  567. {
  568. return;
  569. }
  570. if (sre.Data != null && sre.Data.Tables.Count > 0)
  571. {
  572. // 设置全部注浆选项
  573. DataTable ngrDataTable = sre.Data.Tables[0].Copy();
  574. DataRow ngrDataRow = ngrDataTable.NewRow();
  575. ngrDataRow["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
  576. ngrDataRow["DictionaryValue"] = "全部注浆";
  577. ngrDataRow["DisplayNo"] = 0;
  578. ngrDataTable.Rows.InsertAt(ngrDataRow, 0);
  579. this.cboNoGroutingRreason.ValueMember = "DictionaryID";
  580. this.cboNoGroutingRreason.DisplayMember = "DictionaryValue";
  581. this.cboNoGroutingRreason.DataSource = ngrDataTable;
  582. this._dtNotGroutingRreason = sre.Data.Tables[0];
  583. // 设置空选项
  584. DataRow dataRow = this._dtNotGroutingRreason.NewRow();
  585. dataRow["DictionaryID"] = DBNull.Value;
  586. dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
  587. dataRow["DisplayNo"] = 0;
  588. this._dtNotGroutingRreason.Rows.InsertAt(dataRow, 0);
  589. }
  590. this.NoGroutingRreason.ValueMember = "DictionaryID";
  591. this.NoGroutingRreason.DisplayMember = "DictionaryValue";
  592. this.NoGroutingRreason.DataSource = this._dtNotGroutingRreason;
  593. if (this._formMode == Constant.FormMode.Edit)
  594. {
  595. _canEdit = ((int)sre.Result == 1);
  596. // 编辑时,修改未注浆原因
  597. if (_canEdit)
  598. {
  599. this.lblNoGroutingRreason.Visible = true;
  600. this.cboNoGroutingRreason.Visible = true;
  601. this.btnNGRSetting.Visible = true;
  602. }
  603. else
  604. {
  605. this.txtGrouting1.Visible = true;
  606. this.txtGrouting.Visible = false;
  607. this.gbxInfo.Height -= 30;// 67;
  608. this.dgvDetail.Top -= 30;
  609. this.dgvDetail.Height += 30;
  610. }
  611. sre.Data.Tables.RemoveAt(0);
  612. this.DataSource = sre.Data;
  613. if (this.DataSource != null && this.DataSource.Tables.Count == 2)
  614. {
  615. DataRow gdDataRow = this.DataSource.Tables[0].Rows[0];
  616. this.txtGrouting.Text = string.Format("{0}({1})", gdDataRow["GroutingLineCode"], gdDataRow["MouldQuantity"]);
  617. this.txtGrouting1.Text = this.txtGrouting.Text;
  618. this._groutingDate = Convert.ToDateTime(gdDataRow["GroutingDate"]);
  619. //this._accountDate = this._groutingDate;
  620. this.dgvDetail.DataSource = this.DataSource.Tables[1];
  621. this.SetEditGrid();
  622. this.dgvDetail.IsSetInputColumnsColor = true;
  623. // 按钮状态
  624. this.btnSave.Enabled = true;
  625. }
  626. // 编辑时,修改未注浆原因
  627. if (!_canEdit)
  628. {
  629. this.txtGrouting1.Text += System.Environment.NewLine + System.Environment.NewLine + sre.Message;
  630. this.txtGrouting1.ForeColor = System.Drawing.Color.Red;
  631. }
  632. this.dgvDetail.Focus();
  633. }
  634. else
  635. {
  636. if (sre.Result != null)
  637. {
  638. this._accountDate = Convert.ToDateTime(sre.Result);
  639. this._groutingDate = this._accountDate;
  640. }
  641. }
  642. this.lblGroutingDateValue.Text = this._groutingDate.ToString(Constant.S_DATE_YYYY_MM_DD);
  643. }
  644. catch (Exception ex)
  645. {
  646. throw ex;
  647. }
  648. }
  649. /// <summary>
  650. /// 取得可注浆信息
  651. /// </summary>
  652. /// <param name="groutingDate">注浆日期</param>
  653. /// <param name="groutingIDs">成型线ID(多个用【,】隔开)</param>
  654. /// <returns>可注浆信息</returns>
  655. private DataSet GetGroutingDailyInfo(DateTime? groutingDate, string groutingLineIDs)
  656. {
  657. try
  658. {
  659. // 根据注浆日期、成型线获取所有可注浆模具信息
  660. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  661. {
  662. return PMModuleProxyNew.Service.GetFPM0102_GroutingLine(groutingDate, groutingLineIDs);
  663. }
  664. );
  665. // 取注浆日期
  666. if (sre.Result != null)
  667. {
  668. this._groutingDate = Convert.ToDateTime(sre.Result);
  669. }
  670. else if (groutingDate.HasValue)
  671. {
  672. this._groutingDate = groutingDate.Value.Date;
  673. }
  674. else
  675. {
  676. this._groutingDate = DateTime.Now.Date;
  677. }
  678. this.lblGroutingDateValue.Text = this._groutingDate.ToString(Constant.S_DATE_YYYY_MM_DD);
  679. // 异常情况处理
  680. if (sre.Status > Constant.ServiceResultStatus.Success)
  681. {
  682. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  683. return null;
  684. }
  685. return sre.Data;
  686. }
  687. catch (Exception ex)
  688. {
  689. throw ex;
  690. }
  691. }
  692. /// <summary>
  693. /// 编辑模式下设置Grid编辑状态
  694. /// </summary>
  695. private void SetEditGrid()
  696. {
  697. if(this._formMode != Constant.FormMode.Edit)
  698. {
  699. return;
  700. }
  701. foreach (DataGridViewRow row in this.dgvDetail.Rows)
  702. {
  703. // 交坯后,不能编辑
  704. object deliverFlag = (row.DataBoundItem as DataRowView)["DeliverFlag"];
  705. if (deliverFlag != null && "1" == deliverFlag.ToString())
  706. {
  707. row.Cells["colLogo"].ReadOnly = true;
  708. row.Cells["GroutingFlag"].ReadOnly = true;
  709. row.Cells["NoGroutingRreason"].ReadOnly = true;
  710. }
  711. // 绑定条码后,不能编辑
  712. object barCode = row.Cells["BarCode"].Value;
  713. object scrapFlag = row.Cells["ScrapFlag"].Value;
  714. if ((barCode != null && !string.IsNullOrWhiteSpace(barCode.ToString())) ||
  715. (scrapFlag != null && ((int)Constant.GroutingScrapFlag.Yes).ToString() == scrapFlag.ToString()))
  716. {
  717. row.Cells["GroutingFlag"].ReadOnly = true;
  718. row.Cells["NoGroutingRreason"].ReadOnly = true;
  719. row.Cells["NoGroutingRreason"].Value = DBNull.Value;
  720. //row.Cells["Remarks"].ReadOnly = false;
  721. continue;
  722. }
  723. // 未注浆,可以输入未注浆原因
  724. if (((int)Constant.GroutingFlag.No).ToString() == row.Cells["GroutingFlag"].Value.ToString())
  725. {
  726. row.Cells["NoGroutingRreason"].ReadOnly = false;
  727. }
  728. else
  729. {
  730. row.Cells["NoGroutingRreason"].Value = DBNull.Value;
  731. row.Cells["NoGroutingRreason"].ReadOnly = true;
  732. }
  733. }
  734. if (!this._canEdit)
  735. {
  736. dgvDetail.Columns["GroutingFlag"].ReadOnly = true;
  737. dgvDetail.Columns["NoGroutingRreason"].ReadOnly = true;
  738. }
  739. }
  740. #endregion
  741. private void c_Button1_Click(object sender, EventArgs e)
  742. {
  743. if (this.cmbLogo.SelectedIndex < 0)
  744. {
  745. return;
  746. }
  747. try
  748. {
  749. foreach (DataGridViewRow row in this.dgvDetail.Rows)
  750. {
  751. if (!row.Cells["colLogo"].ReadOnly)
  752. {
  753. row.Cells["colLogo"].Value = this.cmbLogo.SelectedValue;
  754. DataRowView dataRow = row.DataBoundItem as DataRowView;
  755. if (dataRow != null)
  756. {
  757. dataRow.EndEdit();
  758. }
  759. }
  760. }
  761. }
  762. catch (Exception ex)
  763. {
  764. // 对异常进行共通处理
  765. ExceptionManager.HandleEventException(this.ToString(),
  766. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  767. }
  768. }
  769. }
  770. }