F_PM_0505.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*******************************************************************************
  2. * Copyright(c) 2020 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0505.cs
  5. * 2.功能描述:窑炉更新财年
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 付斌 2020/06/24 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.Library;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.WinForm.Controls;
  19. namespace Dongke.IBOSS.PRD.Client.PMModule
  20. {
  21. /// <summary>
  22. /// 组织机构新建/编辑界面
  23. /// </summary>
  24. public partial class F_PM_0505 : FormDialog
  25. {
  26. #region 成员变量
  27. DataTable _dtKilntInfo = null;
  28. #endregion
  29. #region 构造函数
  30. /// <summary>
  31. /// 构造函数
  32. /// </summary>
  33. public F_PM_0505()
  34. {
  35. InitializeComponent();
  36. // 标题
  37. Text = FormTitles.F_PM_0505;
  38. // 按钮
  39. btnSave.Text = ButtonText.BTN_SAVE;
  40. }
  41. #endregion
  42. #region 事件
  43. /// <summary>
  44. /// 窗体加载事件
  45. /// </summary>
  46. /// <param name="sender"></param>
  47. /// <param name="e"></param>
  48. private void F_PM_0505_Load(object sender, EventArgs e)
  49. {
  50. try
  51. {
  52. // 获取窑炉信息
  53. DataSet dsResultAccount = SystemModuleProxy.Service.GetAllKilntInfo();
  54. if (dsResultAccount != null && dsResultAccount.Tables.Count > 0 && dsResultAccount.Tables[0].Rows.Count > 0)
  55. {
  56. _dtKilntInfo = dsResultAccount.Tables[0];
  57. }
  58. else
  59. {
  60. // 提示信息
  61. MessageBox.Show("当前系统中不存在窑炉,请重新加载或配置窑炉信息",
  62. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  63. Close();
  64. return;
  65. }
  66. string kilnCode = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  67. Constant.INI_KEY_KILN_CODE, LocalPath.LocalINIFilePath).Trim();
  68. if (!string.IsNullOrEmpty(kilnCode))
  69. {
  70. txtKiln.Text = kilnCode;
  71. // 设置窑炉信息
  72. SetSKInfo();
  73. }
  74. else
  75. {
  76. txtKiln.Focus();
  77. }
  78. }
  79. catch (Exception ex)
  80. {
  81. // 对异常进行共通处理
  82. ExceptionManager.HandleEventException(ToString(),
  83. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  84. }
  85. }
  86. /// <summary>
  87. /// 保存按钮事件
  88. /// </summary>
  89. /// <param name="sender"></param>
  90. /// <param name="e"></param>
  91. private void btnSave_Click(object sender, EventArgs e)
  92. {
  93. try
  94. {
  95. if (!SetSKInfo(true))
  96. {
  97. return;
  98. }
  99. DialogResult drs = MessageBox.Show(
  100. string.Format("请确认窑炉【{0}】【{1}】第【{2}】次烧成的窑车已全部入窑,确定后窑号将增加?",
  101. txtKiln.Text.Trim(), txtSKDate.Text, txtSKBatchNo.Text),
  102. Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  103. if (drs == DialogResult.Yes)
  104. {
  105. // 异步处理
  106. ClientRequestEntity cre = new ClientRequestEntity();
  107. cre.NameSpace = "F_PM_0505";
  108. cre.Name = "SaveSKBatchNo";
  109. cre.Properties["KilnCode"] = txtKiln.Text.Trim();
  110. cre.Properties["Remarks"] = txtRemarks.Text.Trim();
  111. ServiceResultEntity sre = null;
  112. DoAsync(() => { return PMModuleProxyNew.Service.HandleRequest(cre); }, out sre);
  113. if (sre.Status == Constant.ServiceResultStatus.Success)
  114. {
  115. if (sre.OtherStatus > 0)
  116. {
  117. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "更新财年", "保存"), Text,
  118. MessageBoxButtons.OK, MessageBoxIcon.Information);
  119. DialogResult = DialogResult.OK;
  120. Close();
  121. }
  122. else if (sre.OtherStatus < 0 && !string.IsNullOrEmpty(sre.Message))
  123. {
  124. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, sre.Message), Text,
  125. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  126. }
  127. else
  128. {
  129. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "更新财年", "保存"), Text,
  130. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  131. }
  132. }
  133. else
  134. {
  135. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "更新财年", "保存"), Text,
  136. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  137. }
  138. }
  139. }
  140. catch (Exception ex)
  141. {
  142. // 对异常进行共通处理
  143. ExceptionManager.HandleEventException(ToString(),
  144. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  145. }
  146. }
  147. /// <summary>
  148. /// 键盘按下事件
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void txtKiln_KeyPress(object sender, KeyPressEventArgs e)
  153. {
  154. try
  155. {
  156. if (e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE) // 按了回车键
  157. {
  158. if (string.IsNullOrEmpty(txtKiln.Text.Trim()))
  159. {
  160. return;
  161. }
  162. // 设置窑炉信息
  163. SetSKInfo(true);
  164. }
  165. }
  166. catch (Exception ex)
  167. {
  168. // 对异常进行共通处理
  169. ExceptionManager.HandleEventException(this.ToString(),
  170. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  171. }
  172. }
  173. /// <summary>
  174. /// 窑炉编码改变事件
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. private void txtKiln_TextChanged(object sender, EventArgs e)
  179. {
  180. txtSKDate.Text = string.Empty;
  181. txtSKBatchNo.Text = string.Empty;
  182. }
  183. #endregion
  184. #region 私有方法
  185. /// <summary>
  186. /// 设置窑炉信息
  187. /// </summary>
  188. /// <param name="isFormInit">是否校验窑炉编码,而非初始加载</param>
  189. private bool SetSKInfo(bool isCheck = false)
  190. {
  191. try
  192. {
  193. DataView dv = _dtKilntInfo.DefaultView;
  194. dv.RowFilter = "ValueFlag = '1' and KilnCode='" + txtKiln.Text.Trim() + "'";
  195. DataTable dt = dv.ToTable();
  196. if (dt.Rows.Count > 0)
  197. {
  198. DataRow drKiln = dt.Rows[0];
  199. int sk_Date = 0;
  200. int.TryParse(drKiln["SK_Date"] + "", out sk_Date);
  201. int sk_BatchNo = 0;
  202. int.TryParse(drKiln["SK_BatchNo"] + "", out sk_BatchNo);
  203. if (sk_Date == 0)
  204. {
  205. sk_Date = DateTime.Now.Year;
  206. }
  207. else if (sk_Date + 1 < DateTime.Now.Year)
  208. {
  209. sk_Date = DateTime.Now.Year;
  210. sk_BatchNo = 1;
  211. }
  212. txtSKDate.Text = sk_Date + "";
  213. txtSKBatchNo.Text = sk_BatchNo + "";
  214. if (isCheck)
  215. {
  216. // 保存业务系统配置
  217. Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_KILN_CODE,
  218. this.txtKiln.Text.Trim(), LocalPath.LocalINIFilePath);
  219. }
  220. return true;
  221. }
  222. else
  223. {
  224. if (isCheck)
  225. {
  226. // 提示信息
  227. MessageBox.Show("不存在此窑炉编号",
  228. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  229. }
  230. txtKiln.SelectAll();
  231. txtKiln.Focus();
  232. return false;
  233. }
  234. }
  235. catch (Exception ex)
  236. {
  237. throw ex;
  238. }
  239. }
  240. #endregion
  241. }
  242. }