using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Control; 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; 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 FrmCollarOutventory : FrmBase { private string strOutbound = "800802";//出库类型编码 private string strOutname = "";//出库类型名称 public FrmCollarOutventory() { InitializeComponent(); } private void FrmCollarOutventory_Load(object sender, EventArgs e) { StorInfo(); DateTime now =DateTime.Now; RegStartTime.Value = DateTime.Parse(now.AddDays(1 - now.Day).ToString("yyyy-MM-dd")); 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); PipeManageClass.setUltraGridColumnInput(ultraGrid2, new string[] { "DealNum" });//支数 PipeManageClass.setUltraGridColumnMaxInput(ultraGrid2, new string[] { "DealWt" });//重量 } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": if (!CheckQuery()) return; doQuery(); break; case "Add": doAdd(); break; case "Delete": doDelete(); break; //case "Refresh": // doRefresh(); // break; case "Export": if (ultraTabControl1.SelectedTab.Key.Equals("Library1")) { GridHelper.ulGridToExcel(ultraGrid1, "库存实绩表"); } else { GridHelper.ulGridToExcel(ultraGrid2, "倒库实绩表"); } break; case "Close": this.Close(); break; } } private void doQuery() { string strRegStart = ""; string strRegEnd = ""; string orderNo = ""; string codeJg = ""; string strFurnace = ""; ArrayList pram = new ArrayList(); if (chkOrderNo.Checked) { orderNo = txtOrderNo.Value.ToString(); } if (chcCodeJg.Checked) { codeJg = txtCodeJg.Value.ToString(); } if (chkRegTime.Checked) { strRegStart = RegStartTime.Value.ToString(); strRegEnd = RegEndTime.Value.ToString(); } if (chkFurnace.Checked) { strFurnace = txtFurnace.Text.Trim(); } pram.Clear(); 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; } if (ultraTabControl1.SelectedTab.Key.Equals("Library1")) { DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.CollarLibrary.FrmCollarOutventory.doQueryInfoResult", new object[] { pram, arr, orderNo, codeJg, strFurnace }, ob); GridHelper.CopyDataToDatatable(dt, this.dataStorage, true); } else { pram.Add(strOutbound); List listSource = EntityHelper.GetData ("com.steering.mes.mcp.CollarLibrary.FrmCollarOutventory.queryOutPerfo", new object[] { pram, arr,orderNo, codeJg, strFurnace }, 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); //cmbWarehous.DataSource = dt; //cmbWarehous.DisplayMember = "STORAGE_NAME"; //cmbWarehous.ValueMember = "STORAGE_NO"; //PipeManageClass.SetComboItemHeight(cmbWarehous); CKstorage.DataSource = dt; CKstorage.DisplayMember = "STORAGE_NAME"; CKstorage.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(CKstorage); } ///查询时验证必填项 private bool CheckQuery() { if (DataTimeUtil.JudgeTime(DateTime.Parse(RegStartTime.Value.ToString()), DateTime.Parse(RegEndTime.Value.ToString())) == 0) { MessageUtil.ShowTips("开始时间不能大于结束时间!"); return false; } if (chkOrderNo.Checked && string.IsNullOrEmpty(txtOrderNo.Text.Trim())) { MessageBox.Show("请输入合同号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chcCodeJg.Checked && string.IsNullOrEmpty(txtCodeJg.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 (chkOrderNo.Checked) { txtOrderNo.Enabled = true; } else { txtOrderNo.Enabled = false; } if (chcCodeJg.Checked) { txtCodeJg.Enabled = true; } else { txtCodeJg.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 FrmCollarOutventory_Shown(object sender, EventArgs e) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False; } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null) return; if (ultraTabControl1.SelectedTab.Key.Equals("Library1")) { this.chkRegTime.Text = "入库时间"; toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False; toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.True; //chkMaterial.Visible = true; //cmbMaterial.Visible = true; } else { this.chkRegTime.Text = "出库时间"; toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True; toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.False; //chkMaterial.Visible = false; //cmbMaterial.Visible = false; } } /// /// 回车键查询 /// /// /// private void txtFurnace_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { doQuery(); } } private void ultraGrid1_AfterSelectChange(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHOOSE"].Value = true; } } } private void ultraGrid2_AfterSelectChange(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGrid2.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHOOSE"].Value = true; } } } /// /// 新增 /// private void doAdd() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); //查询出库类型 DataTable dt = PipeManageClass.getComTypeInfo(strOutbound, ob); if (dt.Rows.Count >= 1) { strOutname = dt.Rows[0]["BASENAME"].ToString(); } else { MessageUtil.ShowTips("出库类型不能为空,请确认基础信息是否有对应出库类型信息!"); return; } int num = 0; ArrayList List = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid1.Rows) { if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { num++; if (uRow.Cells["PLA_COUNT"].Text.Trim() == "") { MessageUtil.ShowTips("请输入个数!"); return; } if (double.Parse(uRow.Cells["PLA_COUNT"].Value.ToString()) > double.Parse(uRow.Cells["PRO_NUM"].Value.ToString())) { MessageUtil.ShowTips("盘库出库个数不能大于库存个数!"); return; } if (double.Parse(uRow.Cells["PLA_WEIGHT"].Value.ToString()) > double.Parse(uRow.Cells["PRO_WT"].Value.ToString())) { MessageUtil.ShowTips("盘库出库总重量不能大于库存总重量!"); return; } ArrayList pram = new ArrayList(); pram.Add(uRow.Cells["MAT_NO"].Text.Trim()); pram.Add(uRow.Cells["RESULT_NO"].Text.Trim()); pram.Add(uRow.Cells["ZY_PLAN_ID"].Text.Trim()); pram.Add(uRow.Cells["STORAGE_NO"].Text.Trim()); pram.Add(uRow.Cells["KEP_NO"].Text.Trim()); pram.Add(TxtMemo.Text.ToString()); pram.Add(this.UserInfo.GetUserOrder()); pram.Add(this.UserInfo.GetUserGroup()); pram.Add(this.UserInfo.GetUserName()); pram.Add(uRow.Cells["PLA_COUNT"].Value.ToString()); pram.Add(uRow.Cells["PLA_WEIGHT"].Value.ToString()); pram.Add(strOutbound); pram.Add(strOutname); pram.Add(uRow.Cells["WO_ID"].Value.ToString()); pram.Add(uRow.Cells["MAT_NO_XH"].Value.ToString()); pram.Add(uRow.Cells["GUID"].Value.ToString()); List.Add(pram); } } if (num == 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.FrmCollarOutventory"; ccp.MethodName = "addOutLibResult"; 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("盘库出库成功!")) { TxtMemo.Text = ""; doQuery(); } } /// /// 撤销 /// private void doDelete() { UltraGridRow ugr = this.ultraGrid2.ActiveRow; int count = 0; if (ugr == null) return; 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["ResultNo"].Text.Trim()); pram.Add(uRow.Cells["ZyPlanId"].Text.Trim()); pram.Add(uRow.Cells["MatNo"].Text.Trim()); pram.Add(uRow.Cells["KepNo"].Value.ToString()); pram.Add(uRow.Cells["StorageNo"].Value.ToString()); pram.Add(uRow.Cells["DealNum"].Value.ToString()); pram.Add(uRow.Cells["DealWt"].Value.ToString()); pram.Add(this.UserInfo.GetUserName()); pram.Add(this.UserInfo.GetUserOrder()); pram.Add(this.UserInfo.GetUserGroup()); pram.Add(uRow.Cells["DealOrde"].Text.ToString()); pram.Add(uRow.Cells["MatNoXh"].Text.ToString()); pram.Add(uRow.Cells["JgOrderno"].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.FrmCollarOutventory"; 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 ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); if (e.Cell.Column.Key.Equals("PLA_COUNT")) { if (e.Cell.Row.Cells["PLA_COUNT"].Text.ToString().Trim() == "") { e.Cell.Row.Cells["PLA_COUNT"].Value = "0"; } e.Cell.Row.Cells["PLA_WEIGHT"].Value = double.Parse(e.Cell.Row.Cells["PLA_COUNT"].Value.ToString()) * (double.Parse(e.Cell.Row.Cells["SINGLEWEIGHT"].Value.ToString())/1000); } } } }