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.Tool; using Core.StlMes.Client.YdmPipeManage.Controls; using Core.Mes.Client.Comm.Control; using System.Collections; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.YdmBase; 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 frmPipeAdjust : FrmBase { public frmPipeAdjust() { this.IsLoadUserView = true; InitializeComponent(); } private string strOutbound = "800603";//出库类型编码 private string strInMemo = "";//入库简码 /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": QueryData(); break; case"Query1": QueryAdjustData(); break; case "Add": AddData(); break; case"updateYear": updateYear(); break; case "Refresh": DoRefresh(); break; case "Export": ExportData(); break; case "Close": this.Close(); break; } } /// /// 修改结转年月 /// private void updateYear() { this.ultraGrid2.UpdateData(); ArrayList list = new ArrayList(); ArrayList parm = new ArrayList(); UltraGridRow uRow = this.ultraGrid2.ActiveRow; string yearMoth = uRow.Cells["BAL_YEAR_MONTH"].Text.Substring(0, 4) + uRow.Cells["BAL_YEAR_MONTH"].Text.Substring(5, 2); string adjustDoc = uRow.Cells["STOCKTAKING_DOC"].Value.ToString(); string heatNo = uRow.Cells["JUDGE_STOVE_NO"].Value.ToString(); string bacthNo = uRow.Cells["BATCH_NO"].Value.ToString(); string bacthGroupNo = uRow.Cells["BATCH_GROUD_NO"].Value.ToString(); //string moth = DateTime.Now.AddMonths(1).ToString("yyyyMM"); string moth = DateTime.Parse(uRow.Cells["BAL_YEAR_MONTH"].Text).AddMonths(1).ToString("yyyyMM"); string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds,ob); //parm.Add(heatNo); //parm.Add(bacthNo); //parm.Add(bacthGroupNo); parm.Add(moth); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.selectYearMoth", new object[] { parm, arr }, ob); if (int.Parse(ds.Rows[0]["ACOUNT"].ToString())>0) { MessageUtil.ShowTips("此炉【" + heatNo + "】已进行结转,不允许调整结转年月!"); return; } string nowYearMoth = DateTime.Now.ToString("yyyyMM"); //if (int.Parse(yearMoth) < int.Parse(nowYearMoth)) //{ // MessageUtil.ShowTips("修改的结转年月不能小于当月!"); // return; //} list.Add(yearMoth); list.Add(yearMoth + "02 12:00:00"); list.Add(adjustDoc); int count = ServerHelper.SetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.updateYear", new object[] { list }, ob); if (count > 0) { QueryAdjustData(); MessageUtil.ShowTips("修改成功"); } } /// /// 查询调差实绩 /// private void QueryAdjustData() { string heatNo = "";//炉号 ArrayList list = new ArrayList(); DataTable dt = new DataTable(); if (this.checkHeatNo.Checked) { if (this.txt_heatNo.Text == "") { MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { heatNo = this.txt_heatNo.Text.Trim(); } } list.Add(heatNo); string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob); string supplyUnit = this.CustomInfo; dt.Clear(); dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.getAdjustData", new object[] { list, arr, supplyUnit}, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true); } /// /// 查询库存信息 /// private void QueryData() { string heatNo = "";//炉号 string storgeNo = "";//库号 string locationNo = "";//料位 string supplyUnit = this.CustomInfo; ArrayList list = new ArrayList(); DataTable dt = new DataTable(); if (this.checkHeatNo.Checked) { if (this.txt_heatNo.Text == "") { MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { heatNo = this.txt_heatNo.Text.Trim(); } } if (this.checkStorgeNo.Checked) { if (this.cmbStorgeNo.Text == "") { MessageBox.Show("请选择仓库!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { storgeNo = this.cmbStorgeNo.Value.ToString(); } } list.Add(heatNo); list.Add(storgeNo); //string[] arr = BaseMethod.WarehousePermissions(CustomInfo, this.ValidDataPurviewIds, this.ob); string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob); dt.Clear(); dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.getStorgeData", new object[] { list, arr ,supplyUnit}, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true); //YdmBaseClass.SetColAutoSizeExceptMemo(ultraGrid1); } /// /// 导出调差实绩 /// private void ExportData() { GridHelper.ulGridToExcel(ultraGrid2, this.Text); } /// /// 新增调差实绩 /// private void AddData() { //UltraGridRow row = this.ultraGrid1.ActiveRow; ArrayList parm = new ArrayList(); int count = 0; int n = 0; int actCount = 0; //if (row == null || row.Index < -1) //{ // MessageBox.Show("选择你所要操作的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} foreach (UltraGridRow us in ultraGrid1.Rows) { if (Convert.ToBoolean(us.Cells["CHOOSE"].Text) == true) { n++; } } if (n < 1) { MessageBox.Show("请选择要操作的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (n > 1) { MessageBox.Show("不允许多条记录同时进行调差!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } this.ultraGrid1.UpdateData(); foreach(UltraGridRow ugr in ultraGrid1.Rows ) { if (Convert.ToBoolean(ugr.Cells["CHOOSE"].Text) == true) { if (!StringUtil.IsNumber(ugr.Cells["ADJ_WEIGHT"].Text.Trim())) { MessageBox.Show("调差重量只能是数字!","提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ugr.Cells["ADJ_WEIGHT"].Text == "" || ugr.Cells["REASON"].Text == "") { MessageBox.Show("调整重量和调整原因不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning); return; } if (Convert.ToDouble(ugr.Cells["TOTAL_WEIGHT"].Text) < Math.Abs(Convert.ToDouble(ugr.Cells["ADJ_WEIGHT"].Text))) { MessageBox.Show("调差重量不能超过实际重量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning); return; } DataTable dd = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.CorePipeInTemp.getLockFlag", new object[] { ugr.Cells["JUDGE_STOVE_NO"].Text, ugr.Cells["BATCH_NO"].Text, ugr.Cells["BATCH_GROUD_NO"].Text }, ob); if (int.Parse(dd.Rows[0]["ACOUNT"].ToString()) > 0) { MessageUtil.ShowTips("炉号:" + ugr.Cells["JUDGE_STOVE_NO"].Text + "、批号:" + ugr.Cells["BATCH_NO"].Text + "的数据有被封锁的,不能调差!"); return; } ArrayList parmlist = new ArrayList(); actCount = int.Parse(ugr.Cells["TOTAL_COUNT"].Text.Trim()); parmlist.Add(ugr.Cells["TOTAL_COUNT"].Text.Trim());//总支数 parmlist.Add(ugr.Cells["JUDGE_STOVE_NO"].Text.Trim()); parmlist.Add(ugr.Cells["BATCH_NO"].Text.Trim()); parmlist.Add(ugr.Cells["BATCH_GROUD_NO"].Text.Trim()); parmlist.Add(""); parmlist.Add(""); parmlist.Add(ugr.Cells["MEMO"].Text.Trim()); parmlist.Add(ugr.Cells["MAT_STATUS"].Value.ToString());//材料状态 parmlist.Add(ugr.Cells["PRODUCT_FLAG"].Value.ToString());//材料类别 parmlist.Add(ugr.Cells["JUDGE_RESULT"].Text.Trim());//综合判定结果 parmlist.Add(ugr.Cells["ADJ_WEIGHT"].Text.Trim()); //parmlist.Add(ugr.Cells["REASON"].Value.ToString()); parmlist.Add("");//调差原因代码 parmlist.Add(this.UserInfo.GetUserGroup()); parmlist.Add(this.UserInfo.GetUserOrder()); parmlist.Add(this.UserInfo.GetUserName()); parmlist.Add(this.UserInfo.GetDeptid()); parmlist.Add(this.UserInfo.GetDepartment()); parmlist.Add(ClsBaseInfo.GetDepartIdBySectionId(UserInfo.GetDeptid(), this.ob)); parmlist.Add(ClsBaseInfo.GetDepartBySectionId(UserInfo.GetDeptid(), this.ob)); parmlist.Add(strOutbound); ArrayList pram = new ArrayList(); pram.Clear(); pram.Add(DateTime.Now.ToString("yyyy/MM/dd")); pram.Add(strOutbound); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.queryAdjustList", new object[] { pram }, ob); string str = ""; if (dt.Rows.Count >= 1) { str = dt.Rows[0]["STOCKTAKING_DOC"].ToString(); } DataTable dtMemo = PipeManageClass.getComTypeInfo(strOutbound, ob); if (dtMemo.Rows.Count >= 1) { strInMemo = dtMemo.Rows[0]["MEMO"].ToString(); } parmlist.Add(strInMemo); //20 parmlist.Add(ugr.Cells["REASON"].Text.Trim()); parmlist.Add(ugr.Cells["TOTAL_WEIGHT"].Value.ToString());//总重量 parmlist.Add(ugr.Cells["BELONG_CODE"].Value.ToString()); parmlist.Add(ugr.Cells["BELONG_NAME"].Value.ToString()); parmlist.Add(ugr.Cells["ORD_LN_DLY_PK"].Value.ToString()); parmlist.Add(ugr.Cells["STORAGE_NO"].Value.ToString()); parmlist.Add(ugr.Cells["MEMO"].Value.ToString()); parmlist.Add(ugr.Cells["FINISHPRO_MOLD"].Value.ToString()); parmlist.Add(ugr.Cells["IN_MOLD"].Value.ToString()); parmlist.Add(ugr.Cells["SUPPLY_UNIT_CODE"].Value.ToString()); parmlist.Add(ugr.Cells["SUPPLY_UNIT"].Value.ToString()); parm.Add(parmlist); } } if (MessageUtil.ShowYesNoAndQuestion("是否确认调差?") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.pipemanage.FrmPipeAdjust"; ccp.MethodName = "addAdjustData"; ccp.ServerParams = new object[] { parm }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnInfo.Equals("调差成功!")) { QueryData(); YdmBaseClass.Postioning(this.ultraGrid1, "TOTAL_COUNT", actCount.ToString()); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } /// /// 刷新 /// private void DoRefresh() { BaseMethod.InitStorage(this.cmbStorgeNo, CustomInfo, this.ValidDataPurviewIds, this.ob); } private void frmPipeAdjust_Load(object sender, EventArgs e) { txt_heatNo.Enabled = false; this.cmbStorgeNo.Enabled = false; BaseMethod.InitStorage(this.cmbStorgeNo, CustomInfo, this.ValidDataPurviewIds, this.ob); // InintAdjustReson(); InitBindColumn(); } private void InitBindColumn() { //材料状态 this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150101", "材料产出等待"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150102", "材料管理封锁"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150103", "材料质量封锁"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150104", "材料可编计划"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150105", "材料已编计划"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150106", "材料为余材"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150201", "材料产出等待(未综合判定)"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150202", "材料产出(已综合判定"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150203", "材料为余材(已综合判定)"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150204", "材料脱单余材(销售组织脱单)"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150301", "材料可编提单"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150302", "材料已编提单"); this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150303", "销售出厂"); //材料类别 this.ultraGrid1.DisplayLayout.ValueLists[1].ValueListItems.Add("801401", "在制品"); this.ultraGrid1.DisplayLayout.ValueLists[1].ValueListItems.Add("801402", "成品"); this.ultraGrid1.DisplayLayout.ValueLists[1].ValueListItems.Add("801403", "商品"); //DataTable ds = ClsLoad.GetValueListDataTable("8014", this.ob); //this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCT_FLAG"].ValueList = ClsLoad.GeneralValuelist(ref ds, "BASECODE", "BASENAME"); //string [] arr = new string[3]{"801501","801502","801503"}; //DataTable dt = ClsLoad.GetValueListDataTable(arr, this.ob); //this.ultraGrid1.DisplayLayout.Bands[0].Columns["MAT_STATUS"].ValueList = ClsLoad.GeneralValuelist(ref dt, "BASECODE", "BASENAME"); } /// /// 获取调整原因 /// UltraComboEditor uceReson = new UltraComboEditor(); private void InintAdjustReson() { YdmBaseClass.InitComboEditor(uceReson, "com.steering.pss.ydm.pipemanage.FrmPipeAdjust.getAdjustReason", "BASECODE", this.ob, true); YdmBaseClass.BindColumn(uceReson,"REASON",this.Controls,this.ultraGrid1,0); } /// /// 单选框事件 /// /// /// private void checkHeatNo_CheckedChanged(object sender, EventArgs e) { txt_heatNo.Enabled = this.checkHeatNo.Checked; } private void checkStorgeNo_CheckedChanged(object sender, EventArgs e) { this.cmbStorgeNo.Enabled = this.checkStorgeNo.Checked; } /// /// 绑定料位号 /// /// /// private void cmbStorgeNo_TextChanged(object sender, EventArgs e) { ArrayList pram = new ArrayList(); string strStorage = ""; if (this.cmbStorgeNo.Value == null) { return; } else { strStorage = cmbStorgeNo.Value.ToString(); } pram.Clear(); pram.Add(strStorage); //PipeManageClass.BindLocationInfo(pram, this.cmbLocatonNo, ob); } /// /// 单击事件 /// /// /// private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow uRow = this.ultraGrid1.ActiveRow; DataTable dt = new DataTable(); ArrayList list = new ArrayList(); string heatNo = uRow.Cells["JUDGE_STOVE_NO"].Text.ToString();//炉号 string bacthNo = uRow.Cells["BATCH_NO"].Text.ToString();//批号 string bacthGroupNo = uRow.Cells["BATCH_GROUD_NO"].Text.ToString(); string lactionNo = uRow.Cells["LOCATION_NO"].Text.ToString(); list.Add(heatNo); list.Add(bacthNo); list.Add(bacthGroupNo); list.Add(lactionNo); dt.Clear(); dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.getAdjustData", new object[] { list }, this.ob); //查询调差实绩 GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true); GridHelper.RefreshAndAutoSize(this.ultraGrid2); } /// /// 生成调差单号 /// /// /// private void txtAdjustList_EditorButtonClick(object sender, EditorButtonEventArgs e) { ArrayList pram = new ArrayList(); pram.Clear(); pram.Add(DateTime.Now.ToString("yyyy/MM/dd")); pram.Add(strOutbound); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.queryAdjustList", new object[] { pram }, ob); string str = ""; if (dt.Rows.Count >= 1) { str = dt.Rows[0]["STOCKTAKING_DOC"].ToString(); } DataTable dtMemo = PipeManageClass.getComTypeInfo(strOutbound, ob); if (dtMemo.Rows.Count >= 1) { strInMemo = dtMemo.Rows[0]["MEMO"].ToString(); } //this.txtAdjustList.Text = PipeManageClass.NextNumber(str, strInMemo, "00001"); } private void txt_heatNo_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { QueryData(); } } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null) return; if (ultraTabControl1.SelectedTab.Key == "0") { if (toolMenu.Toolbars[0].Tools.Exists("Query1")) { toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Export")) { toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("Add")) { toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("updateYear")) { toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.False; } this.checkStorgeNo.Visible = true; this.cmbStorgeNo.Visible = true; } else if (ultraTabControl1.SelectedTab.Key == "1") { if (toolMenu.Toolbars[0].Tools.Exists("Query1")) { toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("Add")) { toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.False; } if(toolMenu.Toolbars[0].Tools.Exists("Export")) { toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True; } if(toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("updateYear")) { toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.True; } this.checkStorgeNo.Visible = false; this.cmbStorgeNo.Visible = false; } } private void frmPipeAdjust_Shown(object sender, EventArgs e) { if (toolMenu.Toolbars[0].Tools.Exists("Query1")) { toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Export")) { toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("updateYear")) { toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.False; } } } }