/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PC_0101_1_2.cs * 2.功能描述:操作时间及备注录入 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2015/09/25 1.00 新建 *******************************************************************************/ using System; using System.Windows.Forms; using System.Data; using Dongke.IBOSS.PRD.Basics.BaseControls; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.WCF.DataModels; namespace Dongke.IBOSS.PRD.Client.PCModule { public partial class F_PC_0101_1_2 : FormBase { #region 成员变量 // 实例窗体 //private F_PC_0101 _fpc0101; private DataTable _dtBindSource = null; //模具状态 private int _GMouldStatus = 0; #endregion #region 构造函数 //public F_PC_0101_1_2(F_PC_0101 fpc0101, string titleStr) //{ // InitializeComponent(); // this._titleStr = titleStr; // this._fpc0101 = fpc0101; // this._fpc0101.SetTimeOrRemarks(null, ""); // this.Text = _titleStr; // this.btnSave.Text = ButtonText.BTN_SAVE; //} //public F_PC_0101_1_2(DataTable dtBindSource, string titleStr) //{ // InitializeComponent(); // _dtBindSource = dtBindSource; // this.Text = titleStr; // this.btnSave.Text = ButtonText.BTN_SAVE; // this.btnCancel.Text = ButtonText.BTN_CLOSE; // this.txtGroutingLineCode.Text = dtBindSource.Rows[0]["GroutingLineCode"].ToString(); //} public F_PC_0101_1_2(DataTable dtBindSource, string titleStr, int GMouldStatus) { InitializeComponent(); _dtBindSource = dtBindSource; this.Text = titleStr; this._GMouldStatus = GMouldStatus; this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; if (GMouldStatus != 6) { this.txtGroutingLineCode.Text = dtBindSource.Rows[0]["GroutingLineCode"].ToString(); } if (GMouldStatus == 0 || GMouldStatus == 1) { this.btnDelete.Visible = true; this.dgvGroutingLineDetail.AllowUserToDeleteRows = true; } } public int GroutingLineID { get; set; } public string GroutingLineCode { get { return this.txtGroutingLineCode.Text; } set { this.txtGroutingLineCode.Text = value; } } public DateTime LineOPTimeStamp { get; set; } #endregion #region 事件 /// /// 保存按钮事件 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { DataTable dtName = this.dgvGroutingLineDetail.DataSource as DataTable; dtName.AcceptChanges(); if (dtName.Rows.Count == 0) { MessageBox.Show("没有选择任何数据", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } dtName.TableName = "GMouldRecord"; if (this.pnlMouldStatus.Visible) { if (!dtName.Columns.Contains("MouldStatus")) { dtName.Columns.Add("MouldStatus", typeof(int)); dtName.Columns.Add("ScrapReason", typeof(int)); dtName.Columns.Add("ScrapResponsibility"); } int ms = (this.rabMouldStatus1.Checked ? 1 : (this.rabMouldStatus3.Checked ? 3 : 4)); foreach (DataRow item in dtName.Rows) { // 非条码模具 if (item["MouldID"] + "" == "") { continue; } item["MouldStatus"] = ms; if (ms == 4) { item["ScrapReason"] = this.ftcScrapReason.SelectedValue; item["ScrapResponsibility"] = this.txtScrapResponsibility.Text; } } } int returnRow = 0; if (this._GMouldStatus == 0) { // 停用 returnRow = (int)DoAsync(new BaseAsyncMethod(() => { return PCModuleProxy.Service.StopGroutingLineDetail(dtName); })); } else if (this._GMouldStatus == 1) { // 启用 returnRow = (int)DoAsync(new BaseAsyncMethod(() => { return PCModuleProxy.Service.StartGroutingLineDetail(dtName); })); } else if (this._GMouldStatus == 2) { // 维修 returnRow = (int)DoAsync(new BaseAsyncMethod(() => { return PCModuleProxy.Service.RepairStartGroutingLineDetail(dtName); })); } else if (this._GMouldStatus == 3) { //维修结束 returnRow = (int)DoAsync(new BaseAsyncMethod(() => { return PCModuleProxy.Service.RepairEndGroutingLineDetail(dtName); })); } else if (this._GMouldStatus == 4) { //换模 returnRow = (int)DoAsync(new BaseAsyncMethod(() => { return PCModuleProxy.Service.ChangeGMouldStartGroutingLineDetail(dtName); })); } else if (this._GMouldStatus == 5) { //变产 returnRow = (int)DoAsync(new BaseAsyncMethod(() => { return PCModuleProxy.Service.UpdateLineStartGroutingLineDetail(dtName); })); } else if (this._GMouldStatus == 6) { //整线变产 returnRow = (int)DoAsync(new BaseAsyncMethod(() => { return PCModuleProxy.Service.UpdateAllLineStartGroutingLineDetail(dtName, this.GroutingLineID, this.LineOPTimeStamp); })); } else if (this._GMouldStatus == 7) { // 卸模 returnRow = (int)DoAsync(new BaseAsyncMethod(() => { return PCModuleProxy.Service.UnloadGroutingLineDetail(dtName); })); } if (returnRow > 0) { //成功 MessageBox.Show(this.Text + "成功", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; } else if (returnRow == -500) { MessageBox.Show("数据已经被修改,请重新编辑", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.DialogResult = DialogResult.No; } else { //失败 MessageBox.Show(this.Text + "失败", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.DialogResult = DialogResult.No; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 窗体加载事件 /// /// /// private void F_PC_0101_1_2_Load(object sender, EventArgs e) { try { this.dgvGroutingLineDetail.AutoGenerateColumns = false; DateTime accountDate = CommonModuleProxy.Service.GetAccountDate(); this.txtDateStart.Value = accountDate; this.dgvGroutingLineDetail.DataSource = _dtBindSource; // 设置可输入单元格的颜色 this.dgvGroutingLineDetail.IsSetInputColumnsColor = true; if (this._GMouldStatus == 4 || this._GMouldStatus == 5 || this._GMouldStatus == 6 || this._GMouldStatus == 7) { DataRow[] dr = _dtBindSource.Select("MouldID is not null"); if (dr != null && dr.Length > 0) { this.pnlMouldStatus.Visible = true; ClientRequestEntity creLoad = new ClientRequestEntity(); creLoad.NameSpace = "FPC1004"; creLoad.Name = "GetFPC1004LoadData"; creLoad.Properties["MouldOperationType"] = (int)Constant.MouldOperationType.OnLineToScrap; ServiceResultEntity sreLoad = PCModuleProxyNew.Service.HandleRequest(creLoad); this.ftcScrapReason.ValueMember = "dictionaryid"; this.ftcScrapReason.DisplayMember = "dictionaryvalue"; this.ftcScrapReason.DataSource = sreLoad.Data.Tables[0]; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 关闭按钮事件 /// /// /// private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } /// /// 自适应 /// /// /// private void btnAdaptive_Click(object sender, EventArgs e) { this.dgvGroutingLineDetail.AutoResizeColumns(); } /// /// 条码模具去向(报废) /// /// /// private void rabMouldStatus4_CheckedChanged(object sender, EventArgs e) { this.pnlScrap.Visible = this.rabMouldStatus4.Checked; } #endregion private void btnDelete_Click(object sender, EventArgs e) { if (this.dgvGroutingLineDetail.CurrentRow == null) { return; } try { this.dgvGroutingLineDetail.Rows.Remove(this.dgvGroutingLineDetail.CurrentRow); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } } }