/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_TAT_0603.cs * 2.功能描述:行政考核明细 * 编辑履历: * 作者 日期 版本 修改内容 * 宋扬 2014/12/16 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.Client.Controls; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService; using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService; namespace Dongke.IBOSS.PRD.Client.TATModule { public partial class F_TAT_0603 : FormBase { #region 成员变量 // 窗体模式ID private Constant.FormMode _formType; // 操作实体ID private int? _entityId; // 选择窗体弹出标识 private bool _showFlag = true; // 数据源 private DataSet _dsSourse; #endregion #region 构造函数 /// /// 窗体构造 /// /// 窗体开启模式 /// 操作实体ID public F_TAT_0603(Constant.FormMode formType, int entityId) { InitializeComponent(); this._formType = formType; this._entityId = entityId; this.Text = FormTitles.F_TAT_0603; } #endregion #region 事件处理 /// /// 窗体加载 /// /// /// private void F_TAT_0603_Load(object sender, EventArgs e) { try { this.dgvJobs.AutoGenerateColumns = false; //绑定数据源与列表 this.BindData(); //如果是审核及观看模式 if (this._formType == Constant.FormMode.Display) { //列表设置为只读 this.dgvJobs.ReadOnly = true; this.dgvJobs.IsSetInputColumnsColor = false; //控件除关闭外全部不可用 this.tsbtnCreateJobs.Enabled = false; this.btnSubmit.Enabled = false; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 关闭窗体 /// /// /// private void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 窗体自适应 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvJobs.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// 提交操作 /// /// /// private void btnSubmit_Click(object sender, EventArgs e) { try { //提交操作 ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() => { return TATModuleProxy.Service.EditAdminDetail(Convert.ToInt32(this._entityId), this._dsSourse); }); ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text); if (srEntity.Status == Constant.ServiceResultStatus.Success) { this.DialogResult = DialogResult.OK; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 创建全部工种信息,并同时创建各工种对应的明细信息 /// /// /// private void tsbtnCreateJobs_Click(object sender, EventArgs e) { try { //这句话,因为新建的时候,莫名其妙会多出一个数据源不存在的空行,这样设定就不会出现了。 this.dgvJobs.AllowUserToAddRows = false; //获取全部工种 DataSet dsJobs = (DataSet)DoAsync(() => { return SystemModuleProxy.Service.GetJobsData(1); }); //如果获取到了工种 if (dsJobs != null && dsJobs.Tables.Count != Constant.INT_IS_ZERO) { //循环生成工种信息并加入到数据源中 foreach (DataRow drFor in dsJobs.Tables[Constant.INT_IS_ZERO].Rows) { //首先查看该工种在现有数据源中是否存在 int JobIsHave = 0; foreach (DataRow drSourse in this._dsSourse.Tables[Constant.INT_IS_ZERO].Rows) { if (drSourse.RowState == DataRowState.Deleted) { continue; } int drForJobsId = Convert.ToInt32(drFor["JobsId"]); int drSourseJobsId = Convert.ToInt32(drSourse["JobsId"]); if (drForJobsId == drSourseJobsId) { JobIsHave++; break; } } //如果不存在才重新生成 if (JobIsHave == Constant.INT_IS_ZERO && drFor["JobsId"] != DBNull.Value) { DataRow drJobs = _dsSourse.Tables[Constant.INT_IS_ZERO].NewRow(); drJobs["JobsId"] = drFor["JobsId"]; drJobs["JobsCode"] = drFor["JobsCode"]; drJobs["JobsName"] = drFor["JobsName"]; drJobs["BaseAmount"] = Constant.INT_IS_ZERO; drJobs["Isend"] = Constant.INT_IS_ZERO; this._dsSourse.Tables[0].Rows.Add(drJobs); } } //绑定 this.dgvJobs.AutoGenerateColumns = false; this.dgvJobs.DataSource = this._dsSourse.Tables[Constant.INT_IS_ZERO]; } //加载完毕 // this._pageLoadOK = true; this.dgvJobs.AllowUserToAddRows = true; this.dgvJobs.IsSetInputColumnsColor = true; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 工种列表值变更 /// /// /// private void dgvJobs_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { if (this.dgvJobs.Rows.Count <= 1 || !this._showFlag) { return; } DataGridViewRow rowItem = this.dgvJobs.Rows[e.RowIndex]; DataGridViewColumn columnItem = this.dgvJobs.Columns[e.ColumnIndex]; //打开多选页面进行值绑定 this._showFlag = false; FormUtility.BindJobsRowDataSource(this.dgvJobs, e.RowIndex, columnItem.Name, string.Empty); this._showFlag = true; // 设置可输入单元格的颜色 this.dgvJobs.IsSetInputColumnsColor = true; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 私有方法/函数 /// /// 绑定数据源 /// private void BindData() { try { if (this._entityId != Constant.INT_IS_ZERO && this._entityId != null) { ServiceResultEntity srEntity = TATModuleProxy.Service.GetAdminDetailEntityById(Convert.ToInt32(this._entityId)); if (srEntity.Data != null) { this._dsSourse = (DataSet)srEntity.Data; this.dgvJobs.DataSource = this._dsSourse.Tables[Constant.INT_IS_ZERO]; this.dgvJobs.IsSetInputColumnsColor = true; } } } catch (Exception ex) { throw ex; } } #endregion } }