| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_TAT_0103.cs
- * 2.功能描述:新建/编辑/复制缺陷扣罚信息
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 庄天威 2014/11/18 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
- namespace Dongke.IBOSS.PRD.Client.TATModule
- {
- public partial class F_TAT_0103 : FormBase
- {
- #region 成员变量
- // 窗体模式ID
- private Constant.FormMode _formType;
- // 操作实体ID
- private int? _entityId;
- // 操作实体信息
- private DefectFineEntity _dfEntity = new DefectFineEntity();
- #endregion
- #region 构造函数
- /// <summary>
- /// 窗体构造
- /// </summary>
- /// <param name="formType">窗体打开模式</param>
- /// <param name="entityId">操作实体ID</param>
- public F_TAT_0103(Constant.FormMode formType,int entityId)
- {
- InitializeComponent();
- _formType = formType;
- _entityId = entityId;
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_TAT_0103_Load(object sender, EventArgs e)
- {
- try
- {
- if (this._formType == Constant.FormMode.Add)
- {
- this.Text = FormTitles.F_TAT_0103_ADD;
- }
- else if (this._formType == Constant.FormMode.Edit)
- {
- this.Text = FormTitles.F_TAT_0103_EDIT;
- }
- else if (this._formType == Constant.FormMode.CopyAndAdd)
- {
- this.Text = FormTitles.F_TAT_0103_COPY;
- }
- else if (this._formType == Constant.FormMode.Display)
- {
- this.Text = FormTitles.F_TAT_0103_AUDIT;
- }
- //设定按钮的文本值
- this.btnSubmit.Text = ButtonText.BTN_SAVE;
- this.btnClose.Text = ButtonText.BTN_CANCEL;
- this.btnPass.Text = Constant.BUTTON_TEXT_AUDITPASS;
- this.btnReturn.Text = Constant.BUTTON_TEXT_AUDITRETURN;
- //绑定缺陷扣罚
- this.BindSelectDate();
- //如果是修改,要绑定选中的信息
- if (this._formType == Constant.FormMode.Edit)
- {
- this.BindPage();
- }
- //如果是新建,选项默认值设定
- else if(this._formType == Constant.FormMode.Add || this._formType == Constant.FormMode.CopyAndAdd)
- {
- this.cbCeremonial.Checked = true;
- this.cbCoefficient.Checked = true;
- // 如果是复制明细,那么扣罚类型就不可修改。
- if(this._formType == Constant.FormMode.CopyAndAdd)
- {
- this.cbCoefficient.Checked = false;
- this.cbMoney.Checked = true;
- this.cbCoefficient.Enabled = false;
- this.cbMoney.Enabled = false;
- this.txtCoefficient.Enabled = false;
- }
- }
- //如果是审核,绑定值后,所有控件不可用,保存按钮变为明细按钮,并且审批通过与不通过按钮变为可见
- else
- {
- //绑定页面实体成员变量
- this.BindPage();
- this.txtCoefficient.Enabled = false;
- this.txtDefectFineName.Enabled = false;
- this.txtRemarks.Enabled = false;
- this.lbxDefectFine.Enabled = false;
- this.dtpStartTime.Enabled = false;
- this.cbCeremonial.Enabled = false;
- this.cbCoefficient.Enabled = false;
- this.cbMoney.Enabled = false;
- this.cbTrial.Enabled = false;
- this.btnSubmit.Text = Constant.BUTTON_TEXT_DETAIL;
- this.btnPass.Visible = true;
- this.btnReturn.Visible = true;
- //并且,如果是按系数扣罚,明细按钮也要不可用
- if(this.cbCoefficient.Checked == true)
- {
- this.btnSubmit.Enabled = false;
- }
- }
- }
- 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 btnSubmit_Click(object sender, EventArgs e)
- {
- //如果是审批以外的状态,进行添加信息相关的操作
- if (this._formType != Constant.FormMode.Display)
- {
- //首先验证数据合法性
- if (this.ValidationInput() == false)
- {
- return;
- }
- //为实体绑定属性
- this.BindEntity();
- //进行添加操作
- ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
- {
- return EntityToServer();
- });
- //服务实体共通处理
- ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
- if (srEntity.Status == Constant.ServiceResultStatus.Success)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- else//审批操作的话,只打开明细的查看模式就可以了
- {
- //模式化开启明细窗体
- F_TAT_0102 frmTAT0102 = new F_TAT_0102(Constant.FormMode.Display, Convert.ToInt32(this._entityId));
- DialogResult dialogResult = frmTAT0102.ShowDialog();
- }
- }
- /// <summary>
- /// 窗体关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.OK;
- }
- /// <summary>
- /// 选项改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cbCoefficient_CheckedChanged(object sender, EventArgs e)
- {
- if (this.cbCoefficient.Checked == true)
- {
- this.txtCoefficient.Enabled = true;
- }
- else
- {
- this.txtCoefficient.Enabled = false;
- this.txtCoefficient.Text = string.Empty;
- }
- }
- /// <summary>
- /// 选项改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cbMoney_CheckedChanged(object sender, EventArgs e)
- {
- if (this.cbCoefficient.Checked == true)
- {
- this.txtCoefficient.Enabled = true;
- }
- else
- {
- this.txtCoefficient.Enabled = false;
- this.txtCoefficient.Text = string.Empty;
- }
- }
- /// <summary>
- /// 审批通过
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnPass_Click(object sender, EventArgs e)
- {
- //进行审核操作
- this._dfEntity.AuditStatus = Convert.ToInt32(Constant.AuditStatus.Agree);
- ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
- {
- return EntityToServer();
- });
- //服务实体共通处理
- ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
- if (srEntity.Status == Constant.ServiceResultStatus.Success)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- /// <summary>
- /// 审批驳回
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnReturn_Click(object sender, EventArgs e)
- {
- //进行审核操作
- this._dfEntity.AuditStatus = Convert.ToInt32(Constant.AuditStatus.Disagree);
- ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
- {
- return EntityToServer();
- });
- //服务实体共通处理
- ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
- if (srEntity.Status == Constant.ServiceResultStatus.Success)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- #endregion
- #region 私有方法/函数
- /// <summary>
- /// 绑定检索条件数据
- /// </summary>
- private void BindSelectDate()
- {
- try
- {
- //绑定缺陷扣罚
- DataTable dtDefectFine = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.ASE002, Constant.INT_IS_ONE);
- if (dtDefectFine != null)
- {
- lbxDefectFine.DisplayMember = "DictionaryValue";
- lbxDefectFine.ValueMember = "DictionaryID";
- lbxDefectFine.DataSource = dtDefectFine;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 为实体绑定页面属性
- /// </summary>
- private void BindEntity()
- {
- this._dfEntity.DefectFineName = this.txtDefectFineName.Text.Trim();
- this._dfEntity.DefectFine = Convert.ToInt32(this.lbxDefectFine.SelectedValue);
- this._dfEntity.BeginAccountMonth = this.dtpStartTime.Value.Date;
- if(this.cbCeremonial.Checked)
- {
- this._dfEntity.SalaryType = 1;
- }
- else
- {
- this._dfEntity.SalaryType = 0;
- }
- if(this.cbCoefficient.Checked)
- {
- this._dfEntity.FineType = 1;
- this._dfEntity.Coefficient = Convert.ToDecimal(this.txtCoefficient.Text);
- }
- else
- {
- this._dfEntity.FineType = 2;
- }
- this._dfEntity.Remarks = this.txtRemarks.Text;
- this._dfEntity.AuditStatus = 0;
- }
- /// <summary>
- /// 与服务交互操作
- /// </summary>
- /// <returns></returns>
- private ServiceResultEntity EntityToServer()
- {
- if (this._formType == Constant.FormMode.Add)
- {
- return TATModuleProxy.Service.AddDefectFine(this._dfEntity);
- }
- else if(this._formType == Constant.FormMode.Edit)
- {
- return TATModuleProxy.Service.UpdateDefectFine(this._dfEntity);
- }
- else if(_formType == Constant.FormMode.CopyAndAdd)
- {
- this._dfEntity.CopyId = Convert.ToInt32(this._entityId);
- return TATModuleProxy.Service.AddDefectFine(this._dfEntity);
- }
- else if(_formType == Constant.FormMode.Display)
- {
- return TATModuleProxy.Service.AuditDefectFine(this._dfEntity);
- }
- return null;
- }
- /// <summary>
- /// 验证必填项
- /// </summary>
- /// <returns>是否通过</returns>
- private bool ValidationInput()
- {
- if (string.IsNullOrWhiteSpace(this.txtDefectFineName.Text))
- {
- this.txtDefectFineName.Focus();
- return false;
- }
- if(this.lbxDefectFine.SelectedValue == null)
- {
- this.lbxDefectFine.Focus();
- return false;
- }
- if (this.cbCoefficient.Checked == true && string.IsNullOrWhiteSpace(this.txtCoefficient.Text))
- {
- this.txtCoefficient.Focus();
- return false;
- }
- return true;
- }
- /// <summary>
- /// 清空页面
- /// </summary>
- private void ClaerInput()
- {
- this.txtDefectFineName.Text = string.Empty;
- this.lbxDefectFine.Text = string.Empty;
- this.txtCoefficient.Text = string.Empty;
- this.cbCoefficient.Checked = true;
- this.cbCeremonial.Checked = true;
- this.txtRemarks.Text = string.Empty;
- }
- /// <summary>
- /// 绑定需要操作的实体信息
- /// </summary>
- private void BindPage()
- {
- if(this._entityId != 0 && this._entityId != null)
- {
- this._dfEntity.DefectFineID = this._entityId;
- ServiceResultEntity srEntity = TATModuleProxy.Service.GetDefectFine(this._dfEntity);
- if (srEntity.Data != null && srEntity.Data.Tables.Count != 0
- && srEntity.Data.Tables[0].Rows.Count != 0)
- {
- DataSet dsEntityData = (DataSet)srEntity.Data;
- DataRow drEntityRow = dsEntityData.Tables[0].Rows[0];
- this.txtDefectFineName.Text = drEntityRow["DefectFineName"].ToString();
- this.lbxDefectFine.SelectedValue = Convert.ToInt32(drEntityRow["DefectFine"]);
- int FineType = Convert.ToInt32(drEntityRow["FineType"]);
- if(FineType == 1)
- {
- this.cbCoefficient.Checked = true;
- this.txtCoefficient.Text = Convert.ToDecimal(drEntityRow["Coefficient"]).ToString();
- }
- else
- {
- this.cbMoney.Checked = true;
- }
- int SalaryType = Convert.ToInt32(drEntityRow["SalaryType"]);
- this._dfEntity.SalaryType = SalaryType;
- if(SalaryType == 1)
- {
- this.cbCeremonial.Checked = true;
- }
- else
- {
- this.cbTrial.Checked = true;
- }
- this.txtRemarks.Text = drEntityRow["Remarks"].ToString();
- this.dtpStartTime.Text = drEntityRow["BeginAccountMonth"].ToString();
- this._dfEntity.BeginAccountMonth = Convert.ToDateTime(drEntityRow["BeginAccountMonth"].ToString());
- //将时间戳给到要修改的实体中
- this._dfEntity.OPTimeStamp = Convert.ToDateTime(drEntityRow["OPTimeStamp"]);
- }
- }
- }
- #endregion
- }
- }
|