/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_2105.cs * 2.功能描述:注浆变更 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2015/06/19 1.00 新建 *******************************************************************************/ using System; using System.Data; using System.Reflection; using System.Text; 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.Client.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; namespace Dongke.IBOSS.PRD.Client.PMModule { /// /// 注浆变更 /// public partial class F_PM_2105 : DKFormBase { #region 成员变量 private int? _groutingDailyID; //注浆主表ID private DateTime? _groutingDate; //注浆日期 private int? _groutingLineID; //成型线ID #endregion #region 构造函数 public F_PM_2105() { InitializeComponent(); this.btnSearch.Text = ButtonText.BTN_SEARCH; this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION; this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; this.Text = FormTitles.F_PM_2105; this.btnCancel.Text = ButtonText.BTN_CLOSE; this.btnReplace.Text = ButtonText.BTN_REPLACE; this.btnCancelBarCode.Text = ButtonText.BTN_CANCELBINDBARCODE; } #endregion #region 事件 /// /// 关闭按钮事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 窗体加载事件 /// /// /// private void F_PM_2105_Load(object sender, EventArgs e) { try { this.dgvGroutingDaily.AutoGenerateColumns = false; this.txtGroutingDate.Value = DateTime.Now; //this.dkGroutingLine.IsEnablePurview = true; //getPurviewLine();//获取成型线权限 } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 自动列宽事件 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvGroutingDaily.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } #endregion /// /// 清空条件按钮事件 /// /// /// private void btnClearCondition_Click(object sender, EventArgs e) { this.scbGroutingLine.ClearValue(); this.txtGroutingDate.Value = DateTime.Now; } /// /// 查询按钮事件 /// /// /// private void btnSearch_Click(object sender, EventArgs e) { try { if (this.scbGroutingLine.Text == string.Empty) { // 提示 MessageBox.Show("请选择成型线", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.scbGroutingLine.Focus(); return; } this.dgvGroutingDaily.DataSource = null; this.dgvGroutingDaily.DataSource = this.GetSearchData(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 根据界面查询条件获取数据集 /// private DataTable GetSearchData() { try { GroutingDailyEntity se = new GroutingDailyEntity(); se.GroutingLineID = this.scbGroutingLine.SearchedPKMember; se.GroutingDate = this.txtGroutingDate.Value; se.GroutingBatchNo = (this.txtGroutingBatchNo.DataValue.HasValue ? (int)this.txtGroutingBatchNo.DataValue : 1); // 调用服务器端获取数据集 ServiceResultEntity sre = DoAsync(() => { return PCModuleProxy.Service.GetFPM2105Data(se); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { if (sre.Data.Tables[0].Rows.Count > 0) { this._groutingDailyID = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["GroutingDailyID"]); this._groutingDate = Convert.ToDateTime(sre.Data.Tables[0].Rows[0]["GroutingDate"]); this._groutingLineID = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["GroutingLineId"]); } return sre.Data.Tables[0]; } return null; } catch (Exception ex) { throw ex; } } /// /// 获取成型线权限 /// protected void getPurviewLine() { try { //StringBuilder sbProcedurePurview = new StringBuilder(); ////权限 //DataSet dsProcedurePurview = (DataSet)DoAsync(new BaseAsyncMethod(() => //{ // return SystemModuleProxy.Service.GetUserPurview(6, LogInUserInfo.CurrentUser.UserID); //})); //if (dsProcedurePurview != null) //{ // foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows) // { // sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ","); // } // if (sbProcedurePurview.Length != Constant.INT_IS_ZERO) // { // this.dkGroutingLine.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1); // this.dkGroutingLine.GroutingLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1); // } //} } catch (Exception ex) { throw ex; } } /// /// 全选按钮事件 /// /// /// private void chkUserChoose_CheckedChanged(object sender, EventArgs e) { DataTable returnData = (DataTable)this.dgvGroutingDaily.DataSource; if (returnData != null) { int rightFlag = Convert.ToInt16(chkUserChoose.Checked); for (int i = 0; i < returnData.Rows.Count; i++) { returnData.Rows[i]["Sel"] = rightFlag; } } } /// /// 替换按钮事件 /// /// /// private void btnReplace_Click(object sender, EventArgs e) { string groutingUserCode = this.txtGroutingUserCode.Text.Trim(); int? goodsid = this.dkGoodsCode.GoodsID; try { if (this._groutingDailyID == null) { // 提示信息 MessageBox.Show("请先查询注浆信息!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(groutingUserCode) && goodsid == null) { // 提示信息 MessageBox.Show("成型工号与产品编码至少填写一项!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string GroutingDailyDetailIDs = ""; DataTable dt = this.dgvGroutingDaily.DataSource as DataTable; if (dt != null && dt.Rows.Count > 0) { //dt.AcceptChanges(); for (int i = 0; i < dt.Rows.Count; i++) { if (Convert.ToInt32(dt.Rows[i]["Sel"]) == 1) { GroutingDailyDetailIDs += dt.Rows[i]["GroutingDailyDetailID"].ToString() + ","; } } GroutingDailyDetailIDs = GroutingDailyDetailIDs.TrimEnd(','); } ServiceResultEntity sre = this.DoAsync(() => { return PCModuleProxy.Service.SetFPM2105Data(this._groutingLineID, this._groutingDailyID, GroutingDailyDetailIDs, Convert.ToDateTime(this._groutingDate), this.txtGroutingUserCode.Text.Trim(), this.dkGoodsCode.GoodsID); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002); this.DialogResult = DialogResult.OK; this._groutingDailyID = null; this._groutingDate = null; this.dgvGroutingDaily.DataSource = null; this.txtGroutingUserCode.Text = string.Empty; this.dkGoodsCode.ClearControl(); this.scbGroutingLine.ClearValue(); this.txtGroutingDate.Value = DateTime.Now.Date; //this.Close(); return; } if (sre.Status == Constant.ServiceResultStatus.Other) { DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 取消绑定事件 /// /// /// private void btnCancelBarCode_Click(object sender, EventArgs e) { try { if (this._groutingDailyID == null) { // 提示信息 MessageBox.Show("请先查询注浆信息!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string BarCodes = ""; DataTable dt = this.dgvGroutingDaily.DataSource as DataTable; if (dt != null && dt.Rows.Count > 0) { //dt.AcceptChanges(); for (int i = 0; i < dt.Rows.Count; i++) { if (Convert.ToInt32(dt.Rows[i]["Sel"]) == 1 && dt.Rows[i]["BarCode"].ToString()!="") { BarCodes += dt.Rows[i]["BarCode"].ToString() + ","; } } BarCodes = BarCodes.TrimEnd(','); } if(BarCodes==string.Empty) { MessageBox.Show("请先选择取消绑定的条码!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ServiceResultEntity sre = this.DoAsync(() => { return PCModuleProxy.Service.SetFPM2105CancelBarCodeData(BarCodes); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002); this.DialogResult = DialogResult.OK; this._groutingDailyID = null; this._groutingDate = null; this.dgvGroutingDaily.DataSource = null; this.txtGroutingUserCode.Text = string.Empty; this.dkGoodsCode.ClearControl(); this.scbGroutingLine.ClearValue(); this.txtGroutingDate.Value = DateTime.Now.Date; return; } if (sre.Status == Constant.ServiceResultStatus.Other) { DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } } }