using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.SaleOrder.BLL; using Core.StlMes.Client.SaleOrder.Dialog; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; 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; namespace Core.StlMes.Client.SaleOrder.ReviewForm { public partial class FrmChoiceCraftFileLv2 : FrmBase { private CraftOrdDesignBLL _craftOrdDesignBLL; public FrmChoiceCraftFileLv2() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); this.IsLoadUserView = true; } private void FrmChoiceCraftFileLv2_Load(object sender, EventArgs e) { _craftOrdDesignBLL = new CraftOrdDesignBLL(ob); lblCmbPlanStatus.ComboBox.SelectedIndex = 0; ultraGrid1.DisplayLayout.Bands[0].Columns["CraftFileLv2" + CustomInfo + "Desc"].Hidden = false; if (CustomInfo != "D") { GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBZg", "CraftFileLv2DDesc"); } if (CustomInfo != "E") { GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBDbk", "CraftFileLv2EDesc"); } if (CustomInfo != "F") { GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBRcl", "CraftFileLv2FDesc"); } if (CustomInfo != "G") { GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBJgx", "CraftFileLv2GDesc"); } if (CustomInfo != "H") { GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBProp", "CraftFileLv2HDesc"); } } public override void ToolBar_Click(object sender, string ToolbarKey) { base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "Query": Query(); break; case "Save": Save(); break; case "Close": this.Close(); break; } } private void Query() { WaitingForm2 wf = new WaitingForm2("正在查询,请稍候...."); try { this.Cursor = Cursors.WaitCursor; string craftNo = labelTextBox1.Checked ? labelTextBox1.Text.Trim() : ""; string orderNo = labelTextBox2.Checked ? labelTextBox2.Text.Trim() : ""; string planStatus = lblCmbPlanStatus.Checked ? lblCmbPlanStatus.SelecteValue.ToString2() : ""; string maintenanceStatus = labelCheckBox1.Checked ? "1" : ""; ultraGrid1.BeginUpdate(); craftOrdDesignEntityBindingSource.DataSource = _craftOrdDesignBLL.QueryCraftLv2( craftNo, orderNo, planStatus, maintenanceStatus, CustomInfo); foreach (var row in ultraGrid1.Rows) { Color color = row.Cells["CraftNo"].Appearance.BackColor; if (!row.GetValue("ProcessCodes").Contains("D")) { row.Cells["CraftFileLv2DDesc"].Appearance.BackColor = color; row.Cells["CraftFileLv2DDesc"].Value = "无"; } if (!row.GetValue("ProcessCodes").Contains("E")) { row.Cells["CraftFileLv2EDesc"].Appearance.BackColor = color; row.Cells["CraftFileLv2EDesc"].Value = "无"; } if (!row.GetValue("ProcessCodes").Contains("F")) { row.Cells["CraftFileLv2FDesc"].Appearance.BackColor = color; row.Cells["CraftFileLv2FDesc"].Value = "无"; } if (!row.GetValue("ProcessCodes").Contains("G")) { row.Cells["CraftFileLv2GDesc"].Appearance.BackColor = color; row.Cells["CraftFileLv2GDesc"].Value = "无"; } if (!row.GetValue("ProcessCodes").Contains("H")) { row.Cells["CraftFileLv2HDesc"].Appearance.BackColor = color; row.Cells["CraftFileLv2HDesc"].Value = "无"; } } ultraGrid1.EndUpdate(); ultraGrid1.UpdateData(); } finally { wf.Close(); this.Cursor = Cursors.Default; } } private void Relocat(string ordLnPk, string craftSeq) { Query(); var row = ultraGrid1.Rows.Where(a => a.GetValue("OrdLnPk") == ordLnPk && a.GetValue("CraftSeq") == craftSeq).FirstOrDefault(); if (row != null) { row.Activate(); } } private void Save() { ultraGrid1.UpdateData(); var rows = ultraGrid1.Rows.Where(a=>a.GetValue("Chk") == "True"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择记录!"); return; } List craftOrdDesignList = new List(); string ordLnPk = ""; string craftSeq = ""; foreach (var row in rows) { CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity(row.ListObject); craftOrdDesign.UpdateName = UserInfo.GetUserName(); craftOrdDesignList.Add(craftOrdDesign); ordLnPk = craftOrdDesign.OrdLnPk; craftSeq = craftOrdDesign.CraftSeq.ToString(); } if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No) { return; } _craftOrdDesignBLL.SaveCraftLv2(craftOrdDesignList); MessageUtil.ShowTips("保存成功!"); Relocat(ordLnPk, craftSeq); } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { CraftOrdDesignEntity craftOrdDesign = _craftOrdDesignBLL.QueryByPk(new CraftOrdDesignEntity() { OrdLnPk = ultraGrid1.ActiveRow.GetValue("OrdLnPk"), CraftSeq = decimal.Parse(ultraGrid1.ActiveRow.GetValue("CraftSeq")) }); //if (craftOrdDesign.Validflag != "1") //{ // MessageUtil.ShowWarning("只有生效状态才能选择二级工艺文件!"); // return; //} if (e.Button.Key.Equals("select")) { string msc = ultraGrid1.ActiveRow.GetValue("Msc"); switch (ultraGrid1.ActiveCell.Column.Key) { case "CraftFileLv2DDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "D", "轧制", craftOrdDesign.CraftNo, msc); break; case "CraftFileLv2EDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "E", "镦拔扩", craftOrdDesign.CraftNo, msc); break; case "CraftFileLv2FDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "F", "热处理", craftOrdDesign.CraftNo, msc); break; case "CraftFileLv2GDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "G", "加工", craftOrdDesign.CraftNo, msc); break; case "CraftFileLv2HDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "H", "接箍加工", craftOrdDesign.CraftNo, msc); break; } } if (e.Button.Key.Equals("down")) { var strurl = ""; string ordNo = craftOrdDesign.CraftNo; strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepHttGjgProcess.cpt&orderManageNo={0}&desginKey={1}"; strurl = String.Format(strurl, ordNo.Substring(0, ordNo.Length - 4), craftOrdDesign.DesginKey); var fre = new FrmRepExcel(ob, strurl); fre.AutoSize = true; fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fre.WindowState = FormWindowState.Maximized; fre.Show(); } } private void ChoiceCraftFileLv2(string designKey, string processCode, string processDesc, string craftNo, string msc) { var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True"); //if (rows.Count() == 0) //{ // MessageUtil.ShowWarning("请至少勾选一条记录!"); // return; //} int cnt = _craftOrdDesignBLL.GetCntByDesignKeyProcess(designKey, processCode); if (cnt == 0) { MessageUtil.ShowWarning("一级工艺文件不包含" + processDesc + "工序!"); return; } string craftFileLv2Pks = ultraGrid1.GetActiveRowValue("CraftFileLv2" + processCode); bool isAddAsk = ultraGrid1.GetActiveRowValue("DescriptionDiff") == "" ? false : true; string modelCode = ultraGrid1.GetActiveRowValue("ModelCode"); string modelDesc = ultraGrid1.GetActiveRowValue("ModelDesc"); string dimater = ultraGrid1.GetActiveRowValue("Dimater"); string height = ultraGrid1.GetActiveRowValue("Height"); FrmCraftFileLv2 frmCraftFileLv2 = new FrmCraftFileLv2(designKey, processCode, craftFileLv2Pks, craftNo, "0", ob, msc, isAddAsk, modelCode, modelDesc, dimater, height); if (frmCraftFileLv2.ShowDialog() == DialogResult.OK) { foreach (var row in rows) { row.SetValue("CraftFileLv2" + processCode, frmCraftFileLv2.CraftFileLv2Pks); row.SetValue("CraftFileLv2" + processCode + "Desc", frmCraftFileLv2.CraftFileLv2Nos); } } } private PopupTextBox popupTextBox; private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { switch (ultraGrid1.ActiveCell.Column.Key) { case "CraftPath": var row = ultraGrid1.ActiveRow; CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; string filePathOld = row.GetValue("CraftPathOld"); string filePathNew = "Qcm/Craft/" + craftOrdDesign.OrdLnPk + "/" + craftOrdDesign.CraftSeq + "/"; if (e.Button.Key.ToLower().Equals("select")) { dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathOld); down.DeleteButton.Visible = false; down.ShowDialog(); } break; case "OrderSpecialDesc": case "DescriptionDiff": case "DescriptionAll": case "ChgeVal": case "Memo": case "CraftChangeMemo": popupTextBox = new PopupTextBox(ultraGrid1.ActiveCell.Value.ToString()); popupTextBox.TxtInfo.ReadOnly = true; popupTextBox.UltraPanel1.Visible = false; popupTextBox.Show(); break; } } private void lblCmbPlanStatus_CheckBox_CheckedChanged(object sender, EventArgs e) { } private void ultraGrid1_MouseUp(object sender, MouseEventArgs e) { //foreach (var row in ultraGrid1.Rows) //{ // if (row.Selected) // { // row.Cells["CHK"].Value = true; // } //} ultraGrid1.UpdateData(); } private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if (e.Cell.Column.Key == "Chk") { UltraGridRow chkRow = e.Cell.Row; foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.Cells["Chk"].Value.ToString() == "True" && row != chkRow) { row.Cells["Chk"].Value = false; row.Update(); } } } ultraGrid1.UpdateData(); } } }