| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using CCore.StlMes.Client.Mcp.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Mcp.Control.Entity;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle;
- using ColumnStyle = Infragistics.Win.UltraWinGrid.ColumnStyle;
- using Core.Mes.Client.Comm.Control;
- using System.Collections;
- namespace Core.StlMes.Client.Mcp.Control.Common
- {
- public delegate void MchWasteChange();
- public partial class PortMchBatchControl : UserControl
- {
- public PortMchBatchControl()
- {
- InitializeComponent();
- EntityHelper.ShowGridCaption<PortMchBatchSampleResultEntity>(ultraGrid3.DisplayLayout.Bands[0]);
-
- commHelper.RefreshAndAutoSize(ultraGrid3);
- ShowTop = true;
- ShowSeq = false;
- }
- public MchWasteChange MchWasteChange = null;
- public void DisableFiltering()
- {
- //ultraGrid3.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- ultraGrid3.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
-
- }
- public bool ShowTop
- {
- get { return ultraPanel9.Visible; }
- set { ultraPanel9.Visible = value; }
- }
- private bool _showSeq = false;
- public bool ShowSeq
- {
- get { return _showSeq; }
- set { _showSeq = value;
- ultraPanel3.Visible = _showSeq;
- ultraGrid3.DisplayLayout.Bands[0].Columns["BarCode"].CellActivation= _showSeq? Activation.AllowEdit : Activation.ActivateOnly;
- }
- }
- /// <summary>
- ///
- /// </summary>
- public bool GetAllRtdPort { get; set; }
- public bool CanFail
- {
- get
- {
- return !ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].Hidden;
- }
- set
- {
- ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].Hidden = !value;
- }
- }
- public void SetDeleteReason(string failCode)
- {
- var dt3 = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getBaseInfo",
- new object[] { failCode }, ob);
- reason.DataSource = dt3;
- reason.DisplayMember = "BASENAME";
- reason.ValueMember = "BASECODE";
- YdmBaseClass.SetComboItemHeight(reason);
- ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].EditorComponent = reason;
- ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].ButtonDisplayStyle = ButtonDisplayStyle.Always;
- ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].Style = ColumnStyle.DropDownList;
- ultraGrid3.DisplayLayout.Bands[0].Columns["MatStatus"].ButtonDisplayStyle = ButtonDisplayStyle.Always;
- }
- public bool ShowDelete { get; set; }
- public OpeBase ob { get; set; }
- private string heatPlanNo = "";
- private string batchNo = "";
- private string gx = "";
- public string userName {
- get;
- set; }
- public string Group { get; set; }
- public string Shift { get; set; }
- public List<PortMchBatchSampleResultEntity> Data
- {
- get
- {
- return portMchBatchSampleResultEntityBindingSource.DataSource as List<PortMchBatchSampleResultEntity>;
- }
- }
- private void Query()
- {
- Query(heatPlanNo, batchNo,gx);
- }
- public void Query(string HeatPlanNo, string BatchNo,string Gx,bool isD = false)
- {
-
- heatPlanNo = HeatPlanNo;
- batchNo = BatchNo;
- gx = Gx;
- List<PortMchBatchSampleResultEntity> list;
- if (GetAllRtdPort && !isD)
- {
- list = EntityHelper.GetData<PortMchBatchSampleResultEntity>(
- "com.steering.mes.mcp.common.PlanService.getQueryJGPortVrphotAll",
- new object[] {HeatPlanNo, BatchNo, ShowSeq}, ob);
- }
- else
- {
- if (HeatPlanNo.StartsWith("D")|| HeatPlanNo.StartsWith("E"))//镦拔扩查询
- {
- list = EntityHelper.GetData<PortMchBatchSampleResultEntity>(
- "com.steering.mes.mcp.common.PlanService.getQueryDBPortVrphot",
- new object[] { HeatPlanNo, BatchNo, ShowSeq }, ob);
- }
- else
- {
- list = EntityHelper.GetData<PortMchBatchSampleResultEntity>(
- "com.steering.mes.mcp.common.PlanService.getQueryJGPortVrphot",
- new object[] { HeatPlanNo, BatchNo, ShowSeq }, ob);
- }
- }
- portMchBatchSampleResultEntityBindingSource.DataSource = list;
- string info = String.Format("作业 {0} 支 ", list.Count );
- var Instore =
- list.Where(p => p.InstoreFlag == "1" || p.InstoreFlag == "已入库").ToList();
- if (Instore.Any())
- {
- info = info + String.Format(" 已入库 {0} 支 ", Instore.Count);
- }
- var Fail =
- list.Where(p => p.MatStatus == "10" || p.MatStatus == "40" || p.MatStatus == "剔除" || p.MatStatus == "委外废品").ToList();
- if (Fail.Any())
- {
- info = info + String.Format(" 废品 {0} 支 ", Fail.Count);
- }
- var Offline =
- list.Where(p => p.MatStatus == "20" || p.MatStatus == "待处理").ToList();
- if (Offline.Any())
- {
- info = info + String.Format(" 离线 {0} 支 ", Offline.Count);
- }
- var Other =
- list.Where(p => p.MatStatus == "30" || p.MatStatus == "另组炉").ToList();
- if (Other.Any())
- {
- info = info + String.Format(" 另组炉 {0} 支 ", Other.Count);
- }
- ultraGrid3.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = info;
- commHelper.RefreshAndAutoSize(ultraGrid3);
- ShowMsg();
- }
- private void officeNum_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- FrmScrapMchNum FrmScrapMchNum = new FrmScrapMchNum(ob,heatPlanNo,batchNo,gx,userName,Shift,Group);
- FrmScrapMchNum.ShowDialog();
- if (FrmScrapMchNum.DialogResult == DialogResult.OK)
- Query();
- }
- private void ultraGrid3_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
- {
- PortMchBatchSampleResultEntity row = e.Row.ListObject as PortMchBatchSampleResultEntity;
- if (e.Row.Cells["MatStatus"].Text.Equals("剔除") || e.Row.Cells["MatStatus"].Text.Equals("委外废品"))
- e.Row.Cells["MatStatus"].Appearance.ForeColor = Color.Red;
- if (ShowSeq && row != null && row.TrFlag =="1")
- {
- e.Row.Appearance.BackColor = Color.LightGreen;
- }
- if (CanFail)
- {
- if (e.Row.Cells["MatStatus"].Text.Equals("合格") )
- {
- e.Row.Cells["MatStatus"].EditorComponent = utDelete;
- e.Row.Cells["MatStatus"].IgnoreRowColActivation = true;
- ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].CellActivation = Activation.AllowEdit;
- }
- if (e.Row.Cells["MatStatus"].Text.Equals("剔除") && gx ==(e.Row.Cells["OpProcessCode"].Value.ToString2()))
- {
- e.Row.Cells["MatStatus"].EditorComponent = utCancelDelete;
- e.Row.Cells["MatStatus"].IgnoreRowColActivation = true;
- }
- }
- }
- private void btnUp_Click(object sender, EventArgs e)
- {
- if (ultraGrid3.Selected.Rows.Count <= 0)
- {
- tipMessage.Show("请选择需要往上移动的数据", btnUp );
- return;
- }
- List<UltraGridRow> rows = ultraGrid3.Selected.Rows.OfType<UltraGridRow>()
- .OrderBy(p => p.Index).ToList();
- int Index = rows[0].Index;
- if (rows[0].Index <= Data.Count(p => p.TrFlag == "1"))
- {
- tipMessage.Show("无法再向上移动", btnUp);
- return;
- }
- List<PortMchBatchSampleResultEntity> data = rows
- .Select(p => p.ListObject as PortMchBatchSampleResultEntity).ToList();
- if (data.Any(p => p.TrFlag == "1"))
- {
- tipMessage.Show("无法移动已匹配的管号", btnUp);
- return;
- }
- if (data.Any(p => p.MatStatus == "10" || p.MatStatus == "40" || p.MatStatus == "剔除" || p.MatStatus == "委外废品"))
- {
- tipMessage.Show("无法移动标废的管号", btnUp);
- return;
- }
- for (int i = 0; i < rows.Count; i++)
- {
- ultraGrid3.Rows.Move(rows[i], Index-1 + i);
- }
- }
- private void btnDown_Click(object sender, EventArgs e)
- {
- if (ultraGrid3.Selected.Rows.Count <= 0)
- {
- tipMessage.Show("请选择需要往上移动的数据", btnDown);
- return;
- }
- List<UltraGridRow> rows = ultraGrid3.Selected.Rows.OfType<UltraGridRow>()
- .OrderBy(p => p.Index).ToList();
- int Index = rows[rows.Count-1].Index;
- if (rows[0].Index >= Data.Count-1)
- {
- tipMessage.Show("无法再向下移动", btnDown);
- return;
- }
- List<PortMchBatchSampleResultEntity> data = rows
- .Select(p => p.ListObject as PortMchBatchSampleResultEntity).ToList();
- if (data.Any(p => p.TrFlag == "1"))
- {
- tipMessage.Show("无法移动已匹配的管号", btnDown);
- return;
- }
- for (int i = 0; i < rows.Count; i++)
- {
- ultraGrid3.Rows.Move(rows[i], Index +1);
- }
- }
- private void ultraGrid3_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- List<UltraGridRow> rows = ultraGrid3.Selected.Rows.OfType<UltraGridRow>()
- .OrderBy(p => p.Index).ToList();
- //移动行
- if (rows.Count <= 0)
- {
- return;
- }
- //定位行
- UIElement myUIElement = ultraGrid3.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y));
- if(myUIElement==null) return;
- UltraGridCell myCell = (UltraGridCell)myUIElement.GetContext(typeof(UltraGridCell));
- if (myCell == null) return;
-
- UltraGridRow ugr = myCell.Row;
- if (ugr == null) { return; }
- int Index = ugr.Index;
- int cout = 0;
- for (int i = 0; i < rows.Count; i++)
- {
- int moveIndex = Index;
- if (Index < rows[i].Index) moveIndex = Index + cout++;
- ultraGrid3.Rows.Move(rows[i], moveIndex);
- }
- }
- }
-
- private void utDelete_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- try
- {
- if (ultraGrid3.ActiveRow.Cells["DeleteReason"].Value.ToString2()== "")
- {
- MessageBox.Show("请选择废品原因");
- return;
- }
- ServerHelper.SetData("com.steering.mes.mcp.Mch.FrmMchBugD.AddMchWaste",
- new object[]
- {
- heatPlanNo,
- gx,
- ultraGrid3.ActiveRow.Cells["PlineCode"].Text.ToString2(),
- userName,
- ultraGrid3.ActiveRow.Cells["MatNo"].Text.ToString2(),
- new List<MchBugDEntity>(){new MchBugDEntity()
- {
- MatNo = ultraGrid3.ActiveRow.Cells["MatNo"].Text.ToString2(),
- BatchNo = ultraGrid3.ActiveRow.Cells["PhyBatchNo"].Text,
-
- FailTypeCode = ultraGrid3.ActiveRow.Cells["DeleteReason"].Value.ToString2(),
- FailNum = 1,
- FailTypeName = ultraGrid3.ActiveRow.Cells["DeleteReason"].Text.ToString2(),
- FailWt = decimal.Parse(ultraGrid3.ActiveRow.Cells["ActWeight"].Value.ToString3())
- }}.Select(JSONFormat.Format).ToList()
- },
- ob);
- MessageBox.Show("剔除成功");
- var handler = MchWasteChange;
- if (handler != null) handler();
- }
- catch (Exception)
- {
-
- }
- }
- private void utCancelDelete_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- try
- {
- ServerHelper.SetData("com.steering.mes.mcp.Mch.FrmMchBugD.DeleteMchWaste",
- new object[]
- {
- heatPlanNo,
- ultraGrid3.ActiveRow.Cells["MatNo"].Text.ToString2(),
- gx,
- ultraGrid3.ActiveRow.Cells["PlineCode"].Text.ToString2(),
- },
- ob);
- MessageBox.Show("撤销成功");
- var handler = MchWasteChange;
- if (handler != null) handler();
- }
- catch (Exception)
- {
- }
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- ultraGrid3.UpdateData();
- var check = Data.Where(p => !string.IsNullOrWhiteSpace(p.BarCode)).GroupBy(p => p.BarCode).ToList();
- if (check.Any(p => p.Count() > 1))
- {
- string barcode = check.Where(p => p.Count() > 1).Select(p=>p.Key).Aggregate((a, b) => a + " " + b);
- MessageBox.Show("逐支跟踪号 " + barcode + "重复");
- return;
- }
- var Re = ServerHelper.SetDataReturnObj("com.steering.mes.mcp.common.PlanService.SaveBarcode",
- new object[] {Data.Select(JSONFormat.Format).ToList()}, ob);
-
-
- if (Re.ToString2() == "修改成功!")
- {
- MessageBox.Show("保存成功");
- Query();
- }
-
-
- }
- private void ultraGrid3_CellChange(object sender, CellEventArgs e)
- {
- if (e.Cell.Column.Key == "BarCode")
- {
- var check =
- ultraGrid3.Rows.Where(
- p =>
- p.Cells["MatNo"].Text != e.Cell.Row.Cells["MatNo"].Value.ToString2() &&
- !string.IsNullOrEmpty(p.Cells["BarCode"].Text) &&
- !string.IsNullOrEmpty(e.Cell.Text) &&
- p.Cells["BarCode"].Text == e.Cell.Text
- ).ToList();
- if (check.Any())
- {
- e.Cell.Appearance.BackColor = Color.Red;
- /* tipMessage.Show(
- @"
- 管号重复
- ", ultraGrid3);*/
- // e.Cell.EditorComponent = uteBarcode;
- }
- else
- {
- e.Cell.Appearance.ResetBackColor();
- e.Cell.EditorComponent = null;
- tipMessage.RemoveAll();
- }
- ShowMsg();
- }
- }
- private void ShowMsg()
- {
- try
- {
- var list = ultraGrid3.Rows.Where(p =>
- {
- int num = 0;
- return int.TryParse(p.Cells["BarCode"].Text.ToString(), out num);
- }).Select(p => int.Parse(p.Cells["BarCode"].Text.ToString())).ToList();
- if (list.Any())
- {
- var list2 = Enumerable.Range(list.Min(), list.Max()).ToList().Except(list
- ).ToList();
- lblMsg.Text = "(" + list.Min() + "-" + list.Max() + " )未录入:" + string.Join(",", list2.ToArray());
- }
- else
- {
- lblMsg.Text = "";
- }
- }
- catch (Exception)
- {
- lblMsg.Text = "";
- }
- }
- private void btnExport_Click(object sender, EventArgs e)
- {
- GridHelper.ulGridToExcel(ultraGrid3, "管号队列");
- }
- private void button1_Click(object sender, EventArgs e)
- {
- IQueryable<UltraGridRow> checkRows = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkRows.Count() == 0)
- {
- MessageUtil.ShowTips("请勾选要保存的数据");
- return;
- }
- string remark = remarkTxt.Value.ToString2();
- ArrayList parmList = new ArrayList();
- foreach (UltraGridRow row in checkRows)
- {
- PortMchBatchSampleResultEntity entity = (PortMchBatchSampleResultEntity)row.ListObject;
- if (entity.InstoreFlag.Equals("已入库"))
- {
- MessageUtil.ShowTips("已入库,无法保存备注!");
- return;
- }
- string matEntity = JSONFormat.Format(entity);
- parmList.Add(matEntity);
- }
- var Re = ServerHelper.SetDataReturnObj("com.steering.mes.mcp.common.PlanService.SaveRemark",
- new object[] { parmList, remark }, ob);
- if (Re.ToString2() == "修改成功!")
- {
- MessageBox.Show("保存成功");
- Query();
- }
- }
- }
- }
-
|