| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- 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 frmEntrustOfflineData : FrmBase
- {
- protected string _plineCode = "";
- private string[] plineCodes = {};
- public frmEntrustOfflineData()
- {
- 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<OfflineResultEntity>(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 = "";
- var flagStove = "";
- 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();
- if (chkFlagStove.Checked)
- flagStove = flagStoveNo.Text.Trim();
- List<OfflineResultEntity> listSource = EntityHelper.GetData<OfflineResultEntity>(
- "com.steering.mes.mcp.common.frmEntrust.doQueryOffline",
- new object[] {startTime, endTime, judgeNo, plineCodes, upStatus0.CheckedItem.DataValue.ToString(), flagStove }, ob);
- if (chkOrderNo.Checked)
- {
- offlineResultEntityBindingSource.DataSource = listSource.Where(p=>p.OrderNo.ToUpper().Contains(txtOrderNo.Text.ToUpper())).ToList();
- }
- else {
- 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<OfflineResultEntity>;
- 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<OfflineResultEntity>;
- 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--;
- };
- }
-
- }
- }
|