private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (cmboReportOptions.SelectedValue != null) { repOps.DO_OptionSelected = Int32.Parse(cmboReportOptions.SelectedValue.ToString()); } else { repOps.DO_OptionSelected = 0; } if (chkException.Checked) { repOps.ExceptionOnly = true; repOps.Percentage_Exception = Convert.ToInt32(txtPercentage.Text); } repOps.fromDate = DateTime.Parse(dtpFromDate.Value.ToShortDateString()); repOps.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); frmDyeViewReport vRep = new frmDyeViewReport(24, repOps); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); repOps = new DyeReportOptions(); chkException.Checked = false; } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null) { DateTime FDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); DateTime TDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); TDate = TDate.AddHours(23); DyeReportOptions repOps = new DyeReportOptions(); repOps.fromDate = FDate; repOps.toDate = TDate; if (chkProdResults.Checked) { repOps.ProductionResults = true; } frmDyeViewReport vRep = new frmDyeViewReport(43, repOps); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (rbAll.Checked) { repOpts.DYEPFirstT = true; } else if (rbReprocess.Checked) { repOpts.DYEPReprocessed = true; } else if (rbAll.Checked) { repOpts.DYEPAll = true; } repOpts.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); repOpts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); repOpts.toDate = repOpts.toDate.AddHours(23.00); frmDyeViewReport viewRep = new frmDyeViewReport(31, repOpts); viewRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null) { using (var context = new TTI2Entities()) { if (DyeOrderReprint) { var DyeOrder = context.TLDYE_DyeOrder.Where(x => x.TLDYO_DyeOrderNum == txtInput.Text).FirstOrDefault(); if (DyeOrder == null) { MessageBox.Show("Dye Order as entered not found"); txtInput.Text = string.Empty; return; } frmDyeViewReport vRep = new frmDyeViewReport(3, DyeOrder.TLDYO_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } else { var DyeBatch = context.TLDYE_DyeBatch.Where(x => x.DYEB_BatchNo == txtInput.Text).FirstOrDefault(); if (DyeBatch == null) { MessageBox.Show("Dye Batch as entered not found"); txtInput.Text = string.Empty; return; } frmDyeViewReport vRep = new frmDyeViewReport(4, DyeBatch.DYEB_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); DialogResult Result = MessageBox.Show("Would you like to print the transfer tickets", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.Yes) { vRep = new frmDyeViewReport(5, DyeBatch.DYEB_Pk); h = Screen.PrimaryScreen.WorkingArea.Height; w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { DyeReportOptions repOptions = new DyeReportOptions(); repOptions.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); repOptions.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); repOptions.toDate = repOptions.toDate.AddHours(23); var selected = (TLADM_MachineDefinitions)cmboMachines.SelectedItem; if (selected != null) { repOptions.DYEMPMachineSelected = selected.MD_Pk; } if (rbFirstTime.Checked) { repOptions.DYEMPProdType = 1; } else if (rbOwnReprocessing.Checked) { repOptions.DYEMPProdType = 2; } else { repOptions.DYEMPProdType = 3; } if (rbModeSummary.Checked) { repOptions.DYEMPReportType = 1; } else { repOptions.DYEMPReportType = 2; } if (cmboReportOptions.SelectedValue != null) { repOptions.DYEMPSortOptions = int.Parse(cmboReportOptions.SelectedValue.ToString()); } else { repOptions.DYEMPSortOptions = 1; }; frmDyeViewReport vRep = new frmDyeViewReport(34, repOptions); vRep.ShowDialog(this); cmboMachines.SelectedIndex = -1; cmboReportOptions.SelectedIndex = -1; } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (cmboReportOptions.SelectedValue != null) { QueryParms.DO_OptionSelected = Int32.Parse(cmboReportOptions.SelectedValue.ToString()); } else { QueryParms.DO_OptionSelected = 1; } QueryParms.FromDate = DateTime.Parse(dtpFromDate.Value.ToShortDateString()); QueryParms.ToDate = DateTime.Parse(dtpToDate.Value.ToShortDateString()); QueryParms.ToDate = QueryParms.ToDate.AddHours(23); if (rbAll.Checked) { QueryParms.RejectedBatches = false; } else { QueryParms.RejectedBatches = true; } if (_Stage == 3) //Stage 3 Colour Matching after Dyeing { frmDyeViewReport vRep = new frmDyeViewReport(28, QueryParms); vRep.ShowDialog(this); } else if (_Stage == 4) //Stage 4 Stability Check after Drying; { frmDyeViewReport vRep = new frmDyeViewReport(32, QueryParms); vRep.ShowDialog(this); } else //Stage 5 Results Check after Compacting; { frmDyeViewReport vRep = new frmDyeViewReport(33, QueryParms); vRep.ShowDialog(this); } cmboCause.Items.Clear(); cmboColour.Items.Clear(); cmboDyeMachine.Items.Clear(); cmboDyeOperator.Items.Clear(); cmboQuality.Items.Clear(); cmboRemedy.Items.Clear(); this.frmShadeAfterDyeing_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Util core = new Util(); DyeReportOptions dro = new DyeReportOptions(); //------------------------------------------------------------ // if (rbGarmentsOnly.Checked) { dro.SelGarments = true; } else if (rbFabricOnly.Checked) { dro.SelFabric = true; } else if (rbBoth.Checked) { dro.SelBoth = true; } if (rbAdditionalBoth.Checked) { dro.DO_Both = true; } else if (rbOrderOpen.Checked) { dro.DO_Open = true; } else if (rbOrderClosed.Checked) { dro.DO_Closed = true; } if (cmboReportOptions.SelectedValue != null) { dro.DO_OptionSelected = int.Parse(cmboReportOptions.SelectedValue.ToString()); if (dro.DO_OptionSelected == 0) { dro.DO_ByOrderNo = true; } } else { dro.DO_ByOrderNo = true; } frmDyeViewReport vRep = new frmDyeViewReport(14, dro); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { DyeReportOptions repOpts = new DyeReportOptions(); repOpts.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); repOpts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); repOpts.toDate = repOpts.toDate.AddHours(23); frmDyeViewReport vRep = new frmDyeViewReport(36, repOpts); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (groupBox2.Visible) { repOps.FabricToQ = true; if (radFirstTime.Checked) { repOps.FirstTime = true; } else { repOps.FirstTime = false; } } else { repOps.FirstTime = false; repOps.FabricToStore = true; if (_RepNumber == 3) { repOps.FabricToStore = false; repOps.FabricNotFinished = true; } } if (chkQASummary.Checked) { repOps.QASummary = true; } repOps.fromDate = Convert.ToDateTime(dtFromDate.Value.ToShortDateString()); repOps.toDate = Convert.ToDateTime(dtToDate.Value.ToShortDateString()); repOps.toDate = repOps.toDate.AddHours(23.00); frmDyeViewReport vRep = new frmDyeViewReport(31, repOps); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); repOps = new DyeReportOptions(); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { DyeReportOptions DOpts = new DyeReportOptions(); DOpts.fromDate = DateTime.Parse(dtpFromDate.Value.ToShortDateString()); DOpts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); frmDyeViewReport vRep = new frmDyeViewReport(23, DOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { frmDyeViewReport vRep = new frmDyeViewReport(1, parms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); this.cmboColours.Items.Clear(); this.cmboQualities.Items.Clear(); this.cmboReceipeDefintions.Items.Clear(); frmSelReceipeDefinitions_Load(this, null); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var oDgv = sender as DataGridView; if (oDgv.Focused && oDgv.CurrentCell is DataGridViewCheckBoxCell) { bool isChecked = (bool)oDgv[e.ColumnIndex, e.RowIndex].EditedFormattedValue; if (isChecked) { using (var context = new TTI2Entities()) { var CurrentRow = oDgv.CurrentRow; var Pk = (int)CurrentRow.Cells[0].Value; frmDyeViewReport vRep = new frmDyeViewReport(4, Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); DialogResult Result = MessageBox.Show("Would you like to print the transfer tickets", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.Yes) { vRep = new frmDyeViewReport(5, Pk); h = Screen.PrimaryScreen.WorkingArea.Height; w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } var SingleRow = (from Rows in dataGridView1.Rows.Cast <DataGridViewRow>() where (bool)Rows.Cells[1].Value == true select Rows).FirstOrDefault(); if (SingleRow != null) { SingleRow.Cells[1].Value = false; } } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { if (repOps.stkWhseSelected == false && repOps.stkTakeCategorySelected == false && repOps.stkTypeSelected == false) { MessageBox.Show("Please select one option from the drop down box"); return; } frmDyeViewReport vRep = new frmDyeViewReport(25, repOps); vRep.ShowDialog(this); repOps = new DyeReportOptions(); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { DyeHouse.DyeRepository repo = new DyeRepository(); DyeHouse.DyeQueryParameters QueryParms = new DyeQueryParameters(); QueryParms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); QueryParms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); QueryParms.ToDate = QueryParms.ToDate.AddHours(23); frmDyeViewReport vRep = new frmDyeViewReport(44, QueryParms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { var selected = (TLDYE_DyeBatch)cmboTransferTickets.SelectedItem; if (selected == null) { MessageBox.Show("Please select a batch number from the drop down box"); return; } frmDyeViewReport vRep = new frmDyeViewReport(5, selected.DYEB_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (cmboReportOptions.SelectedValue != null) { repOps.DO_OptionSelected = Int32.Parse(cmboReportOptions.SelectedValue.ToString()); } else { repOps.DO_OptionSelected = 0; } frmDyeViewReport vRep = new frmDyeViewReport(29, repOps); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && FormLoad) { if (cmboReportOptions.SelectedValue != null) { repOps.DO_OptionSelected = Int32.Parse(cmboReportOptions.SelectedValue.ToString()); } else { repOps.DO_OptionSelected = 0; } if (rbFabFS.Checked) { repOps.FabricStore = true; } if (rbFabQS.Checked) { repOps.FabricQSStore = true; } if (rbFabRS.Checked) { repOps.FabricRejectStore = true; } if (rbStandard.Checked) { repOps.FabricType = true; } repOps.ShowIndvidualNo = false; frmDyeViewReport vRep = new frmDyeViewReport(22, repOps); vRep.ShowDialog(this); repOps = new DyeReportOptions(); } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { using (var context = new TTI2Entities()) { foreach (DataGridViewRow row in dataGridView1.Rows) { if ((bool)row.Cells[7].Value == false) { var index = (int)row.Cells[0].Value; var Record = context.TLDYE_DyeBatchDetails.Find(index); if (Record != null) { Record.DYEBO_DateSold = null; Record.DYEBO_Sold = false; Record.DYEBO_TransactionNo = string.Empty; } } } try { context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); string transnumber = cmboPendingSales.SelectedValue.ToString(); frmDyeViewReport vRep = new frmDyeViewReport(18, transnumber); vRep.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnProcess_Click(object sender, EventArgs e) { IList <DyeProductionDetails> prodDetail = new List <DyeProductionDetails>(); Button oBtn = sender as Button; if (oBtn != null && formloaded) { foreach (var Batch in QueryParms.DyeBatches) { DyeProductionDetails prodDet = new DyeProductionDetails(); prodDet.GreigePk = Batch.DYEB_Greige_FK; prodDet.ColorPk = Batch.DYEB_Colour_FK; prodDet.PlannedProd = Batch.DYEB_BatchKG; prodDet.DyeBatchPk = Batch.DYEB_Pk; prodDetail.Add(prodDet); } frmDyeViewReport vRep = new frmDyeViewReport(37, prodDetail); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { DyeReportOptions RepOptions = new DyeReportOptions(); RepOptions.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); RepOptions.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); RepOptions.toDate = RepOptions.toDate.AddHours(23); var selected = (TLADM_MachineDefinitions)cmboMachines.SelectedItem; if (selected != null) { RepOptions.ResEficMachine = selected.MD_Pk; } if (rbDyeFirstTime.Checked) { RepOptions.ResEfficTrans = true; } var FTSelected = (TLADM_FabricProduct)cmboFabricType.SelectedItem; if (FTSelected != null) { RepOptions.ResFabType = FTSelected.FP_Id; } frmDyeViewReport ViewRep = new frmDyeViewReport(35, RepOptions); ViewRep.ShowDialog(this); formloaded = false; cmboFabricType.SelectedIndex = -1; cmboMachines.SelectedIndex = -1; formloaded = true; } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView oDgv = sender as DataGridView; if (oDgv.Focused && oDgv.CurrentCell is DataGridViewCheckBoxCell) { bool isChecked = (bool)oDgv[e.ColumnIndex, e.RowIndex].EditedFormattedValue; if (isChecked) { using (var context = new TTI2Entities()) { var CurrentRow = oDgv.CurrentRow; var Pk = (int)CurrentRow.Cells[0].Value; frmDyeViewReport vRep = new frmDyeViewReport(3, Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null) { QueryParms = new DyeQueryParameters(); QueryParms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); QueryParms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); QueryParms.ToDate = QueryParms.ToDate.AddHours(23); if (chkProductionResults.Checked) { QueryParms.CalculateProdResults = true; } frmDyeViewReport vRep = new frmDyeViewReport(43, QueryParms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { try { frmDyeViewReport vRep = new frmDyeViewReport(10, QueryParms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { cmboColour.Items.Clear(); cmboCustomers.Items.Clear(); cmboGreige.Items.Clear(); cmboStyle.Items.Clear(); this.frmDyeOrdersSelection_Load(this, null); } }
private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var WhseIssue = (TLADM_WhseStore)cmboIssueDepartment.SelectedItem; if (WhseIssue == null) { MessageBox.Show("Please select a Chemical Store from the list provided"); return; } var WhseReceiving = (TLADM_WhseStore)cmboReceivingDepartment.SelectedItem; if (WhseReceiving == null) { MessageBox.Show("Please select a Dye Kitchen from the list provided"); return; } using (var context = new TTI2Entities()) { var LNU = context.TLADM_LastNumberUsed.Find(3); LNU.col12 += 1; foreach (DataGridViewRow row in dataGridView1.Rows) { if (!(bool)row.Cells[1].Value) { continue; } var index = (int)row.Cells[0].Value; //--------------------------------------- // 1st decision //------------------------------------------------------- TLDYE_ConsumableSOH newSOH = new TLDYE_ConsumableSOH(); newSOH = context.TLDYE_ConsumableSOH.Where(x => x.DYCSH_WhseStore_FK == WhseReceiving.WhStore_Id && x.DYCSH_Consumable_FK == index).FirstOrDefault(); if (newSOH == null) { newSOH = new TLDYE_ConsumableSOH(); newSOH.DYCSH_StockOnHand = (decimal)row.Cells[4].Value; newSOH.DYCSH_TransNumber = -1 + LNU.col12; newSOH.DYCSH_Consumable_FK = (int)row.Cells[5].Value; newSOH.DYCSH_WhseStore_FK = WhseReceiving.WhStore_Id; newSOH.DYCSH_DyeKitchen = WhseReceiving.WhStore_DyeKitchen; context.TLDYE_ConsumableSOH.Add(newSOH); } else { newSOH.DYCSH_StockOnHand += (decimal)row.Cells[4].Value; } TLDYE_ConsumableSOH oldSOH = new TLDYE_ConsumableSOH(); oldSOH = context.TLDYE_ConsumableSOH.Find(index); if (oldSOH != null) { oldSOH.DYCSH_StockOnHand -= (Decimal)row.Cells[4].Value; } } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); DyeReportOptions opts = new DyeReportOptions(); opts.fromDate = DateTime.Now; opts.LNU = -1 + LNU.col12; opts.toStore = WhseReceiving.WhStore_Id; TLADM_WhseStore FromWhse = context.TLADM_WhseStore.Where(x => x.WhStore_Code.Contains("CS")).FirstOrDefault(); opts.fromStore = FromWhse.WhStore_Id; frmDyeViewReport vRep = new frmDyeViewReport(30, opts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var ErrM = core.returnMessage(MandSelected, false, MandatoryFields); if (!String.IsNullOrEmpty(ErrM)) { MessageBox.Show(ErrM); return; } using (var context = new TTI2Entities()) { if (Add) { var LNU = context.TLADM_LastNumberUsed.Find(3); if (LNU != null) { LNU.col4 += 1; } } TLDYE_ComDyeBatch cb = new TLDYE_ComDyeBatch(); if (!Add) { var Prev = (TLDYE_ComDyeBatch)cmboPrevBatches.SelectedItem; if (Prev != null) { cb = context.TLDYE_ComDyeBatch.Find(Prev.DYEBC_Pk); } } cb.DYEBC_BatchDate = dtpBatchDate.Value; cb.DYEBC_BatchNo = txtBatchNo.Text; cb.DYEBC_DateOrder = dtpDateOrdered.Value; cb.DYEBC_DateRequired = dtpDateOrdered.Value; cb.DYEBC_Greige_FK = (int)cmboGreige.SelectedValue; cb.DYEBC_Trim_Fk = (int)cmboTrims.SelectedValue; cb.DYEBC_Customer_FK = (int)cmboCustomer.SelectedValue; cb.DYEBC_Colour_FK = (int)cmboColours.SelectedValue; var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("DYE")).FirstOrDefault(); if (Dept != null) { var TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 300).FirstOrDefault(); if (TranType != null) { cb.DYEBC_TransactionType = TranType.TrxT_Pk; } } if (Add) { context.TLDYE_ComDyeBatch.Add(cb); try { context.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException en) { foreach (var eve in en.EntityValidationErrors) { MessageBox.Show("following validation errors: Type" + eve.Entry.Entity.GetType().Name.ToString() + "State " + eve.Entry.State.ToString()); foreach (var ve in eve.ValidationErrors) { MessageBox.Show("- Property" + ve.PropertyName + " Message " + ve.ErrorMessage); } } } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[1].Value.ToString() == bool.FalseString) { continue; } var index = (int)row.Cells[0].Value; TLKNI_GreigeCommissionTransctions rec = context.TLKNI_GreigeCommissionTransctions.Find(index); if (rec != null) { rec.GreigeCom_Batched = true; rec.GreigeCom_DyeBatch_FK = cb.DYEBC_Pk; } TLDYE_ComDyeBatchDetails cdb = new TLDYE_ComDyeBatchDetails(); cdb.TLCDD_PieceNo_FK = rec.GreigeCom_PK; cdb.TLCDD_ComDyeBatch_FK = cb.DYEBC_Pk; context.TLDYE_ComDyeBatchDetails.Add(cdb); } try { context.SaveChanges(); MessageBox.Show("Data saved to database successfully"); frmDyeViewReport vrep = new frmDyeViewReport(9, cb.DYEBC_Pk); vrep.ShowDialog(this); SetUp(); } catch (System.Data.Entity.Validation.DbEntityValidationException en) { foreach (var eve in en.EntityValidationErrors) { MessageBox.Show("following validation errors: Type" + eve.Entry.Entity.GetType().Name.ToString() + "State " + eve.Entry.State.ToString()); foreach (var ve in eve.ValidationErrors) { MessageBox.Show("- Property" + ve.PropertyName + " Message " + ve.ErrorMessage); } } } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView oDgv = sender as DataGridView; if (oDgv.Focused && oDgv.CurrentCell is DataGridViewCheckBoxCell) { TLDYE_DyeBatch db = new TLDYE_DyeBatch(); using (var context = new TTI2Entities()) { int DyeBatchKey = (int)oDgv.CurrentRow.Cells[0].Value; db = context.TLDYE_DyeBatch.Find(DyeBatchKey); if (db != null) { db.DYEB_Transfered = true; db.DYEB_TransferDate = dtpTransferDate.Value; var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("DYE")).FirstOrDefault(); if (Dept != null) { var TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 300).FirstOrDefault(); if (TranType != null) { db.DYEB_TransactionType_FK = TranType.TrxT_Pk; } } TLDYE_DyeTransactions dt = new TLDYE_DyeTransactions(); dt.TLDYET_BatchNo = db.DYEB_BatchNo; dt.TLDYET_BatchWeight = db.DYEB_BatchKG; dt.TLDYET_Date = dtpTransferDate.Value; dt.TLDYET_SequenceNo = db.DYEB_SequenceNo; dt.TLDYET_TransactionType = db.DYEB_TransactionType_FK; dt.TLDYET_Batch_FK = db.DYEB_Pk; dt.TLDYET_Stage = 2; dt.TLDYET_CurrentStore_FK = (int)context.TLADM_TranactionType.Find(db.DYEB_TransactionType_FK).TrxT_ToWhse_FK; context.TLDYE_DyeTransactions.Add(dt); var DBD = context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_DyeBatch_FK == db.DYEB_Pk).ToList(); foreach (var rowx in DBD) { rowx.DYEBO_CurrentStore_FK = dt.TLDYET_CurrentStore_FK; } try { context.SaveChanges(); frmDyeViewReport vRep = new frmDyeViewReport(8, DyeBatchKey); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } oDgv.Rows.RemoveAt(oDgv.CurrentRow.Index); } }
private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (!rbAllCustomers.Checked) { var selected = (TLADM_CustomerFile)cmboCustomer.SelectedItem; if (selected == null) { MessageBox.Show("Please select a customer record"); return; } } DyeReportOptions opts = new DyeReportOptions(); opts.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); opts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); opts.toDate = opts.toDate.AddHours(23.00); if (rbAllCustomers.Checked) { opts.AllCustomersSelected = true; } else { var select = (TLADM_CustomerFile)cmboCustomer.SelectedItem; opts.CustomerNumberSelected = select.Cust_Pk; opts.CustomerSelected = true; } if (rbDyeBatchPending.Checked) { opts.DBPending = true; } else { opts.DBWIP = true; } if (rbBatchNumber.Checked) { opts.SortByBatchNumber = true; } if (rbByQuality.Checked) { opts.SortByQuality = true; } if (rbSortByDate.Checked) { opts.SortByDate = true; } frmDyeViewReport vRep = new frmDyeViewReport(12, opts); vRep.ShowDialog(this); rbAllCustomers.Checked = false; } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; Decimal weight = 0.00M; bool AddRec = false; TLADM_TranactionType TranType = null; if (oBtn != null && formloaded) { var Select = (TLDYE_DyeBatch)cmboBatchNumber.SelectedItem; if (Select == null) { MessageBox.Show("Please select a batch number from the drop down box "); return; } using (var context = new TTI2Entities()) { var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "DYE").FirstOrDefault(); if (Dept != null) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1400).FirstOrDefault(); } foreach (DataGridViewRow row in dataGridView1.Rows) { TLDYE_DyeBatchDetails bd = new TLDYE_DyeBatchDetails(); int index = (int)row.Cells[0].Value; bd = context.TLDYE_DyeBatchDetails.Find(index); if (bd != null) { if ((bool)row.Cells[6].Value == true) { bd.DYEBO_Rejected = false; bd.DYEBO_RejectedDate = null; bd.DYEBO_QAApproved = true; bd.DYEBO_ApprovalDate = dtpTransDate.Value; if (bd.DYEBO_CutSheet) bd.DYEBO_CutSheet = false; weight += (decimal)row.Cells[5].Value; bd.DYEBO_CurrentStore_FK = (int)TranType.TrxT_ToWhse_FK; AddRec = true; } } } if (AddRec) { var LNU = context.TLADM_LastNumberUsed.Find(3); TLDYE_DyeTransactions tt = new TLDYE_DyeTransactions(); tt.TLDYET_BatchNo = Select.DYEB_BatchNo; tt.TLDYET_BatchWeight = Select.DYEB_BatchKG; tt.TLDYET_SequenceNo = Select.DYEB_SequenceNo; tt.TLDYET_Batch_FK = Select.DYEB_Pk; tt.TLDYET_TransactionNumber = "RFREV" + LNU.col7.ToString().PadLeft(6, '0'); tt.TLDYET_Date = dtpTransDate.Value; tt.TLDYET_TransactionWeight = weight; tt.TLDYET_TransactionType = (int)TranType.TrxT_Pk; tt.TLDYET_CurrentStore_FK = (int)TranType.TrxT_ToWhse_FK; context.TLDYE_DyeTransactions.Add(tt); try { LNU.col7 += 1; context.SaveChanges(); MessageBox.Show("Data successfully saved to the database"); frmDyeViewReport vRep = new frmDyeViewReport(11, tt.TLDYET_Pk, true); vRep.ShowDialog(this); frmRejectFabricReversal_Load(this, null); } catch (System.Data.Entity.Validation.DbEntityValidationException en) { foreach (var eve in en.EntityValidationErrors) { MessageBox.Show("following validation errors: Type" + eve.Entry.Entity.GetType().Name.ToString() + "State " + eve.Entry.State.ToString()); foreach (var ve in eve.ValidationErrors) { MessageBox.Show("- Property" + ve.PropertyName + " Message " + ve.ErrorMessage); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; bool Add = false; TLADM_QADyeProcess Stages = null; if (oBtn != null && formloaded) { var selected = (TLDYE_NonCompliance)cmboBatches.SelectedItem; if (selected != null) { if (dataGridView4.Rows.Count == 0) { MessageBox.Show("Please supply a non consumable description and quantity"); return; } using (var context = new TTI2Entities()) { if (rbPass.Checked || rbReprocess.Checked) { var DB = context.TLDYE_DyeBatch.Find(selected.TLDYE_NcrBatchNo_FK); if (DB != null) { Stages = (TLADM_QADyeProcess)cmboProcess.SelectedItem; if (rbPass.Checked) { if (Stages.QADYEP_Pk == 1) { DB.DYEB_Stage1 = true; } else if (Stages.QADYEP_Pk == 2) { DB.DYEB_Stage2 = true; } else { DB.DYEB_Stage3 = true; } } if (rbReprocess.Checked) { DB.DYEB_Reprocess = true; if (rbReprocess.Checked) { var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("DYE")).FirstOrDefault(); if (Dept != null) { TLDYE_DyeTransactions trns = new TLDYE_DyeTransactions(); trns.TLDYET_BatchNo = DB.DYEB_BatchNo; trns.TLDYET_BatchWeight = DB.DYEB_BatchKG; trns.TLDYET_Date = DateTime.Now; trns.TLDYET_SequenceNo = DB.DYEB_SequenceNo; trns.TLDYET_Batch_FK = DB.DYEB_Pk; trns.TLDYET_RejectDate = DateTime.Now; var TT = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 500).FirstOrDefault(); if (TT != null) { trns.TLDYET_TransactionType = TT.TrxT_Pk; trns.TLDYET_CurrentStore_FK = (int)TT.TrxT_ToWhse_FK; } context.TLDYE_DyeTransactions.Add(trns); } } } } } foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[1].Value.ToString() == bool.FalseString) { continue; } //-------------------------------------------------------------- // We dont want to update the same record twice //---------------------------------------------------------- var Value = (int)row.Cells[0].Value; var record = context.TLDYE_NonComplianceDetail.Where(x => x.DYENCRD_ComNumber == selected.TLDYE_NcrNumber && x.DYENCRD_Code_FK == Value && x.DYENCRD_FR).FirstOrDefault(); if (record != null) { continue; } TLDYE_NonComplianceDetail nonD = new TLDYE_NonComplianceDetail(); nonD.DYENCRD_BatchNo_Fk = selected.TLDYE_NcrBatchNo_FK; nonD.DYENCRD_FR = true; nonD.DYENCRD_Code_FK = (int)row.Cells[0].Value; nonD.DYENCRD_ComNumber = selected.TLDYE_NcrNumber; context.TLDYE_NonComplianceDetail.Add(nonD); } foreach (DataGridViewRow row in dataGridView2.Rows) { if (row.Cells[1].Value.ToString() == bool.FalseString) { continue; } //-------------------------------------------------------------- // We dont want to update the same record twice //---------------------------------------------------------- var Value = (int)row.Cells[0].Value; var record = context.TLDYE_NonComplianceDetail.Where(x => x.DYENCRD_ComNumber == selected.TLDYE_NcrNumber && x.DYENCRD_Code_FK == Value && !x.DYENCRD_FR).FirstOrDefault(); if (record != null) { continue; } TLDYE_NonComplianceDetail nonD = new TLDYE_NonComplianceDetail(); nonD.DYENCRD_BatchNo_Fk = selected.TLDYE_NcrBatchNo_FK; nonD.DYENCRD_FR = false; nonD.DYENCRD_Code_FK = (int)row.Cells[0].Value; nonD.DYENCRD_ComNumber = selected.TLDYE_NcrNumber; context.TLDYE_NonComplianceDetail.Add(nonD); } foreach (DataGridViewRow row in dataGridView3.Rows) { if (row.Cells[1].Value == null) { continue; } var Value = 0.00M; if (row.Cells[4].Value != null) { decimal.TryParse(row.Cells[4].Value.ToString(), out Value); } if (Value == 0.00M) { continue; } Add = false; TLDYE_NonComplianceConsDetail nonD = new TLDYE_NonComplianceConsDetail(); // Cant add the same record twice if (row.Cells[0].Value != null) { var index = (int)row.Cells[0].Value; nonD = context.TLDYE_NonComplianceConsDetail.Find(index); } else { Add = true; } nonD.DYENCCON_BatchNo_FK = selected.TLDYE_NcrBatchNo_FK; nonD.DYENCCON_ConOrNon = true; nonD.DYENCCON_Code_FK = (int)row.Cells[1].Value; nonD.DYENCCON_ConNumber = selected.TLDYE_NcrNumber; nonD.DYENCCON_Qunatities = (decimal)row.Cells[4].Value; if (Add) { context.TLDYE_NonComplianceConsDetail.Add(nonD); } } foreach (DataGridViewRow row in dataGridView4.Rows) { if (row.Cells[1].Value == null) { continue; } Add = false; TLDYE_NonComplianceConsDetail nonD = new TLDYE_NonComplianceConsDetail(); // Cant add the same record twice if (row.Cells[0].Value != null) { var index = (int)row.Cells[0].Value; nonD = context.TLDYE_NonComplianceConsDetail.Find(index); } else { Add = true; } nonD.DYENCCON_BatchNo_FK = selected.TLDYE_NcrBatchNo_FK; nonD.DYENCCON_ConOrNon = false; nonD.DYENCCON_Code_FK = (int)row.Cells[1].Value; nonD.DYENCCON_ConNumber = selected.TLDYE_NcrNumber; if (row.Cells[2].Value != null) { nonD.DYENCCON_Qunatities = (decimal)row.Cells[2].Value; } else { nonD.DYENCCON_Qunatities = 0.00M; } if (Add) { context.TLDYE_NonComplianceConsDetail.Add(nonD); } } try { context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); frmDyeViewReport vRep = new frmDyeViewReport(7, selected.TLDYE_NcrNumber); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; bool Add = true; if (oBtn != null && formloaded) { /* * var ErrM = core.returnMessage(MandSelected, false, MandatoryFields); * if (!String.IsNullOrEmpty(ErrM)) * { * MessageBox.Show(ErrM); * return; * } */ } using (var context = new TTI2Entities()) { var LastNum = context.TLADM_LastNumberUsed.Find(3); if (LastNum != null) { LastNum.col2 += 1; } TLDYE_DyeOrderFabric dof = new TLDYE_DyeOrderFabric(); var selected = (TLDYE_DyeOrderFabric)cmboDyeOrders.SelectedItem; if (selected != null) { dof = context.TLDYE_DyeOrderFabric.Find(selected.TLDYEF_Pk); Add = false; } dof.TLDYEF_Colours_FK = (int)cmboColors.SelectedValue; dof.TLDYEF_Customer_FK = (int)cmboCustomerNo.SelectedValue; dof.TLDYEF_CustomerOrder = txtCustomerOrder.Text; dof.TLDYEF_DyeOrderNo = txtDyeOrder.Text; dof.TLDYEF_DyeWeek = Convert.ToInt32(txtWFDye.Text); dof.TLDYEF_Greige_FK = (int)cmboFabric.SelectedValue; dof.TLDYEF_OrderDate = dtpDyeOrder.Value; dof.TLDYEF_PLoss = Convert.ToDecimal(txtDyeProductionLoss.Text); dof.TLDYEF_Yield = Convert.ToDecimal(txtYieldFactor.Text); DataGridViewRow dr = new DataGridViewRow(); dr = dataGridView1.Rows[0]; dof.TLDYEF_Quantity = Convert.ToDecimal(dr.Cells[1].Value.ToString()); dof.TLDYEF_ProjectedLoss = Convert.ToDecimal(dr.Cells[2].Value.ToString()); dof.TLDYEF_Demand = Convert.ToDecimal(dr.Cells[3].Value.ToString()); if (Add) { context.TLDYE_DyeOrderFabric.Add(dof); } try { context.SaveChanges(); SetUp(); MessageBox.Show("Data saved successfully to database"); frmDyeViewReport vRep = new frmDyeViewReport(2, dof.TLDYEF_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } }