using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Treatment.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment { public partial class frmEntrustBCData : FrmBase { protected string _plineCode = ""; private string[] plineCodes = {}; public frmEntrustBCData() { InitializeComponent(); IsLoadUserView = true; } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": QueryOffline(); break; case "Apply": Apply(); break; case "CancelApply": CancelApply(); break; case "Close": Close(); break; case "Export": Export(); break; } } private void Export() { string title = ""; title += "半成品余材明细"; GridHelper.ulGridToExcel(ultraGrid1, title); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); StartTime.Value = DateTime.Parse(DateTime.Now.AddDays(1 - DateTime.Now.Day).AddDays(-1).ToString("yyyy-MM-dd 21:00")); EndTime.Value = DateTime.Parse( DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd 20:59")); plineCodes = comm.GetPlineCodeWithOther(ValidDataPurviewIds, ob); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); comm.RefreshAndAutoSize(ultraGrid1, true); } private void QueryOffline() { var wf = new WaitingForm2("正在查询,请稍候...."); try { Cursor = Cursors.WaitCursor; var startTime = ""; var endTime = ""; var judgeNo = ""; if (chkTim.Checked) if (DateTime.Parse(StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString())) { MessageUtil.ShowTips("选择时间区间错误,请重新选择!"); return; } else { startTime = StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTime = EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } // else if (!chkJugeHeatNo.Checked) // if (MessageUtil.ShowYesNoAndQuestion("未加时间条件,查询时间可能比较长,请确定是否继续查询?") == DialogResult.No) return; if (chkJugeHeatNo.Checked) judgeNo = txtJugeNo.Text.Trim(); List listSource = EntityHelper.GetData( "com.steering.mes.mcp.common.frmEntrust.doQueryBc", new object[] {startTime, endTime, judgeNo, plineCodes, upStatus0.CheckedItem.DataValue.ToString()}, ob); offlineResultEntityBindingSource.DataSource = listSource; comm.RefreshAndAutoSize(ultraGrid1, new[] {"StdName"}); } catch (Exception ex) { if (ex.Message.ToString2() != "") MessageBox.Show(ex.Message); } finally { wf.Close(); Cursor = Cursors.Default; } } private void Apply() { ultraGrid1.UpdateData(); var list = offlineResultEntityBindingSource.DataSource as List; list = list.Where(p => p.Chk).ToList(); if (!list.Any()) { MessageBox.Show("请选择需要申请的数据"); return; } if (list.Select(p => p.Process).Distinct().Count() != 1) { MessageBox.Show("只能同时申请同工序的数据"); return; } if (list.Select(p => p.PlineCode).Distinct().Count() != 1) { MessageBox.Show("只能同时申请同产线的数据"); return; } if ( list.Any( p => (!string.IsNullOrWhiteSpace(p.Type) && (p.Type != "BC") && (p.Type != "ZC") && (p.Type != "20") && (p.Type != "40") && (p.Type != "60")) || ((p.OfflineNum ?? 0) <= 0))) { MessageBox.Show("已申请的数据无法再次申请"); return; } var FrmEntrustApply = new FrmEntrustApplyNew(ob, FrmEntrustApplyNew.ApplyType.ApplyProject, list, list[0].Process, list[0].PlineCode, null, null, this.CustomInfo.ToString()); if (FrmEntrustApply.ShowDialog() == DialogResult.OK) { // var Type = FrmEntrustApply.Type; // var Note = FrmEntrustApply.Note; FrmEntrustApply.Dispose(); QueryOffline(); } } private void CancelApply() { ultraGrid1.UpdateData(); var list = offlineResultEntityBindingSource.DataSource as List; list = list.Where(p => p.Chk).ToList(); if (!list.Any()) { MessageBox.Show("请选择需要撤销申请的数据"); return; } if (list.Select(p => p.Process).Distinct().Count() != 1) { MessageBox.Show("只能同时撤销申请同工序的数据"); return; } if (list.Any(p => p.Type != "00")) { MessageBox.Show("只能撤销已申请的数据!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否撤销申请委外?") == DialogResult.No) return; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.common.frmEntrust"; ccp.MethodName = "CancelApply"; ccp.ServerParams = new object[] { list.Select(p => p.SubcontractNo).Distinct().ToList(), list[0].Process }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("撤销申请成功!")) QueryOffline(); } } public void SetFillerHeaderCheck(UltraGrid ug, string name) { ug.DisplayLayout.Bands[0].Columns[name].Header.CheckBoxVisibility = HeaderCheckBoxVisibility.Always; ug.DisplayLayout.Bands[0].Columns[name].Header.CheckBoxSynchronization = HeaderCheckBoxSynchronization.None; var _isInCellChange = 0; ug.AfterHeaderCheckStateChanged += (sender, e) => { if (_isInCellChange > 0) return; //更新状态时 不执行全选或全不选 var isChecked = e.Column.GetHeaderCheckedState(e.Rows) == CheckState.Checked; foreach (var filteredInNonGroupByRow in e.Rows.GetFilteredInNonGroupByRows()) filteredInNonGroupByRow.Cells[e.Column].SetValue(isChecked, false); }; ug.CellChange += (sender, e) => { ug.UpdateData(); if (e.Cell.Column.Key == name) { _isInCellChange++; var allTrue = true; var allFalse = true; foreach (var row in ug.Rows.GetFilteredInNonGroupByRows()) if ((bool) row.Cells[name].Value) allFalse = false; else allTrue = false; if (allFalse) ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false); else if (allTrue) ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, true); else ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false); // 当前版本无法直接更新Indeterminate 状态 改成不勾选 _isInCellChange--; } }; ug.AfterRowFilterChanged += (sender, e) => { _isInCellChange++; var allTrue = true; var allFalse = true; foreach (var row in ug.Rows.GetFilteredInNonGroupByRows()) if ((bool) row.Cells[name].Value) allFalse = false; else allTrue = false; if (allFalse) ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false); else if (allTrue) ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, true); else ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false); // 当前版本无法直接更新Indeterminate 状态 改成不勾选 _isInCellChange--; }; } } }