Exemple #1
0
        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();
            }
        }
Exemple #2
0
        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");
            }
        }