using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.CollarMaterial; using Core.StlMes.Client.Mcp.Common; using Core.StlMes.Client.Mcp.Control; using Core.StlMes.Client.Mcp.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.Mcp.CollarLibrary { public partial class FrmCollarInventory : FrmBase { private string departm = "";//获取部门ID private string[] plineCode = null;//获取产线代码 public FrmCollarInventory() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmCollarInventory_Load(object sender, EventArgs e) { //departm = UserInfo.GetDeptid(); //plineCode = McpBaseHelper.GetPCodePline(departm, this.ob); McpBaseHelper.InitPlineUnit(TxtPline, this.ValidDataPurviewIds, this.ob, "H"); StorInfo(); //getStoreAll(); RegStartTime.Value = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00:00"); RegEndTime.Value = DateTime.Parse(DateTime.Today.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd") + " 23:59:59"); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getKepNo", null, this.ob); cmbMaterial.DataSource = dt; cmbMaterial.DisplayMember = "KEP_NO"; PipeManageClass.SetComboItemHeight(cmbMaterial); TxtLocation.DataSource = dt; TxtLocation.DisplayMember = "KEP_NO"; PipeManageClass.SetComboItemHeight(TxtLocation); PipeManageClass.setUltraGridColumnInput(ultraGrid2, new string[] { "DealNum" });//支数 PipeManageClass.setUltraGridColumnMaxInput(ultraGrid2, new string[] { "DealWt" });//重量 //获取材料类别 DataTable dt1 = ServerHelper.GetData("com.steering.mes.mcp.CollarLibrary.FrmCollarInventory.queryProductFlag", new object[]{"8014"}, this.ob); txtProductFlag.DataSource = dt1; txtProductFlag.ValueMember = "BASECODE"; txtProductFlag.DisplayMember = "BASENAME"; PipeManageClass.SetComboItemHeight(txtProductFlag); //综合判断结果 DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.CollarLibrary.FrmCollarInventory.queryProductFlag", new object[] { "407407" }, this.ob); txtDeterResults.DataSource = dt2; txtDeterResults.ValueMember = "BASECODE"; txtDeterResults.DisplayMember = "BASENAME"; PipeManageClass.SetComboItemHeight(txtDeterResults); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Add": doAdd(); break; case "Delete": doDelete(); break; case "Export": GridHelper.ulGridToExcel(ultraGrid2, "盘库入库实绩"); break; case "Close": this.Close(); break; } } private void doQuery() { string strRegStart = ""; string strRegEnd = ""; string strWare = "";//仓库号 string strMat = "";//框号 string strFurnace = ""; ArrayList pram = new ArrayList(); if (!CheckQuery()) return; if (chkWarehous.Checked) { strWare = cmbWarehous.Value.ToString(); } if (chkMaterial.Checked) { strMat = cmbMaterial.Value.ToString(); } if (chkRegTime.Checked) { strRegStart = RegStartTime.Value.ToString(); strRegEnd = RegEndTime.Value.ToString(); } if (chkFurnace.Checked) { strFurnace = txtFurnace.Text.Trim(); } pram.Clear(); pram.Add(strWare); pram.Add(strMat); pram.Add(strFurnace); pram.Add(strRegStart); pram.Add(strRegStart); pram.Add(strRegStart); pram.Add(strRegEnd); pram.Add(strRegEnd); string[] str = this.ValidDataPurviewIds; //获取用户对应科室ID string User = this.UserInfo.GetDeptid(); string StorageType = "";//根据传递的参数获取仓库类别 string StorageAttr = "";////根据传递的参数获取仓库类型 if (CustomInfo != "") { string[] strflg = CustomInfo.ToString().Split(new char[] { ',' }); StorageType = strflg[0]; StorageAttr = strflg[1]; } string[] arr = null; DataTable ds = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getStoreNo", new object[] { StorageType, StorageAttr, str }, this.ob); if (ds.Rows.Count > 0) { arr = new string[ds.Rows.Count]; for (int i = 0; i < ds.Rows.Count; i++) { arr[i] = ds.Rows[i][0].ToString(); } } if (arr == null) { MessageUtil.ShowTips("无仓库权限!"); return; } if (arr.Length < 1) { return; } List listSource = EntityHelper.GetData ("com.steering.mes.mcp.CollarLibrary.FrmCollarInventory.queryOutPerfo", new object[] { pram, arr }, this.ob); couplingMatDealEntityBindingSource.DataSource = listSource; GridHelper.RefreshAndAutoSize(ultraGrid2); } /// /// 获取仓库 /// private void StorInfo() { string[] str = this.ValidDataPurviewIds; ArrayList arList = new ArrayList(); //获取用户对应科室ID string User = this.UserInfo.GetDeptid(); string StorageType = "";//根据传递的参数获取仓库类别 string StorageAttr = "";////根据传递的参数获取仓库类型 if (CustomInfo != "") { string[] strflg = CustomInfo.ToString().Split(new char[] { ',' }); StorageType = strflg[0]; StorageAttr = strflg[1]; } DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getStoreNo", new object[] { StorageType, StorageAttr, str }, this.ob); CKstorage.DataSource = dt; CKstorage.DisplayMember = "STORAGE_NAME"; CKstorage.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(CKstorage); TxtStorage.DataSource = dt; TxtStorage.DisplayMember = "STORAGE_NAME"; TxtStorage.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(TxtStorage); cmbWarehous.DataSource = dt; cmbWarehous.DisplayMember = "STORAGE_NAME"; cmbWarehous.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(cmbWarehous); } /// /// 获取所有的目标库 /// private void getStoreAll() { string storeNo = "800202"; string[] arr = McpBaseHelper.WarehousePermissions(this.CustomInfo, this.ValidDataPurviewIds, this.ob); DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getStoreAll", new object[] { storeNo, arr }, this.ob); cmbWarehous.DataSource = dt; cmbWarehous.DisplayMember = "STORAGE_NAME"; cmbWarehous.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(cmbWarehous); } ///查询时验证必填项 private bool CheckQuery() { if (DataTimeUtil.JudgeTime(DateTime.Parse(RegStartTime.Value.ToString()), DateTime.Parse(RegEndTime.Value.ToString())) == 0) { MessageUtil.ShowTips("开始时间不能大于结束时间!"); return false; } if (chkWarehous.Checked && string.IsNullOrEmpty(cmbWarehous.Text.Trim())) { MessageBox.Show("请选择仓库号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } //if (chkMaterial.Checked && string.IsNullOrEmpty(cmbMaterial.Text.Trim())) //{ // MessageBox.Show("请选择料位号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return false; //} if (chkFurnace.Checked && string.IsNullOrEmpty(txtFurnace.Text.Trim())) { MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } return true; } /// /// 验证Checked是否勾选,显示控件可编辑 打勾表示可编辑,不打勾表示不可编辑 /// /// /// private void chk_CheckedChanged(object sender, EventArgs e) { if (chkWarehous.Checked) { cmbWarehous.Enabled = true; } else { cmbWarehous.Enabled = false; } if (chkMaterial.Checked) { cmbMaterial.Enabled = true; } else { cmbMaterial.Enabled = false; } if (chkFurnace.Checked) { txtFurnace.Enabled = true; } else { txtFurnace.Enabled = false; } if (chkRegTime.Checked) { RegStartTime.Enabled = true; RegEndTime.Enabled = true; } else { RegStartTime.Enabled = false; RegEndTime.Enabled = false; } } /// /// 接箍基础信息 /// /// /// private void button1_Click(object sender, EventArgs e) { FrmCollarDialog frmMaterialDialog = new FrmCollarDialog(this.ob); frmMaterialDialog.ShowDialog(); ComMscJgEntity baseEntity = frmMaterialDialog.BaseEntity; if (baseEntity == null) { return; } //TxtMaterial.Text = baseEntity..ToString(); //TxtProduc.Tag = baseEntity.Produccode.ToString(); TxtProduc.Text = baseEntity.CodeJg.ToString(); TxtMinD.Text = baseEntity.MinD.ToString(); TxtMinH.Text = baseEntity.MinH.ToString(); TxtLenMin.Text = baseEntity.LengthMin.ToString(); TxtLenMax.Text = baseEntity.LengthMax.ToString(); TxtTaper.Text = baseEntity.Taper.ToString(); TxtSteelCode.Text = baseEntity.SteelcodeJgDesc.ToString(); TxtModel.Text = baseEntity.ModelDesc.ToString(); TxtOutDimater.Text = baseEntity.DiameterJg.ToString(); TxtHeight.Text = baseEntity.HeightJg.ToString(); TxtSpcName.Text = baseEntity.SpecJgDesc.ToString(); TxtStyleJg.Text = baseEntity.StyleJg.ToString(); TxtInDimater.Text = baseEntity.Diameter.ToString(); TxtCheckVar.Text = baseEntity.CheckJVal.ToString(); TxtJgLen.Text = baseEntity.LengthJg.ToString(); TxtJgWeght.Text = baseEntity.WeightJg.ToString(); } //新增时验证必填项 private string CheckAdd() { if (TxtProduc.Text.Equals("")) { return "请选择接箍基础信息!"; } if (TxtStorage.Text.Equals("")) { return "请选择仓库号!"; } if (TxtLocation.Text.Equals("")) { return "请选择框号!"; } if (txtProductFlag.Text.Equals("")) { return "请选择材料类别!"; } if (txtMatStatus.Text.Equals("")) { return "请选择材料状态!"; } //if (txtDeterResults.Text.Equals("")) //{ // return "请选择框号!"; //} /*if (TxtStoveNo.Text.Equals("") || TxtStoveNo.Text.ToString().Length != 6 || (!StringUtil.IsOnlyLetterAndDigit(TxtStoveNo.Text.ToString()))) { return "炉号由6位数字和字母组成!"; }*/ if (TxtBathNo.Text.Equals("") || TxtBathNo.Text.ToString().Length > 6 || TxtBathNo.Text.ToString().Length < 2 || (!StringUtil.IsOnlyLetterAndDigit(TxtBathNo.Text.ToString()))) { return "批号由2-6位数字和字母组成!"; } //if (TxtPline.Text.Equals("")) //{ // return "请选择产线!"; //} if (TxtNum.Value.ToString().Equals("") || Convert.ToDouble(TxtNum.Value.ToString()) <= 0) { return "请输入个数!"; } if (TxtStoveNo2.Text.ToString().Equals("") ) { return "请输入熔炼炉号!"; } if (TxtOrderno.Text.ToString().Equals("")) { return "请输入合同号!"; } if (TxtOrderNoSeq.Text.ToString().Equals("")) { return "请输入合同行号!"; } //if (TxtCodeJgBl.Text.ToString().Equals("")) //{ // return "请输入备料码!"; //} //if (TxtWoId.Text.ToString().Equals("")) //{ // return "请输入工单号!"; //} return ""; } private CouplingMatDealEntity1 GetAddData() { CouplingMatDealEntity1 entity = new CouplingMatDealEntity1(); entity.DealTypeCode = "800702"; entity.DealTypeName = "盘库入库"; entity.KepNo = TxtLocation.Text.ToString(); entity.StorageNo = TxtStorage.Value == null ? "" : TxtStorage.Value.ToString(); entity.JudgeStoveNo = TxtStoveNo.Text.Trim(); entity.BatchNo = TxtBathNo.Text.Trim(); entity.DealNum = TxtNum.Text.Trim(); entity.DealWt = TxtActWgt.Value == null ? "" : TxtActWgt.Value.ToString(); entity.PlineCode = TxtPline.Value == null ? "" : TxtPline.Value.ToString(); entity.PlineName = TxtPline.Text; entity.CreateName = UserInfo.GetUserName(); entity.Memo = ultraTextEditor1.Text.Trim(); entity.CodeJg = TxtProduc.Text.ToString(); entity.DeterResults = txtDeterResults.Value == null ? "" : txtDeterResults.Value.ToString(); entity.ProductFlag = txtProductFlag.Value.ToString(); entity.MatStatus = txtMatStatus.Value.ToString(); entity.StoveNo = TxtStoveNo2.Text.Trim(); entity.WoId = TxtWoId.Text.Trim(); entity.Gradename = TxtGradeCode.Text.Trim(); entity.CodeJgBl = TxtCodeJgBl.Text.Trim(); entity.OrderNo = TxtOrderno.Text.Trim() + "/" + TxtOrderNoSeq.Text.Trim(); return entity; } /// /// 新增 /// private void doAdd() { string errMessage = CheckAdd(); if (errMessage.Length > 0) { MessageUtil.ShowWarning(errMessage); return; } CouplingMatDealEntity1 entity = GetAddData(); if (MessageUtil.ShowYesNoAndQuestion("是否新增盘库入库信息?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.CollarLibrary.FrmCollarInventory"; ccp.MethodName = "addOutLibResult"; ccp.ServerParams = new object[] { JSONFormat.Format(entity), this.UserInfo.GetUserOrder(), this.UserInfo.GetUserGroup() }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("盘库入库成功!")) { doQuery(); clean(); } } /// /// 删除 /// private void doDelete() { UltraGridRow row = ultraGrid2.ActiveRow; if (row == null) return; int count = 0; ArrayList list = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows) { if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { count += 1; ArrayList pram = new ArrayList(); pram.Add(uRow.Cells["matNo"].Text.Trim()); pram.Add(uRow.Cells["kepNo"].Value.ToString()); pram.Add(uRow.Cells["storageNo"].Value.ToString()); pram.Add(this.UserInfo.GetUserName()); pram.Add(uRow.Cells["dealOrde"].Text.ToString()); pram.Add(uRow.Cells["JudgeStoveNo"].Text.ToString()); pram.Add(uRow.Cells["BatchNo"].Text.ToString()); list.Add(pram); } } if (count == 0) { MessageUtil.ShowTips("请选择要撤销的数据"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销?") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); ccp.ServerName = "com.steering.mes.mcp.CollarLibrary.FrmCollarInventory"; ccp.MethodName = "deleteOutLibResult"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("撤销成功!")) { doQuery(); } } private void ultraGrid2_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { try { ultraGrid2.UpdateData(); foreach (UltraGridRow r in ultraGrid2.Rows) { r.Cells["CHOOSE"].Value = r.Selected; } } catch { } } private void TxtNum_ValueChanged(object sender, EventArgs e) { string count = "0"; if (!TxtNum.Value.Equals("")) { count = TxtNum.Value.ToString(); } string dwgt = "0"; if (TxtJgWeght.Text.ToString() != "") { dwgt = TxtJgWeght.Text.ToString(); } TxtActWgt.Value = double.Parse(count) * (double.Parse(dwgt)/1000); } private void TxtJgWeght_ValueChanged(object sender, EventArgs e) { string count = "0"; if (!TxtNum.Value.Equals("")) { count = TxtNum.Value.ToString(); } string dwgt = "0"; if (TxtJgWeght.Text.ToString() != "") { dwgt = TxtJgWeght.Text.ToString(); } TxtActWgt.Value = double.Parse(count) * double.Parse(dwgt); } /// /// 查询物料码 /// private void QueryMaterial(string plineCode, string codeJg) { DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.CollarLibrary.FrmCollarInventory.queryMaterial", new object[] { plineCode, codeJg }, this.ob); TxtMaterial.DataSource = dt; TxtMaterial.ValueMember = "OUT_MATERIAL_NO"; TxtMaterial.DisplayMember = "OUT_MATERIAL_DESC"; PipeManageClass.SetComboItemHeight(TxtMaterial); } private void TxtPline_ValueChanged(object sender, EventArgs e) { if (txtProductFlag.Text.Equals("")) { return; } string plineCode = TxtPline.Value == null ? "" : TxtPline.Value.ToString(); QueryMaterial(plineCode, TxtProduc.Text.ToString().Trim()); } /// /// 根据材料类别过滤材料类型 /// /// /// private void txtProductFlag_ValueChanged(object sender, EventArgs e) { if (txtProductFlag.Text.Equals("")) { return; } string flag = txtProductFlag.Value.ToString(); if (flag.Equals("801401")) { flag = "801501"; } else if (flag.Equals("801402")) { flag = "801502"; } DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.CollarLibrary.FrmCollarInventory.queryProductFlag", new object[] { flag }, this.ob); txtMatStatus.DataSource = dt; txtMatStatus.ValueMember = "BASECODE"; txtMatStatus.DisplayMember = "BASENAME"; PipeManageClass.SetComboItemHeight(txtMatStatus); } private void clean() { TxtProduc.Text = ""; TxtMinD.Text = ""; TxtMinH.Text = ""; TxtLenMin.Text = ""; TxtLenMax.Text = ""; TxtTaper.Text = ""; TxtSteelCode.Text = ""; TxtModel.Text = ""; TxtOutDimater.Text = ""; TxtHeight.Text = ""; TxtSpcName.Text = ""; TxtStyleJg.Text = ""; TxtInDimater.Text = ""; TxtCheckVar.Text = ""; TxtJgLen.Text = ""; TxtJgWeght.Text = ""; TxtLocation.Text = ""; TxtStoveNo.Text = ""; TxtBathNo.Text = ""; TxtNum.Value = "0"; TxtActWgt.Value = "0"; TxtPline.Text = ""; ultraTextEditor1.Text = ""; TxtProduc.Text = ""; txtDeterResults.Text = ""; txtProductFlag.Text = ""; txtMatStatus.Text = ""; TxtStoveNo2.Text = ""; TxtWoId.Text = ""; } } }