using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.StlMes.Client.YdmPipeManage.Controls; using System.Collections; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Tool; using Infragistics.Win.UltraWinEditors; using Infragistics.Win; namespace Core.StlMes.Client.YdmPipeManage { public partial class frmPipePayIn : FrmBase { ArrayList pram = new ArrayList(); private Dictionary cmbMatEditor = null; private string strInbound = "800701";//入库类型 private string strInname = "";//入库类型名称 private string strInMemo = "";//入库简码 private int isSelect = 0;//新增 private int isDelete = 0;//废除 public frmPipePayIn() { InitializeComponent(); } private void frmPipePayIn_Load(object sender, EventArgs e) { StorInfo(); Init(); ultraGrid2.Enabled = false; GridComboMat(); RegStartTime.DateTime = DateTime.Parse(DateTime.Now.ToString("yyyy年MM月dd日") + " 00:00:00"); RegEndTime.DateTime = DateTime.Parse(DateTime.Now.ToString("yyyy年MM月dd日") + " 23:59:59"); ProEndTime.DateTime = DateTime.Parse(DateTime.Now.ToString("yyyy年MM月dd日") + " 23:59:59"); doQuery(); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": if (!CheckQuery()) return; doQuery(); break; case "Add": doAdd(); doQuery(); break; case "Delete": doDelete(); doQuery(); break; case "Refresh": doRefresh(); break; case "Export": GridHelper.ulGridToExcel(ultraGrid3, "产出入库实绩表"); break; case "Colse": this.Close(); break; } } private void GridComboMat() { int cout = cmbWarehous.Items.Count; cmbMatEditor = new Dictionary(cout); for (int i = 0; i < cmbWarehous.Items.Count; i++) { string phymaxcode = cmbWarehous.Items[i].DataValue.ToString(); pram.Clear(); pram.Add(phymaxcode); UltraComboEditor cmb = new UltraComboEditor(); PipeManageClass.BindLocationInfo(pram, cmb, ob); cmb.Visible = false; cmbMatEditor.Add(phymaxcode, cmb); this.Controls.Add(cmb); } } /// /// 将生成的下拉框绑定到GRID /// /// 初始化行时使用 /// Grid的子表行,刷新时用 /// private void BandComboToGrid(InitializeRowEventArgs e, UltraGridRow ugr) { string phycodemax = e.Row.Cells["STORAGE_NO"].Value.ToString(); if (cmbMatEditor.ContainsKey(phycodemax)) { e.Row.Cells["LOCATION_NO"].EditorComponent = cmbMatEditor[phycodemax]; } else { e.Row.Cells["LOCATION_NO"].EditorComponent = null; } } /// /// 绑定仓库号 /// private void StorInfo() { 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]; //strInbound = strflg[2]; } pram.Clear(); pram.Add(StorageType); pram.Add(StorageAttr); pram.Add(User); PipeManageClass.BindComBaseInfo(pram, cmbWarehous, ob); } /// /// 绑定原料位号下拉框 /// private void Init() { //绑定料位号 string strStorage = ""; if (cmbWarehous.SelectedIndex != -1) { strStorage = cmbWarehous.Value.ToString(); } pram.Clear(); pram.Add(strStorage); PipeManageClass.BindLocationInfo(pram, cmbMaterial, ob); } /// /// 查询 /// private void doQuery() { ArrayList list = new ArrayList(); string strRegStart = ""; string strRegEnd = ""; string strProStart = ""; string strProEnd = ""; string strWare = "";//仓库号 string strMat = "";//料位号 string strFurnace = ""; string strBatch = ""; 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 (chkProTime.Checked) { strProStart = ProStartTime.Value.ToString(); strProEnd = ProEndTime.Value.ToString(); } if (chkFurnace.Checked) { strFurnace = txtFurnace.Text.Trim(); } if (chkBatch.Checked) { strBatch = txtBatch.Text.Trim(); } pram.Clear(); pram.Add(strFurnace); //pram.Add(strBatch); //pram.Add(txtGroup.Text.Trim()); pram.Add(strRegStart); pram.Add(strRegStart); pram.Add(strRegStart); pram.Add(strRegEnd); pram.Add(strRegEnd); //pram.Add(strProStart); //pram.Add(strProStart); //pram.Add(strProStart); //pram.Add(strProEnd); //pram.Add(strProEnd); pram.Add(this.UserInfo.GetUserName()); if (ultraTabControl1.SelectedTab.Key.Equals("0")) { DataTable dt = PipeManageClass.getComPlineInfo(this.UserInfo.GetDeptid(), ob); if (dt.Rows.Count == 0) { MessageUtil.ShowTips("您所在的部门没有对应的产线,请配置!"); return; } for (int i = 0; i < dt.Rows.Count;i++ ) { list.Add(dt.Rows[i]["PLINE_CODE"].ToString()); } DataTable dtStor = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipePayIn.queryStorage", new object[] { pram, list }, ob); if (dtStor.Rows.Count == 0) { MessageUtil.ShowTips("您所在的部门没有对应的产线,请配置!"); return; } GridHelper.CopyDataToDatatable(dtStor, this.dataStorage, true); UltraGridBand ugb = this.ultraGrid1.DisplayLayout.Bands[0]; UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["STD_NAME"], ugb.Columns["MODEL_DESC"], ugb.Columns["PLINE_NAME"], ugb.Columns["SPEC_NAME"] }; GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, col); this.ultraGrid1.DisplayLayout.Override.CellAppearance.TextTrimming = TextTrimming.EllipsisCharacter; } else { pram.Add(strWare); pram.Add(strMat); pram.Add(strInbound); DataTable dtIn = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipePayIn.queryInList", new object[] { pram }, ob); GridHelper.CopyDataToDatatable(dtIn, this.dataInList, true); UltraGridBand ugb = this.ultraGrid3.DisplayLayout.Bands[0]; UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["STD_NAME"], ugb.Columns["MODEL_DESC"], ugb.Columns["PLINE_NAME"], ugb.Columns["SPEC_NAME"] }; GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid3, col); this.ultraGrid3.DisplayLayout.Override.CellAppearance.TextTrimming = TextTrimming.EllipsisCharacter; } } /// /// 新增 /// private void doAdd() { UltraGridRow ugr = this.ultraGrid2.ActiveRow; UltraGridRow ugr1 = this.ultraGrid1.ActiveRow; if (ugr == null||isSelect==0) { MessageUtil.ShowTips("请选择库位信息!"); return; } int count = 0; if (MessageUtil.ShowYesNoAndQuestion("是否确认新增?") == DialogResult.No) return; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows) { if (uRow.Cells["ACT_COUNT"].Value.ToString() == "0"|| uRow.Cells["ACT_COUNT"].Value.ToString()=="") { MessageUtil.ShowTips("支数不能为空或为零!"); return; } if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { if (!doAddCheck(uRow)) return; DataTable dt = PipeManageClass.getComTypeInfo(strInbound, ob); if (dt.Rows.Count >= 1) { strInname = dt.Rows[0]["BASENAME"].ToString(); strInMemo = dt.Rows[0]["MEMO"].ToString(); } else { MessageUtil.ShowTips("出库类型不能空,请确认基础信息是否有对应出库类型信息!"); return; } pram.Clear(); pram.Add(DateTime.Now.ToString("yyyy/MM/dd")); pram.Add(strInbound); DataTable dtList = PipeManageClass.getInList(pram, ob); string str = ""; if (dtList.Rows.Count >= 1) { str = dtList.Rows[0]["INSTOCK_DOC"].ToString(); } string strList = PipeManageClass.NextNumber(str, strInMemo, "00001"); pram.Clear(); pram.Add(ugr1.Cells["JUDGE_STOVE_NO"].Text.Trim()); pram.Add(ugr1.Cells["BATCH_NO"].Text.Trim()); pram.Add(ugr1.Cells["BATCH_GROUD_NO"].Text.Trim()); pram.Add(ugr1.Cells["PLINE_CODE"].Text.Trim()); pram.Add(uRow.Cells["ACT_COUNT"].Value.ToString()); pram.Add(uRow.Cells["LOCATION_NO"].Value.ToString()); pram.Add(uRow.Cells["STORAGE_NO"].Value.ToString()); pram.Add(strInbound); pram.Add(strInname); pram.Add(strList); pram.Add(this.UserInfo.GetUserOrder()); pram.Add(this.UserInfo.GetUserGroup()); pram.Add(this.UserInfo.GetUserName()); count = ServerHelper.SetData("com.steering.pss.ydm.pipemanage.FrmPipePayIn.addPipeSwtow", new object[] { pram }, ob); } } if (count != 0) { MessageUtil.ShowTips("新增成功!"); } } private void doRefresh() { StorInfo(); Init(); } /// /// 作废 /// private void doDelete() { UltraGridRow ugr = this.ultraGrid3.ActiveRow; if (ugr == null || isDelete==0) { MessageUtil.ShowTips("请选择你要作废的信息!"); return; } int count=0; if (MessageUtil.ShowYesNoAndQuestion("是否确认作废?") == DialogResult.No) return; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid3.Rows) { if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { pram.Clear(); pram.Add(uRow.Cells["ACT_COUNT"].Text.Trim()); pram.Add(uRow.Cells["JUDGE_STOVE_NO"].Text.Trim()); pram.Add(uRow.Cells["BATCH_NO"].Text.Trim()); pram.Add(uRow.Cells["BATCH_GROUD_NO"].Text.Trim()); pram.Add(uRow.Cells["INSTOCK_TYPE_CODE"].Text.Trim()); pram.Add(this.UserInfo.GetUserName()); count = ServerHelper.SetData("com.steering.pss.ydm.pipemanage.FrmPipePayIn.deletePipeSwtow", new object[] { pram }, ob); } } if(count!=0) { MessageUtil.ShowTips("作废成功!"); } } //新增时验证 private bool doAddCheck(UltraGridRow urg) { if (urg.Cells["STORAGE_NO"].Text.Trim().Equals("")) { MessageUtil.ShowTips("仓库号不能为空!"); return false; } if (urg.Cells["LOCATION_NO"].Text.Trim().Equals("")) { MessageUtil.ShowTips("料位不能为空!"); return false; } if (urg.Cells["ACT_COUNT"].Value.Equals("0") || urg.Cells["ACT_COUNT"].Value.Equals("")) { MessageUtil.ShowTips("支数不能为空或为零!"); return false; } return true; } ///查询时验证必填项 private bool CheckQuery() { if (DataTimeUtil.JudgeTime(DateTime.Parse(RegStartTime.Value.ToString()), DateTime.Parse(RegEndTime.Value.ToString())) == 0) { MessageUtil.ShowTips("登记开始时间不能大于结束时间!"); return false; } if (DataTimeUtil.JudgeTime(DateTime.Parse(ProStartTime.Value.ToString()), DateTime.Parse(ProEndTime.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; } if (chkBatch.Checked && string.IsNullOrEmpty(txtBatch.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 (chkBatch.Checked) { txtBatch.Enabled = true; } else { txtBatch.Enabled = false; } if (chkRegTime.Checked) { RegStartTime.Enabled = true; RegEndTime.Enabled = true; } else { RegStartTime.Enabled = false; RegEndTime.Enabled = false; } if (chkProTime.Checked) { ProStartTime.Enabled = true; ProEndTime.Enabled = true; } else { ProStartTime.Enabled = false; ProEndTime.Enabled = false; } } private void cmbWarehous_TextChanged(object sender, EventArgs e) { Init(); } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null) return; if (e.Tab.TabControl.SelectedTab.Key.Equals("0")) { chkWarehous.Visible = false; chkWarehous.Checked = false; cmbWarehous.Visible = false; chkMaterial.Visible = false; chkMaterial.Checked = false; cmbMaterial.Visible = false; toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False; } else { chkWarehous.Visible = true; cmbWarehous.Visible = true; chkMaterial.Visible = true; cmbMaterial.Visible = true; toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True; } } private void ultraGrid2_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { ultraGrid2.UpdateData(); UltraGridRow ugr = this.ultraGrid2.ActiveRow; UltraGridRow ugr1 = this.ultraGrid1.ActiveRow; string plannum = ugr1.Cells["ACT_COUNT"].Value.ToString();//当前料位支数 if(e.Cell.Column.Key.Equals("ACT_COUNT")) { double strCount = 0; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows) { if (uRow.Cells["ACT_COUNT"].Value.ToString() == "") { uRow.Cells["ACT_COUNT"].Value = "0"; } if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { strCount += double.Parse(uRow.Cells["ACT_COUNT"].Value.ToString());//目标料位支数 } } if (strCount.ToString() != "" && strCount.ToString() != "0") { if (Convert.ToInt32(strCount.ToString()) > Convert.ToInt32(plannum)) { MessageUtil.ShowWarning("目标料位支数不能大于当前料位支数!"); ugr.Cells["ACT_COUNT"].Value = ""; return; } } } if (e.Cell.Column.Key.Equals("CHOOSE")) { if (Convert.ToBoolean(e.Cell.Value)) { isSelect += 1; } else isSelect -= 1; } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { ultraGrid2.Enabled = true; ultraGrid1.UpdateData(); UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (this.ultraGrid1.Rows.Count <= 0) return; if (ugr == null) return; if (ugr.IsFilterRow) return; if (ugr.HasParent() == true) return; DataTable dt = new DataTable(); GridHelper.CopyDataToDatatable(dt, this.dataStow, true); } private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e) { BandComboToGrid(e, null); //增加行如果没有勾选则不可编辑 if (!Convert.ToBoolean(e.Row.Cells["CHOOSE"].Value)) { for (int i = 0; i < e.Row.Cells.Count; i++) { if (!e.Row.Cells[i].Column.Key.Equals("CHOOSE")) e.Row.Cells[i].Activation = Activation.ActivateOnly; } } else { for (int i = 0; i < e.Row.Cells.Count; i++) { e.Row.Cells[i].Activation = Activation.AllowEdit; } } } private void frmPipeStow_Shown(object sender, EventArgs e) { toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False; } private void ultraGrid3_CellChange(object sender, CellEventArgs e) { if (e.Cell.Column.Key.Equals("CHOOSE")) { if (Convert.ToBoolean(e.Cell.Text) == true) { isDelete += 1; } else isDelete -= 1; } } } }