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; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.PlnSaleOrd.BaseMethod; using Core.StlMes.Client.PlnSaleOrd.炼钢计划; using Core.StlMes.Client.PlnSaleOrd.物料Bom.entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.PlnSaleOrd { public partial class FrmMaterialBom : FrmBase { private bool FLAG = false; public FrmMaterialBom() { InitializeComponent(); } private void FrmMaterialBom_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGridOrderInfo.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBom.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBom1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBomA.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBomB.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBomC.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBomD.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBomE.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBomF.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBomK.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGridBomJ.DisplayLayout.Bands[0]); BaseHelper.setOtherColumnReadOnly(ultraGridOrderInfo, new string[] { "CHC" }); BaseHelper.setOtherColumnReadOnly(ultraGridBom, new string[] { "CHC" }); BaseHelper.setOtherColumnReadOnly(ultraGridBom1, new string[] { "CHC" }); BaseHelper.setOtherColumnReadOnly(ultraGridBomA, new string[] { "" }); BaseHelper.setOtherColumnReadOnly(ultraGridBomB, new string[] { "" }); BaseHelper.setOtherColumnReadOnly(ultraGridBomC, new string[] { "" }); BaseHelper.setOtherColumnReadOnly(ultraGridBomD, new string[] { "" }); BaseHelper.setOtherColumnReadOnly(ultraGridBomE, new string[] { "" }); BaseHelper.setOtherColumnReadOnly(ultraGridBomF, new string[] { "" }); BaseHelper.setOtherColumnReadOnly(ultraGridBomK, new string[] { "" }); BaseHelper.setOtherColumnReadOnly(ultraGridBomJ, new string[] { "" }); InitTime(); } void InitTime() { dateBegin.Value = DateTime.Now.AddDays(-60); dateEnd.Value = DateTime.Now.AddDays(1).AddSeconds(-1); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey.Trim()) { case "Query": Query(); break; case "Delete": Delete(); break; case "GenerationQ"://技术评审 Generation("Q"); break; case "GenerationC"://工艺评审 Generation("C"); break; case "Close": this.Close(); break; } } /// ///生成Bom /// private void Generation(string flag) { ultraGridOrderInfo.UpdateData(); UltraGridRow chcRow = ultraGridOrderInfo.ActiveRow; if (chcRow == null) { MessageUtil.ShowWarning("请激活生成Bom的合同行!"); return; } ArrayList list = new ArrayList(); SlmOrderLineEntity bomEntity = (SlmOrderLineEntity)chcRow.ListObject; list.Add(bomEntity.OrdLnPk); if (MessageUtil.ShowYesNoAndQuestion("是否生成合同行(" + bomEntity .OrderNo+ ")的Bom?(" + (flag == "Q" ? "技术评审" : "工艺评审") + ")") == DialogResult.No) { return; } string[] param = SteelHelper.SetData("com.steering.pss.plnsaleord.FrmMaterialBom.greaBom", new object[] { list, flag }, this.ob); if (param == null) { MessageUtil.ShowTips("服务端处理失败!"); } else { MessageUtil.ShowTips(param[1]); if ((bool.Parse(param[0]))) { UltraGridRow ugr = ultraGridOrderInfo.ActiveRow; QueryBom(ugr.Cells["OrdLnPk"].Text); } } } /// /// 删除Bom /// private void Delete() { ultraGridBom.UpdateData(); IQueryable chcRows = null; if (ultraTabControl2.ActiveTab.Key.Equals("1")) { chcRows= ultraGridBom.Rows.AsQueryable().Where(a => a.GetValue("CHC") == "True"); } else { chcRows = ultraGridBom1.Rows.AsQueryable().Where(a => a.GetValue("CHC") == "True"); } if (chcRows == null || chcRows.Count() == 0) { MessageUtil.ShowWarning("请选择要删除的Bom!"); return; } ArrayList list = new ArrayList(); foreach (UltraGridRow ugr in chcRows) { SlmOrdDesignBomEntity bomEntity = (SlmOrdDesignBomEntity)ugr.ListObject; if (bomEntity.Flag.Equals("true")) { MessageUtil.ShowWarning("生产计划使用的BOM,不能删除!"); } list.Add(bomEntity.Bom); } if (MessageUtil.ShowYesNoAndQuestion("是否删除Bom?(此操作不可逆)") == DialogResult.No) { return; } string[] param = SteelHelper.SetData("com.steering.pss.plnsaleord.FrmMaterialBom.deleteBom", new object[] { list }, this.ob); if (param == null) { MessageUtil.ShowTips("服务端处理失败!"); } else { MessageUtil.ShowTips(param[1]); if ((bool.Parse(param[0]))) { UltraGridRow ugr = ultraGridOrderInfo.ActiveRow; if (ultraTabControl2.ActiveTab.Key.Equals("1")) { QueryBom(ugr.Cells["OrdLnPk"].Text); } else { QueryBomByCondition(); } } } } private void Query() { if (ultraTabControl2.ActiveTab.Key.Equals("1")) { QueryOrderInfo(); } else { QueryBomByCondition(); } } private void QueryBomByCondition() { string msc = ""; if (chcMsc.Checked) { msc = txtMsc.Text.Trim(); } string mscPline = ""; if (chcMscPline.Checked) { mscPline = txtMscPline.Text.Trim(); } string gradename = ""; if (chcGrade.Checked) { gradename = txtGrade.Text.Trim(); } string specname = ""; if (chcRollSpec.Checked) { specname = txtRollSpec.Text.Trim(); } string flag = "";//0代表全部查询 1代表只查询使用 2代表只查询不使用 3代表不查询 if (chcStatus1.Checked) { if (chcStatus2.Checked) { flag = "0"; } else { flag = "1"; } } else { if (chcStatus2.Checked) { flag = "2"; } else { flag = "3"; } } List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomByCondition", new object[] { msc, mscPline, gradename, specname,flag }, this.ob); slmOrdDesignBomEntityBindingSource1.DataSource = listSource; if (ultraGridBom1.Rows.Count > 0) { foreach (UltraGridRow ugr in ultraGridBom1.Rows) { if (ugr.Cells["Flag"].Text.Equals("true")) { ugr.CellAppearance.BackColor = Color.MistyRose; } } } } void QueryOrderInfo() { string beginTime = ""; string endTime = ""; if (chcTime.Checked && dateBegin.Value != null && dateEnd.Value != null) { beginTime = DateTime.Parse(dateBegin.Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss"); endTime = DateTime.Parse(dateEnd.Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss"); } string orderno = ""; if (chcOrderno.Checked) { orderno = txtOrderno.Text.Trim(); } if (beginTime.Equals("") && orderno.Equals("")) { MessageUtil.ShowWarning("请至少选择一个查询条件!"); return; } List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryOrderInfo", new object[] { beginTime, endTime, orderno }, this.ob); slmOrderLineEntityBindingSource.DataSource = listSource; } void QueryBom(string ordlnpk) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBom", new object[] { ordlnpk }, this.ob); slmOrdDesignBomEntityBindingSource.DataSource = listSource; if (ultraGridBom.Rows.Count > 0) { foreach (UltraGridRow ugr in ultraGridBom.Rows) { if (ugr.Cells["Flag"].Text.Equals("true")) { ugr.CellAppearance.BackColor = Color.MistyRose; } } } } void QueryBomA(string bom) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomA", new object[] { bom }, this.ob); slmOrdDesignBomAEntityBindingSource.DataSource = listSource; } void QueryBomB(string bom) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomB", new object[] { bom }, this.ob); slmOrdDesignBomBEntityBindingSource.DataSource = listSource; } void QueryBomC(string bom) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomC", new object[] { bom }, this.ob); slmOrdDesignBomCEntityBindingSource.DataSource = listSource; } void QueryBomD(string bom) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomD", new object[] { bom }, this.ob); slmOrdDesignBomDEntityBindingSource.DataSource = listSource; } void QueryBomE(string bom) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomE", new object[] { bom }, this.ob); slmOrdDesignBomEEntityBindingSource.DataSource = listSource; } void QueryBomF(string bom) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomF", new object[] { bom }, this.ob); slmOrdDesignBomFEntityBindingSource.DataSource = listSource; } void QueryBomK(string bom) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomK", new object[] { bom }, this.ob); slmOrdDesignBomKEntityBindingSource.DataSource = listSource; } void QueryBomJ(string bom) { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.FrmMaterialBom.queryBomJ", new object[] { bom }, this.ob); slmOrdDesignBomHEntityBindingSource.DataSource = listSource; } private void chcTime_CheckedChanged(object sender, EventArgs e) { if (chcTime.Checked) { dateBegin.ReadOnly = false; dateEnd.ReadOnly = false; } else { dateBegin.ReadOnly = true; dateEnd.ReadOnly = true; } if (chcOrderno.Checked) { txtOrderno.ReadOnly = false; } else { txtOrderno.ReadOnly = true; } } private void ultraGridOrderInfo_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGridOrderInfo.ActiveRow; if (ugr == null) { slmOrdDesignBomEntityBindingSource.Clear(); slmOrdDesignBomAEntityBindingSource.Clear(); slmOrdDesignBomBEntityBindingSource.Clear(); slmOrdDesignBomCEntityBindingSource.Clear(); slmOrdDesignBomDEntityBindingSource.Clear(); slmOrdDesignBomEEntityBindingSource.Clear(); slmOrdDesignBomFEntityBindingSource.Clear(); slmOrdDesignBomKEntityBindingSource.Clear(); slmOrdDesignBomHEntityBindingSource.Clear(); } else { QueryBom(ugr.Cells["OrdLnPk"].Text); if (ultraGridBom.Rows.Count == 0) { slmOrdDesignBomAEntityBindingSource.Clear(); slmOrdDesignBomBEntityBindingSource.Clear(); slmOrdDesignBomCEntityBindingSource.Clear(); slmOrdDesignBomDEntityBindingSource.Clear(); slmOrdDesignBomEEntityBindingSource.Clear(); slmOrdDesignBomFEntityBindingSource.Clear(); slmOrdDesignBomKEntityBindingSource.Clear(); slmOrdDesignBomHEntityBindingSource.Clear(); } } } private void ultraGridBom_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGridBom.ActiveRow; if (ugr == null) { slmOrdDesignBomAEntityBindingSource.Clear(); slmOrdDesignBomBEntityBindingSource.Clear(); slmOrdDesignBomCEntityBindingSource.Clear(); slmOrdDesignBomDEntityBindingSource.Clear(); slmOrdDesignBomEEntityBindingSource.Clear(); slmOrdDesignBomFEntityBindingSource.Clear(); slmOrdDesignBomKEntityBindingSource.Clear(); slmOrdDesignBomHEntityBindingSource.Clear(); } else { string bom = ugr.Cells["Bom"].Text.Trim(); QueryBomA(bom); QueryBomB(bom); QueryBomC(bom); QueryBomD(bom); QueryBomE(bom); QueryBomF(bom); QueryBomK(bom); QueryBomJ(bom); } } private void ultraGridBom_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGridBom.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHC"].Value = true; } } } private void AddColumn() { } private void chcMsc_CheckedChanged(object sender, EventArgs e) { if (chcMsc.Checked) { txtMsc.ReadOnly = false; } else { txtMsc.ReadOnly = true; } if (chcMscPline.Checked) { txtMscPline.ReadOnly = false; } else { txtMscPline.ReadOnly = true; } if (chcGrade.Checked) { txtGrade.ReadOnly = false; } else { txtGrade.ReadOnly = true; } if (chcRollSpec.Checked) { txtRollSpec.ReadOnly = false; } else { txtRollSpec.ReadOnly = true; } } private void ultraGridBom1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGridBom1.ActiveRow; if (ugr == null) { slmOrdDesignBomAEntityBindingSource.Clear(); slmOrdDesignBomBEntityBindingSource.Clear(); slmOrdDesignBomCEntityBindingSource.Clear(); slmOrdDesignBomDEntityBindingSource.Clear(); slmOrdDesignBomEEntityBindingSource.Clear(); slmOrdDesignBomFEntityBindingSource.Clear(); slmOrdDesignBomKEntityBindingSource.Clear(); slmOrdDesignBomHEntityBindingSource.Clear(); } else { string bom = ugr.Cells["Bom"].Text.Trim(); QueryBomA(bom); QueryBomB(bom); QueryBomC(bom); QueryBomD(bom); QueryBomE(bom); QueryBomF(bom); QueryBomK(bom); QueryBomJ(bom); } } private void ultraTabControl2_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (!FLAG) { FLAG = true; return; } if (ultraTabControl2.ActiveTab.Key.Equals("1")) { if (toolMenu.Toolbars[0].Tools.Exists("GenerationQ")) { toolMenu.Toolbars[0].Tools["GenerationQ"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("GenerationC")) { toolMenu.Toolbars[0].Tools["GenerationC"].InstanceProps.Visible = DefaultableBoolean.True; } } else { if (toolMenu.Toolbars[0].Tools.Exists("GenerationQ")) { toolMenu.Toolbars[0].Tools["GenerationQ"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("GenerationC")) { toolMenu.Toolbars[0].Tools["GenerationC"].InstanceProps.Visible = DefaultableBoolean.False; } } } } }