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 System.Collections; using Core.StlMes.Client.YdmPipeManage.Controls; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Infragistics.Win.UltraWinGrid; using Infragistics.Win; using Core.StlMes.Client.YdmPipeManage.Tool; using com.steering.pss.ydm.entity; using Core.StlMes.Client.YdmPipeManage.Dialog; using Core.StlMes.Client.YdmPipeManage.Entity; using Infragistics.Win.UltraWinToolTip; using Core.StlMes.Client.YdmBase; namespace Core.StlMes.Client.YdmPipeManage { public partial class frmPipeInventoryIn : FrmBase { public frmPipeInventoryIn() { InitializeComponent(); } private void frmPipeInventoryIn_Load(object sender, EventArgs e) { BaseMethod.InitStorage(cmbStorage, CustomInfo, this.ValidDataPurviewIds, this.ob); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); InitDropBox(); BaseMethod.InitGrade(cmbGrade, this.ob); 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.setOtherColumnReadOnly(ultraGrid1, new string[] { "Chc" }); BaseMethod.InitCellPosition(ultraGrid1, new string[] { "ActWeight", "ActCount", "ActLenMax", "ActLenMin", "ActTheoryWeight", "ActHeight", "ActDimater" }); ultraGrid1.DisplayLayout.Bands[0].Columns["StocktakingRsnName"].Header.Caption = "盘盈原因"; } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": DoQuery(); break; case "Add": DoAdd(); break; case "updateYear": updateYear(); break; case "Export": GridHelper.ulGridToExcel(ultraGrid1, "盘盈实绩"); break; case "Close": this.Close(); break; } } /// /// 调整结转年月 /// private void updateYear() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); ArrayList parm = new ArrayList(); UltraGridRow uRow = this.ultraGrid1.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.FrmPipeInventoryIn.updateYear", new object[] { list }, ob); if (count > 0) { DoQuery(); MessageUtil.ShowTips("修改成功"); } } /// /// 编辑区下拉框绑定 /// private void InitDropBox() { //产线 BaseMethod.InitPline(TxtPline, this.ob); DataTable dt= ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.queryMaterialSTyle", new object[] { }, ob); TxtProductFlag.DataSource = dt; TxtProductFlag.DisplayMember="BASENAME"; TxtProductFlag.ValueMember = "BASENAME"; BaseMethod.InitSourse(TxtSourse, this.ob); TxtSourse.Value = "801305"; BaseMethod.InitReason(TxtReason, this.ob); BaseMethod.InitStorage(TxtStorage, CustomInfo, this.ValidDataPurviewIds, this.ob); BaseMethod.InitJustResult(cmbResult, this.ob); // BaseMethod.InitBelongCode(TxtBelongCode, this.ob); } /// /// 查询 /// private void DoQuery() { 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 = "";//料位号 //string[] stoveages = BaseMethod.WarehousePermissions(CustomInfo, this.ValidDataPurviewIds, this.ob); string[] stoveages = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob); if (chkRegTime.Checked) { if (RegStartTime.Value == null || RegEndTime.Value == null) { MessageUtil.ShowWarning("请选择正确的创建时间"); return; } 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); List listSource = EntityHelper.GetData( "com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getYdmZcStocktakingList", new object[] { param, stoveages,this.CustomInfo.ToString2() }, this.ob); ydmZcStocktakinglistEntityBindingSource.DataSource = listSource; } /// /// 新增 /// private void DoAdd() { OYdmZcStorcktakinglistEntity entity = GetAddData(); string errMessage = CheckAdd(entity); if (errMessage.Length > 0) { MessageUtil.ShowWarning(errMessage); return; } if (MessageUtil.ShowYesNoAndQuestion("是否新增盘盈信息?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn"; ccp.MethodName = "doAdd"; ccp.ServerParams = new object[] { entity }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { DoQuery(); if (!ccp.ReturnInfo.Contains(",")) { MessageUtil.ShowTips(ccp.ReturnInfo); } else { string[] message = ccp.ReturnInfo.Split(','); MessageUtil.ShowTips(message[0]); foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (ugr.Cells["StocktakingDoc"].Value.ToString().Equals(message[1])) { ugr.Activate(); break; } } } } } private OYdmZcStorcktakinglistEntity GetAddData() { OYdmZcStorcktakinglistEntity entity = new OYdmZcStorcktakinglistEntity(); entity.StocktakingTypeCode = "800601"; entity.StocktakingTypeName = "盘盈"; entity.StocktakingRsnCode = TxtReason.Value == null ? "" : TxtReason.Value.ToString(); entity.StocktakingRsnName = TxtReason.Text.Trim(); entity.JudgeStoveNo = TxtStoveNo.Text.Trim(); entity.BatchNo = TxtBathNo.Text.Trim(); entity.BatchGroudNo = "1"; entity.MaterialNo = TxtMaterial.Tag == null ? "" : TxtMaterial.Tag.ToString(); entity.MaterialName = TxtMaterial.Text; entity.Produccode = TxtProduc.Tag == null ? "" : TxtProduc.Tag.ToString(); entity.Producname = TxtProduc.Text; entity.StdCode = TxtStdName.Tag == null ? "" : TxtStdName.Tag.ToString(); entity.StdName = TxtStdName.Text; entity.Steelcode = TxtSteelCode.Tag == null ? "" : TxtSteelCode.Tag.ToString(); entity.Steelname = TxtSteelCode.Text; entity.StdStyle = TxtStdStyle.Tag == null ? "" : TxtStdStyle.Tag.ToString(); entity.StdStyleDesc = TxtStdStyle.Text; entity.SpecCode = TxtSpcName.Tag == null ? "" : TxtSpcName.Tag.ToString(); entity.SpecName = TxtSpcName.Text; entity.ModelCode = TxtModel.Tag == null ? "" : TxtModel.Tag.ToString(); entity.ModelDesc = TxtModel.Text; entity.PlineCode = TxtPline.Value == null ? "" : TxtPline.Value.ToString(); entity.PlineName = TxtPline.Text; entity.ActDimater = TxtDimater.Text; entity.ActHeight = TxtHeight.Text; entity.ActLenMax = TxtMax.Value == null ? "" : TxtMax.Value.ToString(); entity.ActLenMin = TxtMin.Value == null ? "" : TxtMin.Value.ToString(); entity.ActCount = TxtNum.Text.Trim(); entity.ActWeight = TxtActWgt.Value == null ? "" : TxtActWgt.Value.ToString(); entity.ActLen = TxtActLen.Value == null ? "" : TxtActLen.Value.ToString(); //entity.ActTheoryWeight = TxtWgt.Value == null ? "" : TxtWgt.Value.ToString(); entity.BelongCode = TxtBelongCode.Value == null ? "" : TxtBelongCode.Value.ToString(); entity.BelongName = TxtBelongCode.Text; entity.StorageNo = TxtStorage.Value == null ? "" : TxtStorage.Value.ToString(); entity.LocationNo = TxtLocation.Value == null ? "" : TxtLocation.Value.ToString(); entity.CreateName = UserInfo.GetUserName(); entity.Memo = ultraTextEditor1.Text.Trim(); entity.MatOriginCode = TxtSourse.Value == null ? "" : TxtSourse.Value.ToString(); entity.MatOriginName = TxtSourse.Text; entity.MatStatus = TxtMagstatus.Value == null ? "" : TxtMagstatus.Value.ToString(); entity.ProductFlag = TxtProductFlag.Value == null ? "" : TxtProductFlag.Value.ToString(); entity.JudgeResultCode = cmbResult.Value == null ? "" : cmbResult.Value.ToString(); entity.JudgeResult = cmbResult.Text; entity.BalYearMonth = DateTime.Now.ToString("yyyyMM"); entity.SoureCode = TxtPline.Value == null ? "" : TxtPline.Value.ToString(); entity.SoureName = TxtPline.Text; entity.Gradecode = cmbGrade.Value == null ? "" : cmbGrade.Value.ToString(); entity.Gradename = cmbGrade.Text; entity.SupplyUnit = this.CustomInfo.Equals("120504") ? "江苏天淮钢管有限公司" : "天津钢管制造有限公司"; entity.SupplyUnitCode = this.CustomInfo.Equals("120504") ? "120504" : "120501"; return entity; } //新增时验证必填项 private string CheckAdd(OYdmZcStorcktakinglistEntity entity) { if (entity.MaterialNo.Equals("")) { return "请选择产品信息!"; } if (entity.Produccode.Equals("")) { return "请选择产品信息!"; } if (entity.StdCode.Equals("")) { return "请选择产品信息!"; } if (entity.SpecCode.Equals("")) { return "请选择产品信息!"; } if (entity.ProductFlag.Equals("")) { return "请选择材料类别!"; } if (entity.MatStatus.Equals("")) { return "请选择材料状态!"; } if (entity.ActLenMax.Equals("") || Convert.ToDouble(entity.ActLenMax.ToString()) <= 0) { return "请输入长度上限!"; } if (entity.ActLenMin.Equals("") || Convert.ToDouble(entity.ActLenMin.ToString()) <= 0) { return "请输入长度下限!"; } if (Convert.ToDouble(entity.ActLenMax.ToString()) < Convert.ToDouble(entity.ActLenMin.ToString())) { return "长度上限不能小于长度下限"; } if (entity.MatOriginCode.Equals("")) { return "请选择材料来源!"; } if (entity.ActCount.Equals("") || Convert.ToDouble(entity.ActCount.ToString()) <= 0) { return "请输入支数!"; } if (entity.ActWeight.Equals("") || Convert.ToDouble(entity.ActWeight.ToString()) <= 0) { return "请输入实重!"; } if (entity.BelongCode.Equals("")) { return "请选择销售组织"; } if (entity.StorageNo.Equals("")) { return "请选择仓库号!"; } //if (entity.LocationNo.Equals("")) //{ // return "请选择料位号!"; //} if (entity.StocktakingRsnCode.Equals("")) { return "请选择盘盈原因!"; } if (entity.JudgeStoveNo.Equals("") || entity.JudgeStoveNo.ToString().Length != 6 || (!StringUtil.IsOnlyLetterAndDigit(entity.JudgeStoveNo.ToString()))) { return "炉号由6位数字和字母组成!"; } //if (entity.PlineCode.Equals("")) //{ // return "请选择产线!"; //} if (entity.BatchNo.Equals("") || entity.BatchNo.ToString().Length > 3 || entity.BatchNo.ToString().Length < 2 || (!StringUtil.IsOnlyLetterAndDigit(entity.BatchNo.ToString()))) { return "批号由2-3位数字和字母组成!"; } if (entity.JudgeResultCode.Equals("")) { return "请选择判定结果!"; } return ""; } //--------------2015/08/13 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 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"; } /// /// 验证Checked是否勾选,显示控件可编辑 打勾表示可编辑,不打勾表示不可编辑 /// /// /// private void chk_CheckedChanged(object sender, EventArgs e) { if (chkFurnace.Checked) { txtFurnace.Enabled = true; } else { txtFurnace.Enabled = false; } if (chkMaterial.Checked) { cmbLocation.Enabled = true; } else { cmbLocation.Enabled = false; } } /// /// 物料信息选择 /// /// /// private void button1_Click(object sender, EventArgs e) { //FrmMaterialDialog frmMaterialDialog = new FrmMaterialDialog("","0", this.ob); //frmMaterialDialog.ShowDialog(); //SlmBaseMaterialEntity baseEntity = frmMaterialDialog.BaseEntity; //ComPscEntity pscEntity = frmMaterialDialog.PscEntity; //if (baseEntity == null || pscEntity == null) //{ // return; //} //TxtMaterial.Tag = baseEntity.MaterialNo.ToString(); //TxtMaterial.Text = baseEntity.MaterialDesc.ToString(); //TxtProduc.Tag = baseEntity.Produccode.ToString(); //TxtProduc.Text = baseEntity.Producname.ToString(); //TxtStdName.Tag = pscEntity.StdCode.ToString(); //TxtStdName.Text = pscEntity.StdName.ToString(); //TxtStdStyle.Tag = baseEntity.StdStyle == null ? "" : baseEntity.StdStyle.ToString(); //TxtStdStyle.Text = baseEntity.StdStyleDesc == null ? "" : baseEntity.StdStyleDesc.ToString(); //TxtSpcName.Tag = baseEntity.SpecCode.ToString(); //TxtSpcName.Text = baseEntity.SpecName.ToString(); //TxtModel.Tag = baseEntity.ModelCode == null ? "" : baseEntity.ModelCode.ToString(); //TxtModel.Text = baseEntity.ModelDesc == null ? "" : baseEntity.ModelDesc.ToString(); //TxtDimater.Value = baseEntity.Dimater.ToString(); //TxtHeight.Value = baseEntity.Height.ToString(); //TxtSteelCode.Tag = baseEntity.Steelcode.ToString(); //TxtSteelCode.Text = baseEntity.Steelname.ToString(); } private void TxtProductFlag_SelectionChanged(object sender, EventArgs e) { if (TxtProductFlag.Value == null) { TxtMagstatus.DataSource = null; return; } else { string value = TxtProductFlag.Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getmagStatus", new object[] { value }, this.ob); BaseMethod.InitComboEditor(TxtMagstatus, dt, "BASENAME", "BASECODE"); } } private void TxtStorage_SelectionChanged(object sender, EventArgs e) { if (TxtStorage.Value == null) { TxtLocation.DataSource = null; return; } string storageNo = TxtStorage.Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getLocationNo", new object[] { storageNo }, this.ob); TxtLocation.DataSource = dt; TxtLocation.DisplayMember = "LOCATION_NO"; TxtLocation.ValueMember = "LOCATION_NO"; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGrid1.ActiveRow; if (ugr == null) { return; } TxtMaterial.Tag = ugr.Cells["MaterialNo"].Text; TxtMaterial.Text = ugr.Cells["MaterialName"].Text; TxtSpcName.Tag = ugr.Cells["SpecCode"].Text; TxtSpcName.Text = ugr.Cells["SpecName"].Text; TxtProduc.Tag = ugr.Cells["Produccode"].Text; TxtProduc.Text = ugr.Cells["Producname"].Text; TxtModel.Tag = ugr.Cells["ModelCode"].Text; TxtModel.Text = ugr.Cells["ModelDesc"].Text; TxtStdName.Tag = ugr.Cells["StdCode"].Text; TxtStdName.Text = ugr.Cells["StdName"].Text; TxtDimater.Value = ugr.Cells["ActDimater"].Text; TxtHeight.Value = ugr.Cells["ActHeight"].Text; TxtStdStyle.Tag = ugr.Cells["StdStyle"].Text; TxtStdStyle.Text = ugr.Cells["StdStyleDesc"].Text; TxtSteelCode.Tag = ugr.Cells["Steelcode"].Text; TxtSteelCode.Text = ugr.Cells["Steelname"].Text; TxtMax.Value = ugr.Cells["ActLenMax"].Text; TxtMin.Value = ugr.Cells["ActLenMin"].Text; TxtNum.Value = ugr.Cells["ActCount"].Text; TxtActWgt.Value = ugr.Cells["ActWeight"].Text; TxtBelongCode.Value = ugr.Cells["BelongCode"].Text; TxtStorage.Value = ugr.Cells["StorageNo"].Text; TxtLocation.Value = ugr.Cells["LocationNo"].Text; TxtReason.Value = ugr.Cells["StocktakingRsnCode"].Text; TxtStoveNo.Value = ugr.Cells["JudgeStoveNo"].Text; TxtPline.Value = ugr.Cells["PlineCode"].Text; TxtBathNo.Value = ugr.Cells["BatchNo"].Text; } private void TxtSourse_ValueChanged(object sender, EventArgs e) { if (this.TxtSourse.Text != "") { if (this.TxtSourse.Value.ToString() == "801302")//产线 { YdmBaseClass.InitComboEditor(TxtPline, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getFactoryDetail", "PLINE_CODE", this.ob, false); } else if (this.TxtSourse.Value.ToString() == "801301")//外购 { YdmBaseClass.InitComboEditor(TxtPline, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getWg", "BASE_CODE", this.ob, false); } else if (this.TxtSourse.Value.ToString() == "801303")//倒库 { YdmBaseClass.InitComboEditor(TxtPline, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getDk", "BASE_CODE", this.ob, false); } else if (this.TxtSourse.Value.ToString() == "801304")//外委 { YdmBaseClass.InitComboEditor(TxtPline, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getWw", "BASE_CODE", this.ob, false); } } } } }