public IQueryable <TLCUT_QAResults> SelectQaResults(CuttingQueryParameters parameters) { var QARes = _context.TLCUT_QAResults.AsQueryable(); if (parameters.FromDate.Day != parameters.ToDate.Day) { QARes = QARes.Where(x => x.TLCUTQA_Date >= parameters.FromDate && x.TLCUTQA_Date <= parameters.ToDate).AsQueryable(); } if (parameters.QAResults.Count != 0) { var CSPredicate = PredicateBuilder.False <TLCUT_QAResults>(); foreach (var CSR in parameters.QAResults) { var temp = CSR; CSPredicate = CSPredicate.Or(s => s.TLCUTQA_Bundle_FK == temp.TLCUTQA_Bundle_FK); } QARes = QARes.AsExpandable().Where(CSPredicate); } else { QARes = _context.TLCUT_QAResults.Where(x => x.TLCUTQA_Date >= parameters.FromDate && x.TLCUTQA_Date <= parameters.ToDate).AsQueryable(); } return(QARes); }
private void frmSelPanelStock_Load(object sender, EventArgs e) { formloaded = false; parms = new CuttingQueryParameters(); using (var context = new TTI2Entities()) { var Existing = context.TLADM_WhseStore.Where(x => x.WhStore_PanelStore).ToList(); foreach (var Entry in Existing) { cmboWareHouseStore.Items.Add(new Cutting.CheckComboBoxItem(Entry.WhStore_Id, Entry.WhStore_Description, false)); } } sortOptions = 1; var reportOptions = new BindingList <KeyValuePair <int, string> >(); reportOptions.Add(new KeyValuePair <int, string>(2, "Quality")); reportOptions.Add(new KeyValuePair <int, string>(3, "Colour")); reportOptions.Add(new KeyValuePair <int, string>(5, "Style")); cmboReportSelection.DataSource = reportOptions; cmboReportSelection.ValueMember = "Key"; cmboReportSelection.DisplayMember = "Value"; cmboReportSelection.SelectedIndex = -1; formloaded = true; formloaded = true; }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; frmCutViewRep vRep = null; if (oBtn != null && formloaded) { if (rbFullDetail.Checked) { parms.QAFullDetail = true; } else { parms.QAFullDetail = false; } parms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); parms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); parms.ToDate = parms.ToDate.AddHours(23); vRep = new frmCutViewRep(8, parms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); cmboCutSheets.Items.Clear(); cmboSizes.Items.Clear(); cmboStyles.Items.Clear(); frmQaReportSelection_Load(this, null); parms = new CuttingQueryParameters(); } }
private void FrmBierriebiSel_Load(object sender, EventArgs e) { FormLoaded = false; parms = new CuttingQueryParameters(); using (var context = new TTI2Entities()) { var Query = from T1 in context.TLCUT_QCBerrie join T2 in context.TLCUT_CutSheetReceipt on T1.TLQCFB_CutSheetReceipt_FK equals T2.TLCUTSHR_Pk join T3 in context.TLCUT_CutSheet on T2.TLCUTSHR_CutSheet_FK equals T3.TLCutSH_Pk where (T1.TLQCFB_Measure1 != 0 || T1.TLQCFB_Measure10 != 0 || T1.TLQCFB_Measure11 != 0 || T1.TLQCFB_Measure2 != 0 || T1.TLQCFB_Measure3 != 0 || T1.TLQCFB_Measure4 != 0 || T1.TLQCFB_Measure5 != 0 || T1.TLQCFB_Measure6 != 0 || T1.TLQCFB_Measure7 != 0 || T1.TLQCFB_Measure8 != 0 || T1.TLQCFB_Measure9 != 0) && !T3.TLCutSH_Closed select new { T2.TLCUTSHR_Pk, T3.TLCutSH_No }; var QueryGroup = Query.OrderBy(x => x.TLCutSH_No).GroupBy(x => x.TLCUTSHR_Pk); foreach (var Receipt in QueryGroup) { comboCutSheets.Items.Add(new Cutting.CheckComboBoxItem(Receipt.FirstOrDefault().TLCUTSHR_Pk, Receipt.FirstOrDefault().TLCutSH_No, false)); } var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("CUT")).FirstOrDefault(); if (Dept != null) { var Operators = context.TLADM_MachineOperators.Where(x => x.MachOp_Department_FK == Dept.Dep_Id && !x.MachOp_Inspector && !x.MachOp_Discontinued).ToList(); foreach (var Operator in Operators) { this.comboOperator.Items.Add(new Cutting.CheckComboBoxItem(Operator.MachOp_Pk, Operator.MachOp_Description, false)); } var Machines = context.TLADM_MachineDefinitions.Where(x => x.MD_Department_FK == Dept.Dep_Id).ToList(); foreach (var Machine in Machines) { this.comboMachines.Items.Add(new Cutting.CheckComboBoxItem(Machine.MD_Pk, Machine.MD_AlternateDesc, false)); } } var Qualities = context.TLADM_Griege.OrderBy(x => x.TLGreige_Description).ToList(); foreach (var Quality in Qualities) { this.comboGreige.Items.Add(new Cutting.CheckComboBoxItem(Quality.TLGreige_Id, Quality.TLGreige_Description, false)); } } FormLoaded = true; }
private void frmCutSheetRegister_Load(object sender, EventArgs e) { formloaded = false; parms = new CuttingQueryParameters(); using (var context = new TTI2Entities()) { var Departments = context.TLADM_Departments.Where(x => x.Dep_IsCut).OrderBy(x => x.Dep_Description).ToList(); foreach (var Department in Departments) { cmboDepartments.Items.Add(new Cutting.CheckComboBoxItem(Department.Dep_Id, Department.Dep_Description, false)); } } formloaded = true; }
public IQueryable <TLCUT_CutSheet> SelectWIPCutSheets(CuttingQueryParameters parameters) { IQueryable <TLCUT_CutSheet> CS; if (parameters.AllWIP) { CS = _context.TLCUT_CutSheet.Where(x => !x.TLCutSH_WIPComplete && x.TLCutSH_Accepted && !x.TLCutSH_Closed).AsQueryable(); } else { CS = _context.TLCUT_CutSheet.Where(x => x.TLCutSH_Date >= parameters.FromDate && x.TLCutSH_Date <= parameters.ToDate && !x.TLCutSH_WIPComplete && x.TLCutSH_Accepted && !x.TLCutSH_Closed).AsQueryable(); } if (parameters.Departments.Count != 0) { var DeptPredicate = PredicateBuilder.False <TLCUT_CutSheet>(); foreach (var Dept in parameters.Departments) { var temp = Dept; DeptPredicate = DeptPredicate.Or(s => s.TLCutSH_Department_FK == Dept.Dep_Id); } CS = CS.AsExpandable().Where(DeptPredicate); } if (parameters.Qualities.Count != 0) { var CSPredicate = PredicateBuilder.False <TLCUT_CutSheet>(); foreach (var CSR in parameters.Qualities) { var temp = CSR; CSPredicate = CSPredicate.Or(s => s.TLCutSH_Quality_FK == temp.TLGreige_Id); } CS = CS.AsExpandable().Where(CSPredicate); } if (parameters.Colours.Count != 0) { var CSColourPredicate = PredicateBuilder.False <TLCUT_CutSheet>(); foreach (var Colour in parameters.Colours) { var temp = Colour; CSColourPredicate = CSColourPredicate.Or(s => s.TLCutSH_Colour_FK == temp.Col_Id); } CS = CS.AsExpandable().Where(CSColourPredicate); } return(CS); }
public frmQaReportSelection() { InitializeComponent(); parms = new CuttingQueryParameters(); repo = new CuttingRepository(); //-------------------------------------------------------- // wire up the check state changed event //-------------------------------------------------------------------------------------------------------- this.cmboCutSheets.CheckStateChanged += new System.EventHandler(this.cmboQAResults_CheckStateChanged); this.cmboStyles.CheckStateChanged += new System.EventHandler(this.cmboStyles_CheckStateChanged); this.cmboSizes.CheckStateChanged += new System.EventHandler(this.cmboSizes_CheckStateChanged); }
public IQueryable <TLCUT_CutSheet> SelectCustSheetsByLocation(CuttingQueryParameters parameters) { var CS = _context.TLCUT_CutSheet.Where(x => x.TLCutSH_Date >= parameters.FromDate && x.TLCutSH_Date <= parameters.ToDate).AsQueryable(); if (parameters.Departments.Count != 0) { var DeptPredicate = PredicateBuilder.False <TLCUT_CutSheet>(); foreach (var Dept in parameters.Departments) { var temp = Dept; DeptPredicate = DeptPredicate.Or(s => s.TLCutSH_Department_FK == temp.Dep_Id); } CS = CS.AsExpandable().Where(DeptPredicate); } return(CS); }
private void frmSelWipCutting_Load(object sender, EventArgs e) { formloaded = false; core = new Util(); parms = new CuttingQueryParameters(); _RepSortOption = 1; chkAllWIP.Checked = true; dtpFromDate.Value = DateTime.Now; dtpToDate.Value = DateTime.Now; using (var context = new TTI2Entities()) { var Existing = context.TLADM_Griege.OrderBy(x => x.TLGreige_Description).ToList(); foreach (var Row in Existing) { cmboQuality.Items.Add(new Cutting.CheckComboBoxItem(Row.TLGreige_Id, Row.TLGreige_Description, false)); } var Colours = context.TLADM_Colours.ToList(); foreach (var Colour in Colours) { cmboColour.Items.Add(new Cutting.CheckComboBoxItem(Colour.Col_Id, Colour.Col_Display, false)); } var Depts = context.TLADM_Departments.Where(x => x.Dep_IsCut).OrderBy(x => x.Dep_Description).ToList(); foreach (var Dep in Depts) { cmboDepartments.Items.Add(new Cutting.CheckComboBoxItem(Dep.Dep_Id, Dep.Dep_Description, false)); } } var reportOptions = new BindingList <KeyValuePair <int, string> >(); reportOptions.Add(new KeyValuePair <int, string>(1, "Cut Sheet Number")); reportOptions.Add(new KeyValuePair <int, string>(2, "Colour")); reportOptions.Add(new KeyValuePair <int, string>(3, "Style")); cmboReportOptions.DataSource = reportOptions; cmboReportOptions.ValueMember = "Key"; cmboReportOptions.DisplayMember = "Value"; cmboReportOptions.SelectedIndex = -1; formloaded = true; }
public IQueryable <TLCUT_CutSheetReceipt> SelectCSReceipts(CuttingQueryParameters parameters) { var CSRep = _context.TLCUT_CutSheetReceipt.Where(x => x.TLCUTSHR_InBundleStore && !x.TLCUTSHR_Issued).AsQueryable(); if (parameters.CutSheetReceipts.Count > 0) { var CSPredicate = PredicateBuilder.False <TLCUT_CutSheetReceipt>(); foreach (var CSR in parameters.CutSheetReceipts) { var temp = CSR; CSPredicate = CSPredicate.Or(s => s.TLCUTSHR_Pk == temp.TLCUTSHR_Pk); } CSRep = CSRep.AsExpandable().Where(CSPredicate); } return(CSRep); }
public IQueryable <TLCUT_CutSheetReceipt> SelCutReceiptByLoc(CuttingQueryParameters parameters) { var CutRec = _context.TLCUT_CutSheetReceipt.Where(x => !x.TLCUTSHR_Issued && x.TLCUTSHR_InPanelStore).AsQueryable(); if (parameters.WareHouses.Count != 0) { var WhsePredicate = PredicateBuilder.False <TLCUT_CutSheetReceipt>(); foreach (var Whse in parameters.WareHouses) { var temp = Whse; WhsePredicate = WhsePredicate.Or(s => s.TLCUTSHR_WhsePanStore_FK == temp.WhStore_Id); } CutRec = CutRec.AsExpandable().Where(WhsePredicate); } return(CutRec); }
public IQueryable <TLKNI_GreigeProduction> SelectGreigeProduction(CuttingQueryParameters parameters) { var Entries = (from GP in _context.TLKNI_GreigeProduction join DBD in _context.TLDYE_DyeBatchDetails on GP.GreigeP_Pk equals DBD.DYEBD_GreigeProduction_FK where GP.GreigeP_BoughtIn && !DBD.DYEBO_CutSheet select GP).AsQueryable(); if (parameters.GreigeProd.Count != 0) { var GriegePredicate = PredicateBuilder.False <TLKNI_GreigeProduction>(); foreach (var Prod in parameters.GreigeProd) { var temp = Prod; GriegePredicate = GriegePredicate.Or(s => s.GreigeP_Pk == temp.GreigeP_Pk); } Entries = Entries.AsExpandable().Where(GriegePredicate); } return(Entries); }
private void frmSelBundleStore_Load(object sender, EventArgs e) { QueryParms = new CuttingQueryParameters(); formloaded = false; using (var context = new TTI2Entities()) { var CSR = context.TLCUT_CutSheetReceipt.Where(x => x.TLCUTSHR_InBundleStore && !x.TLCUTSHR_Issued); foreach (var Record in CSR) { var CutSheet = context.TLCUT_CutSheet.Find(Record.TLCUTSHR_CutSheet_FK); if (CutSheet != null && !CutSheet.TLCutSH_Closed) { cmboCutSheets.Items.Add(new Cutting.CheckComboBoxItem(Record.TLCUTSHR_Pk, CutSheet.TLCutSH_No, false)); } } } formloaded = true; }
public IQueryable <TLCSV_StockOnHand> FromWareHouse(CuttingQueryParameters parameters) { var FmWhse = _context.TLCSV_StockOnHand.Where(x => x.TLSOH_WareHouse_FK == parameters.FromWhse && !x.TLSOH_Picked).AsQueryable(); if (parameters.Styles.Count() > 0) { var stylePredicate = PredicateBuilder.False <TLCSV_StockOnHand>(); foreach (var style in parameters.Styles) { var temp = style; stylePredicate = stylePredicate.Or(s => s.TLSOH_Style_FK == temp.Sty_Id); } FmWhse = FmWhse.AsExpandable().Where(stylePredicate); } if (parameters.Colours.Count() > 0) { var colourPredicate = PredicateBuilder.False <TLCSV_StockOnHand>(); foreach (var style in parameters.Colours) { var temp = style; colourPredicate = colourPredicate.Or(s => s.TLSOH_Colour_FK == temp.Col_Id); } FmWhse = FmWhse.AsExpandable().Where(colourPredicate); } if (parameters.Sizes.Count() > 0) { var sizePredicate = PredicateBuilder.False <TLCSV_StockOnHand>(); foreach (var style in parameters.Sizes) { var temp = style; sizePredicate = sizePredicate.Or(s => s.TLSOH_Size_FK == temp.SI_id); } FmWhse = FmWhse.AsExpandable().Where(sizePredicate); } return(FmWhse); }
public IQueryable <TLCUT_QCBerrie> SelectQCBerrie(CuttingQueryParameters parameters) { var QCBerrie = _context.TLCUT_QCBerrie.Where(x => x.TLQCFB_Measure1 != 0 || x.TLQCFB_Measure10 != 0 || x.TLQCFB_Measure11 != 0 || x.TLQCFB_Measure2 != 0 || x.TLQCFB_Measure3 != 0 || x.TLQCFB_Measure4 != 0 || x.TLQCFB_Measure5 != 0 || x.TLQCFB_Measure6 != 0 || x.TLQCFB_Measure7 != 0 || x.TLQCFB_Measure8 != 0 || x.TLQCFB_Measure9 != 0).AsQueryable(); if (parameters.CutSheetReceipts.Count != 0) { var CutSheetPredicate = PredicateBuilder.False <TLCUT_QCBerrie>(); foreach (var Receipt in parameters.CutSheetReceipts) { var temp = Receipt; CutSheetPredicate = CutSheetPredicate.Or(s => s.TLQCFB_CutSheetReceipt_FK == temp.TLCUTSHR_Pk); } QCBerrie = QCBerrie.AsExpandable().Where(CutSheetPredicate); } if (parameters.Operators.Count != 0) { var OperatorsPredicate = PredicateBuilder.False <TLCUT_QCBerrie>(); foreach (var Operator in parameters.Operators) { var temp = Operator; OperatorsPredicate = OperatorsPredicate.Or(s => s.TLQCFB_Operator_FK == temp.MachOp_Pk); } QCBerrie = QCBerrie.AsExpandable().Where(OperatorsPredicate); } return(QCBerrie); }
private void frmCreatePickingList_Load(object sender, EventArgs e) { FormLoaded = false; using (var context = new TTI2Entities()) { cmboFromwarehouse.DataSource = context.TLADM_WhseStore.Where(x => !x.WhStore_WhseOrStore).ToList(); cmboFromwarehouse.DisplayMember = "WhStore_Description"; cmboFromwarehouse.ValueMember = "WhStore_Id"; cmboFromwarehouse.SelectedItem = -1; cmboTowareHouse.DataSource = context.TLADM_WhseStore.Where(x => !x.WhStore_WhseOrStore).ToList(); cmboTowareHouse.DisplayMember = "WhStore_Description"; cmboTowareHouse.ValueMember = "WhStore_Id"; cmboTowareHouse.SelectedItem = -1; var Styles = context.TLADM_Styles.OrderBy(x => x.Sty_Description).ToList(); foreach (var Style in Styles) { cmboStyle.Items.Add(new Cutting.CheckComboBoxItem(Style.Sty_Id, Style.Sty_Description, false)); } var Colours = context.TLADM_Colours.OrderBy(x => x.Col_Display).ToList(); foreach (var Colour in Colours) { cmboColour.Items.Add(new Cutting.CheckComboBoxItem(Colour.Col_Id, Colour.Col_Display, false)); } var Sizes = context.TLADM_Sizes.OrderBy(x => x.SI_DisplayOrder).ToList(); foreach (var Size in Sizes) { cmboSizes.Items.Add(new Cutting.CheckComboBoxItem(Size.SI_id, Size.SI_Description, false)); } } QueryParms = new CuttingQueryParameters(); TransferMode = false; btnSubmit.Text = "Submit"; FormLoaded = true; }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; var TransNo = 0; if (oBtn != null && FormLoaded) { var Origin = (TLADM_CottonOrigin)cmboCountry.SelectedItem; if (Origin == null) { MessageBox.Show("Please select a Country of Origin"); return; } var Greige = (TLADM_Griege)cmboGreige.SelectedItem; if (Greige == null) { MessageBox.Show("Please select a quality"); return; } var CurrentStore = (TLADM_WhseStore)cmboStore.SelectedItem; if (CurrentStore == null) { MessageBox.Show("Please select a store"); return; } var Machine = (TLADM_MachineDefinitions)cmboMachine.SelectedItem; if (Machine == null) { MessageBox.Show("Please select a machine"); return; } var Colour = (TLADM_Colours)cmboColour.SelectedItem; if (Colour == null) { MessageBox.Show("Please select a colour"); return; } TransNo = core.CenturyDayNumber(DateTime.Now) + DateTime.Now.Hour + DateTime.Now.Minute; using (var context = new TTI2Entities()) { foreach (DataGridViewRow Row in dataGridView1.Rows) { if (Row.Cells[0].Value == null) { continue; } TLKNI_BoughtInFabric BoughtIn = new TLKNI_BoughtInFabric(); BoughtIn.TLBIN_COfOrigin_FK = Origin.CottonOrigin_Pk; BoughtIn.TLBIN_CurrentStore_FK = CurrentStore.WhStore_Id; BoughtIn.TLBIN_TransDate = TransDate.Value; BoughtIn.TLBIN_Greige_FK = Greige.TLGreige_Id; BoughtIn.TLBIN_Machine_FK = Machine.MD_Pk; BoughtIn.TLBIN_TTS_PN = (string)Row.Cells[0].Value; BoughtIn.TLBIN_Their_PN = (string)Row.Cells[1].Value; BoughtIn.TLBIN_Colour_FK = (int)cmboColour.SelectedValue; BoughtIn.TLBIN_Dsk_Weight = (decimal)Row.Cells[2].Value; BoughtIn.TLBIN_Dsk_Width = (decimal)Row.Cells[3].Value; BoughtIn.TLBIN_Nett_Weight = (decimal)Row.Cells[4].Value; BoughtIn.TLBIN_Meters_Roll = (decimal)Row.Cells[5].Value; BoughtIn.TLBIN_TransNumber = TransNo; context.TLKNI_BoughtInFabric.Add(BoughtIn); try { context.SaveChanges(); } catch (Exception ex) { } //we need to store further information in a separate file for the processing in the Dye Module //----------------------------------------------------------------------------------------------------------- TLKNI_GreigeProduction gp = new TLKNI_GreigeProduction(); gp.GreigeP_Captured = true; gp.GreigeP_BoughtIn = true; gp.GreigeP_KnitO_Fk = BoughtIn.TLBIN_Pk; // Provides a link to the original transaction gp.GreigeP_Grade = "A"; gp.GreigeP_InspDate = TransDate.Value; gp.GreigeP_Inspected = true; gp.GreigeP_Meas1 = 0; gp.GreigeP_Meas2 = 0; gp.GreigeP_Meas3 = 0; gp.GreigeP_Meas4 = 0; gp.GreigeP_Meas5 = 0; gp.GreigeP_Meas6 = 0; gp.GreigeP_Meas7 = 0; gp.GreigeP_Meas8 = 0; gp.GreigeP_PDate = DateTime.Now; gp.GreigeP_PieceNo = (string)Row.Cells[0].Value; gp.GreigeP_BoughtIn_FabWeight = (decimal)Row.Cells[2].Value; gp.GreigeP_BoughtIn_FabWidth = (decimal)Row.Cells[3].Value; gp.GreigeP_weight = (decimal)Row.Cells[4].Value; gp.GreigeP_weightAvail = (decimal)Row.Cells[5].Value; gp.GreigeP_Store_FK = CurrentStore.WhStore_Id; gp.GreigeP_Greige_Fk = Greige.TLGreige_Id; gp.GreigeP_BIFColour_FK = BoughtIn.TLBIN_Colour_FK; gp.GreigeP_BoughtIn_Fk = BoughtIn.TLBIN_Pk; gp.GreigeP_Meters = BoughtIn.TLBIN_Meters_Roll; context.TLKNI_GreigeProduction.Add(gp); } try { context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); Cutting.CuttingQueryParameters QParms = new CuttingQueryParameters(); QParms.BIFTransNumber = TransNo; frmCutViewRep vRep = new frmCutViewRep(19, QParms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); vRep = new frmCutViewRep(20, QParms); h = Screen.PrimaryScreen.WorkingArea.Height; w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); frmBoughtInFabric_Load(this, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; QueryParms = new CuttingQueryParameters(); repo = new CuttingRepository(); if (oBtn != null) { DateTime FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); DateTime ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); ToDate = ToDate.AddHours(23); QueryParms.FromDate = FromDate; QueryParms.ToDate = ToDate; if (_ProductionResults) { if (chkProductionResults.Checked) { QueryParms.ProductionResults = true; } frmCutViewRep vRep = new frmCutViewRep(18, QueryParms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } else { using (var context = new TTI2Entities()) { foreach (DataGridViewRow Row in dataGridView1.Rows) { if ((bool)Row.Cells[1].Value == false) { continue; } var Pk = (int)Row.Cells[0].Value; var Cutsheet = context.TLCUT_CutSheet.Find(Pk); if (Cutsheet != null) { Cutsheet.TLCUTSH_RequiredDate = dtpFromDate.Value; } } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } } }