using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public partial class CtrlMscJg : UserControl { private DtBaseQcm _dtBaseQcm; public DtBaseQcm DtBaseQcm { get { return _dtBaseQcm; } set { _dtBaseQcm = value; } } private FrmProPSCMSC2 _frmProPscMsc2; public FrmProPSCMSC2 FrmProPscMsc2 { get { return _frmProPscMsc2; } set { _frmProPscMsc2 = value; } } public UltraGrid GridJG { get { return ultraGrid1; } set { ultraGrid1 = value; } } public UltraGrid GridBL { get { return ultraGrid2; } set { ultraGrid2 = value; } } public DataTable DtJG { get { return dataTable1; } set { dataTable1 = value; } } public DataTable DtTorque { get { return dataTable3; } set { dataTable3 = value; } } public DataTable DtBL { get { return dataTable2; } set { dataTable2 = value; } } private UltraComboEditor[] _cmbs = new UltraComboEditor[5]; public CtrlMscJg() { InitializeComponent(); } public void MscJgLoad() { _dtBaseQcm = new DtMscJg(this); GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], ""); } public void Query() { dataTable2.Clear(); ((DtMscJg)_dtBaseQcm).Flag = _frmProPscMsc2.IsCraft == null ? "0" : "1";//0不用合同规格过滤, 1用合同规格过滤。 _dtBaseQcm.DoQuery("DefaultQuery"); } public void LoadData() { for (int i = 0; i < _cmbs.Length; i++) { _cmbs[i] = new UltraComboEditor(); _cmbs[i].DropDownListWidth = -1; _cmbs[i].Visible = false; this.Controls.Add(_cmbs[i]); } ClsBaseInfo.FillComBaseInfo(_cmbs[0], "408401", _frmProPscMsc2.ob, false); ultraGrid1.DisplayLayout.Bands[0].Columns["DEMAND_DETECTION"].EditorComponent = _cmbs[0]; ultraGrid1.DisplayLayout.Bands[0].Columns["DEMAND_DETECTION"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ClsBaseInfo.FillComBaseInfo(_cmbs[1], "408402", _frmProPscMsc2.ob, true); ultraGrid1.DisplayLayout.Bands[0].Columns["DEMAND_BONDERIZING"].EditorComponent = _cmbs[1]; ultraGrid1.DisplayLayout.Bands[0].Columns["DEMAND_BONDERIZING"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ClsBaseInfo.FillComBaseInfo(_cmbs[2], "408403", _frmProPscMsc2.ob, false); ultraGrid1.DisplayLayout.Bands[0].Columns["DEMAND_COPPER"].EditorComponent = _cmbs[2]; ultraGrid1.DisplayLayout.Bands[0].Columns["DEMAND_COPPER"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ClsBaseInfo.FillComBaseInfo(_cmbs[3], "408404", _frmProPscMsc2.ob, false); ultraGrid1.DisplayLayout.Bands[0].Columns["DEMAND_BLAST"].EditorComponent = _cmbs[3]; ultraGrid1.DisplayLayout.Bands[0].Columns["DEMAND_BLAST"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ClsBaseInfo.FillComBaseInfo(_cmbs[4], "4093", _frmProPscMsc2.ob, false); ultraGrid1.DisplayLayout.Bands[0].Columns["TORQUE_UNIT"].EditorComponent = _cmbs[4]; ultraGrid1.DisplayLayout.Bands[0].Columns["TORQUE_UNIT"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ClsBaseInfo.FillComBaseInfo(_cmbs[4], "4093", _frmProPscMsc2.ob, false); ultraGrid1.DisplayLayout.Bands[1].Columns["TORQUE_UNIT"].EditorComponent = _cmbs[4]; ultraGrid1.DisplayLayout.Bands[1].Columns["TORQUE_UNIT"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; } public void Save() { _dtBaseQcm.DoAction(ActionType.Save); //((DtMscJg)_dtBaseQcm).Save(); } public void Delete() { ((DtMscJg)_dtBaseQcm).Delete(); } public void SaveTorque() { ((DtMscJg)_dtBaseQcm).SaveTorque(); } public void DeleteTorque() { ((DtMscJg)_dtBaseQcm).DeleteTorque(); } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { _dtBaseQcm.DoQuery("QueryBL"); ((DtMscJg)_dtBaseQcm).relocatKey = ultraGrid1.ActiveRow.GetValue("KEY_JG"); } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.HasParent()) return; _frmProPscMsc2.SetColor(e); e.Row.Cells["BL_BTN"].ButtonAppearance.BackColor = Color.FromArgb(99, 184, 255); } private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e) { _frmProPscMsc2.SetColor(e); e.Row.Cells["REVIEW"].ButtonAppearance.BackColor = Color.FromArgb(99, 184, 255); } private void ultraGrid2_ClickCellButton(object sender, CellEventArgs e) { if (_frmProPscMsc2.IsCraft == null) { MessageUtil.ShowWarning("如需备料评审,请到技术评审或工艺评审界面中进行评审!"); return; } else { if (_frmProPscMsc2.IsCraft == true) { string blCode = e.Cell.Row.GetValue("PSC_BL"); PopupCraftReviewTechnology popup = new PopupCraftReviewTechnology(blCode, _frmProPscMsc2.DataPurviewIds, _frmProPscMsc2.ob); popup.FormClosed += new FormClosedEventHandler((a, b) => { this.BeginInvoke(new EventHandler((c, d) => { _dtBaseQcm.DoQuery("QueryBL"); }), new object[] { null, null }); }); popup.Show(); } else { string blCode = e.Cell.Row.GetValue("PSC_BL"); PopupOrderReviewTechnology popup = new PopupOrderReviewTechnology(blCode, _frmProPscMsc2.ob); popup.FormClosed += new FormClosedEventHandler((a, b) => { this.BeginInvoke(new EventHandler((c, d) => { _dtBaseQcm.DoQuery("QueryBL"); }), new object[] { null, null }); }); popup.Show(); } } } private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e) { string[] repSteelCodes = e.Cell.Row.Cells["REP_STEELCODE"].Value.ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string[] steels = new string[repSteelCodes.Length + 1]; for (int i = 0; i < repSteelCodes.Length; i++) { steels[i] = repSteelCodes[i]; } // 有替代钢级则备料只能选择替代钢级,不能选择接箍钢级。 if (repSteelCodes.Length == 0) { steels[steels.Length - 1] = e.Cell.Row.Cells["STEELCODE_JG"].Value.ToString(); } else { steels[steels.Length - 1] = ""; } ShowBLForm(steels, e.Cell.Row); Query(); } private void ShowBLForm(string[] steels, UltraGridRow row) { UltraGridRow mscRow = _frmProPscMsc2.ControlMsc.GridMsc.ActiveRow; UltraGridRow pscRow = _frmProPscMsc2.ultraGrid1.ActiveRow; string jgCode = row.Cells["CODE_JG"].Value.ToString(); string custAlphaNo = row.Cells["CUST_ALPHA_NO"].Value.ToString(); string orderSpecialDesc = row.Cells["ORDER_SPECIAL_DESC"].Value.ToString(); string alphaCode = row.Cells["ALPHA_CODE"].Value.ToString(); string dimater = row.GetValue("MIN_D"); string height = row.GetValue("MIN_H"); BLCodeManageParms blCodeParms = new BLCodeManageParms(); blCodeParms.Ob = _frmProPscMsc2.ob; blCodeParms.Msc = mscRow.GetValue("MSC"); blCodeParms.Msc_desc = mscRow.GetValue("OLD_MSC_DESC"); blCodeParms.Alpha = mscRow.GetValue("USE_CODE"); blCodeParms.StdName = pscRow.GetValue("STD_NAME"); blCodeParms.StdCode = pscRow.GetValue("STD_CODE"); ; blCodeParms.StdType = pscRow.GetValue("STD_STYLE_DESC"); blCodeParms.Steels = steels; blCodeParms.SaveType = "2"; blCodeParms.Dimater = dimater; blCodeParms.Height = height; blCodeParms.JgCode = row.Cells["CODE_JG"].Value.ToString(); blCodeParms.CustAlphaCode = custAlphaNo; blCodeParms.OrderSpecialDesc = orderSpecialDesc; blCodeParms.AlphaCode = alphaCode; blCodeParms.KeyJg = row.Cells["KEY_JG"].Value.ToString(); blCodeParms.SpecCode = _frmProPscMsc2.SpecCode; blCodeParms.OrdLnPk = _frmProPscMsc2.OrdLnPk; BLCodeManage frmBL; try { this.Cursor = Cursors.WaitCursor; frmBL = new BLCodeManage(blCodeParms); frmBL.Size = new Size(SystemInformation.WorkingArea.Width, SystemInformation.WorkingArea.Height); } finally { this.Cursor = Cursors.Default; } frmBL.ShowDialog(); } PopupTextBox popupTextBox; private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { if (e.Tool.Key == "作废") { ((DtMscJg)_dtBaseQcm).DeleteJgRBl(); } else if (e.Tool.Key == "查看技术要求") { DataTable dt = GetOrdLnState(_frmProPscMsc2.OrdLnPk); string orderSpecialDesc = dt.Rows[0]["ORDER_SPECIAL_DESC"].ToString(); popupTextBox = new PopupTextBox(orderSpecialDesc, orderSpecialDesc.Length); popupTextBox.TxtInfo.ReadOnly = true; popupTextBox.UltraPanel1.Visible = false; popupTextBox.Show(); } } private DataTable GetOrdLnState(string ordLnPk) { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnologyList.getOrdLnState", new object[] { ordLnPk }, _frmProPscMsc2.ob); return dt; } private void craftImg_EditorButtonClick(object sender, EditorButtonEventArgs e) { string filePath = ultraGrid2.GetActiveRowValue("CRAFT_PATH"); FormFileDown down = new FormFileDown(_frmProPscMsc2.ob, filePath); down.DeleteButton.Visible = false; down.ShowDialog(); } private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { } private void ultraTextEditor16_EditorButtonClick(object sender, EditorButtonEventArgs e) { //Qcm/Jg/接箍码/文件名 var row = ultraGrid1.ActiveRow; string codejg = row.GetValue("CODE_JG"); string keyJg = row.GetValue("KEY_JG"); string path = "Qcm/Jg/" + keyJg + "/"; if (e.Button.Key == "Show") { if (ultraGrid1.ActiveCell.Column.Key == "FILE_NAME") { string jgPath = "Qcm/Jg/" + row.GetValue("CODE_JG") + "/"; FormFileDown down; if (FileHelper.Download(path).Count == 0) { down = new FormFileDown(_frmProPscMsc2.ob, jgPath); } else { down = new FormFileDown(_frmProPscMsc2.ob, path); } down.ShowDialog(); if (down.CtrlFileDown1.List.Count == 0) { row.Cells["FILE_NAME"].Value = ""; row.Cells["FILE_PATH"].Value = ""; ((DtMscJg)_dtBaseQcm).UpdateJgPath(); } } } else if (e.Button.Key == "Upload") { var serverFileList = FileHelper.Download(row.GetValue("FILE_PATH")); List list = new List(); FileBean bean = new FileBean(); OpenFileDialog file = new OpenFileDialog(); file.Multiselect = true; file.Title = "选择需要上传的图片"; file.Filter = "图片文件(*.jpg);(*.gif);(*.png);(*.bmp)|*.jpg;*.gif;*.png;*.bmp"; DialogResult drStat; drStat = file.ShowDialog(); if (drStat == DialogResult.OK) { foreach (string fileName in file.FileNames) { string name = System.IO.Path.GetFileName(fileName); if (name.Contains(" ")) { MessageUtil.ShowWarning("上传的图片名称不能包含空格!"); return; } if (name.Contains("°")) { MessageUtil.ShowWarning("上传的图片名称不能包含特殊符号【°】"); return; } bean = new FileBean(); bean.setFileName(name); bean.setPathName(path); bean.setFile(FileHelper.FileToArray(fileName)); list.Add(bean); } bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list); if (isSuccess) { string fileNames = ""; List fileBeans = FileHelper.Download(path); foreach (var fileBean in fileBeans) { if (fileNames == "") { fileNames = path + fileBean.getFileName(); } else { fileNames += "#" + path + fileBean.getFileName(); } } row.Cells["FILE_PATH"].Value = fileNames; row.Update(); ((DtMscJg)_dtBaseQcm).UpdateJgPath(); MessageUtil.ShowTips("上传成功!"); Query(); var redirectRow = ultraGrid1.Rows.Where( a => a.GetValue("KEY_JG") == keyJg).FirstOrDefault(); if (redirectRow != null) { redirectRow.Activate(); } } else { MessageUtil.ShowTips("上传失败,请重试!"); } } } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { e.Cell.Row.Update(); var row = e.Cell.Row.HasParent() ? e.Cell.Row : e.Cell.Row.ParentRow; var pRow = e.Cell.Row.HasParent() ? e.Cell.Row.ParentRow : e.Cell.Row; if (row.GetValue("TORQUE_BEST") != "") { decimal torqueBest = decimal.Parse(row.GetValue("TORQUE_BEST")); decimal torqueMin = Math.Round(0.9m * torqueBest / 10m, 0) * 10m; decimal torqueMax = Math.Round(1.1m * torqueBest / 10m, 0) * 10m; decimal pointMax = Math.Round(0.7m * torqueBest / 10m, 0) * 10m; decimal pointMin = 0; if (pRow.GetValue("MIN_D_JG") == "") { pointMin = Math.Round(0.05m * torqueBest / 10m, 0) * 10m; } else { decimal minD = decimal.Parse(pRow.GetValue("MIN_D_JG")); if (minD <= 114.3m) { pointMin = Math.Round(0.05m * torqueBest / 10m, 0) * 10m; } else { pointMin = Math.Round(0.1m * torqueBest / 10m, 0) * 10m; } } row.SetValue("TORQUE_MIN", torqueMin.ToString()); row.SetValue("TORQUE_MAX", torqueMax.ToString()); row.SetValue("POINT_MIN", pointMin.ToString()); row.SetValue("POINT_MAX", pointMax.ToString()); } else { row.SetValue("TORQUE_MIN", ""); row.SetValue("TORQUE_MAX", ""); row.SetValue("POINT_MIN", ""); row.SetValue("POINT_MAX", ""); } } private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e) { string key = ultraGrid1.ActiveCell.Column.Key; if (key == "MEMO" || key == "JG_MEMO") { PopupTextBox popupTextBox = new PopupTextBox(ultraGrid1.ActiveCell.Value.ToString(), 500); if (popupTextBox.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveCell.Value = popupTextBox.TextInfo; } } else if (key == "M_STD_NO" || key == "W_STD_NO" || key == "M_PRINT_NO" || key == "W_PRINT_NO") { PopupTextBox popupTextBox = new PopupTextBox(ultraGrid1.ActiveCell.Value.ToString(), 200); if (popupTextBox.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveCell.Value = popupTextBox.TextInfo; } } } private void UltraGrid1_AfterRowInsert(object sender, RowEventArgs e) { if (e.Row.HasParent()) { e.Row.SetValue("KEY_JG", e.Row.ParentRow.GetValue("KEY_JG")); } } } }