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 btnPrint_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var selected = (TLCMT_PanelIssue)cmboCurrentPI.SelectedItem; if (selected == null) { MessageBox.Show("please select a panel issue from the drop down"); return; } frmCMTViewRep vRep = new frmCMTViewRep(1, selected.CMTPI_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); DialogResult Res = MessageBox.Show("Do you wish to reprint the Cut Sheet Summary Report", "Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Res == DialogResult.Yes) { Cutting.frmCutViewRep vRepx = new Cutting.frmCutViewRep(12, selected.CMTPI_Pk); h = Screen.PrimaryScreen.WorkingArea.Height; w = Screen.PrimaryScreen.WorkingArea.Width; vRepx.ClientSize = new Size(w, h); vRepx.ShowDialog(); } /* * Res = MessageBox.Show("Do you wish to reprint the CMT Panel Issue", "Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question); * if (Res == DialogResult.Yes) * { * Cutting.frmCutViewRep vRepx = new Cutting.frmCutViewRep(13, selected.CMTPI_Pk); * h = Screen.PrimaryScreen.WorkingArea.Height; * w = Screen.PrimaryScreen.WorkingArea.Width; * vRepx.ClientSize = new Size(w, h); * vRepx.ShowDialog(); * }*/ frmTruckLoading_Load(this, null); } }
private void cmboPickingLists_SelectedIndexChanged(object sender, EventArgs e) { ComboBox oCmbo = (ComboBox)sender; if (oCmbo != null && FormLoaded) { var BIFTransit = (TLDYE_BIFInTransit)oCmbo.SelectedItem; if (BIFTransit != null) { if (_Reprint) { Cutting.frmCutViewRep vRep = new Cutting.frmCutViewRep(16, BIFTransit.BIFT_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); } else { dataGridView1.Rows.Clear(); using (var context = new TTI2Entities()) { var Entries = context.TLDYE_BIFInTransitDetails.Where(x => x.BIFD_Intransit_FK == BIFTransit.BIFT_Pk).ToList(); foreach (var Entry in Entries) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = Entry.BIFD_Pk; dataGridView1.Rows[index].Cells[1].Value = Entry.BIFD_DyeBatchDetail_FK; dataGridView1.Rows[index].Cells[2].Value = true; var GreigePk = Entry.BIFD_Greige_FK; dataGridView1.Rows[index].Cells[3].Value = context.TLKNI_GreigeProduction.Find(GreigePk).GreigeP_PieceNo; } } } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLADM_LastNumberUsed LNU = null; TLCMT_PanelIssue pi = new TLCMT_PanelIssue(); TLCMT_PanelIssueDetail pid = new TLCMT_PanelIssueDetail(); TLCUT_CutSheetReceipt CSR = new TLCUT_CutSheetReceipt(); bool Add = false; if (oBtn != null && formloaded) { var selected = (TLADM_Departments)cmboCMTDepartment.SelectedItem; if (selected == null) { MessageBox.Show("Please select a CMT from the drop downlist"); return; } if (((TLADM_WhseStore)cmboDepartments.SelectedItem) == null) { MessageBox.Show("Please select Store from which to make an selection"); return; } using (var context = new TTI2Entities()) { int Number = Convert.ToInt32(label1.Text); pi = context.TLCMT_PanelIssue.Where(x => x.CMTPI_Number == Number).FirstOrDefault(); if (pi == null) { pi = new TLCMT_PanelIssue(); Add = true; } pi.CMTPI_Number = Number; pi.CMTPI_Date = dtpTransDate.Value; pi.CMTPI_Department_FK = selected.Dep_Id; pi.CMTPI_Closed = false; pi.CMTPI_DeliveryNumber = 0; pi.CMTPI_CutSheetSummary = false; pi.CMTPI_FromWhse_FK = ((TLADM_WhseStore)cmboDepartments.SelectedItem).WhStore_Id; var TransType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 100 && x.TrxT_Department_FK == selected.Dep_Id).FirstOrDefault(); if (TransType != null) { pi.CMTPI_TranType_FK = TransType.TrxT_Pk; } pi.CMTPI_Display = "DN -" + "0".PadLeft(4, ' ') + " - TL " + Number.ToString().PadLeft(5, '0'); if (Add) { context.TLCMT_PanelIssue.Add(pi); } if (Add && selected != null) { LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == selected.Dep_Id).FirstOrDefault(); if (LNU != null) { LNU.col1 += 1; } } try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (DataGridViewRow row in dataGridView1.Rows) { //--------------------------------------------------------------- if ((bool)row.Cells[2].Value == false) { continue; } Add = true; pid = new TLCMT_PanelIssueDetail(); if ((int)row.Cells[0].Value != 0) { var index = (int)row.Cells[0].Value; pid = context.TLCMT_PanelIssueDetail.Find(index); if (pid == null) { pid = new TLCMT_PanelIssueDetail(); } else { Add = false; } } //-------------------------------------------------------- pid.CMTPID_CutSheet_FK = (int)row.Cells[1].Value; pid.CMTPID_PI_FK = pi.CMTPI_Pk; pid.CMTPID_Receipted = false; pid.CMTPID_BIFabric = false; CSR = context.TLCUT_CutSheetReceipt.Find(pid.CMTPID_CutSheet_FK); if (CSR != null) { CSR.TLCUTSHR_Issued = true; } if (Add) { context.TLCMT_PanelIssueDetail.Add(pid); } } try { var SelectedRows = ( from Rows in dataGridView1.Rows.Cast <DataGridViewRow>() where (bool)Rows.Cells[2].Value == true select Rows).ToList(); foreach (var SelectedRow in SelectedRows) { var index = SelectedRow.Index; dataGridView1.Rows.RemoveAt(index); } context.SaveChanges(); MessageBox.Show("Data saved successfully to to database"); //This report has been housed in the the Cutting Form View Program.... Cutting.frmCutViewRep vRep = new Cutting.frmCutViewRep(12, pi.CMTPI_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int 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) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; int LastNumberUsed = 0; if (oBtn != null && FormLoaded) { CutReportOptions ops = new CutReportOptions(); using (var context = new TTI2Entities()) { var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "CUT").FirstOrDefault(); if (Dept != null) { var LstNumberUsed = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); if (LstNumberUsed != null) { LastNumberUsed = LstNumberUsed.col4; LstNumberUsed.col4 += 1; } } foreach (DataGridViewRow Row in dataGridView2.Rows) { bool IsChecked = (bool)Row.Cells[1].Value; if (!IsChecked) { continue; } int Pk = (int)Row.Cells[0].Value; ops.BIFTransit.Add(Pk); var BIFInTrans = context.TLDYE_BIFInTransit.Find(Pk); if (BIFInTrans != null) { var BifDetails = context.TLDYE_BIFInTransitDetails.Where(x => x.BIFD_Intransit_FK == BIFInTrans.BIFT_Pk).ToList(); foreach (var Detail in BifDetails) { var DBDetail = context.TLDYE_DyeBatchDetails.Find(Detail.BIFD_DyeBatchDetail_FK); if (DBDetail != null) { DBDetail.DYEBO_CurrentStore_FK = BIFInTrans.BIFT_ToFabric_FK; } } BIFInTrans.BIFT_Delivery_Number = LastNumberUsed; BIFInTrans.BIFT_Despatched = true; BIFInTrans.BIFT_Despatched_Date = DateTime.Now; } } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } Cutting.frmCutViewRep vRep = new Cutting.frmCutViewRep(17, ops); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; TLDYE_BIFInTransit BIFTransit = new TLDYE_BIFInTransit(); if (oBtn != null && FormLoaded) { var CurrWhse = (TLADM_WhseStore)cmboWareHouses.SelectedItem; if (CurrWhse == null) { MessageBox.Show("Please select a from Warehouse"); return; } var ToWhse = (TLADM_WhseStore)cmboToWareHouse.SelectedItem; if (ToWhse == null) { MessageBox.Show("Please select a to Warehouse"); return; } var SingleRow = (from Rows in dataGridView1.Rows.Cast <DataGridViewRow>() where (bool)Rows.Cells[1].Value == true select Rows).FirstOrDefault(); if (SingleRow == null) { MessageBox.Show("Please select at least one record"); return; } using (var context = new TTI2Entities()) { var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "CUT").FirstOrDefault(); if (Dept != null) { var LstNumberUsed = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); if (LstNumberUsed != null) { BIFTransit = new TLDYE_BIFInTransit(); BIFTransit.BIFT_PickingList = true; BIFTransit.BIFT_PickingList_Date = DateTime.Now; BIFTransit.BIFT_PickingList_Number = LstNumberUsed.col3; BIFTransit.BIFT_FromFabric_FK = CurrWhse.WhStore_Id; BIFTransit.BIFT_ToFabric_FK = ToWhse.WhStore_Id; context.TLDYE_BIFInTransit.Add(BIFTransit); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (DataGridViewRow Row in dataGridView1.Rows) { var IsChecked = (bool)Row.Cells[1].Value; if (!IsChecked) { continue; } TLDYE_BIFInTransitDetails TransDetails = new TLDYE_BIFInTransitDetails(); TransDetails.BIFD_Intransit_FK = BIFTransit.BIFT_Pk; var Greige_Pk = (int)Row.Cells[0].Value; TransDetails.BIFD_Greige_FK = Greige_Pk; if (Row.Cells[5].Value != null) { var Col = (string)Row.Cells[5].Value; var Colour_Pk = context.TLADM_Colours.Where(x => x.Col_Display == Col).FirstOrDefault().Col_Id; TransDetails.BIFD_Colour_FK = Colour_Pk; } var DyeBatchDetail = context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_GreigeProduction_FK == Greige_Pk).FirstOrDefault(); if (DyeBatchDetail != null) { DyeBatchDetail.DYEBO_BIFInTransit = true; TransDetails.BIFD_DyeBatchDetail_FK = DyeBatchDetail.DYEBD_Pk; } context.TLDYE_BIFInTransitDetails.Add(TransDetails); } try { LstNumberUsed.col3 += 1; context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); dataGridView1.Rows.Clear(); FrmSelectBIF_Load(this, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } Cutting.frmCutViewRep vRep = new Cutting.frmCutViewRep(16, BIFTransit.BIFT_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); } }