private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && FormLoaded) { YarnReportOptions opts = new YarnReportOptions(); opts.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); opts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); opts.toDate = opts.toDate.AddHours(23); if (rbQuality.Checked) { opts.GKM_Quality = true; } else if (rbMachine.Checked) { opts.GKM_Machines = true; } else { opts.GKM_Operators = true; } frmKnitViewRep vRep = new frmKnitViewRep(33, Parms, opts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnReports_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var KO = (TLKNI_Order)cmbKnitOrder.SelectedItem; if (KO != null) { YarnReportOptions repOpts = new YarnReportOptions(); repOpts.ReportKey = KO.KnitO_Pk; DialogResult res = MessageBox.Show("Print Report with Current Results", "Print Options", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { repOpts.PrintWithCurrent = true; } else { repOpts.PrintWithCurrent = false; } frmKnitViewRep vRep = new frmKnitViewRep(9, repOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { using (var context = new TTI2Entities()) { var _Begin = dtpDate.Value.ToShortDateString(); DateTime ped = Convert.ToDateTime(_Begin); DateTime time = dtpTime.Value; var KO = (TLKNI_Order)cmbKnitOrders.SelectedItem; if (KO != null) { KO = context.TLKNI_Order.Find(KO.KnitO_Pk); KO.KnitO_ProductionEndDate = ped.AddHours(time.Hour); KO.KnitO_Confirmed = true; if (chkProduction.Checked) { KO.KnitO_ProductionCaptured = true; } if (chkYarnReturned.Checked) { KO.KnitO_YarnReturned = true; } if (chkReOpenKnitOrder.Checked) { KO.KnitO_ReOpen = true; } if (chkKnitOrderClosed.Checked && !KO.KnitO_Closed) { KO.KnitO_Closed = true; KO.KnitO_ClosedDate = dtpDate.Value; } try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } frmKnitViewRep vRep = new frmKnitViewRep(12, KO.KnitO_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; string Code = string.Empty; int LN = 0; if (oBtn != null && formloaded) { using (var context = new TTI2Entities()) { var TotalPieces = _KO.KnitO_NoOfPieces; var I = 1; /* * var Machine = context.TLADM_MachineDefinitions.Where(x=>x.MD_Pk == _KO.KnitO_Machine_FK).FirstOrDefault(); * if(Machine != null) * { * Code = Machine.MD_MachineCode; * Code = Code.Substring(1, -1 + Code.Length); * LN = Machine.MD_LastNumberUsed; * } * * do * { * TLKNI_GreigeProduction greigP = new TLKNI_GreigeProduction(); * greigP.GreigeP_KnitO_Fk = _KO.KnitO_Pk; * greigP.GreigeP_Greige_Fk = _KO.KnitO_Product_FK; * greigP.GreigeP_PieceNo = Code + (LN++).ToString(); * greigP.GreigeP_weight = 0.00M; * * context.TLKNI_GreigeProduction.Add(greigP); * * I++; * } while (I <= TotalPieces); * * Machine = context.TLADM_MachineDefinitions.Find(Machine.MD_Pk); * if(Machine != null) * context.UpdateLastNumber(LN, Machine.MD_MachineCode); * //LastNumberUsed.col6 = LN; */ try { // context.SaveChanges(); frmKnitViewRep vRep = new frmKnitViewRep(2, _KO.KnitO_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 button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { YarnReportOptions opts = new YarnReportOptions(); opts.reportChoice = 1; frmKnitViewRep vRep = new frmKnitViewRep(16, opts); vRep.ShowDialog(this); } }
private void btnReprint_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null) { frmKnitViewRep vRep = new frmKnitViewRep(7, KnitO.KnitO_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { YarnReportOptions opts = new YarnReportOptions(); opts.reportChoice = 1; frmKnitViewRep vRep = new frmKnitViewRep(16, opts); 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) { QueryParms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); QueryParms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); QueryParms.ToDate = QueryParms.ToDate.AddHours(23.30); frmKnitViewRep vRep = new frmKnitViewRep(29, QueryParms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnReports_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var KO = (TLKNI_Order)cmbKnitOrders.SelectedItem; if (KO != null) { frmKnitViewRep vRep = new frmKnitViewRep(10); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } }
private void btnReport_Click(object sender, EventArgs e) { YarnReportOptions YarnOpts = new YarnReportOptions(); YarnOpts.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); YarnOpts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); YarnOpts.toDate = YarnOpts.toDate.AddHours(23); if (rbShifts.Checked) { YarnOpts.SplitByShift = true; } frmKnitViewRep vRep = new frmKnitViewRep(25, YarnOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); }
private void btnProcess_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { YarnReportOptions repOts = new YarnReportOptions(); repOts.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); repOts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); repOts.toDate = repOts.toDate.AddHours(23.59); if (rbKnitOrder.Checked) { repOts.KnitOrder = true; } else if (rbKnitMachime.Checked) { repOts.KnitMachines = true; } else if (rbGreigeProduct.Checked) { repOts.GreigeProduct = true; } else if (rbProcesdLoss.Checked) { repOts.ProcessLoss = true; } else if (rbYarnTex.Checked) { repOts.YarnTex = true; } else if (rbYarnType.Checked) { repOts.YarnType = true; } frmKnitViewRep vRep = new frmKnitViewRep(18, repOts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var selected = (TLKNI_Order)cmboKnitOrders.SelectedItem; if (selected == null) { MessageBox.Show("Please select a Knit Order from the drop down box"); return; } frmKnitViewRep vRep = new frmKnitViewRep(26, selected.KnitO_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) { if (FormLoaded) { KnitReportOptions RepOpts = new KnitReportOptions(); DateTime From = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); DateTime To = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); To = To.AddHours(23); RepOpts.ThirdParty = chkThirdPTrans.Checked; RepOpts.FromDate = From; RepOpts.ToDate = To; frmKnitViewRep vRep = new frmKnitViewRep(32, RepOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnProcess_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { YarnReportOptions repOts = new YarnReportOptions(); repOts.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); repOts.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); if (rbKnitOrder.Checked) { repOts.KnitOrder = true; } else if (rbKnitMachime.Checked) { repOts.KnitMachines = true; } else if (rbGreigeProduct.Checked) { repOts.GreigeProduct = true; } else if (rbProcesdLoss.Checked) { repOts.ProcessLoss = true; } else if (rbYarnTex.Checked) { repOts.YarnTex = true; } else if (rbYarnType.Checked) { repOts.YarnType = true; } frmKnitViewRep vRep = new frmKnitViewRep(18, repOts); vRep.ShowDialog(this); } }
private void btnReport_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { Util core = new Util(); YarnReportOptions repOps = new YarnReportOptions(); repOps.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); repOps.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); repOps.toDate = repOps.toDate.AddHours(23); if (rbKnitMachine.Checked) { repOps.K12KnitMachine = true; } else if (rbOperator.Checked) { repOps.K12Operator = true; } else if (rbSpinning.Checked) { repOps.K12Spinning = true; } else { repOps.K12YarnOrder = true; } frmKnitViewRep vRep = new frmKnitViewRep(21, repOps); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; int _LastNumber = 0; TLKNI_GreigeProduction GreigeP = null; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandatorySelected, false, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } var GrnNumber = (TLKNI_GreigeCommissionTransctions)cmbTrans.SelectedItem; using (var context = new TTI2Entities()) { TLADM_LastNumberUsed LNU = context.TLADM_LastNumberUsed.Find(2); if (LNU != null) { _LastNumber = LNU.col10; LNU.col10 += 1; } foreach (DataGridViewRow row in dataGridView1.Rows) { var Pk = (int)row.Cells[0].Value; if (Pk != 0) { var Existing = context.TLKNI_GreigeCommissionTransctions.Find(Pk); if (Existing != null) { var NewValue = (decimal)row.Cells[4].Value; if (NewValue != Existing.GreigeCom_NettWeight) { Existing.GreigeCom_NettWeight += NewValue; //Notes -- we must also now adjust the value in the GreigeProduction File //==================================================================== GreigeP = context.TLKNI_GreigeProduction.Where(x => x.GreigeP_KnitO_Fk == Pk).FirstOrDefault(); if (GreigeP != null) { GreigeP.GreigeP_weight += NewValue; GreigeP.GreigeP_weightAvail += NewValue; TLKNI_GreigeCommisionAdjustment adj = new TLKNI_GreigeCommisionAdjustment(); adj.GreigeComAJ_AjustmentNo = _LastNumber; adj.GreigeComAJ_AmtAdjusted = NewValue; adj.GreigeComAJ_AprovedBy = txtApprovedBy.Text; adj.GreigeComAJ_PieceNo_FK = (int)row.Cells[0].Value; adj.GreigeComAJ_Reasons = txtReason.Text; adj.GreigeComAJ_Strore_FK = (int)cmbStore.SelectedValue; adj.GreigeComAJ_TransDate = (DateTime)dtpTransactionDate.Value; adj.GreigeComAJ_GreigeProduction_FK = GreigeP.GreigeP_Pk; if (GrnNumber != null) { adj.GreigeComAJ_GrnNumber = GrnNumber.GreigeCom_GrnNo; } context.TLKNI_GreigeCommisionAdjustment.Add(adj); } } } } } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); dataGridView1.Rows.Clear(); SetUp(false); frmKnitViewRep vRep = new frmKnitViewRep(19, _LastNumber); 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; TLADM_TranactionType TranType = null; int GProdKey = 0; TLADM_Departments Dept = null; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandatorySelected, true, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } var KO = (TLKNI_Order)cmbKnitOrder.SelectedItem; if (KO != null) { using (var context = new TTI2Entities()) { // We may have added some records //-------------------------------------------- var Machine = context.TLADM_MachineDefinitions.Find(KO.KnitO_Machine_FK); if (Machine != null) { if (MLNU > Machine.MD_LastNumberUsed) { Machine.MD_LastNumberUsed = MLNU + 1; } } var LNU = context.TLADM_LastNumberUsed.Find(2); if (LNU != null) { LNU.col8 += 1; } Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); if (Dept != null) { if (KO.KnitO_YarnO_FK == null) { if (KO.KnitO_CommisionCust) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 2002).FirstOrDefault(); } else { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 2003).FirstOrDefault(); } } else { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 2001).FirstOrDefault(); } } foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[0].Value == null) continue; var Pk = (int)row.Cells[0].Value; if (Pk != 0) { var GreigeProd = context.TLKNI_GreigeProduction.Find(Pk); if (GreigeProd != null) { var NewValue = (Decimal)row.Cells[3].Value; if (NewValue != GreigeProd.GreigeP_weight) { GreigeProd.GreigeP_weight += NewValue; TLKNI_GreigeTransactions GreigeT = new TLKNI_GreigeTransactions(); GreigeT.GreigeT_AdjustedWeight = NewValue; if (row.Cells[2].Value != null) GreigeT.GreigeT_Grade = row.Cells[2].Value.ToString(); else GreigeT.GreigeT_Grade = string.Empty; GreigeT.GreigeT_KOrder_FK = KO.KnitO_Pk; if ((int)row.Cells[0].Value == 0) GreigeT.GreigeT_Piece_FK = GProdKey; else GreigeT.GreigeT_Piece_FK = (int)row.Cells[0].Value; GreigeT.GreigeT_TransactionDate = dtpAdjustDate.Value; GreigeT.GreigeT_TransactionNumber = LNU.col8 - 1; GreigeT.GreigeT_TransactionType_FK = TranType.TrxT_Pk; GreigeT.GreigeT_ApprovedBy = txtApprovedBy.Text; context.TLKNI_GreigeTransactions.Add(GreigeT); } } } } string Mach_IP = Dns.GetHostEntry(Dns.GetHostName()) .AddressList.First(f => f.AddressFamily == AddressFamily.InterNetwork) .ToString(); 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 = "Greige Adjustment"; DailyLog.TLDL_AuthorisedBy = txtApprovedBy.Text; DailyLog.TLDL_Comments = txtGreigeAdjNo.Text; try { context.TLADM_DailyLog.Add(DailyLog); context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); SetUp(false); frmKnitViewRep vRep = new frmKnitViewRep(14, LNU.col8 - 1); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } 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; int CLNU = 0; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandatorySelected, false, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } using (var context = new TTI2Entities()) { var LNU = context.TLADM_LastNumberUsed.Find(2); if (LNU != null) { LNU.col8 += 1; } var custSelected = (TLADM_CustomerFile)cmbCommissionC.SelectedItem; var store = (TLADM_WhseStore)cmbStore.SelectedItem; if (custSelected != null) { CLNU = custSelected.Cust_LastNumberUsed; custSelected = context.TLADM_CustomerFile.Find(custSelected.Cust_Pk); custSelected.Cust_LastNumberUsed = CLNU + 1; } foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[0].Value == null) { continue; } TLKNI_GreigeCommissionTransctions comTrans = new TLKNI_GreigeCommissionTransctions(); comTrans.GreigeCom_Custdoc = txtCustDeliveryDoc.Text; comTrans.GreigeCom_Customer_FK = custSelected.Cust_Pk; comTrans.GreigeCom_Comments = txtComments.Text; comTrans.GreigeCom_CustOrderNo = (string)row.Cells[4].Value; comTrans.GreigeCom_Grade = (string)row.Cells[3].Value; comTrans.GreigeCom_GrnNo = CLNU; comTrans.GreigeCom_NettWeight = (decimal)row.Cells[5].Value; comTrans.GreigeCom_PieceNo = row.Cells[0].Value.ToString(); comTrans.GreigeCom_ProductType_FK = (int)row.Cells[2].Value; comTrans.GreigeCom_Transdate = dateTimePicker1.Value; comTrans.GreigeCom_TTSNo = (string)row.Cells[1].Value; comTrans.GreigeCom_Store_FK = store.WhStore_Id; comTrans.GreigeCom_Display = CLNU.ToString() + " " + txtCustDeliveryDoc.Text; context.TLKNI_GreigeCommissionTransctions.Add(comTrans); 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_KnitO_Fk = CLNU; //------------------------------------------------------ gp.GreigeP_KnitO_Fk = comTrans.GreigeCom_PK; gp.GreigeP_CommisionCust = true; gp.GreigeP_CommissionCust_FK = custSelected.Cust_Pk; gp.GreigeP_Grade = (string)row.Cells[3].Value; gp.GreigeP_InspDate = DateTime.Now; 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_weight = (decimal)row.Cells[5].Value; gp.GreigeP_weightAvail = (decimal)row.Cells[5].Value; gp.GreigeP_Store_FK = store.WhStore_Id; gp.GreigeP_Greige_Fk = (int)row.Cells[2].Value; gp.GreigeP_CommissionGrn = CLNU; context.TLKNI_GreigeProduction.Add(gp); } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to the database"); frmKnitViewRep vRep = new frmKnitViewRep(13, CLNU); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); dataGridView1.Rows.Clear(); SetUp(false); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLADM_TranactionType TranType = null; if (oBtn != null && formloaded) { var KO = (TLKNI_Order)cmbKnitOrder.SelectedItem; if (KO != null) { using (var context = new TTI2Entities()) { KO = context.TLKNI_Order.Find(KO.KnitO_Pk); KO.KnitO_Closed = true; KO.KnitO_ClosedDate = dtpKnitOrderClosed.Value; var LNU = context.TLADM_LastNumberUsed.Find(2); var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); foreach (DataGridViewRow dr in dataGridView1.Rows) { if (dr.Cells[0].Value == null) { continue; } if (dr.Cells[3].Value != null && (bool)dr.Cells[3].Value == true) { if (dr.Cells[4].Value == null) { MessageBox.Show("When using the select button please select an alternative Knit Order to allocate against", "Line " + (dr.Index + 1).ToString()); return; } } TLKNI_YarnTransactionDetails trnsDet = new TLKNI_YarnTransactionDetails(); trnsDet.KnitYD_Notes = txtNotes.Text; trnsDet.KnitYD_OriginalOrderNo = KO.KnitO_OrderNumber; trnsDet.KnitYD_PalletNo_FK = (int)dr.Cells[0].Value; trnsDet.KnitYD_RTS = false; trnsDet.KnitYD_TransactionDate = dtpKnitOrderClosed.Value; trnsDet.KnitYD_WriteOff = false; if (LNU != null) { trnsDet.KnitYD_TransactionNumber = LNU.col7; } trnsDet.KnitYD_ApprovedBy = string.Empty; trnsDet.KnitYD_NoOfCones = (int)dr.Cells[1].Value; trnsDet.KnitYD_NettWeight = (decimal)dr.Cells[2].Value; trnsDet.KnitYD_GrossWeight = 0.00M; trnsDet.KnitYD_KnitY_FK = KO.KnitO_Pk; trnsDet.KnitYD_YarnReturned = true; Decimal WeightRecorded = (decimal)dr.Cells[2].Value; var Pallet = context.TLKNI_YarnOrderPallets.Find(trnsDet.KnitYD_PalletNo_FK); if (Pallet != null) { trnsDet.KnitYD_YarnType_FK = Pallet.TLKNIOP_YarnType_FK; if (dr.Cells[3].Value != null && (bool)dr.Cells[3].Value == true) { //====================================================================== // has to be a negative number to facilitate the calculations //================================================================= TLKNI_YarnAllocTransctions TransAlloc = new TLKNI_YarnAllocTransctions(); TransAlloc.TLKYT_KnitOrder_FK = KO.KnitO_Pk; TransAlloc.TLKYT_NettWeight = -1 * WeightRecorded; TransAlloc.TLKYT_NoOfCones = -1 * (int)dr.Cells[1].Value;; TransAlloc.TLKYT_TransDate = dtpKnitOrderClosed.Value; TransAlloc.TLKYT_TranType = 3; TransAlloc.TLKYT_YOP_FK = Pallet.TLKNIOP_Pk; context.TLKNI_YarnAllocTransctions.Add(TransAlloc); //================================================================= // Now find the pallet to which the balance is going to be added //======================================================== var ReservedBy = (int)dr.Cells[4].Value; var Trans = context.TLKNI_YarnAllocTransctions.Where(x => x.TLKYT_KnitOrder_FK == ReservedBy && x.TLKYT_TranType == 1).FirstOrDefault(); if (Trans != null) { var PalletTo = context.TLKNI_YarnOrderPallets.Find(Trans.TLKYT_YOP_FK); if (PalletTo != null) { PalletTo.TLKNIOP_AdditionalYarn += WeightRecorded; //============================================= // we need a record of this transaction //======================================== TransAlloc = new TLKNI_YarnAllocTransctions(); TransAlloc.TLKYT_KnitOrder_FK = ReservedBy; TransAlloc.TLKYT_NoOfCones += (int)dr.Cells[1].Value; TransAlloc.TLKYT_NettWeight = WeightRecorded; TransAlloc.TLKYT_TransDate = dtpKnitOrderClosed.Value; TransAlloc.TLKYT_TranType = 3; TransAlloc.TLKYT_YOP_FK = PalletTo.TLKNIOP_Pk; context.TLKNI_YarnAllocTransctions.Add(TransAlloc); if (core.CalculatePalletNett(PalletTo) <= 0.00m) { PalletTo.TLKNIOP_PalletAllocated = true; } else { PalletTo.TLKNIOP_PalletAllocated = false; } } } trnsDet.KnitYD_TransactionType = 2005; } else { var Cones = (int)dr.Cells[1].Value; WeightRecorded = (decimal)dr.Cells[2].Value; trnsDet.KnitYD_YarnReturned = true; Pallet.TLKNIOP_NettWeightReturned += WeightRecorded; //============================================= //we need a record of this transaction //======================================== var TransAlloc = new TLKNI_YarnAllocTransctions(); TransAlloc.TLKYT_KnitOrder_FK = KO.KnitO_Pk; TransAlloc.TLKYT_NettWeight = WeightRecorded; TransAlloc.TLKYT_NoOfCones = -Cones; TransAlloc.TLKYT_TransDate = dtpKnitOrderClosed.Value; TransAlloc.TLKYT_TranType = 2; TransAlloc.TLKYT_YOP_FK = Pallet.TLKNIOP_Pk; context.TLKNI_YarnAllocTransctions.Add(TransAlloc); //========================================= // This should make the pallet available //====================================================== if (core.CalculatePalletNett(Pallet) <= 0.00M) { Pallet.TLKNIOP_PalletAllocated = true; } else { Pallet.TLKNIOP_PalletAllocated = false; } //============================== // Now do the the swop between stores // dont have to do this for the above has it stays in WIP spinning //=================================================== if (Pallet.TLKNIOP_OwnYarn) { frmSelectStore selectStore = new frmSelectStore(); selectStore.ShowDialog(); Pallet.TLKNIOP_Store_FK = selectStore.WhseId; /* * TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 1400).FirstOrDefault(); * if (TranType != null) * Pallet.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; */ trnsDet.KnitYD_TransactionType = 1400; } else { if (Pallet.TLKNIOP_CommisionCust) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 1300).FirstOrDefault(); if (TranType != null) { Pallet.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; } trnsDet.KnitYD_TransactionType = 1300; } else { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 1200).FirstOrDefault(); if (TranType != null) { Pallet.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; } trnsDet.KnitYD_TransactionType = 1200; } } } } context.TLKNI_YarnTransactionDetails.Add(trnsDet); } if (LNU != null) { LNU.col7 += 1; } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); dataGridView1.Rows.Clear(); frmKnitViewRep vRep = new frmKnitViewRep(11, LNU.col7 - 1); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); frmCloseKnitOrder_Load(this, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }
private void btnReport_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { YarnReportOptions YarnOpts = new YarnReportOptions(); if (chkQASummary.Checked) { YarnOpts.QASummary = true; } //-------------------------------------------------------------------------- // Do the selection first //----------------------------------------------------------------------- QueryParms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); QueryParms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); YarnOpts.toDate = QueryParms.ToDate.AddHours(23.59); int index = -1; foreach (var element in MandFieldsSelected) { ++index; if (element) { if (index == 0) { YarnOpts.K8CustSel = true; //YarnOpts.K8KnittingCustomer_FK = ((TLADM_CustomerFile)cmbKnittingCustomer.SelectedItem).Cust_Pk; } else if (index == 1) { YarnOpts.K8QualSel = true; //YarnOpts.K8GreigeProduct_FK = ((TLADM_Griege)cmbGreigeProduct.SelectedItem).TLGreige_Id; } else if (index == 2) { YarnOpts.K8MachineSel = true; //YarnOpts.K8KnittingMachine_FK = ((TLADM_MachineDefinitions)cmbKnittingMachine.SelectedItem).MD_Pk; } else if (index == 3) { YarnOpts.K8OperatorSel = true; //YarnOpts.K8Operator_Fk = ((TLADM_MachineOperators)cmbOperator.SelectedItem).MachOp_Pk; } } } //------------------------------------------------------------------- // Do The Sort next //----------------------------------------------------------------------- if (rbQA1.Checked) { YarnOpts.K8rbQA1 = true; } else if (rbQA2.Checked) { YarnOpts.K8rbQA2 = true; } else if (rbQA3.Checked) { YarnOpts.K8rbQA3 = true; } else if (rbQA4.Checked) { YarnOpts.K8rbQA4 = true; } if (rbExcludeCommission.Checked) { YarnOpts.ExcludeCommission = true; } frmKnitViewRep vRep = new frmKnitViewRep(22, QueryParms, YarnOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); MandFieldsSelected = core.PopulateArray(MandatoryFields.Length, false); } }
private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { YarnReportOptions YarnOpts = new YarnReportOptions(); var index = -1; YarnOpts.BIFSummarised = rbBIFSummarised.Checked; QueryParms.BoughtInFabric = chkBoughtInFabric.Checked; //QueryParms.Grade = txtGrade.Text; foreach (var element in MandSelected) { ++index; if (element) { if (index == 0) { YarnOpts.K10Store = true; // YarnOpts.K10StoreFK = ((TLADM_WhseStore)cmboStore.SelectedItem).WhStore_Id; } else if (index == 1) { YarnOpts.K10Grade = true; // YarnOpts.K10GradeFK = txtGrade.Text; } else if (index == 2) { YarnOpts.GreigeProduct = true; // YarnOpts.K10GreigeProductFK = ((TLADM_Griege)cmboProduct.SelectedItem).TLGreige_Id; } else if (index == 3) { YarnOpts.K10ProductQ = true; // YarnOpts.K10GreigeProductQFK = ((TLADM_GreigeQuality)cmboProductGroup.SelectedItem).GQ_Pk; } else if (index == 4) { YarnOpts.K10STF = true; // YarnOpts.K10StockTakeFreqFK = ((TLADM_StockTakeFreq)cmboStockTake.SelectedItem).STF_Pk; } } } // QueryParms.GradeAwithWarnings = (bool)cbIncludeWarnings.Checked; if (!rbBIFSummarised.Checked) { frmKnitViewRep vRep = new frmKnitViewRep(24, QueryParms, YarnOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } else { frmKnitViewRep vRep = new frmKnitViewRep(30, QueryParms, YarnOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } /* * if (_Version) * { * * * } * else * { * if (YarnOpts.K10STF || chkBoughtInFabric.Checked) // This is for the SOH Report * { * if (!chkBoughtInFabric.Checked || !rbBIFSummarised.Checked) * { * frmKnitViewRep vRep = new frmKnitViewRep(24, QueryParms, YarnOpts); * int h = Screen.PrimaryScreen.WorkingArea.Height; * int w = Screen.PrimaryScreen.WorkingArea.Width; * vRep.ClientSize = new Size(w, h); * vRep.ShowDialog(this); * } * else * { * frmKnitViewRep vRep = new frmKnitViewRep(30, QueryParms, YarnOpts); * int h = Screen.PrimaryScreen.WorkingArea.Height; * int w = Screen.PrimaryScreen.WorkingArea.Width; * vRep.ClientSize = new Size(w, h); * vRep.ShowDialog(this); * } * * } * else * { * * frmKnitViewRep vRep = new frmKnitViewRep(30, QueryParms); * int h = Screen.PrimaryScreen.WorkingArea.Height; * int w = Screen.PrimaryScreen.WorkingArea.Width; * vRep.ClientSize = new Size(w, h); * vRep.ShowDialog(this); * } * * } */ MandSelected = core.PopulateArray(MandatoryFields.Length, false); cmboStockTake.Items.Clear(); cmboProductGroup.Items.Clear(); cmboProduct.Items.Clear(); cmboStore.Items.Clear(); chkBoughtInFabric.Checked = false; rbBIFSummarised.Checked = true; Form_Load(this, null); } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; int RecCount = 0; int LastNumberUsed = 0; TLADM_Suppliers CommissionCust; TLKNI_YarnTransaction yarnT; TLKNI_YarnTransactionDetails yarnTD; TLADM_TranactionType TranType = null; TLKNI_YarnOrderPallets PalletStore; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandFieldsSelected, false, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } if (dataGridView1.RowCount == 0) { MessageBox.Show("Please enter a least one row in the datagrid"); return; } foreach (DataGridViewRow dr in dataGridView1.Rows) { var tst = fieldEntered.Find(x => x.rownumber == dr.Index); if (tst.fieldComplete == null) { continue; } var cnt = tst.fieldComplete.Where(x => x == false).Count(); if (cnt == MandatoryRows.Length) { continue; } cnt = tst.fieldComplete.Where(x => x == true).Count(); if (cnt != MandatoryRows.Length) { MessageBox.Show("Line " + (1 + dr.Index).ToString() + " Has not been completed correctly"); return; } } CommissionCust = (TLADM_Suppliers)cmbCommissionCustomers.SelectedItem; using (var context = new TTI2Entities()) { yarnT = new TLKNI_YarnTransaction(); yarnT.KnitY_TransactionDate = dtpDateReceived.Value; yarnT.KnitY_Customer_FK = CommissionCust.Sup_Pk; yarnT.KnitY_Notes = rtbComments.Text; yarnT.KnitY_TransactionDoc = txtCustomerDoc.Text; yarnT.KnitY_ThirdParty = true; var LastNumber = context.TLADM_LastNumberUsed.Find(2); if (LastNumber != null) { LastNumberUsed = LastNumber.col2; yarnT.KnitY_GRNNumber = LastNumberUsed; LastNumber.col2 += 1; } var YarnLastNumber = context.TLADM_LastNumberUsed.Find(1); var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); if (Dept != null) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 200).FirstOrDefault(); } try { context.TLKNI_YarnTransaction.Add(yarnT); context.SaveChanges(); StringBuilder sb = null; int Counter = 0; foreach (DataGridViewRow dr in dataGridView1.Rows) { var tst = fieldEntered.Find(x => x.rownumber == dr.Index); if (tst.fieldComplete == null) { continue; } var cnt = tst.fieldComplete.Where(x => x == false).Count(); if (cnt == MandatoryRows.Count()) { continue; } var PalletNo = (int)dr.Cells[0].Value; PalletStore = new TLKNI_YarnOrderPallets(); PalletStore.TLKNIOP_CommisionCust = false; sb = new StringBuilder(); sb.Append(YarnLastNumber.col6.ToString()); sb.Append(" - "); sb.Append((++Counter).ToString()); PalletStore.TLKNIOP_TLPalletNo = sb.ToString(); PalletStore.TLKNIOP_Cones = (int)dr.Cells[7].Value; PalletStore.TLKNIOP_DatePacked = dtpDateReceived.Value; PalletStore.TLKNIOP_Grade = string.Empty; PalletStore.TLKNIOP_GrossWeight = (decimal)dr.Cells[5].Value; PalletStore.TLKNIOP_TareWeight = 0.00M; PalletStore.TLKNIOP_NettWeight = (decimal)dr.Cells[6].Value; PalletStore.TLKNIOP_YarnType_FK = (int)dr.Cells[1].Value; PalletStore.TLKNIOP_PalletNo = PalletNo; PalletStore.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; PalletStore.TLKNIOP_NettWeightReserved = 0.00M; PalletStore.TLKNIOP_HeaderRecord_FK = yarnT.KnitY_Pk; PalletStore.TLKNIOP_ConesReserved = 0; context.TLKNI_YarnOrderPallets.Add(PalletStore); context.SaveChanges(); yarnTD = new TLKNI_YarnTransactionDetails(); yarnTD.KnitYD_KnitY_FK = yarnT.KnitY_Pk; yarnTD.KnitYD_YarnType_FK = (int)dr.Cells[1].Value; yarnTD.KnitYD_PalletNo_FK = PalletStore.TLKNIOP_Pk; yarnTD.KnitYD_GrossWeight = (decimal)dr.Cells[5].Value; yarnTD.KnitYD_NettWeight = (decimal)dr.Cells[6].Value; yarnTD.KnitYD_NoOfCones = (int)dr.Cells[7].Value; yarnTD.KnitYD_TransactionDate = dtpDateReceived.Value; yarnTD.KnitYD_RTS = false; yarnTD.KnitYD_TransactionNumber = LastNumberUsed; if (TranType != null) { yarnTD.KnitYD_TransactionType = TranType.TrxT_Pk; } yarnTD.KnitYD_RTS = false; context.TLKNI_YarnTransactionDetails.Add(yarnTD); RecCount += 1; } YarnLastNumber = context.TLADM_LastNumberUsed.Find(1); if (YarnLastNumber != null) { YarnLastNumber.col6 += 1; } context.SaveChanges(); formloaded = false; dataGridView1.Rows.Clear(); formloaded = true; MessageBox.Show("Records stored successfully to database"); frmKnitViewRep vRep = new frmKnitViewRep(3, yarnT.KnitY_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); SetUp(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLKNI_YarnTransactionDetails yarnTD; TLSPN_YarnOrderPallets palletStore; TLADM_TranactionType TranType = null; int LastNumberUsed = 0; bool success = true; if (oBtn != null && formloaded) { var errorM = core.returnMessage(MandatorySelected, true, MandatoryFields); if (!string.IsNullOrEmpty(errorM)) { MessageBox.Show(errorM); return; } //------------------------------------------------------------- // must write out a header record //------------------------------------------------------------------ if (rbCommission.Checked || rb3rdParty.Checked) { var YarnTrx = (TLKNI_YarnTransaction)oCmboTransactions.SelectedItem; if (YarnTrx != null) { using (var context = new TTI2Entities()) { var LastNumber = context.TLADM_LastNumberUsed.Find(2); if (LastNumber != null) { LastNumberUsed = LastNumber.col5; LastNumber.col5 += 1; } var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); if (Dept != null) { if (rbCommission.Checked) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 600).FirstOrDefault(); } else { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 500).FirstOrDefault(); } } try { context.SaveChanges(); var yt = (TLKNI_YarnTransaction)oCmboTransactions.SelectedItem; foreach (DataGridViewRow dr in dataGridView1.Rows) { if (!(bool)dr.Cells[1].Value) { continue; } yarnTD = new TLKNI_YarnTransactionDetails(); yarnTD.KnitYD_KnitY_FK = YarnTrx.KnitY_Pk; var TypeOfYarn = dr.Cells[3].Value; var YarnDetails = context.TLADM_Yarn.Where(x => x.YA_Description.Contains(TypeOfYarn.ToString())).FirstOrDefault(); if (YarnDetails != null) { yarnTD.KnitYD_YarnType_FK = YarnDetails.YA_Id; } yarnTD.KnitYD_PalletNo_FK = (int)dr.Cells[0].Value; yarnTD.KnitYD_NoOfCones = Convert.ToInt32(dr.Cells[7].Value.ToString()); yarnTD.KnitYD_NettWeight = Convert.ToDecimal(dr.Cells[8].Value.ToString()); yarnTD.KnitYD_TransactionNumber = LastNumberUsed; yarnTD.KnitYD_TransactionDate = dateTimePicker1.Value; yarnTD.KnitYD_ApprovedBy = txtApprovedBy.Text; yarnTD.KnitYD_Notes = rtbNotes.Text; yarnTD.KnitYD_RTS = false; if (yt != null) { yarnTD.KnitYD_OriginalOrderNo = yt.KnitY_GRNNumber; } if (TranType != null) { yarnTD.KnitYD_TransactionType = TranType.TrxT_Pk; } context.TLKNI_YarnTransactionDetails.Add(yarnTD); //-------------------------------------------------------------------- // Now we have to keep the Status file uptodate //-------------------------------------------------------------------------- var _key = (int)dr.Cells[0].Value; var palletStorex = context.TLKNI_YarnOrderPallets.Find(_key); if (palletStorex != null) { if ((bool)dr.Cells[9].Value == true) { palletStorex.TLKNIOP_Cones -= yarnTD.KnitYD_NoOfCones; palletStorex.TLKNIOP_NettWeight -= yarnTD.KnitYD_NettWeight; palletStorex.TLKNIOP_GrossWeight -= yarnTD.KnitYD_GrossWeight; } else { palletStorex.TLKNIOP_Cones += yarnTD.KnitYD_NoOfCones; palletStorex.TLKNIOP_NettWeight += yarnTD.KnitYD_NettWeight; palletStorex.TLKNIOP_GrossWeight += yarnTD.KnitYD_GrossWeight; } if (core.CalculatePalletNett(palletStorex) <= 0.00M) { palletStorex.TLKNIOP_PalletAllocated = true; } else { palletStorex.TLKNIOP_PalletAllocated = false; } } } context.SaveChanges(); MessageBox.Show("Data successfully stored to database"); frmKnitViewRep vRep = new frmKnitViewRep(6, LastNumberUsed); 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); success = false; } } if (success) { dataGridView1.Rows.Clear(); SetUp(); } } } else { } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLKNI_YarnTransactionDetails yarnTD; TLADM_TranactionType TranType = null; int LastNumberUsed = 0; bool success = true; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandatoryFieldsSelected, true, MandatoryFields); if (!string.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } var YO = (TLKNI_YarnTransaction)cmboYarnOrder.SelectedItem; if (YO != null) { using (var context = new TTI2Entities()) { var LNU = context.TLADM_LastNumberUsed.Find(2); if (LNU != null) { LastNumberUsed = LNU.col3; LNU.col3 += 1; } var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); if (Dept != null) { if (_reportNo == 1) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 400).FirstOrDefault(); } else { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 300).FirstOrDefault(); } } foreach (DataGridViewRow dr in dataGridView1.Rows) { if (!(bool)dr.Cells[1].Value) { continue; } yarnTD = new TLKNI_YarnTransactionDetails(); yarnTD.KnitYD_KnitY_FK = YO.KnitY_Pk; var TypeOfYarn = dr.Cells[3].Value; var YarnDetails = context.TLADM_Yarn.Where(x => x.YA_Description.Contains(TypeOfYarn.ToString())).FirstOrDefault(); if (YarnDetails != null) { yarnTD.KnitYD_YarnType_FK = YarnDetails.YA_Id; } yarnTD.KnitYD_PalletNo_FK = (int)dr.Cells[0].Value; yarnTD.KnitYD_GrossWeight = (decimal)dr.Cells[7].Value; yarnTD.KnitYD_NettWeight = (decimal)dr.Cells[8].Value; yarnTD.KnitYD_NoOfCones = (int)dr.Cells[9].Value; yarnTD.KnitYD_WriteOff = true; yarnTD.KnitYD_RTS = true; yarnTD.KnitYD_TransactionDate = dtpDateReceived.Value; yarnTD.KnitYD_TransactionNumber = LastNumberUsed; if (TranType != null) { yarnTD.KnitYD_TransactionType = TranType.TrxT_Pk; } context.TLKNI_YarnTransactionDetails.Add(yarnTD); //-------------------------------------------------------------------- // Now we have to keep the Status file uptodate //-------------------------------------------------------------------------- TLKNI_YarnOrderPallets palletStore = context.TLKNI_YarnOrderPallets.Find(yarnTD.KnitYD_PalletNo_FK); if (palletStore != null) { palletStore.TLKNIOP_Cones -= yarnTD.KnitYD_NoOfCones; palletStore.TLKNIOP_NettWeight -= yarnTD.KnitYD_NettWeight; palletStore.TLKNIOP_GrossWeight -= yarnTD.KnitYD_GrossWeight; palletStore.TLKNIOP_PalletAllocated = true; } } try { context.SaveChanges(); frmKnitViewRep vRep = new frmKnitViewRep(4, LastNumberUsed); 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); } } if (success) { dataGridView1.Rows.Clear(); MessageBox.Show("Data saved to database successfully"); SetUp(); } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLADM_CustomerFile CommissionCust; TLKNI_YarnTransaction yarnT; TLKNI_YarnTransactionDetails yarnTD; //TLKNI_YarnStatus yarnStat; TLADM_TranactionType TranType = null; TLKNI_YarnOrderPallets PalletStore; int LastNumberUsed = 0; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandSelected, false, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } if (dataGridView1.RowCount == 0) { MessageBox.Show("Please enter a least one row in the datagrid"); return; } CommissionCust = (TLADM_CustomerFile)cmbCommissionCustomers.SelectedItem; using (var context = new TTI2Entities()) { //------------------------- // Yarn Header Record //---------------------------------------- yarnT = new TLKNI_YarnTransaction(); yarnT.KnitY_TransactionDate = dtpDateReceived.Value; yarnT.KnitY_Customer_FK = CommissionCust.Cust_Pk; yarnT.KnitY_Notes = rtbComments.Text; yarnT.KnitY_TransactionDoc = txtCustomerDoc.Text; yarnT.KnitY_ThirdParty = false; yarnT.KnitY_RTS = false; var LastNumber = context.TLADM_LastNumberUsed.Find(2); if (LastNumber != null) { LastNumberUsed = LastNumber.col1; yarnT.KnitY_GRNNumber = LastNumberUsed; LastNumber.col1 += 1; } var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); if (Dept != null) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 100).FirstOrDefault(); } try { context.TLKNI_YarnTransaction.Add(yarnT); context.SaveChanges(); foreach (DataGridViewRow dr in dataGridView1.Rows) { if (dr.Cells[1].Value == null) { continue; } var PalletNo = (int)dr.Cells[0].Value; PalletStore = new TLKNI_YarnOrderPallets(); PalletStore.TLKNIOP_CommisionCust = true; PalletStore.TLKNIOP_Cones = (int)dr.Cells[7].Value; PalletStore.TLKNIOP_DatePacked = dtpDateReceived.Value; PalletStore.TLKNIOP_Grade = string.Empty; PalletStore.TLKNIOP_GrossWeight = (decimal)dr.Cells[5].Value; PalletStore.TLKNIOP_TareWeight = 0.00M; PalletStore.TLKNIOP_NettWeight = (decimal)dr.Cells[6].Value; PalletStore.TLKNIOP_YarnType_FK = (int)dr.Cells[1].Value; PalletStore.TLKNIOP_PalletNo = PalletNo; PalletStore.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; PalletStore.TLKNIOP_NettWeightReserved = 0.00M; PalletStore.TLKNIOP_HeaderRecord_FK = yarnT.KnitY_Pk; PalletStore.TLKNIOP_ConesReserved = 0; context.TLKNI_YarnOrderPallets.Add(PalletStore); context.SaveChanges(); yarnTD = new TLKNI_YarnTransactionDetails(); yarnTD.KnitYD_KnitY_FK = yarnT.KnitY_Pk; yarnTD.KnitYD_YarnType_FK = (int)dr.Cells[1].Value; yarnTD.KnitYD_PalletNo_FK = PalletStore.TLKNIOP_Pk; yarnTD.KnitYD_GrossWeight = (decimal)dr.Cells[5].Value; yarnTD.KnitYD_NettWeight = (decimal)dr.Cells[6].Value; yarnTD.KnitYD_NoOfCones = (int)dr.Cells[7].Value; yarnTD.KnitYD_TransactionDate = dtpDateReceived.Value; yarnTD.KnitYD_RTS = false; yarnTD.KnitYD_TransactionNumber = LastNumberUsed; if (TranType != null) { yarnTD.KnitYD_TransactionType = TranType.TrxT_Pk; } yarnTD.KnitYD_RTS = false; context.TLKNI_YarnTransactionDetails.Add(yarnTD); } context.SaveChanges(); dataGridView1.Rows.Clear(); MessageBox.Show("Records stored successfully to database"); frmKnitViewRep vRep = new frmKnitViewRep(1, yarnT.KnitY_Pk); vRep.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnReport_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { YarnReportOptions YarnOpts = new YarnReportOptions(); if (chkQASummary.Checked) { YarnOpts.QASummary = true; } QueryParms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); QueryParms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); QueryParms.ToDate = QueryParms.ToDate.AddHours(23.59); QueryParms.Grade = txtGrade.Text; int index = -1; foreach (var element in MandFieldsSelected) { ++index; if (element) { if (index == 0) { YarnOpts.K7CustSel = true; //YarnOpts.K7KnittingCustomer_FK = ((TLADM_CustomerFile)cmbKnittingCustomer.SelectedItem).Cust_Pk; } else if (index == 1) { YarnOpts.K7ProdSel = true; //YarnOpts.K7GreigeProduct_FK = ((TLADM_Griege)cmbGreigeProduct.SelectedItem).TLGreige_Id; } else if (index == 2) { YarnOpts.K7MachineSel = true; //YarnOpts.K7Machine_FK = ((TLADM_MachineDefinitions)cmbMachines.SelectedItem).MD_Pk; } else if (index == 3) { YarnOpts.K7OperatorSel = true; //YarnOpts.K7Operator_FK = ((TLADM_MachineOperators)cmbOperator.SelectedItem).MachOp_Pk; } else if (index == 4) { YarnOpts.K7GradeSel = true; YarnOpts.K7Grade = txtGrade.Text; } } } if (rbGPByMachine.Checked) { YarnOpts.K7rbQA1 = true; } else if (rbGPByTotal.Checked) { YarnOpts.K7rbQA2 = true; } else if (rbGPOperator.Checked) { YarnOpts.K7rbQA3 = true; } frmKnitViewRep vRep = new frmKnitViewRep(23, QueryParms, YarnOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); MandFieldsSelected = core.PopulateArray(MandatoryFields.Length, false); Form_Load(this, null); } }
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; } 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_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_TransNumber = TransNo; context.TLKNI_BoughtInFabric.Add(BoughtIn); //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 = TransNo; // 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[4].Value; gp.GreigeP_Store_FK = CurrentStore.WhStore_Id; gp.GreigeP_Greige_Fk = Greige.TLGreige_Id; context.TLKNI_GreigeProduction.Add(gp); } try { context.SaveChanges(); MessageBox.Show("data saved successfully to database"); frmKnitViewRep vRep = new frmKnitViewRep(31, TransNo); vRep.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }