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.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Infragistics.Win.UltraWinGrid; using Infragistics.Win; using Core.StlMes.Client.YdmPipeManage.Tool; using com.steering.pss.ydm.entity; namespace Core.StlMes.Client.YdmPipeManage { public partial class frmPipeInventoryOut : FrmBase { private string errMessage = ""; public frmPipeInventoryOut() { InitializeComponent(); } private void frmPipeInventoryOut_Load(object sender, EventArgs e) { RegStartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-1); RegEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddDays(1).AddSeconds(-1); BaseMethod.InitStorage(cmbStorage, CustomInfo, this.ValidDataPurviewIds, this.ob); EntityHelper.ShowGridCaption(ultraGridOut.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridManagement.DisplayLayout.Bands[0]); BaseMethod.InitReason(cmbRsn, this.ob); //BaseMethod.setOtherColumnReadOnly(ultraGridOut, new string[] { "Chc" }); BaseMethod.setOtherColumnReadOnly(ultraGridManagement, new string[] { "" }); BaseMethod.InitCellPosition(ultraGridOut, new string[] { "ActWeight", "ActCount", "ActLenMax", "ActLenMin", "ActTheoryWeight", "ActHeight", "ActDimater" }); ultraGridOut.DisplayLayout.Bands[0].Columns["StocktakingRsnName"].Header.Caption = "盘亏原因"; InitStaus(); } private void InitStaus() { //材料状态 this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150101", "材料产出等待"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150102", "材料管理封锁"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150103", "材料质量封锁"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150104", "材料可编计划"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150105", "材料已编计划"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150106", "材料为余材"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150201", "材料产出等待(未综合判定)"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150202", "材料产出(已综合判定"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150203", "材料为余材(已综合判定)"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150204", "材料脱单余材(销售组织脱单)"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150301", "材料可编提单"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150302", "材料已编提单"); this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150303", "销售出厂"); //材料类别 this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801401", "在制品"); this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801402", "成品"); this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801403", "商品"); //封锁标识 this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("0", "未封锁"); this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("1", "管理封锁"); this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("2", "质量封锁"); this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("3", "管理质量双封锁"); //DataTable ds = ClsLoad.GetValueListDataTable("8014", this.ob); //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["ProductFlag"].ValueList = ClsLoad.GeneralValuelist(ref ds, "BASECODE", "BASENAME"); //string[] arr = new string[3] { "801501", "801502", "801503" }; //DataTable dt = ClsLoad.GetValueListDataTable(arr, this.ob); //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["MatStatus"].ValueList = ClsLoad.GeneralValuelist(ref dt, "BASECODE", "BASENAME"); //DataTable dd = ClsLoad.GetValueListDataTable(this.ob); //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["lockFlag"].ValueList = ClsLoad.GeneralValuelist(ref dd, "LOCK_FLAG", "FLAG"); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": DoQueryMangement(); break; case"Query1": DoQueryOut(); break; case "Delete": DoDelete(); break; case "updateYear": updateYear(); break; case"Read": readCard(); break; case "Export": GridHelper.ulGridToExcel(ultraGridOut, "盘亏实绩"); break; case "Close": this.Close(); break; } } /// /// 读卡 /// private void readCard() { } /// /// 修改结转年月 /// private void updateYear() { this.ultraGridOut.UpdateData(); ArrayList list = new ArrayList(); ArrayList parm = new ArrayList(); UltraGridRow uRow = this.ultraGridOut.ActiveRow; string yearMoth = uRow.Cells["balYearMonth"].Text.Substring(0, 4) + uRow.Cells["balYearMonth"].Text.Substring(5, 2); string adjustDoc = uRow.Cells["stocktakingDoc"].Value.ToString(); string heatNo = uRow.Cells["judgeStoveNo"].Value.ToString(); string bacthNo = uRow.Cells["batchNo"].Value.ToString(); string bacthGroupNo = uRow.Cells["batchGroudNo"].Value.ToString(); //string moth = DateTime.Now.AddMonths(1).ToString("yyyyMM"); string moth = DateTime.Parse(uRow.Cells["balYearMonth"].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.FrmPipeInventoryOut.updateYear", new object[] { list }, ob); if (count > 0) { DoQueryOut(); MessageUtil.ShowTips("修改成功"); } } private void chk_CheckedChanged(object sender, EventArgs e) { if (chkRegTime.Checked) { RegStartTime.Enabled = true; RegEndTime.Enabled = true; } else { RegStartTime.Enabled = false; RegEndTime.Enabled = false; } if (chkFurnace.Checked) { txtFurnace.Enabled = true; } else { txtFurnace.Enabled = false; } if (chkMaterial.Checked) { cmbLocation.Enabled = true; } else { cmbLocation.Enabled = false; } } private void cmbStorage_SelectionChanged(object sender, EventArgs e) { if (cmbStorage.Value == null) { cmbLocation.DataSource = null; return; } string storageNo = cmbStorage.Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getLocationNo", new object[] { storageNo }, this.ob); cmbLocation.DataSource = dt; cmbLocation.DisplayMember = "LOCATION_NO"; cmbLocation.ValueMember = "LOCATION_NO"; } private void chkWarehous_CheckedChanged(object sender, EventArgs e) { if (chkWarehous.Checked) { cmbStorage.Enabled = true; chkMaterial.Enabled = true; if (chkMaterial.Checked) { cmbLocation.Enabled = true; } else { cmbLocation.Enabled = false; } } else { chkMaterial.Checked = false; cmbStorage.Enabled = false; chkMaterial.Enabled = false; cmbLocation.Enabled = false; } } /// /// 查询条件 /// /// private ArrayList getQueryCondition() { ArrayList param = new ArrayList(); string strBegin = "1900-01-01 00:00:00"; string strEnd = "9900-01-01 00:00:00"; string justStoveNo = ""; string stoveNo = "";//仓库号; string locationNo = "";//料位号 if (chkRegTime.Checked) { if (RegStartTime.Value == null || RegEndTime.Value == null) { errMessage = "请选择正确的时间"; return null; } strBegin = RegStartTime.Value.ToString(); strEnd = RegEndTime.Value.ToString(); } if (chkFurnace.Checked) { justStoveNo = txtFurnace.Text.Trim(); } if (chkWarehous.Checked && cmbStorage.Value != null) { stoveNo = cmbStorage.Value.ToString(); } if (chkMaterial.Checked && cmbLocation.Value != null) { locationNo = cmbLocation.Value.ToString(); } param.Add(strBegin); param.Add(strEnd); param.Add(justStoveNo); param.Add(stoveNo); param.Add(locationNo); return param; } /// /// 查询库存信息 /// private void DoQueryMangement() { ArrayList param = getQueryCondition(); if (param == null) { MessageUtil.ShowWarning(errMessage); return; } //string[] stoveages = BaseMethod.WarehousePermissions(CustomInfo, this.ValidDataPurviewIds, this.ob); string[] stoveages = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob); string supplyUnit = this.CustomInfo; List listSource = EntityHelper.GetData( "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut.getMangement", new object[] { param, stoveages, supplyUnit }, this.ob); matZcMEntityBindingSource.DataSource = listSource; BaseMethod.MergedCell(ultraGridManagement,new string[]{"BelongName"}); } /// /// 查询盘亏信息 /// private void DoQueryOut() { ArrayList param = getQueryCondition(); if (param == null) { MessageUtil.ShowWarning(errMessage); return; } //string[] stoveages = BaseMethod.WarehousePermissions(CustomInfo, this.ValidDataPurviewIds, this.ob); string[] stoveages = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob); string supplyUnit = this.CustomInfo; List listSource = EntityHelper.GetData( "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut.getOut", new object[] { param, stoveages, supplyUnit }, this.ob); ydmZcStocktakinglistEntityBindingSource.DataSource = listSource; } /// /// 盘亏操作 /// private void DoDelete() { UltraGridRow ugr = ultraGridManagement.ActiveRow; if (ugr == null) { MessageUtil.ShowWarning("请选择要盘亏的记录!"); return; } MatZcMEntity matzcMEntity = (MatZcMEntity)ugr.ListObject; int count = TxtNum.Value == null ? 0 : Convert.ToInt32(TxtNum.Value.ToString()); if (count <= 0) { MessageUtil.ShowWarning("盘亏支数必须大于0!"); return; } if (count > Convert.ToInt32(matzcMEntity.ActCount.ToString())) { MessageUtil.ShowWarning("盘亏支数不能大于库存实际支数!"); return; } string reasonCode = cmbRsn.Value == null ? "" : cmbRsn.Value.ToString(); if (reasonCode.Equals("")) { MessageUtil.ShowWarning("请选择盘亏原因!"); return; } //if (ugr.Cells["matStatus"].Value != "材料可编计划(发运控制)") //{ // MessageUtil.ShowWarning("材料已被做计划,不能盘亏!"); // return; //} string reasonName = cmbRsn.Text; string memo = txtMemo.Text.Trim(); ArrayList param = new ArrayList(); param.Add(count); param.Add(reasonCode); param.Add(reasonName); param.Add(memo); param.Add(UserInfo.GetUserName()); param.Add(ugr.Cells["OrdLnDlyPk"].Value.ToString()); param.Add(DateTime.Now.ToString("yyyyMM")); DataTable dd = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.CorePipeInTemp.getLockFlag", new object[] { matzcMEntity.JudgeStoveNo, matzcMEntity.BatchNo, matzcMEntity.BatchGroudNo }, ob); if (int.Parse(dd.Rows[0]["ACOUNT"].ToString()) > 0) { MessageUtil.ShowTips("炉号:" + matzcMEntity.JudgeStoveNo + "、批号:" + matzcMEntity.BatchNo + "的数据有被封锁的,不能进行盘亏!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否对炉号:" + matzcMEntity.JudgeStoveNo + " 批号:" + matzcMEntity.BatchNo + " 组号:" + matzcMEntity.BatchGroudNo + "进行盘亏操作?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut"; ccp.MethodName = "InventoryOut"; ccp.ServerParams = new object[] { matzcMEntity, param,this.CustomInfo }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); DoQueryMangement(); //DoQueryOut(); BaseMethod.UltraGridLocation(ultraGridManagement, new string[] { "BatchNo", "JudgeStoveNo", "BatchGroudNo" }, new string[] { matzcMEntity.BatchNo, matzcMEntity.JudgeStoveNo, matzcMEntity.BatchGroudNo }); } } 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("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("Query1")) { toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True; } 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; } this.chkRegTime.Text = "入库时间"; } else if (ultraTabControl1.SelectedTab.Key == "1") { if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Query1")) { toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].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("updateYear")) { toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.True; } this.chkRegTime.Text = "盘亏时间"; } } private void frmPipeInventoryOut_Shown(object sender, EventArgs e) { if (toolMenu == null) return; if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("Query1")) { toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True; } 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; } } } }