F_MST_0301.cs 19 KB

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