| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_0903.cs
- * 2.功能描述:设置缺陷对应缺陷扣罚及扣除数
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2016/1/5 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DockPanel;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels.PAMModule;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- namespace Dongke.IBOSS.PRD.Client.SystemModule
- {
- public partial class F_MST_0903 : FormBase
- {
- #region 成员变量
- // 窗体模式ID
- //private Constant.FormMode _formType;
- // 操作实体ID(方案)
- //private int? _entityId;
- // 工序
- private DataSet _dsProcedure = new DataSet();
- // 工种编码值
- //private string _GoodsCodeValue;
- //private bool _ShowFlag = true;
- // 数据源
- //DataTable dt = null;
- // 当前工资方案ID
- //private int? _currentWagesTypeID = null;
- // 产品全部数据集
- //DataTable dtAllDataLeft = null;
- // 质量全部数据集
- //DataTable dtAllDataRight = null;
- // 产品工价数据源
- DataTable _dtLeftDataSource = null;
- // 质量工价数据源
- DataTable _dtRightDataSource = null;
- // 当前行ID
- private int _selectedrow = -1;
- // 当前选定行
- private int _currentRowIndexFlag = 0;
- // 当前标准工价
- private int _currentStandardWages = 0;
- // 计件工资策略ID
- private int? _PieceTacticsID = null;
- // 缺陷扣罚数据源
- private DataTable _dtDefectFine = null;
- // 缺陷扣除数数据源
- private DataTable _dtDefectDeduction = null;
- // 临时数据源
- private DataTable _dtTempSource = null;
- //上次临时标记
- //private string _tempRowIndex = "";
- // 临时扣除数数据源
- private DataTable _dtTempSource2 = null;
- #endregion
- #region 属性
- /// <summary>
- /// 产品工价数据源属性
- /// </summary>
- public DataTable DtLeftDataSource
- {
- set
- {
- this._dtLeftDataSource = value;
- }
- get
- {
- if (this._dtLeftDataSource == null)
- {
- this._dtLeftDataSource = new DataTable();
- this._dtLeftDataSource.Columns.Add("WagesTypeID", typeof(decimal)); //工价分类ID
- this._dtLeftDataSource.Columns.Add("RowIndexFlag"); //行标识
- return this._dtLeftDataSource;
- }
- else
- {
- return this._dtLeftDataSource;
- }
- }
- }
- /// <summary>
- /// 质量工价数据源属性
- /// </summary>
- public DataTable DtRightDataSource
- {
- set
- {
- this._dtRightDataSource = value;
- }
- get
- {
- if (this._dtRightDataSource == null)
- {
- this._dtRightDataSource = new DataTable();
- this._dtRightDataSource.Columns.Add("QualityRate", typeof(decimal)); //质量区间开始
- this._dtRightDataSource.Columns.Add("WagesTypeID", typeof(int)); //差额
- this._dtRightDataSource.Columns.Add("QualityReward"); //质量工价
- this._dtRightDataSource.Columns.Add("RowIndexFlag", typeof(int)); //行标识
- return this._dtRightDataSource;
- }
- else
- {
- return this._dtRightDataSource;
- }
- }
- }
- #endregion
- #region 构造函数
- /// <summary>
- /// 窗体构造
- /// </summary>
- /// <param name="formType">窗体打开模式</param>
- /// <param name="entityId">操作实体ID</param>
- public F_MST_0903()
- {
- InitializeComponent();
- this.Text = FormTitles.F_MST_0903;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_0903_Load(object sender, EventArgs e)
- {
- try
- {
- this.dgvDefect.AutoGenerateColumns = false;
- this.dgvDefectFine.AutoGenerateColumns = false;
- this.dgvDefectDeduction.AutoGenerateColumns = false;
- #region 加载缺陷扣罚数据源
- DataSet dsDefectFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllDefectFineRelation();
- }));
- //if (dsDefectFine != null && dsDefectFine.Tables[0].Rows.Count > 0)
- //{
- _dtDefectFine = dsDefectFine.Tables[0];
- //}
- #endregion
- #region 加载缺陷扣除数数据源
- DataSet dsDefectDeduction = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllDefectDeductionRelation();
- }));
- //if (dsDefectDeduction != null && dsDefectDeduction.Tables[0].Rows.Count > 0)
- //{
- _dtDefectDeduction = dsDefectDeduction.Tables[0]; ;
- //}
- #endregion
- #region 加载缺陷数据源
- DataSet defectds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetDefectData(1);
- }));
- if (defectds != null
- && defectds.Tables.Count > Constant.INT_IS_ZERO
- && defectds.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- defectds.Tables[0].DefaultView.RowFilter = "valueflag =1";
- this.dgvDefect.DataSource = defectds.Tables[0].DefaultView.ToTable();
- }
- #endregion
- #region 加载缺陷扣罚下拉数据源
- DataSet dsDefectFineDDL = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllDefectFine();
- }));
- if (dsDefectFineDDL != null && dsDefectFineDDL.Tables[0].Rows.Count > 0)
- {
- defectfineID2.DataSource = dsDefectFineDDL.Tables[0];
- defectfineID2.DisplayMember = "DefectFineCode";
- defectfineID2.ValueMember = "DefectFineID";
- }
- #endregion
- #region 加载缺陷扣除数下拉数据源
- DataSet dsDefectDeductionDDL = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllDefectDeduction();
- }));
- if (dsDefectDeductionDDL != null && dsDefectDeductionDDL.Tables[0].Rows.Count > 0)
- {
- DefectDeductionID.DataSource = dsDefectDeductionDDL.Tables[0];
- DefectDeductionID.DisplayMember = "DefectDeductionNum";
- DefectDeductionID.ValueMember = "DefectDeductionID";
- }
- #endregion
- }
- 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 dgvGoods_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
- {
- }
- /// <summary>
- /// 选定项发生改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["defectid"].Value.ToString() != string.Empty)
- {
- DataTable dtJobs = this._dtDefectFine;
- DataTable dtJobs2 = this._dtDefectDeduction;
- DataTable dtHistory = this.dgvDefectFine.DataSource as DataTable;//
- if (dtHistory != null)
- {
- _dtTempSource = dtHistory;
- }
- DataTable dtHistory2 = this.dgvDefectDeduction.DataSource as DataTable;//
- if (dtHistory2 != null)
- {
- _dtTempSource2 = dtHistory2;
- }
- this._currentRowIndexFlag = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["defectid"].Value);
- //if(this._dtDefectFine!=null)
- //{
- // DataView dvDefectFine = this._dtDefectFine.DefaultView;
- // dvDefectFine.RowFilter = "defectid=" + this._currentRowIndexFlag;
- // this.dgvDefectFine.DataSource = dvDefectFine.ToTable();
- //}
- //if(this._dtDefectDeduction!=null)
- //{
- // DataView dvDefectDeduction = this._dtDefectDeduction.DefaultView;
- // dvDefectDeduction.RowFilter = "defectid=" + this._currentRowIndexFlag;
- // this.dgvDefectDeduction.DataSource = dvDefectDeduction.ToTable();
- //}
- if (_dtTempSource != null && _dtTempSource.Rows.Count > 0)
- {
- if (_dtTempSource.Rows[0]["defectid"].ToString() != "")
- {
- DataRow[] dr = dtJobs.Select("defectid=" + _dtTempSource.Rows[0]["defectid"].ToString());//this._currentRowIndexFlag
- //先删除掉
- foreach (DataRow r in dr)
- {
- r.Delete();
- }
- //重新插入
- for (int i = 0; i < _dtTempSource.Rows.Count; i++)
- {
- if (_dtTempSource.Rows[i]["DefectID"].ToString() != "" && _dtTempSource.Rows[i]["DefectFineID"].ToString() != "")
- {
- DataRow drNew = dtJobs.NewRow();
- drNew["DefectID"] = _dtTempSource.Rows[i]["DefectID"].ToString();
- drNew["DefectFineID"] = _dtTempSource.Rows[i]["DefectFineID"].ToString();
- dtJobs.Rows.Add(drNew);
- }
- }
- _dtTempSource = null;
- }
- }
- if (dtJobs != null)
- {
- DataView dv = dtJobs.DefaultView;
- dv.RowFilter = "defectid=" + this._currentRowIndexFlag;
- this.dgvDefectFine.DataSource = dv.ToTable();
- }
- if (_dtTempSource2 != null && _dtTempSource2.Rows.Count > 0)
- {
- if (_dtTempSource2.Rows[0]["defectid"].ToString() != "")
- {
- DataRow[] dr = dtJobs2.Select("defectid=" + _dtTempSource2.Rows[0]["defectid"].ToString());//this._currentRowIndexFlag
- //先删除掉
- foreach (DataRow r in dr)
- {
- r.Delete();
- }
- //重新插入
- for (int i = 0; i < _dtTempSource2.Rows.Count; i++)
- {
- if (_dtTempSource2.Rows[i]["DefectID"].ToString() != "" && _dtTempSource2.Rows[i]["DefectDeductionID"].ToString() != "")
- {
- DataRow drNew = dtJobs2.NewRow();
- drNew["DefectID"] = _dtTempSource2.Rows[i]["DefectID"].ToString();
- drNew["DefectDeductionID"] = _dtTempSource2.Rows[i]["DefectDeductionID"].ToString();
- dtJobs2.Rows.Add(drNew);
- }
- }
- _dtTempSource2 = null;
- }
- }
- if (dtJobs2 != null)
- {
- DataView dv = dtJobs2.DefaultView;
- dv.RowFilter = "defectid=" + this._currentRowIndexFlag;
- this.dgvDefectDeduction.DataSource = dv.ToTable();
- }
- }
- else
- {
- //DataTable dtJobs = this.DtRightDataSource;
- //DataTable dtHistory = this.dgvDefectFine.DataSource as DataTable;//
- //if (dtHistory != null && dtHistory.Rows.Count > 0)
- //{
- // // DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + (dtHistory.Rows[0]["RowIndexFlag"].ToString() == "" ? "0" : dtHistory.Rows[0]["RowIndexFlag"].ToString()));
- // DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + (dtHistory.Rows[0]["RowIndexFlag"].ToString() == "" ? this._currentRowIndexFlag : Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"].ToString())));
- // //先删除掉
- // foreach (DataRow r in dr)
- // {
- // r.Delete();
- // }
- // //重新插入
- // for (int i = 0; i < dtHistory.Rows.Count; i++)
- // {
- // if (dtHistory.Rows[i]["QualityRate"].ToString() != "" || dtHistory.Rows[i]["QualityReward"].ToString() != "")
- // {
- // DataRow drNew = DtRightDataSource.NewRow();
- // drNew["QualityRate"] = dtHistory.Rows[i]["QualityRate"].ToString();
- // drNew["QualityReward"] = dtHistory.Rows[i]["QualityReward"].ToString();
- // drNew["RowIndexFlag"] = dtHistory.Rows[i]["RowIndexFlag"].ToString();
- // DtRightDataSource.Rows.Add(drNew);
- // }
- // }
- // if (dtJobs != null)
- // {
- // DataView dv = dtJobs.DefaultView;
- // //dv.RowFilter = "RowIndexFlag=" + this._currentRowIndexFlag;
- // dv.RowFilter = "RowIndexFlag=-1";
- // this.dgvDefectFine.DataSource = dv.ToTable();
- // }
- // //}
- //}
- //else
- //{
- // if (dtJobs != null)
- // {
- // DataView dv = dtJobs.DefaultView;
- // dv.RowFilter = "RowIndexFlag=-1";
- // this.dgvDefectFine.DataSource = dv.ToTable();
- // }
- // else
- // {
- // this.dgvDefectFine.DataSource = null;
- // }
- //}
- }
- }
- this.dgvDefectFine.IsSetInputColumnsColor = 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 btnSave_Click_1(object sender, EventArgs e)
- {
- try
- {
- dgvDefect_SelectionChanged(null, null);
- if (this._dtDefectFine == null || this._dtDefectFine.Rows.Count == 0)
- {
- return;
- }
- if (this._dtDefectDeduction == null || this._dtDefectDeduction.Rows.Count == 0)
- {
- return;
- }
- //// 获取缺陷数据源,校验是否有重重的数据
- //DataTable dtDefect = this.dgvDefect.DataSource as DataTable;
- //bool isError = false;
- //int ErrorIndex = 0;
- //for (int i = 0; i < dtDefect.Rows.Count; i++)
- //{
- // DataRow[] dr = _dtDefectFine.Select("defectid=" + dtDefect.Rows[i]["defectid"]);
- // if(dr.Length>1)
- // {
- // ErrorIndex = i;
- // isError = true;
- // break;
- // }
- //}
- //if(isError)
- //{
- // this.dgvDefect.Rows[ErrorIndex].Selected = true;
- // // 提示信息
- // MessageBox.Show("当前缺陷有重复的缺陷扣罚",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- //}
- //for (int i = 0; i < dtDefect.Rows.Count; i++)
- //{
- // DataRow[] dr = _dtDefectDeduction.Select("defectid=" + dtDefect.Rows[i]["defectid"]);
- // if (dr.Length > 1)
- // {
- // ErrorIndex = i;
- // isError = true;
- // break;
- // }
- //}
- //if (isError)
- //{
- // this.dgvDefect.Rows[ErrorIndex].Selected = true;
- // // 提示信息
- // MessageBox.Show("当前缺陷有重复的缺陷扣除数",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- //}
- int returnValue = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.SaveDefectRelation(this._dtDefectFine, this._dtDefectDeduction);
- }));
- if (returnValue >= 0) //等于O,表示未修改数据,影响行为0
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- }
- else if (returnValue == -1)
- {
- // 提示信息
- MessageBox.Show("保存失败",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 绑定编辑数据
- /// </summary>
- private void BindData()
- {
- try
- {
- DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PAMModuleProxy.Service.GetQualityASSByID(Convert.ToInt32(this._PieceTacticsID));
- }));
- if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
- {
- //绑定主信息
- //////if (dsResultAccount.Tables[0].Rows[0]["PayPlanID"].ToString() != "")
- //////{
- ////// this.cmbPayPlan.SelectedValue = dsResultAccount.Tables[0].Rows[0]["PayPlanID"].ToString();
- //////}
- //////this.cmbDefectFine.SelectedValue = dsResultAccount.Tables[0].Rows[0]["DefectFine"].ToString();
- ////////this.dkQualityBaseProcedure.ProcedureID = Convert.ToInt32(dsResultAccount.Tables[0].Rows[0]["QualityBaseProcedureID"]);
- ////////this.dkQualityBaseProcedure.Text = dsResultAccount.Tables[0].Rows[0]["QualityBaseProcedure"].ToString();
- //////this.txtPayPlanName.Text = dsResultAccount.Tables[0].Rows[0]["QualityTacticsName"].ToString();
- //if (dsResultAccount.Tables[3].Rows.Count > 0)
- //{
- // string IDS = "";
- // string TextS = "";
- // foreach (DataRow r1 in dsResultAccount.Tables[3].Rows)
- // {
- // TextS += r1["ProcedureName"].ToString() + ",";
- // IDS += r1["ProcedureID"].ToString() + ",";
- // }
- // IDS = IDS.Trim(',');
- // TextS = TextS.Trim(',');
- // if (IDS != "")
- // {
- // //this.dkQualityBaseProcedure.Text = TextS;
- // //this.dkQualityBaseProcedure.ProcedureIDS = IDS;
- // }
- //}
- if (dsResultAccount != null && dsResultAccount.Tables[1].Rows.Count > 0)
- {
- //产品工价
- this._selectedrow = dsResultAccount.Tables[1].Rows.Count;
- for (int i = 0; i < dsResultAccount.Tables[1].Rows.Count; i++)
- {
- DataRow dr = this.DtLeftDataSource.NewRow();
- dr["WagesTypeID"] = dsResultAccount.Tables[1].Rows[i]["WagesTypeID"];
- dr["RowIndexFlag"] = i;
- this.DtLeftDataSource.Rows.Add(dr);
- //this._selectedrow++;//用于过滤边条件
- if (dsResultAccount != null && dsResultAccount.Tables[2].Rows.Count > 0)
- {
- DataRow[] r = dsResultAccount.Tables[2].Select("WagesTypeID=" + dsResultAccount.Tables[1].Rows[i]["WagesTypeID"]);
- if (r.Length > 0)
- {
- foreach (DataRow rr in r)
- {
- DataRow dr2 = this.DtRightDataSource.NewRow();
- dr2["QualityRate"] = Convert.ToDecimal(rr["QualityRate"]) * 100;
- dr2["WagesTypeID"] = rr["WagesTypeID"];
- dr2["QualityReward"] = rr["QualityReward"];
- dr2["RowIndexFlag"] = i;
- this.DtRightDataSource.Rows.Add(dr2);
- }
- }
- }
- }
- }
- DataView dv = this.DtRightDataSource.DefaultView;
- dv.RowFilter = "RowIndexFlag=0";
- this.dgvDefectFine.DataSource = dv.ToTable();// DtRightDataSource;
- this.dgvDefect.DataSource = DtLeftDataSource;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- /// <summary>
- /// 删除行时
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvGoods_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- }
- private void dgvQualityWages_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
- {
- }
- private void F_PAM_0402_Shown(object sender, EventArgs e)
- {
- this.dgvDefectFine.IsSetInputColumnsColor = true;
- }
- private void dgvDefectFine_CellValidated(object sender, DataGridViewCellEventArgs e)
- {
- if ((e.ColumnIndex == 0 || e.ColumnIndex == 1) && e.RowIndex != -Constant.INT_IS_ONE)
- {
- this.dgvDefectFine.Rows[this.dgvDefectFine.CurrentCell.RowIndex].Cells["defectid1"].Value = this._currentRowIndexFlag;
- }
- }
- private void dgvDefectDeduction_CellValidated(object sender, DataGridViewCellEventArgs e)
- {
- if ((e.ColumnIndex == 0 || e.ColumnIndex == 1) && e.RowIndex != -Constant.INT_IS_ONE)
- {
- this.dgvDefectDeduction.Rows[this.dgvDefectDeduction.CurrentCell.RowIndex].Cells["defectid2"].Value = this._currentRowIndexFlag;
- }
- }
- }
- }
|