private void SaveVisual(string Judgement, int count, DetailsInspect item) { for (int x = 0; x < count; x++) { iInspectionDetail inspectDetail = new iInspectionDetail(); inspectDetail.InspectionItemId = item.ID; inspectDetail.CheckItemNo = item.No; inspectDetail.Sequence = sampling; inspectDetail.Data = 0; inspectDetail.Judgement = Judgement; inspectDetail.IsPartial = false; inspectDetail.IsFinished = true; inspectDetail.IsDeleted = false; inspectDetail.RegisterID = currentuser.UserID; inspectDetail.RegisterPG = "PG"; inspectDetail.RegisterDate = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm tt"), "yyyy-MM-dd HH:mm tt", System.Globalization.CultureInfo.InvariantCulture); inspectDetail.UpdateID = currentuser.UserID; inspectDetail.UpdatePG = "PG"; inspectDetail.UpdateDate = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm tt"), "yyyy-MM-dd HH:mm tt", System.Globalization.CultureInfo.InvariantCulture); db.iInspectionDetails.Add(inspectDetail); db.SaveChanges(); } }
private void InputData(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { DetailsInspect item = (DetailsInspect)detailsgrid.SelectedItem; if (item.Multipoint == 0) { SingleMultipoint(item); } else { Multipoint.Content = multipointcount + "/" + item.Multipoint; if (multipointcount == item.Multipoint) { Datamultipoint.Add(Convert.ToDecimal(Input.Text)); Multiplemultipoint(item, Datamultipoint); multipointcount = 1; } else { Datamultipoint.Add(Convert.ToDecimal(Input.Text)); multipointcount++; Input.Text = ""; } } } }
private void Multiplemultipoint(DetailsInspect item, List <decimal> multidata) { try { switch (item.Formula) { case "AVG": Input.Text = returnAVG(multidata).ToString(); break; case "MIN": Input.Text = returnMIN(multidata).ToString(); break; case "MAX": Input.Text = returnMAX(multidata).ToString(); break; case "MAX-MIN": Input.Text = returnMaxMinusMin(multidata).ToString(); break; case "MAX+MIN": Input.Text = returnMaxAddMin(multidata).ToString(); break; } SingleMultipoint(item); Datamultipoint = new List <decimal>(); } catch (Exception err) { } }
private void SingleMultipoint(DetailsInspect item) { try { theData data = new theData(); if (sampling <= item.SamplingSize) { decimal MIN, MAX; if (item.LSL != "") { MIN = Convert.ToDecimal(item.Target) + Convert.ToInt32(item.LSL); } else if (item.MIN != "") { MIN = Convert.ToDecimal(item.MIN); } else { MIN = -9999; } if (item.USL != "") { MAX = Convert.ToDecimal(item.Target) + Convert.ToInt32(item.USL); } else if (item.MAX != "") { MAX = Convert.ToDecimal(item.MAX); } else { MAX = 9999; } data.Sequence = "DATA " + sampling; data.Data = Convert.ToDecimal(Input.Text); decimal DATAInpt = Convert.ToDecimal(Input.Text); if (DATAInpt >= MIN && DATAInpt <= MAX) { data.Judgement = "AC"; } else { data.Judgement = "NC"; } Datalist.Add(data); DatainsertGrid.ItemsSource = Datalist.ToList(); sampling++; Input.Text = ""; } } catch (Exception err) { } }
private void MethodSelected(object sender, SelectionChangedEventArgs e) { try { currentIndex = detailsgrid.SelectedIndex; SetNA.Visibility = Visibility.Visible; Input.IsEnabled = true; List <SPModel> splist = new List <SPModel>(); detailsgrid.Columns.Clear(); detailsgrid.ItemsSource = null; string selected = Method.SelectedValue.ToString(); if (TheType.Contains("SP")) { List <DetailsInspect> List = (from c in db.iInspectionItems join sp in db.cMCSSPs on c.MCSChildID equals sp.MCSSPID where c.SAPCode == SapCode && c.LotNo == LotNo && sp.Method == selected && sp.Is_Deleted == false select new DetailsInspect { ID = c.ID, No = sp.No, CheckItem = sp.CheckItem, LSL = sp.LowerTOL, Target = sp.NominalValue, USL = sp.UpperTOL, MIN = sp.Min, MAX = sp.Max, Multipoint = sp.MPCNo, Formula = sp.MPCCriteria, SamplingSize = c.SamplingSize, Judgement = c.OverallJudgement, Datatype = sp.DataType }).ToList(); detailsgrid.ItemsSource = List; DetailsInspect item = (DetailsInspect)detailsgrid.SelectedItem; SamplingSize.Content = item.SamplingSize; if (item.Judgement == null) { btnSave.IsEnabled = true; DatainsertGrid.ItemsSource = null; } else { btnSave.IsEnabled = false; List <theData> datalist = (from c in db.iInspectionDetails where c.InspectionItemId == item.ID select new theData { Data = c.Data, Judgement = c.Judgement }).ToList(); int counter = 1; foreach (theData d in datalist) { d.Sequence = "DATA " + counter; counter++; } DatainsertGrid.ItemsSource = datalist; } } else if (TheType.Contains("FG")) { List <DetailsInspect> List = (from c in db.iInspectionItems join fg in db.cMCSFGs on c.MCSChildID equals fg.MCSFGID where c.SAPCode == SapCode && c.LotNo == LotNo && fg.Method == selected && fg.Is_Deleted == false select new DetailsInspect { ID = c.ID, No = fg.No, CheckItem = fg.CheckItem, LSL = fg.CTQMin, Target = fg.NominalValue, USL = fg.CTQMax, MIN = fg.Min, MAX = fg.Max, Multipoint = fg.MPCNo, Formula = fg.MPCCriteria, SamplingSize = c.SamplingSize, Judgement = c.OverallJudgement, Datatype = fg.DataType }).ToList(); detailsgrid.ItemsSource = List; DetailsInspect item = (DetailsInspect)detailsgrid.SelectedItem; SamplingSize.Content = item.SamplingSize; if (item.Judgement == null) { btnSave.IsEnabled = true; DatainsertGrid.ItemsSource = null; } else { btnSave.IsEnabled = false; List <theData> datalist = (from c in db.iInspectionDetails where c.InspectionItemId == item.ID select new theData { Data = c.Data, Judgement = c.Judgement }).ToList(); int counter = 1; foreach (theData d in datalist) { d.Sequence = "DATA " + counter; counter++; } DatainsertGrid.ItemsSource = datalist; } } } catch (Exception err) { SamplingSize.Content = "0"; } detailsgrid.SelectedIndex = currentIndex; }
private void detailsgrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { sampling = 1; multipointcount = 1; Datamultipoint = new List <decimal>(); Datalist = new List <theData>(); try { insss.Text = "START INSPECT"; DetailsInspect item = (DetailsInspect)detailsgrid.SelectedItem; if (Method.SelectedIndex != -1) { datain.Visibility = Visibility.Visible; Input.Visibility = Visibility.Visible; if (item.Datatype == "DATA") { STARTINSPECT.Visibility = Visibility.Visible; Attributedata.Visibility = Visibility.Hidden; } else if (item.Datatype == "DATA INPUT") { STARTINSPECT.Visibility = Visibility.Hidden; Attributedata.Visibility = Visibility.Hidden; } else { Attributedata.Visibility = Visibility.Visible; datain.Visibility = Visibility.Hidden; Input.Visibility = Visibility.Hidden; STARTINSPECT.Visibility = Visibility.Hidden; } } SamplingSize.Content = item.SamplingSize; if (item.Judgement == null) { btnSave.IsEnabled = true; DatainsertGrid.ItemsSource = null; } else { btnSave.IsEnabled = false; List <theData> datalist = (from c in db.iInspectionDetails where c.InspectionItemId == item.ID select new theData { Data = c.Data, Judgement = c.Judgement }).ToList(); int counter = 1; foreach (theData d in datalist) { d.Sequence = "DATA " + counter; counter++; } DatainsertGrid.ItemsSource = datalist; } } catch (Exception err) { btnSave.IsEnabled = true; DatainsertGrid.ItemsSource = null; } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (DatainsertGrid.HasItems) { DetailsInspect item = (DetailsInspect)detailsgrid.SelectedItem; iInspectionItem inspectionITEM = (from c in db.iInspectionItems where c.ID == item.ID select c).FirstOrDefault(); //foreach (DetailsInspect item in detailsgrid.SelectedItems) //{ if (item.Datatype != "ATTRIBUTE") { List <theData> datahere = DatainsertGrid.Items.OfType <theData>().ToList(); string OVERALLJudgement = "AC"; foreach (theData d in datahere) { if (d.Judgement == "NC") { OVERALLJudgement = "NC"; } iInspectionDetail inspectDetail = new iInspectionDetail(); inspectDetail.InspectionItemId = item.ID; inspectDetail.CheckItemNo = item.No; inspectDetail.Sequence = sampling; inspectDetail.Data = Convert.ToDecimal(d.Data); inspectDetail.Judgement = d.Judgement; inspectDetail.IsPartial = false; inspectDetail.IsFinished = true; inspectDetail.IsDeleted = false; inspectDetail.RegisterID = currentuser.UserID; inspectDetail.RegisterPG = "PG"; inspectDetail.RegisterDate = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm tt"), "yyyy-MM-dd HH:mm tt", System.Globalization.CultureInfo.InvariantCulture); inspectDetail.UpdateID = currentuser.UserID; inspectDetail.UpdatePG = "PG"; inspectDetail.UpdateDate = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm tt"), "yyyy-MM-dd HH:mm tt", System.Globalization.CultureInfo.InvariantCulture); db.iInspectionDetails.Add(inspectDetail); db.SaveChanges(); //} inspectionITEM.OverallJudgement = OVERALLJudgement; inspectionITEM.IsFinished = true; db.Entry(inspectionITEM).State = EntityState.Modified; db.SaveChanges(); } } else { List <theVisualData> thevisualdatahere = DatainsertGrid.Items.OfType <theVisualData>().ToList(); SaveVisual("AC", Convert.ToInt32(thevisualdatahere[0].AC), item); SaveVisual("NC", Convert.ToInt32(thevisualdatahere[0].NC), item); SaveVisual("NA", Convert.ToInt32(thevisualdatahere[0].NA), item); if (thevisualdatahere[0].AC == "0" && thevisualdatahere[0].NC == "0") { inspectionITEM.OverallJudgement = "NA"; } else if (Convert.ToInt32(thevisualdatahere[0].NC) > 0) { inspectionITEM.OverallJudgement = "NC"; } else { inspectionITEM.OverallJudgement = "AC"; } inspectionITEM.IsFinished = true; db.Entry(inspectionITEM).State = EntityState.Modified; db.SaveChanges(); } sampling = 1; DatainsertGrid.ItemsSource = null; detailsgrid.SelectedIndex++; Datalist = new List <theData>(); MethodSelected(sender, null); } else { MessageBox.Show("Please select check item to inspect"); } }