| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using System.Windows.Input;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Mcp.Control.Common;
- using Core.StlMes.Client.Mcp.Control.Entity;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.StlMes.Client.Mcp.Control.Machining
- {
- public partial class FinalCheckControl : UserControl
- {
- protected List<HttSignatureEntity> Names = new List<HttSignatureEntity>();
- protected string _plineCode = "";
- private bool isMeasureData = false;
- public FinalCheckControl()
- {
- InitializeComponent();
- EntityHelper.ShowGridCaption<PortMchBatchSampleResultEntity>(ultraGrid2.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<MchFinalCheckTotal>(ultraGrid1.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<MchFinalCheckResultDEntity>(ultraGrid1.DisplayLayout.Bands[1]);
- commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2);
- //commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, "UnPass");
- var list = new ValueList();
- list.ValueListItems.Add(new ValueListItem("0", "合格"));
- list.ValueListItems.Add(new ValueListItem("1", "不合"));
- list.ValueListItems.Add(new ValueListItem("2", "废品"));
- ultraGrid1.DisplayLayout.Bands[0].Columns["Station"].ValueList = list;
-
- }
- private OpeBase ob;
- private DataTable dt;
- private DataTable dtReason;
- private DataTable dtTreat;
- private string BatchNo = "";
- public void Init(OpeBase _ob)
- {
- ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- ultraGrid1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
- ultraGrid2.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- ultraGrid2.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
- ob = _ob;
- dt = ServerHelper.GetData("com.steering.mes.mcp.common.PlanService.getBaseInfoSingle",
- new object[] { "702101" }, ob);
- /* dtReason = ServerHelper.GetData("com.steering.mes.mcp.common.PlanService.getBaseInfo",
- new object[] { "702101" }, ob);*/
- dtTreat = ServerHelper.GetData("com.steering.mes.mcp.common.PlanService.getBaseInfo",
- new object[] { "702103" }, ob);
- var list = new ValueList();
- for (int i = 0; i < dtTreat.Rows.Count; i++)
- {
- list.ValueListItems.Add(new ValueListItem(dtTreat.Rows[i]["BASECODE"].ToString2(), dtTreat.Rows[i]["BASENAME"].ToString2()));
- }
- ultraGrid1.DisplayLayout.Bands[0].Columns["TreatmentCode"].ValueList = list;
- ultraGrid2.DisplayLayout.Bands[0].Columns["PrcTechnologyPath"].Header.Caption = "原管号";
- }
- private List<PortMchBatchSampleResultEntity> _portHttBatchSampleResultEntitys;
- public List<PortMchBatchSampleResultEntity> ProMchPort
- {
- get
- {
- return portMchBatchSampleResultEntityBindingSource.DataSource as List<PortMchBatchSampleResultEntity>;
- }
- }
- /// <summary>
- /// 废品
- /// </summary>
- public List<MchBugDEntity> ScrappedList { get; protected set; }
- public List<MchFinalCheckTotal> Detail { get; private set; }
- private MchFinalCheckResultEntity Data;
- public MchFinalCheckResultEntity GetData()
- {
- if(Data==null) Data=new MchFinalCheckResultEntity();
- Data.ProNum = ProMchPort.Count;
- Data.ProWt = ProMchPort.Sum(p => p.ActWeight);
- Data.CheckNum = Detail.Select(p=>p.MatNo).Distinct().Count();
- Data.CheckWt = ProMchPort.Where(p => Detail.Any(q=>q.MatNo==p.MatNo)).Sum(p => p.ActWeight);
- Data.ProShift = uceBc.Value.ToString2();
- Data.ProGroup = uceBz.Value.ToString2();
- Data.ProTime = udeProData.Value.ToString2();
- Data.ProUser = txtUserName.Text;
- Data.UnqualifiedNum = Detail.Where(p => p.Station == "1").Select(p => p.MatNo).Distinct().Count();
- Data.UnqualifiedWt = ProMchPort.Where(p => Detail.Any(q => q.MatNo == p.MatNo && q.Station == "1")).Sum(p => p.ActWeight);
- Data.FailNum = Detail.Where(p => p.Station == "2").Select(p => p.MatNo).Distinct().Count();
- Data.FailWt = ProMchPort.Where(p => Detail.Any(q => q.MatNo == p.MatNo && q.Station == "2")).Sum(p => p.ActWeight);
- Data.QualifiedNum = Data.CheckNum - Data.UnqualifiedNum;
- Data.QualifiedWt = Data.CheckWt - Data.UnqualifiedWt;
- Data.ResultType = "0";
- return Data;
- }
- public List<MchBugDEntity> GetFailList()
- {
- List<MchBugDEntity> fail = new List<MchBugDEntity>();
- Detail.Where(p => p.Station == "2").GroupBy(p=>p.MatNo).ToList().ForEach(p =>
- {
- fail.Add(new MchBugDEntity()
- {
- BatchNo = Data.BatchNo,
- FailNum = 1,
- FailWt = ProMchPort.First(q => q.MatNo==p.Key).ActWeight,
- FailSort = "10",
- FailTypeCode = p.First().UnPassData[0].UnpassCode,
- FailTypeName = p.First().UnPassData[0].UnpassName,
- MatNo = p.Key
- });
- });
- fail= fail.GroupBy(p=>new {p.BatchNo,p.FailSort, p.FailTypeCode, p.FailTypeName}).Select(p=>new MchBugDEntity()
- {
- BatchNo = p.Key.BatchNo,
- FailNum = p.Sum(q=>q.FailNum),
- FailWt = p.Sum(q=>q.FailWt),
- FailSort = p.Key.FailSort,
- FailTypeCode = p.Key.FailTypeCode,
- FailTypeName = p.Key.FailTypeName,
- MatNo = p.Select(q=>q.MatNo).Aggregate((a,b)=>(a==""?"": a + ",") + b )
- }).ToList();
- return fail;
- }
- public void SetValue(MchFinalCheckResultEntity value, List<PortMchBatchSampleResultEntity> port)
- {
- Data = value;
- isMeasureData = port.Any(p => p.MeasuringSeq != null);
- _portHttBatchSampleResultEntitys = isMeasureData ?
- port.Where(p => (p.MatStatus == "合格" || p.MatStatus == "待处理") && p.MeasuringSeq != null && (p.IsFinalcheck == "" || p.IsFinalcheck == "0")).OrderBy(p => p.MeasuringSeq).ToList() :
- port.Where(p => (p.MatStatus == "合格" || p.MatStatus == "待处理") && (p.IsFinalcheck == "" || p.IsFinalcheck == "0")).OrderBy(p => p.MatNo).ToList();
- Data.ProNum = _portHttBatchSampleResultEntitys.Count;
- if (isMeasureData)
- {
- ultraGrid2.DisplayLayout.Bands[0].Columns["MatNo"].Hidden = true;
- ultraGrid2.DisplayLayout.Bands[0].Columns["PrcTechnologyPath"].Hidden = false;
- ultraGrid2.DisplayLayout.Bands[0].Columns["MeasuringSeq"].Hidden = false;
- ultraGrid1.DisplayLayout.Bands[0].Columns["MatNo"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Columns["MeasuringSeq"].Hidden = false;
- }
- else
- {
- ultraGrid2.DisplayLayout.Bands[0].Columns["MatNo"].Hidden = false;
- ultraGrid2.DisplayLayout.Bands[0].Columns["PrcTechnologyPath"].Hidden = true;
- ultraGrid2.DisplayLayout.Bands[0].Columns["MeasuringSeq"].Hidden = true;
- ultraGrid1.DisplayLayout.Bands[0].Columns["MatNo"].Hidden = false;
- ultraGrid1.DisplayLayout.Bands[0].Columns["MeasuringSeq"].Hidden = true;
- }
- udeProData.Value = DateTime.Now;
- portMchBatchSampleResultEntityBindingSource.DataSource = _portHttBatchSampleResultEntitys;
- txtProNum.MaxValue = _portHttBatchSampleResultEntitys.Count;
-
-
- txtProNum.Text = Data.ProNum.ToString3();
- txtUserName.Text = Data.ProUser;
- uceBc.Value = Data.ProShift;
- uceBz.Value = Data.ProGroup;
- // ultraGrid2.DisplayLayout.Bands[0].Columns["BarCode"].Hidden = port.All(p => p.BarCode == "");
- Detail = new List<MchFinalCheckTotal>();
- mchFinalCheckTotalBindingSource.DataSource = Detail;
- commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2);
- ultraGrid2.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + Data.ProNum + "支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + Data.ProNum + "支 " + "抽检 0支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[1].DisplayFormat = "抽检率 0%";
- txtStart.Text =isMeasureData? port.Min(p => p.MeasuringSeq).ToString3():"1";
- txtEnd.Text = isMeasureData ? port.Max(p => p.MeasuringSeq).ToString3() : "1000";
- if (_plineCode != value.PlineCode)
- {
- Names = EntityHelper.GetData<HttSignatureEntity>(
- "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign",
- new object[] { value.PlineCode, "12" }, ob);
- txtUserName.DisplayMember = "UserName";
- txtUserName.ValueMember = "UserName";
- _plineCode = value.PlineCode;
- txtUserName.DataSource = Names;
- }
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- PortMchBatchSampleResultEntity entity =
- ultraGrid2.ActiveRow.ListObject as PortMchBatchSampleResultEntity;
- if (e.Cell.Column.Key == "Check")
- {
- ultraGrid2.UpdateData();
- if ((bool) e.Cell.Value && dt != null)
- {
- foreach (DataRow t in dt.Rows)
- {
- Detail.Add(new MchFinalCheckTotal()
- {
- MatNo = entity.MatNo,
- BarCode = entity.BarCode,
- MeasuringSeq = entity.MeasuringSeq,
- PositionCode = t["BASECODE"].ToString2(),
- PositionName = t["BASENAME"].ToString2(),
- Station = "0",
- UnPassData = new List<MchFinalCheckResultDEntity>()
- });
- }
- }
- else
- {
- Detail.Where(p=>p.MatNo==entity.MatNo).ToList().ForEach(p=>Detail.Remove(p));
- }
- Detail = Detail.OrderBy(p => p.MeasuringSeq).ThenBy(p => p.MatNo).ThenBy(p => p.PositionCode).ToList();
- // commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, "Unpass");
- }
- int C = Detail.Select(p => p.MatNo).Distinct().Count();
- int F = int.Parse(Data.ProNum.ToString3());
- mchFinalCheckTotalBindingSource.DataSource = Detail;
- ultraGrid1.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + F + "支 " + "抽检 " + C + "支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[1].DisplayFormat = "抽检率" + (C * 100d / F).ToString("0.00") + "%";
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.Cells["PositionCode"].Value.ToString2() != "")
- {
- /*var list = new ValueList();
- dtReason.AsEnumerable().Where(p => p["BASECODE"].ToString2().StartsWith(e.Row.Cells["PositionCode"].Value.ToString2())).ToList().ForEach(
- p=> { list.ValueListItems.Add(new ValueListItem(p["BASECODE"].ToString2(), p["BASENAME"].ToString2()));} );
- e.Row.Cells["UnpassCode"].ValueList = list;*/
- // ultraGrid1.DisplayLayout.Bands[0].Columns["UnpassName"].PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- }
-
- /* if (e.Row.Cells["Station"].Value.ToString2() == "1")
- {
- e.Row.Cells["Station"].Appearance.BackColor= Color.Red;
- }
- else if (e.Row.Cells["Station"].Value.ToString2() == "2")
- {
- e.Row.Cells["Station"].Appearance.BackColor = Color.Red;
- }
- else
- {
- e.Row.Cells["Station"].Appearance.ResetBackColor();
- }*/
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- /* if (e.Cell.Column.Key == "UnPass")
- {
- ultraGrid1.UpdateData();
- MchFinalCheckTotal entity = e.Cell.Row.ListObject as MchFinalCheckTotal;
- if (entity.UnPassData!=null && entity.UnPassData.Any())
- {
- e.Cell.Row.Cells["Station"].Value = entity.UnPassData.Any(p => p.TreatmentCode == "70210304")
- ? "2"
- : "1";
- }
- else
- {
- e.Cell.Row.Cells["Station"].Value = "0";
- }
- }*/
- if (e.Cell.Column.Key == "TreatmentCode")
- {
- ultraGrid1.UpdateData();
- if (e.Cell.Value.ToString2() != "")
- {
- e.Cell.Row.Cells["Station"].Value = "1";
- e.Cell.Row.Cells["TreatmentName"].Value = e.Cell.Text;
- }
- }
- if (e.Cell.Column.Key == "Station")
- {
- ultraGrid1.UpdateData();
- if (e.Cell.Value.ToString2() == "0")
- {
- e.Cell.Row.Cells["UnpassCode"].Value = "";
- e.Cell.Row.Cells["UnpassName"].Value = "";
- e.Cell.Row.Cells["TreatmentCode"].Value = "";
- e.Cell.Row.Cells["TreatmentName"].Value = "";
- e.Cell.Row.Cells["UnpassMemo"].Value = "";
- }
- }
- }
- private void uteUnpass_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- MchFinalCheckTotal entity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTotal;
- string OldStation = entity.Station;
- var matfrm = new ReasonChoose(ob, entity.PositionCode, entity.UnPassData);
- matfrm.ShowDialog();
- if (matfrm.DialogResult == DialogResult.OK)
- {
- List<MchFinalCheckTotal> list = mchFinalCheckTotalBindingSource.DataSource as List<MchFinalCheckTotal>;
- entity.UnPass = matfrm.Name;
- entity.UnPassData = matfrm.ListData ?? new List<MchFinalCheckResultDEntity>();
- entity.Station = (entity.UnPassData == null || !entity.UnPassData.Any())
- ? "0"
- : entity.UnPassData.Any(p => p.TreatmentCode1 == "70210304") ? "2" : "1";
- if (entity.Station == "2")
- {
- entity.UnPassData = entity.UnPassData.Where(p => p.TreatmentCode1 == "70210304").Take(1).ToList();
- }
- entity.UnPassData.ForEach(p =>
- {
- p.Station =entity.UnPassData.Any(q=> q.TreatmentCode1 == "70210304")?"2": "1";
- p.PositionCode = entity.PositionCode;
- p.PositionName = entity.PositionName;
- p.MatNo = entity.MatNo;
- p.MeasuringSeq = entity.MeasuringSeq;
- p.BarCode = entity.BarCode;
- });
- if (entity.Station == "2" || OldStation == "2")
- {
- var MatNos = list.Where(p => p.MatNo == entity.MatNo && p.PositionCode != entity.PositionCode).ToList();
- MatNos.ForEach(p =>
- {
- p.Station = entity.Station == "2" ? "2" : "0";
- p.UnPassData = new List<MchFinalCheckResultDEntity>();
- p.UnPass = "";
- });
- }
- ultraGrid1.Rows.Where(p=>p.Cells["MatNo"].Value.ToString2()==entity.MatNo).ToList().ForEach(
- p =>
- {
- if (p.Cells["Station"].Value.ToString2() == "1")
- {
- p.Cells["Station"].Appearance.BackColor = Color.Red;
- }
- else if (p.Cells["Station"].Value.ToString2() == "2")
- {
- p.Cells["Station"].Appearance.BackColor = Color.Red;
- }
- else
- {
- p.Cells["Station"].Appearance.ResetBackColor();
- }
- }
- );
-
- // ultraGrid1_CellChange(ultraGrid1, new CellEventArgs(ultraGrid1.ActiveRow.Cells["Unpass"]));
- }
- // Value.DubiousNum = Value.DubiousNum ?? 0;
- ultraGrid1.PerformAction(UltraGridAction.ExitEditMode);
- // mchFinalCheckTotalBindingSource.DataSource = Detail;
- mchFinalCheckTotalBindingSource.ResetBindings(false);
- ultraGrid1.UpdateData();
-
- }
- private void ultraButton1_Click(object sender, EventArgs e)
- {
- var entitty =
- ultraGrid2.Rows.Where(p => p.Cells["MeasuringSeq"].Value.ToString2() == txtDir.Text).ToList();
- if (entitty.Count() != 1)
- {
- MessageBox.Show("找不到指定的管号");
- }
- else
- {
- if (!(bool)entitty[0].Cells["Check"].Value)
- {
- entitty[0].Cells["Check"].Value = true;
- entitty[0].Activated = true;
- ultraGrid2_CellChange(null, new CellEventArgs(entitty[0].Cells["Check"]));
- }
-
- }
- txtDir.SelectAll();
- }
- private void txtDir_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar ==13)
- {
- ultraButton1_Click(null, null);
- }
- }
- private void ultraButton2_Click(object sender, EventArgs e)
- {
- int frequency = (int) numF.Value;
- int num = (int) numN.Value;
- if ((int) numN.Value > (int) numF.Value)
- {
- num = frequency;
- }
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- bool NeedCheck = i%frequency < num;
- if ((bool)ultraGrid2.Rows[i].Cells["Check"].Value != NeedCheck)
- {
- ultraGrid2.Rows[i].Cells["Check"].Value = NeedCheck;
- ultraGrid2.Rows[i].Activated = true;
- ultraGrid2_CellChange(null, new CellEventArgs(ultraGrid2.Rows[i].Cells["Check"]));
- }
- }
- }
- private void txtProNum_ValueChanged(object sender, EventArgs e)
- {
- if (_portHttBatchSampleResultEntitys == null || txtProNum.Value.ToString3() == _portHttBatchSampleResultEntitys.Count.ToString3()) return;
- Data.ProNum =decimal.Parse(txtProNum.Value.ToString3());
- var List = _portHttBatchSampleResultEntitys.Take((int)Data.ProNum).ToList();
- portMchBatchSampleResultEntityBindingSource.DataSource = List;
- foreach (var ultraGrid2Row in ultraGrid2.Rows)
- {
- ultraGrid2Row.Cells["Check"].Value = false;
- }
- Detail = new List<MchFinalCheckTotal>();
- mchFinalCheckTotalBindingSource.DataSource = Detail;
- commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2);
- ultraGrid2.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + Data.ProNum + "支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + Data.ProNum + "支 "+ "抽检 0支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[1].DisplayFormat = "抽检率 0%";
-
- }
- private void ultraGrid2_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
- {
- ultraGrid2.UpdateData();
- CheckState newCheckState = e.Column.GetHeaderCheckedState(e.Rows);
- switch (newCheckState)
- {
- case CheckState.Checked:
- PortMchBatchSampleResultEntity entity =
- ultraGrid2.ActiveRow.ListObject as PortMchBatchSampleResultEntity;
-
- ultraGrid2.UpdateData();
- List<PortMchBatchSampleResultEntity> list =
- portMchBatchSampleResultEntityBindingSource.DataSource as List<PortMchBatchSampleResultEntity>;
- list.ForEach(p =>
- {
- if (Detail.All(q => q.MatNo != p.MatNo)){
- foreach (DataRow t in dt.Rows)
- {
- Detail.Add(new MchFinalCheckTotal()
- {
- MatNo = p.MatNo,
- BarCode = p.BarCode,
- MeasuringSeq = p.MeasuringSeq,
- PositionCode = t["BASECODE"].ToString2(),
- PositionName = t["BASENAME"].ToString2(),
- Station = "0",
- UnPassData = new List<MchFinalCheckResultDEntity>()
- });
- }
- }
- } );
-
-
- Detail = Detail.OrderBy(p => p.MeasuringSeq).ThenBy(p => p.MatNo).ThenBy(p => p.PositionCode).ToList();
-
- int C = Detail.Select(p => p.MatNo).Distinct().Count();
- mchFinalCheckTotalBindingSource.DataSource = Detail;
- ultraGrid1.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + C + "支 " + "抽检 " + C + "支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[1].DisplayFormat = "抽检率100%";
- break;
- case CheckState.Unchecked:
- Detail = new List<MchFinalCheckTotal>();
- mchFinalCheckTotalBindingSource.DataSource = Detail;
- ultraGrid2.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + Data.ProNum + "支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + Data.ProNum + "支 " + "抽检 0支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[1].DisplayFormat = "抽检率 0%";
- break;
- default:
- break;
- }
- }
- private void ultraGrid1_InitializeRowsCollection(object sender, InitializeRowsCollectionEventArgs e)
- {
- foreach (var ultraGridRow in e.Rows)
- {
- if (ultraGridRow.Cells["Station"].Value.ToString2() == "1")
- {
- ultraGridRow.Cells["Station"].Appearance.BackColor = Color.Red;
- }
- else if (ultraGridRow.Cells["Station"].Value.ToString2() == "2")
- {
- ultraGridRow.Cells["Station"].Appearance.BackColor = Color.Red;
- }
- else
- {
- ultraGridRow.Cells["Station"].Appearance.ResetBackColor();
- }
- }
-
- }
- private void btnCheck_Click(object sender, EventArgs e)
- {
- int Start = 0;
- int End = 0;
- int Frequency = 0;
- if (!int.TryParse(txtStart.Text, out Start) || Start<=0)
- {
- MessageBox.Show("请输入正确的起始管号");
- return;
- }
- if (!int.TryParse(txtEnd.Text, out End) || End <= 0)
- {
- MessageBox.Show("请输入正确的结束管号");
- return;
- }
- if (!int.TryParse(uceFrequency.Text, out Frequency) && Frequency <= 0)
- {
- MessageBox.Show("请输入正确的抽取频率");
- return;
- }
-
- mchFinalCheckTotalBindingSource.Clear();
- Detail = new List<MchFinalCheckTotal>();
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- var row = ultraGrid2.Rows[i];
- bool NeedCheck = false;
- if (isMeasureData)
- {
- NeedCheck = int.Parse(row.Cells["MeasuringSeq"].Value.ToString3()) >= Start &&
- int.Parse(row.Cells["MeasuringSeq"].Value.ToString3()) <= End &&
- (int.Parse(row.Cells["MeasuringSeq"].Value.ToString3()) - Start)%Frequency == 0;
- }
- else
- {
- NeedCheck = i+1 >= Start &&
- i + 1 <= End &&
- (i+1 - Start) % Frequency == 0;
- }
- row.Cells["Check"].Value = NeedCheck;
- if (NeedCheck)
- {
- foreach (DataRow t in dt.Rows)
- {
- if (isMeasureData)
- {
- Detail.Add(new MchFinalCheckTotal()
- {
- MatNo = row.Cells["MatNo"].Value.ToString2(),
- BarCode = row.Cells["BarCode"].Value.ToString2(),
- MeasuringSeq = decimal.Parse(row.Cells["MeasuringSeq"].Value.ToString3()),
- PositionCode = t["BASECODE"].ToString2(),
- PositionName = t["BASENAME"].ToString2(),
- Station = "0",
- UnPassData = new List<MchFinalCheckResultDEntity>()
- });
- }
- else
- {
- Detail.Add(new MchFinalCheckTotal()
- {
- MatNo = row.Cells["MatNo"].Value.ToString2(),
- BarCode = row.Cells["BarCode"].Value.ToString2(),
- MeasuringSeq = null,
- PositionCode = t["BASECODE"].ToString2(),
- PositionName = t["BASENAME"].ToString2(),
- Station = "0",
- UnPassData = new List<MchFinalCheckResultDEntity>()
- });
- }
- }
- }
- }
- Detail = Detail.OrderBy(p => p.MeasuringSeq).ThenBy(p => p.MatNo).ThenBy(p => p.PositionCode).ToList();
- int C = Detail.Select(p => p.MatNo).Distinct().Count();
- int F = int.Parse(Data.ProNum.ToString3());
- mchFinalCheckTotalBindingSource.DataSource = Detail;
- ultraGrid1.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "送检 " + F + "支 " + "抽检 " + C + "支";
- ultraGrid1.DisplayLayout.Bands[0].Summaries[1].DisplayFormat = "抽检率" + (C * 100d / F).ToString("0.00") + "%";
- }
- private void cmsCopy_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- UltraGrid ug = (sender as ContextMenuStrip).SourceControl as UltraGrid;
- if (ug == null || ug.ActiveRow == null)
- {
- return;
- }
- MchFinalCheckTotal entity;
- if (ug.ActiveRow.HasParent())
- {
- entity = ug.ActiveRow.ParentRow.ListObject as MchFinalCheckTotal;
- }
- else
- {
- entity = ug.ActiveRow.ListObject as MchFinalCheckTotal;
- }
- if (e.ClickedItem.Name == "tmsCopyToAll")
- {
- List<MchFinalCheckTotal> list = mchFinalCheckTotalBindingSource.DataSource as List<MchFinalCheckTotal>;
-
- list.Where(p=>p.PositionCode == entity.PositionCode && p.MatNo !=entity.PositionCode).ToList().ForEach(
- p =>
- {
- p.UnPass = entity.UnPass;
- p.UnPassData = entity.UnPassData.Select(q =>
- {
- MchFinalCheckResultDEntity data = q.Clone();
- data.MatNo = p.MatNo;
- data.MeasuringSeq = p.MeasuringSeq;
- return data;
- }).ToList();
- p.Station = entity.Station;
- });
- mchFinalCheckTotalBindingSource.ResetBindings(false);
- ultraGrid1.UpdateData();
- ultraGrid1.Rows.ToList().ForEach(
- p =>
- {
- if (p.Cells["Station"].Value.ToString2() == "1")
- {
- p.Cells["Station"].Appearance.BackColor = Color.Red;
- }
- else if (p.Cells["Station"].Value.ToString2() == "2")
- {
- p.Cells["Station"].Appearance.BackColor = Color.Red;
- }
- else
- {
- p.Cells["Station"].Appearance.ResetBackColor();
- }
- }
- );
-
- }
- }
- private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.Cells["PrcTechnologyPath"].Value.ToString2() != "")
- {
- e.Row.Appearance.BackColor = Color.Yellow;
- }
- }
- private void ultraTextEditor1_ValueChanged(object sender, EventArgs e)
- {
- }
- }
- }
|