private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && FormLoaded) { if (comboReportOptions.SelectedValue != null) { parms.RepSortOption = Int32.Parse(comboReportOptions.SelectedValue.ToString()); } else { parms.RepSortOption = 1; } frmCutViewRep vRep = new frmCutViewRep(10, parms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); comboCutSheets.Items.Clear(); comboGreige.Items.Clear(); comboMachines.Items.Clear(); comboOperator.Items.Clear(); FrmBierriebiSel_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { CutReportOptions cutOpts = new CutReportOptions(); cutOpts.C3SortOption = sortOptions; cutOpts.RepNo = _RepNo; if (_RepNo == 1) { frmCutViewRep vRep = new frmCutViewRep(7, cutOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); } else { cutOpts.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); cutOpts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); cutOpts.toDate = cutOpts.toDate.AddHours(23); frmCutViewRep vRep = new frmCutViewRep(8, cutOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); } sortOptions = 1; } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { var selected = (TLCUT_CutSheet)cmboReprint.SelectedItem; if (selected != null) { frmCutViewRep vRep = new frmCutViewRep(1, selected.TLCutSH_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); vRep = new frmCutViewRep(2, selected.TLCutSH_Pk); h = Screen.PrimaryScreen.WorkingArea.Height; w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } else { MessageBox.Show("Please select a Cut sheet from the drop down box"); } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { using (var context = new TTI2Entities()) { CutReportOptions repOptions = new CutReportOptions(); if (chkQAReport.Checked) { repOptions.QAReport = true; } repOptions.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); repOptions.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); repOptions.toDate = repOptions.toDate.AddHours(23); repOptions.C4SortOption = RepSortOption; frmCutViewRep vRep = new frmCutViewRep(5, repOptions); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); repOptions = new CutReportOptions(); } } }
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 btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { frmCutViewRep vRep = new frmCutViewRep(9, 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 = (Button)sender; if (oBtn != null && FormLoaded) { if (txtCutSheetNo.Text.Length != 0) { using (var context = new TTI2Entities()) { var CutSheet = context.TLCUT_CutSheet.Where(x => x.TLCutSH_No == txtCutSheetNo.Text).FirstOrDefault(); if (CutSheet == null) { MessageBox.Show("Cut Sheet does not exist"); return; } //This form is the CMT Issued to line document //============================================================== var vRep = new frmCutViewRep(14, CutSheet.TLCutSH_Pk); var h = Screen.PrimaryScreen.WorkingArea.Height; var w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); } } else { foreach (DataGridViewRow Row in dataGridView1.Rows) { if ((bool)Row.Cells[1].Value == true) { int Pk = (int)Row.Cells[0].Value; using (var context = new TTI2Entities()) { Cutting.frmCutViewRep vRepx = new Cutting.frmCutViewRep(13, Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRepx.ClientSize = new Size(w, h); vRepx.ShowDialog(); } } } } frmCMTPanelReissue_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && formloaded) { CutReportOptions repOptions = new CutReportOptions(); parms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); parms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); parms.ToDate = parms.ToDate.AddHours(23); frmCutViewRep vRep = new frmCutViewRep(15, repOptions, parms); 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) { CutReportOptions cutOpts = new CutReportOptions(); cutOpts.C2SortOption = sortOptions; frmCutViewRep vRep = new frmCutViewRep(6, cutOpts, parms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); sortOptions = 1; cmboWareHouseStore.Items.Clear(); frmSelPanelStock_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (chkAllWIP.Checked) { parms.AllWIP = true; } parms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); parms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); parms.ToDate = parms.ToDate.AddHours(23); parms.RepSortOption = _RepSortOption; frmCutViewRep vRep = new frmCutViewRep(4, parms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView oDgv = sender as DataGridView; if (oDgv.Focused && oDgv.CurrentCell is DataGridViewCheckBoxCell) { if (oDgv.CurrentCell.ColumnIndex == 1) { if ((bool)oDgv.CurrentCell.EditedFormattedValue) { var CurrentRow = oDgv.CurrentRow; var Pk = (int)CurrentRow.Cells[0].Value; frmCutViewRep vRep = new frmCutViewRep(1, Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } else { if ((bool)oDgv.CurrentCell.EditedFormattedValue) { var CurrentRow = oDgv.CurrentRow; int Pk = (int)CurrentRow.Cells[0].Value; frmSplitCutSheet SplitCS = new frmSplitCutSheet(Pk); DialogResult dr = SplitCS.ShowDialog(this); if (dr == DialogResult.OK) { } } } } }
private void btnSave_Click(object sender, EventArgs e) { bool Update = false; Button oBtn = sender as Button; if (oBtn != null && formloaded) { var selected = (TLCUT_CutSheet)cmboCutSheet.SelectedItem; if (selected == null) { MessageBox.Show("Please select a cut sheet from the drop down list "); return; } var WhseSelected = (TLADM_WhseStore)cmboRejectStore.SelectedItem; if (WhseSelected == null) { MessageBox.Show("Please select a reject store from the drop down list"); return; } if (String.IsNullOrEmpty(txtAuthorisedBy.Text)) { MessageBox.Show("Please complete the approved by details"); return; } using (var context = new TTI2Entities()) { var CSR = context.TLCUT_CutSheetReceipt.Where(x => x.TLCUTSHR_CutSheet_FK == selected.TLCutSH_Pk).FirstOrDefault(); CutReportOptions cropts = new CutReportOptions(); cropts.remarks = rtbNotes.Text; cropts.TransDate = dtpTransDate.Value; cropts.ApprovedBy = txtAuthorisedBy.Text; cropts.Pk = CSR.TLCUTSHR_Pk; cropts.CutSheetPk = selected.TLCutSH_Pk; cropts.ReturnedTo = context.TLADM_WhseStore.Find(WhseSelected.WhStore_Id).WhStore_Description; var cs = context.TLCUT_CutSheet.Find(selected.TLCutSH_Pk); if (cs != null) { cs.TLCutSH_Notes = rtbNotes.Text; } foreach (DataGridViewRow row in dataGridView1.Rows) { if ((bool)row.Cells[1].Value == false) { continue; } //------------------------------------------------------ // 1st Step reduce the SOH with what was written off //----------------------------------------------------------- var index = (int)row.Cells[0].Value; var CSRD = context.TLCUT_CutSheetReceiptDetail.Find(index); if (CSRD != null) { CSRD.TLCUTSHRD_RejectQty += (int)row.Cells[6].Value; CSRD.TLCUTSHRD_RejectDate = dtpTransDate.Value; CSRD.TLCUTSHRD_RejectReason = (int)row.Cells[5].Value; } //------------------------------------------------- // Now create a new Record of the written off value //--------------------------------------------------- TLCUT_CutSheetReceiptDetail NewCSR = new TLCUT_CutSheetReceiptDetail(); NewCSR.TLCUTSHRD_CutSheet_FK = CSR.TLCUTSHR_Pk; NewCSR.TLCUTSHRD_Description = row.Cells[2].Value.ToString() + "R"; NewCSR.TLCUTSHRD_Size_FK = (int)row.Cells[3].Value; NewCSR.TLCUTSHRD_BundleQty = (int)row.Cells[4].Value; NewCSR.TLCUTSHRD_BoxUnits = 0; NewCSR.TLCUTSHRD_TransactionType = 55; NewCSR.TLCUTSHRD_CurrentStore_FK = WhseSelected.WhStore_Id; NewCSR.TLCUTSHRD_PanelRejected = true; NewCSR.TLCUTSHRD_RejectDate = dtpTransDate.Value; NewCSR.TLCUTSHRD_RejectQty = (int)row.Cells[6].Value; NewCSR.TLCUTSHRD_RejectReason = (int)row.Cells[5].Value; context.TLCUT_CutSheetReceiptDetail.Add(NewCSR); Update = true; } //------------------------------------------------------- // //----------------------------------------------------------- string Mach_IP = Dns.GetHostEntry(Dns.GetHostName()) .AddressList.First(f => f.AddressFamily == AddressFamily.InterNetwork) .ToString(); var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("CUT")).FirstOrDefault(); TLADM_DailyLog DailyLog = new TLADM_DailyLog(); DailyLog.TLDL_IPAddress = Mach_IP; DailyLog.TLDL_Dept_Fk = Dept.Dep_Id; DailyLog.TLDL_Date = DateTime.Now; DailyLog.TLDL_TransDetail = "Cutting Dept Panel Rejected"; DailyLog.TLDL_AuthorisedBy = txtAuthorisedBy.Text;; DailyLog.TLDL_Comments = rtbNotes.Text; context.TLADM_DailyLog.Add(DailyLog); //---------------------------------------------------------- if (Update) { try { context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); frmCutViewRep vRep = new frmCutViewRep(3, cropts); 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 button1_Click(object sender, EventArgs e) { BindingList <KeyValuePair <int, decimal> > CurrentRatios; Button oBtn = sender as Button; if (oBtn != null) { using (var context = new TTI2Entities()) { //------------------------------------------------------------------------------------ // First we must ensure that all records are removed from // the expectedUnits table for this particular Cut Sheet //--------------------------------------------------------------------------- context.TLCUT_ExpectedUnits.RemoveRange(context.TLCUT_ExpectedUnits.Where(x => x.TLCUTE_CutSheet_FK == _CsPk)); context.SaveChanges(); foreach (DataGridViewRow Row in dataGridView1.Rows) { var DbPk = (int)Row.Cells[1].Value; if ((bool)Row.Cells[2].Value == false) { //------------------------------------------------------------ // The pieces that are left are used to recalculate // the number of expected units //-------------------------------------------------------------- decimal Nett = (decimal)Row.Cells[5].Value; TLDYE_DyeBatchDetails dbd = context.TLDYE_DyeBatchDetails.Find(DbPk); if (dbd != null) { // Based on code developed for frmCutSheet // Is a body or is it a Trim Record //================================================= if (dbd.DYEBD_BodyTrim) { //-------------------------------------------------------------- // It is a body // Now calculate the yield //------------------------------------------------------------------ var Yield = core.FabricYield(dbd.DYEBO_DiskWeight, dbd.DYEBO_Width); var Rating = context.TLADM_ProductRating.Find((int)dbd.DYEBO_ProductRating_FK).Pr_numeric_Rating; var Factor = Math.Round(Yield / Rating * Nett, 0); var tst = core.CalculateRatios((int)dbd.DYEBO_ProductRating_FK, (int)Factor); foreach (var row in tst) { bool Add = true; var Kg = Math.Round(0.01M * row.Value / Yield, 2); TLCUT_ExpectedUnits eUnits = new TLCUT_ExpectedUnits(); eUnits = context.TLCUT_ExpectedUnits.Where(x => x.TLCUTE_CutSheet_FK == _CsPk && x.TLCUTE_Size_FK == row.Key).FirstOrDefault(); if (eUnits == null) { eUnits = new TLCUT_ExpectedUnits(); eUnits.TLCUTE_CutSheet_FK = _CsPk; eUnits.TLCUTE_Size_FK = row.Key; eUnits.TLCUTE_NoofGarments = row.Value; eUnits.TLCUTE_NoOfTrims = Kg; eUnits.TLCUTE_NoOfBinding = 0; } else { eUnits.TLCUTE_NoofGarments += row.Value; eUnits.TLCUTE_NoOfTrims += Kg; Add = !Add; } if (Add) { context.TLCUT_ExpectedUnits.Add(eUnits); context.SaveChanges(); } } } else { //-------------------------------------------------------------- // It is a Trim // Now calculate the yield //------------------------------------------------------------------ var Yield = core.FabricYield(dbd.DYEBO_DiskWeight, dbd.DYEBO_Width); var Rating = context.TLADM_ProductRating.Find((int)dbd.DYEBO_ProductRating_FK).Pr_numeric_Rating; CurrentRatios = core.ReturnRatios((int)dbd.DYEBO_ProductRating_FK); if (dbd.DYEBO_GVRowNumber == 1) { var NumberOf = Math.Round(Yield / Rating * Nett, 0); var TotalOf = CurrentRatios.Sum(x => (decimal?)x.Value) ?? 0.00M; foreach (var row in CurrentRatios) { int Calc = (int)Math.Round(row.Value / TotalOf * NumberOf, 0); TLCUT_ExpectedUnits eUnits = new TLCUT_ExpectedUnits(); eUnits = context.TLCUT_ExpectedUnits.Where(x => x.TLCUTE_CutSheet_FK == _CsPk && x.TLCUTE_Size_FK == row.Key).FirstOrDefault(); if (eUnits != null) { // The imfamous switch //---------------------------- eUnits.TLCUTE_NoOfTrims += Calc; } } } else if (dbd.DYEBO_GVRowNumber == 2) { var NumberOf = Math.Round(Yield / Rating * Nett, 0); var TotalOf = CurrentRatios.Sum(x => (decimal?)x.Value) ?? 0.00M; foreach (var row in CurrentRatios) { int Calc = (int)Math.Round(row.Value / TotalOf * NumberOf, 0); TLCUT_ExpectedUnits eUnits = new TLCUT_ExpectedUnits(); eUnits = context.TLCUT_ExpectedUnits.Where(x => x.TLCUTE_CutSheet_FK == _CsPk && x.TLCUTE_Size_FK == row.Key).FirstOrDefault(); if (eUnits != null) { // The imfamous switch //---------------------------- eUnits.TLCUTE_NoOfBinding += Calc; } } } } } continue; } var DyeBatchDetails = context.TLDYE_DyeBatchDetails.Find(DbPk); if (DyeBatchDetails != null) { DyeBatchDetails.DYEBO_CutSheet = false; } var CutSheetPk = (int)Row.Cells[0].Value; var CutSheetDetails = context.TLCUT_CutSheetDetail.Find(CutSheetPk); if (CutSheetDetails != null) { context.TLCUT_CutSheetDetail.Remove(CutSheetDetails); } } try { context.SaveChanges(); MessageBox.Show("Data saved to the database successfully"); frmCutViewRep vRep = new frmCutViewRep(1, _CsPk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); this.Close(); return; } 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 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; } } } } }
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 = sender as Button; if (oBtn != null && FormLoaded) { var FromWhse = (TLADM_WhseStore)cmboFromwarehouse.SelectedItem; if (FromWhse == null) { MessageBox.Show("Please select a warehouse from which to transfer"); return; } var ToWhse = (TLADM_WhseStore)cmboTowareHouse.SelectedItem; if (ToWhse == null) { MessageBox.Show("Please select a warehousewhich to transfer too"); return; } if (FromWhse.WhStore_Id == ToWhse.WhStore_Id) { MessageBox.Show("Please select a different warehouse to transfer too"); return; } if (!TransferMode) { TransferMode = !TransferMode; btnSubmit.Text = "Transfer"; QueryParms.FromWhse = FromWhse.WhStore_Id; //This function needs to be modified for Bought in Fabric purposes //=========================================================================== var Existing = repo.FromWareHouse(QueryParms); if (Existing.Count() == 0) { MessageBox.Show("No Records found for selection made", FromWhse.WhStore_Description); return; } using (var context = new TTI2Entities()) { foreach (var Record in Existing) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = Record.TLSOH_Pk; dataGridView1.Rows[index].Cells[1].Value = false; dataGridView1.Rows[index].Cells[2].Value = Record.TLSOH_BoxNumber; dataGridView1.Rows[index].Cells[3].Value = context.TLADM_Styles.Find(Record.TLSOH_Style_FK).Sty_Description; dataGridView1.Rows[index].Cells[4].Value = context.TLADM_Colours.Find(Record.TLSOH_Colour_FK).Col_Display; dataGridView1.Rows[index].Cells[5].Value = context.TLADM_Sizes.Find(Record.TLSOH_Size_FK).SI_Description; dataGridView1.Rows[index].Cells[6].Value = Record.TLSOH_BoxedQty; } } } else { var CountSelected = (from Rows in dataGridView1.Rows.Cast <DataGridViewRow>() where (bool)Rows.Cells[1].Value == true select Rows).Count(); if (CountSelected == 0) { MessageBox.Show("Please tick at least one box to be transferred"); return; } TransferMode = !TransferMode; btnSubmit.Text = "Submit"; using (var context = new TTI2Entities()) { //Need to create a Header Record in the file //======================================================= TLCSV_WhseTransfer WhseTransfer = new TLCSV_WhseTransfer(); var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "CSV").FirstOrDefault(); if (Dept != null) { var LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); if (LNU != null) { WhseTransfer.TLCSVWHT_Date = DateTime.Now; WhseTransfer.TLCSVWHT_PickList = true; WhseTransfer.TLCSVWHT_FromWhse_Fk = FromWhse.WhStore_Id; WhseTransfer.TLCSVWHT_ToWhse_Fk = ToWhse.WhStore_Id; WhseTransfer.TLCSVWHT_PickListDate = DateTime.Now; WhseTransfer.TLCSVWHT_PickListNo = LNU.col6; LNU.col6 += 1; context.TLCSV_WhseTransfer.Add(WhseTransfer); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (DataGridViewRow Row in dataGridView1.Rows) { if ((bool)Row.Cells[1].Value == false) { continue; } TLCSV_WhseTransferDetail WhDetail = new TLCSV_WhseTransferDetail(); WhDetail.TLCSVWHTD_WhseTranfer_FK = WhseTransfer.TLCSVWHT_Pk; WhDetail.TLCSVWHTD_TLSOH_Fk = (int)Row.Cells[0].Value; WhDetail.TLCSVWHTD_PickList = true; context.TLCSV_WhseTransferDetail.Add(WhDetail); } try { context.SaveChanges(); MessageBox.Show("Records successfully updated to database"); FormLoaded = false; frmCutViewRep vRep = new frmCutViewRep(16, WhseTransfer.TLCSVWHT_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLCUT_CutSheetReceipt CSR = null; if (oBtn != null && formloaded) { using (var context = new TTI2Entities()) { var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("CUT")).FirstOrDefault(); if (CutSheetSelected != 0) { CSR = context.TLCUT_CutSheetReceipt.Where(x => x.TLCUTSHR_CutSheet_FK == CutSheetSelected).FirstOrDefault(); if (CSR != null) { CSR.TLCUTSHR_InBundleStore = false; CSR.TLCUTSHR_InPanelStore = true; CSR.TLCUTSHR_DateIntoPanelStore = dtpTransActionDate.Value; var CS = context.TLCUT_CutSheet.Find(CSR.TLCUTSHR_CutSheet_FK); if (CS != null) { if (rtbAdditional.Text.Length != 0) { CS.TLCUTSH_AddNotes = rtbAdditional.Text; } CS.TLCUTSH_Completed_Date = DateTime.Now; CSR.TLCUTSHR_Colour_FK = CS.TLCutSH_Colour_FK; var CutStore = context.TLADM_WhseStore.Where(x => x.WhStore_DepartmentFK == CS.TLCutSH_Department_FK && x.WhStore_PanelStore).FirstOrDefault(); if (CutStore != null) { CSR.TLCUTSHR_WhsePanStore_FK = CutStore.WhStore_Id; CSR.TLCUTSHR_DateIntoPanelStore = dtpTransActionDate.Value; } } } } else { MessageBox.Show("Please select a cutsheet from the drop down box"); return; } foreach (DataGridViewRow row in dataGridView1.Rows) { TLCUT_CutSheetReceiptDetail CSRD = new TLCUT_CutSheetReceiptDetail(); var index = (int)row.Cells[0].Value; CSRD = context.TLCUT_CutSheetReceiptDetail.Find(index); if (CSRD != null) { CSRD.TLCUTSHRD_BoxNumber = dataGridView1.Rows[row.Index].Cells[3].Value.ToString(); if ((int)dataGridView1.Rows[row.Index].Cells[4].Value == 0) { continue; } CSRD.TLCUTSHRD_BoxUnits = (int)dataGridView1.Rows[row.Index].Cells[4].Value; CSRD.TLCUTSHRD_BoxType_FK = 1; // removed to speed up data capture (int)dataGridView1.Rows[row.Index].Cells[5].Value; CSRD.TLCUTSHRD_InBundleStore = false; CSRD.TLCUTSHRD_PanelDate = dtpTransActionDate.Value; if (Dept != null) { var TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 600).FirstOrDefault(); if (TranType != null) { CSRD.TLCUTSHRD_TransactionType = TranType.TrxT_Pk; CSRD.TLCUTSHRD_CurrentStore_FK = (int)TranType.TrxT_ToWhse_FK; } } } } var CSB = context.TLCUT_CutSheetReceiptBoxes.Where(x => x.TLCUTSHB_Pk == CSR.TLCUTSHR_Pk).FirstOrDefault(); if (CSB != null) { int value = 0; if (int.TryParse(txtAdultBoxes.Text, out value)) { CSB.TLCUTSHB_AdultBoxes = value; } value = 0; if (int.TryParse(txtBinding.Text, out value)) { CSB.TLCUTSHB_Binding = value; } value = 0; if (int.TryParse(txtKidsBoxes.Text, out value)) { CSB.TLCUTSHB_KidBoxes = value; } value = 0; if (int.TryParse(txtRibbing.Text, out value)) { CSB.TLCUTSHB_Ribbing = value; } } try { context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); dataGridView1.Rows.Clear(); //This form is the summary form for Mary in the accessories store //=================================================== frmCutViewRep vRep = new frmCutViewRep(11, CutSheetSelected); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); //This form is the CMT Issued to line document //============================================================== vRep = new frmCutViewRep(14, CutSheetSelected); h = Screen.PrimaryScreen.WorkingArea.Height; w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); } 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); } } } }