| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- /*******************************************************************************
- * Copyright(c) 2020 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_0505.cs
- * 2.功能描述:窑炉更新财年
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 付斌 2020/06/24 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.WinForm.Controls;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- /// <summary>
- /// 组织机构新建/编辑界面
- /// </summary>
- public partial class F_PM_0505 : FormDialog
- {
- #region 成员变量
- DataTable _dtKilntInfo = null;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PM_0505()
- {
- InitializeComponent();
- // 标题
- Text = FormTitles.F_PM_0505;
- // 按钮
- btnSave.Text = ButtonText.BTN_SAVE;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_0505_Load(object sender, EventArgs e)
- {
- try
- {
- // 获取窑炉信息
- DataSet dsResultAccount = SystemModuleProxy.Service.GetAllKilntInfo();
- if (dsResultAccount != null && dsResultAccount.Tables.Count > 0 && dsResultAccount.Tables[0].Rows.Count > 0)
- {
- _dtKilntInfo = dsResultAccount.Tables[0];
- }
- else
- {
- // 提示信息
- MessageBox.Show("当前系统中不存在窑炉,请重新加载或配置窑炉信息",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- Close();
- return;
- }
- string kilnCode = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
- Constant.INI_KEY_KILN_CODE, LocalPath.LocalINIFilePath).Trim();
- if (!string.IsNullOrEmpty(kilnCode))
- {
- txtKiln.Text = kilnCode;
- // 设置窑炉信息
- SetSKInfo();
- }
- else
- {
- txtKiln.Focus();
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
- }
- }
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- if (!SetSKInfo(true))
- {
- return;
- }
- DialogResult drs = MessageBox.Show(
- string.Format("请确认窑炉【{0}】【{1}】第【{2}】次烧成的窑车已全部入窑,确定后窑号将增加?",
- txtKiln.Text.Trim(), txtSKDate.Text, txtSKBatchNo.Text),
- Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
- if (drs == DialogResult.Yes)
- {
- // 异步处理
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_0505";
- cre.Name = "SaveSKBatchNo";
- cre.Properties["KilnCode"] = txtKiln.Text.Trim();
- cre.Properties["Remarks"] = txtRemarks.Text.Trim();
- ServiceResultEntity sre = null;
- DoAsync(() => { return PMModuleProxyNew.Service.HandleRequest(cre); }, out sre);
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- if (sre.OtherStatus > 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "更新财年", "保存"), Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- DialogResult = DialogResult.OK;
- Close();
- }
- else if (sre.OtherStatus < 0 && !string.IsNullOrEmpty(sre.Message))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, sre.Message), Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "更新财年", "保存"), Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "更新财年", "保存"), Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
- }
- }
- /// <summary>
- /// 键盘按下事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtKiln_KeyPress(object sender, KeyPressEventArgs e)
- {
- try
- {
- if (e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE) // 按了回车键
- {
- if (string.IsNullOrEmpty(txtKiln.Text.Trim()))
- {
- return;
- }
- // 设置窑炉信息
- SetSKInfo(true);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 窑炉编码改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtKiln_TextChanged(object sender, EventArgs e)
- {
- txtSKDate.Text = string.Empty;
- txtSKBatchNo.Text = string.Empty;
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 设置窑炉信息
- /// </summary>
- /// <param name="isFormInit">是否校验窑炉编码,而非初始加载</param>
- private bool SetSKInfo(bool isCheck = false)
- {
- try
- {
- DataView dv = _dtKilntInfo.DefaultView;
- dv.RowFilter = "ValueFlag = '1' and KilnCode='" + txtKiln.Text.Trim() + "'";
- DataTable dt = dv.ToTable();
- if (dt.Rows.Count > 0)
- {
- DataRow drKiln = dt.Rows[0];
- int sk_Date = 0;
- int.TryParse(drKiln["SK_Date"] + "", out sk_Date);
- int sk_BatchNo = 0;
- int.TryParse(drKiln["SK_BatchNo"] + "", out sk_BatchNo);
- if (sk_Date == 0)
- {
- sk_Date = DateTime.Now.Year;
- }
- else if (sk_Date + 1 < DateTime.Now.Year)
- {
- sk_Date = DateTime.Now.Year;
- sk_BatchNo = 1;
- }
- txtSKDate.Text = sk_Date + "";
- txtSKBatchNo.Text = sk_BatchNo + "";
- if (isCheck)
- {
- // 保存业务系统配置
- Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_KILN_CODE,
- this.txtKiln.Text.Trim(), LocalPath.LocalINIFilePath);
- }
- return true;
- }
- else
- {
- if (isCheck)
- {
- // 提示信息
- MessageBox.Show("不存在此窑炉编号",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- txtKiln.SelectAll();
- txtKiln.Focus();
- return false;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|