private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { YarnStockOHSel reptSel = new YarnStockOHSel(); if (rbByStore.Checked) { reptSel.ByStore = true; } else if (rbTextCount.Checked) { reptSel.ByTexCount = true; } else if (rbTwistFactor.Checked) { reptSel.ByTwistFactor = true; } else { reptSel.ByYarnOrder = true; } frmViewReport vRep = new frmViewReport(18, reptSel); 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) { YarnTOptions repOptions = new YarnTOptions(); repOptions.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); repOptions.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); repOptions.ReportSelected = ReportSelected; if (radioButton1.Checked) { repOptions.TransNumber = transNumber[0]; } else if (radioButton2.Checked) { repOptions.TransNumber = transNumber[1]; } else if (radioButton3.Checked) { repOptions.TransNumber = transNumber[2]; } else if (radioButton4.Checked) { repOptions.TransNumber = transNumber[3]; } frmViewReport vRep = new frmViewReport(13, repOptions); 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) { DateTime From = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); DateTime To = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); WasteSelection wasteSelect = new WasteSelection(); wasteSelect._From = From; wasteSelect._To = To; if (rbSOH.Checked) { wasteSelect._IncludeSOH = true; } else { wasteSelect._IncludeDispose = true; } frmViewReport vRep = new frmViewReport(19, wasteSelect); 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) { SliverProductionSelection sliverProductionSelection = new SliverProductionSelection(); sliverProductionSelection.DateFrom = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); sliverProductionSelection.DateTo = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); if (rbtnSummary.Checked) { sliverProductionSelection.Summary = true; } else { sliverProductionSelection.Detail = true; } frmViewReport vRep = new frmViewReport(25, sliverProductionSelection); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void Issue_Closing(object sender, FormClosingEventArgs e) { if (Transactions) { if (MessageBox.Show("Do you wish to print the transaction listing report?", "Print Transactions", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // Cancel the Closing event //================================================ e.Cancel = true; YarnTOptions repOptions = new YarnTOptions(); repOptions.FromDate = Convert.ToDateTime(dateTimePicker1.Value.ToShortDateString()); repOptions.ToDate = Convert.ToDateTime(dateTimePicker1.Value.ToShortDateString()); repOptions.ReportSelected = 0; repOptions.TransNumber = 800; frmViewReport vRep = new frmViewReport(13, repOptions); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); Transactions = false; } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oButton = (Button)sender; if (oButton != null && formLoaded) { if (rbYarnOrder.Checked) { YarnRepOpts.YarnOrderAuditTrail = true; } else { YarnRepOpts.KnitOrderAuditTrail = true; } QueryParms.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); QueryParms.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); QueryParms.ToDate = QueryParms.ToDate.AddHours(23); frmViewReport vRep = new frmViewReport(24, QueryParms, YarnRepOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); cmboYarnOrder.Items.Clear(); cmboYarnType.Items.Clear(); this.frmYarnOrderAuditTrail_Load(this, null); } }
private void btnPickList_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (dataGridView1.Rows.Count == 0) { MessageBox.Show("Please select a lot number from the drop down list"); return; } var cnt = RowsSelected.Where(x => x == false).Count(); if (cnt == RowsSelected.Count()) { MessageBox.Show("Please select at least one row from the grid as shown"); return; } var LotNo = (TLSPN_CottonTransactions)cmbLotNo.SelectedItem; frmViewReport vRep = new frmViewReport(11, LotNo.cotrx_LotNo, dataGridView1); 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) { QAYarnReportOptions repsel = new QAYarnReportOptions(); repsel.from = Convert.ToDateTime(dtpRSBFromDate.Value.ToShortDateString()); repsel.to = Convert.ToDateTime(dtpRSBToDate.Value.ToShortDateString()); if (rbCardMeasurements.Checked) { repsel.MeasurementOption = 1; } else if (rbSpinning.Checked) { repsel.MeasurementOption = 2; } else if (rbRSBMeasurements.Checked) { repsel.MeasurementOption = 3; if (rbOutsideTYes.Checked) { QueryParms.OutSideTolerance = true; } QueryParms.LowerTolerance = Convert.ToInt32(txtBottomTolerance.Text); QueryParms.UpperTolerance = Convert.ToInt32(txtTopTolerance.Text); } //------------------------------------------------------------------------------------- // Now To Print the Report //---------------------------------------------------------------------------------------- if (chkRSBQaSummary.Checked) { repsel.QASummary = true; } QueryParms.FromDate = repsel.from; QueryParms.ToDate = repsel.to; frmViewReport vRep = new frmViewReport(14, QueryParms, repsel); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); cmboRSBMachines.Items.Clear(); this.frmQAReportSelection_Load(this, null); //------------------------------------------------------------------------------------------------- } }
private void button2_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { using (var context = new TTI2Entities()) { foreach (DataGridViewRow rw in dataGridView1.Rows) { if (!(bool)rw.Cells[1].Value) { continue; } TLSPN_CottonReceivedBales bales = context.TLSPN_CottonReceivedBales.Find((int)rw.Cells[0].Value); if (bales != null) { if ((bool)rw.Cells[1].EditedFormattedValue) { bales.CoBales_CottonSequence = Convert.ToInt32(txtIssueToProdNo.Text); bales.CoBales_BlowRoomPosition = (int)rw.Cells[2].Value; } else { bales.CoBales_CottonSequence = 0; bales.CoBales_BlowRoomPosition = 0; } try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } //----------------------------------------------------------------------- //Now we need to print the report //------------------------------------------------------------------- frmViewReport vRep = new frmViewReport(1); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } }
private void btnPickList_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var LotNo = (TLSPN_CottonTransactions)cmbLotNo.SelectedItem; frmViewReport vRep = new frmViewReport(11, LotNo.cotrx_LotNo, dataGridView1); 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) { StockStatusReportOptions stat = new StockStatusReportOptions(); //Yarn Stock Status //----------------------------------------- if (rbStockStatYO.Checked) { stat.YSSOption = 1; } else if (rbStockStatTex.Checked) { stat.YSSOption = 2; } else if (rbStockStatMachine.Checked) { stat.YSSOption = 3; } // Yarn Order Status //------------------------------------------------------------ if (rbOrderStatWIP.Checked) { stat.OrderStatus = 1; stat.YSSOption = 0; } //--------------------------------------------------------------------- // //--------------------------------------------------------------------------- // Dates //---------------------------------- stat.DateFrom = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); stat.DateTo = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); //================================================================= frmViewReport vRep = new frmViewReport(12, stat); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); SetUp(); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { YarnProductionSel ysel = new YarnProductionSel(); ysel.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); ysel.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); if (rbYes.Checked) { ysel.IncludeClosed = true; } if (rbSpecificYes.Checked) { var OrderDt = (TLSPN_YarnOrder)cmbSpecificOrder.SelectedItem; if (OrderDt == null) { MessageBox.Show("Please select an order number from the drop down list "); return; } ysel.orderKey = OrderDt.YarnO_Pk; ysel.SpecificOrder = true; ysel.IncludeClosed = false; } if (chkQASummary.Checked) { ysel.QASummary = true; } frmViewReport vRep = new frmViewReport(16, ysel); 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) { var CotTrans = (TLSPN_CottonTransactions)comboLotNo.SelectedItem; if (CotTrans == null) { MessageBox.Show("Please select a Lot number from the designated drop down box"); return; } ReportOptions repOpts = new ReportOptions(); repOpts.Cotton_LotNo = CotTrans.cotrx_LotNo; frmViewReport vRep = new frmViewReport(22, repOpts); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnLabels_Click(object sender, EventArgs e) { Button oBtn = sender as Button; int _fromP = 1; int _toP = 1; if (oBtn != null && formloaded) { if (Convert.ToInt32(txtNoOfCones.Text) == 0) { MessageBox.Show("please enter the number of cones for this pallet"); return; } var selected = (TLSPN_YarnOrder)cmbYarnOrder.SelectedItem; if (selected != null) { var fromP = (TLSPN_YarnOrderPallets)cmbFromPalletNo.SelectedItem; if (fromP != null) { _fromP = fromP.YarnOP_PalletNo; } var toP = (TLSPN_YarnOrderPallets)cmbToPalletNo.SelectedItem; if (toP != null) { _toP = toP.YarnOP_PalletNo; } frmViewReport vRep = new frmViewReport(10, selected.YarnO_Pk, _fromP, _toP); 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) { TLSPN_CottonReceivedBales bales; Button oBtn = sender as Button; if (oBtn != null & formloaded) { if (RowsSelected != null && rbWriteOff.Checked) { var cnt = RowsSelected.Where(x => x == false).Count(); if (cnt == RowsSelected.Count()) { MessageBox.Show("Please select at least one row from the grid as shown"); return; } } var errorM = core.returnMessage(MandSelected, true, MandatoryFields); if (!string.IsNullOrEmpty(errorM)) { MessageBox.Show(errorM); return; } var LotDetails = (TLSPN_CottonTransactions)cmbLotNo.SelectedItem; //dont forget last number used //------------------------------------------- using (var context = new TTI2Entities()) { var LastNumber = context.TLADM_LastNumberUsed.Find(1); if (LastNumber != null) { LastNumber.col3 += 1; } // 0 // 1 Selected // 2 Bales Numeric // 3 MIC Decimal // 4 kgs (NETT) Decimal // 5 Staple Decimal // 6 kgs (GROSS) decimal int NoBales = 0; decimal NettMass = 0M; decimal GrossMass = 0M; var ContractDetails = (TLADM_CottonContracts)cmbContractNo.SelectedItem; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[1].Value == null || (bool)row.Cells[1].Value == false) { continue; } NoBales += 1; NettMass += (decimal)row.Cells[4].Value; GrossMass += (decimal)row.Cells[6].Value; if (rbWriteOn.Checked) { TLSPN_CottonReceivedBales Bales = new TLSPN_CottonReceivedBales(); Bales.CotBales_BaleNo = (int)row.Cells[2].Value; Bales.CotBales_Mic = (decimal)row.Cells[3].Value; Bales.CotBales_Staple = (decimal)row.Cells[5].Value; Bales.CotBales_Weight_Nett = (decimal)row.Cells[4].Value; Bales.CotBales_LotNo = LotDetails.cotrx_LotNo; Bales.CotBales_Weight_Gross = (decimal)row.Cells[6].Value; Bales.CoBales_CottonSequence = Convert.ToInt32(txtAdjustmentNumber.Text); context.TLSPN_CottonReceivedBales.Add(Bales); } else { bales = context.TLSPN_CottonReceivedBales.Find((int)row.Cells[0].Value); if (bales != null) { if ((bool)row.Cells[1].Value == true) { bales.CoBales_CottonReturned = true; bales.CoBales_CottonSequence = Convert.ToInt32(txtAdjustmentNumber.Text); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } } //---------------------------------------------------------------------------- // //------------------------------------------------------------------------------ TLSPN_CottonTransactions cotTrans = new TLSPN_CottonTransactions(); cotTrans.cotrx_TransDate = dateTimePicker1.Value; cotTrans.cotrx_ContractNo_Fk = ContractDetails.CottonCon_Pk; cotTrans.cotrx_LotNo = Convert.ToInt32(cmbLotNo.SelectedValue); cotTrans.cotrx_NetWeight = NettMass; cotTrans.cotrx_GrossWeight = GrossMass; cotTrans.cotrx_NoBales = NoBales; //cotTrans.cotrx_VehReg_FK = null; cotTrans.cotrx_WeighBridgeFull = 0; cotTrans.cotrx_WeighBridgeEmpty = 0; cotTrans.cotrx_NettPerWB = 0; cotTrans.cotrx_Return_No = Convert.ToInt32(txtAdjustmentNumber.Text); cotTrans.cotrx_Supplier_FK = ContractDetails.CottonCon_ConSupplier_FK; cotTrans.cotrx_Notes = rtbNotes.Text; //------------------------------------------------------------------------- // Consult Table TLADM_TranTypes //---------------------------------------------------------------------------- var DepDetail = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "SPIN").FirstOrDefault(); if (DepDetail != null) { var Trantype = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 400 && x.TrxT_Department_FK == DepDetail.Dep_Id).FirstOrDefault(); if (Trantype != null) { cotTrans.cotrx_TranType = Trantype.TrxT_Pk; } } if (rbWriteOff.Checked) { cotTrans.cotrx_WriteOff = true; } else { cotTrans.cotrx_WriteOff = false; } //------------------------------------------------------------------------ context.TLSPN_CottonTransactions.Add(cotTrans); //----------------------------------------------------------- // //------------------------------------------------------------ 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 = DepDetail.Dep_Id; DailyLog.TLDL_Date = DateTime.Now; DailyLog.TLDL_TransDetail = "Cotton Adjustment"; DailyLog.TLDL_AuthorisedBy = txtAdjustmentNumber.Text; DailyLog.TLDL_Comments = txtAdjustmentNumber.Text; context.TLADM_DailyLog.Add(DailyLog); try { context.SaveChanges(); var Retno = Convert.ToInt32(txtAdjustmentNumber.Text); frmViewReport vRep = new frmViewReport(4, Retno); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); SetUp(); MessageBox.Show("Data saved to database successfully"); } 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 ErrorM = core.returnMessage(MandSelected, true, MandatoryFields); if (!string.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } //-------------------------------------------------------------------------------- // Now update the order details //-------------------------------------------------------------------------- TLSPN_YarnOrder yarnorder = new TLSPN_YarnOrder(); using (var context = new TTI2Entities()) { if (_EditMode) { var selected = (TLSPN_YarnOrder)cmbPrevious.SelectedItem; if (selected != null) { yarnorder = context.TLSPN_YarnOrder.Find(selected.YarnO_Pk); } } var Merge = (TLSPN_CottonMerge)cmbMerge.SelectedItem; if (Merge != null) { yarnorder.YarnO_MergeContract_FK = (int)cmbMerge.SelectedValue; } var CottonOrigin = context.TLADM_CottonOrigin.Where(x => x.CottonOrigin_Description == txtCottonOrigin.Text).FirstOrDefault(); if (CottonOrigin != null) { yarnorder.Yarno_CottonOrigin_FK = CottonOrigin.CottonOrigin_Pk; } yarnorder.YarnO_Date = dtpYarnOrderDate.Value; yarnorder.YarnO_DelDate = dtpYarnDeliveryDate.Value; var MachineNo = (TLADM_MachineDefinitions)cmbMachineNo.SelectedItem; if (MachineNo != null) { yarnorder.Yarno_MachNo_FK = MachineNo.MD_Pk; } if (!_EditMode) { yarnorder.YarnO_OrderNumber = Convert.ToInt32(txtYarnOrder.Text); } yarnorder.Yarno_OrderWeight = Convert.ToInt32(txtOrderWeight.Text); yarnorder.Yarno_Packing = rtbPacking.Text; var YarnType = (TLADM_Yarn)cmbYarnType.SelectedItem; if (YarnType != null) { yarnorder.Yarno_YarnType_FK = YarnType.YA_Id; } var deptDetail = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "SPIN").FirstOrDefault(); if (deptDetail != null) { var tranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == deptDetail.Dep_Id && x.TrxT_Number == 600).FirstOrDefault(); if (tranType != null) { yarnorder.YarnO_TransactionType_FK = tranType.TrxT_Pk; } } if (!_EditMode) { //Dont forget to update the last number used //----------------------------------------------------------------------------------- var LastNumberUsed = context.TLADM_LastNumberUsed.Find(1); if (LastNumberUsed != null) { LastNumberUsed.col6 += 1; } context.TLSPN_YarnOrder.Add(yarnorder); } try { context.SaveChanges(); SetUp(); MessageBox.Show("Records successfully updated to database"); if (_EditMode) { DialogResult res = MessageBox.Show("Would you like to reprint the report?", "Info", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (res == DialogResult.Cancel) { return; } } frmViewReport vRep = new frmViewReport(9, yarnorder.YarnO_OrderNumber); 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) { bool success = true; Button oBtn = sender as Button; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandSelected, true, MandatoryFields); if (!string.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } using (var context = new TTI2Entities()) { TLSPN_CottonReceived cotrec = new TLSPN_CottonReceived(); var Contract = (TLADM_CottonContracts)cmbCottonContracts.SelectedItem; var Supplier = (TLADM_Cotton)cmbCottonSuppliers.SelectedItem; var Haulier = (TLADM_CottonHauliers)cmbHaulier.SelectedItem; var NoOfBales = Convert.ToInt32(txtNoOfBales.Text); //--------------------------------------------------------------------------------------------------- //Unfortunately hard coded at the moment //-------------------------------------------------------------------------------------------------- var DeptDetail = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "SPIN").FirstOrDefault(); var TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 100 && x.TrxT_Department_FK == DeptDetail.Dep_Id).FirstOrDefault(); if (TranType != null) { cotrec.CotReC_TranType_FK = TranType.TrxT_Pk; var CountTrx = context.TLSPN_CottonTransactions.Count(); if (CountTrx == 0) { //-------------------------------------------- //this means that this transaction is being run for the first time ie add a record of zeros to the Opening Balance table // This table will cater for future yearend //-------------------------------------------------------------------------------- TLSPN_OpenBalance openBal = new TLSPN_OpenBalance(); openBal.OpenBal_Store_FK = (int)TranType.TrxT_FromWhse_FK; openBal.OpenBal_GrossBaleWeight = 0M; openBal.OpenBal_NettBaleWeight = 0M; openBal.OpenBal_NoOfBales = 0; context.TLSPN_OpenBalance.Add(openBal); } } //---------------------------------------------------------------- // Now onto the main transaction //------------------------------------------------------------------- TLSPN_CottonTransactions CTS = new TLSPN_CottonTransactions(); CTS.cotrx_ContractNo_Fk = Contract.CottonCon_Pk; CTS.cotrx_Customer_FK = null; CTS.cotrx_GrossWeight = Convert.ToDecimal(txtSuppplierGrossWeight.Text); CTS.cotrx_LotNo = Convert.ToInt32(txtLotNo.Text); CTS.cotrx_NettPerWB = Convert.ToDecimal(txtCottonNettWeight.Text); CTS.cotrx_NetWeight = Convert.ToDecimal(txtSupplierNettWeight.Text); CTS.cotrx_NoBales = NoOfBales; CTS.cotrx_Notes = string.Empty; CTS.cotrx_Return_No = Convert.ToInt32(txtGrnNumber.Text); CTS.cotrx_Supplier_FK = Supplier.Cotton_Pk; CTS.cotrx_TransDate = dtpDateReceived.Value; CTS.cotrx_TranType = TranType.TrxT_Pk; CTS.cotrx_VehReg = txtVehReg.Text; CTS.cotrx_Haulier_FK = Haulier.Haul_Pk; CTS.cotrx_WeighBridgeEmpty = Convert.ToDecimal(txtWeighBridgeNett.Text); CTS.cotrx_WeighBridgeFull = Convert.ToDecimal(txtWeighBridgeGross.Text); CTS.cotrx_WriteOff = false; CTS.cottrx_NettAveBaleWeight = Convert.ToDecimal(txtNetAvgBaleWeight.Text); CTS.cotrx_GrossAveBaleWeight = Convert.ToDecimal(txtGrossAvgBaleWeight.Text); context.TLSPN_CottonTransactions.Add(CTS); //-------------------------------------------------------------------------------- var lastNumber = context.TLADM_LastNumberUsed.Find(1); if (lastNumber != null) { lastNumber.col1 += 1; lastNumber.col12 += 1; } try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (microAvailNo.Checked) { decimal micraFrom = 0.00M; decimal micraTo = 0.00M; decimal micraAvg = 0.00M; decimal staplefrom = 0.00M; decimal stapleto = 0.00M; decimal stapleAvg = 0.00M; var CottonContract = (TLADM_CottonContracts)cmbCottonContracts.SelectedItem; if (CottonContract != null) { micraFrom = CottonContract.CottonCon_MicraFrom; micraTo = CottonContract.CottonCon_MicraTo; staplefrom = CottonContract.CottonCon_StapleFrom; stapleto = CottonContract.CottonCon_StapleTo; if (micraFrom > 0 && micraTo > 0) { micraAvg = (micraFrom + micraTo) / 2; } else { micraAvg = 1; } if (staplefrom != 0 && stapleto != 0) { stapleAvg = (staplefrom + stapleto) / 2; } else { stapleAvg = 1; } } var n = 0; while (++n <= CTS.cotrx_NoBales) { TLSPN_CottonReceivedBales recBales = new TLSPN_CottonReceivedBales(); recBales.CotBales_BaleNo = n; recBales.CotBales_CotReceived_FK = cotrec.CotRec_Pk; recBales.CotBales_LotNo = Convert.ToInt32(txtLotNo.Text); recBales.CotBales_Mic = micraAvg; recBales.CotBales_Staple = stapleAvg; recBales.CotBales_Weight_Gross = Convert.ToDecimal(txtGrossAvgBaleWeight.Text); recBales.CotBales_Weight_Nett = Convert.ToDecimal(txtNetAvgBaleWeight.Text); recBales.CoBales_CottonSequence = Convert.ToInt32(txtGrnNumber.Text); context.TLSPN_CottonReceivedBales.Add(recBales); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } if (success) { MessageBox.Show("Data stored to the database successfully"); int returnno = Convert.ToInt32(txtGrnNumber.Text); frmViewReport vRep = new frmViewReport(2, returnno); 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); Setup(); } } }
private void btnSave_Click(object sender, EventArgs e) { bool success = true; Button oBtn = sender as Button; TLSPN_CottonReceivedBales bales; TLADM_TranactionType trantypes = new TLADM_TranactionType(); if (oBtn != null) { var cnt = RowsSelected.Where(x => x == false).Count(); if (cnt == RowsSelected.Count()) { MessageBox.Show("Please select at least one row from the grid as shown"); return; } var errorM = core.returnMessage(MandSelected, true, MandatoryFields); if (!string.IsNullOrEmpty(errorM)) { MessageBox.Show(errorM); return; } var CottonContract = (TLADM_CottonContracts)cmbContractNo.SelectedItem; var CottonTrans = (TLSPN_CottonTransactions)cmbLotNo.SelectedItem; var Supplier = (TLADM_Cotton)cmbSupplierDetails.SelectedItem; //Dont forget last number used //---------------------------------------------- using (var context = new TTI2Entities()) { //Hard Coded at the moment // See Table TLADM_TranactionType for a complete List of the Transaction Type Per Department //-------------------------------------------------------------------------------------------------- var DeptDetails = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "SPIN").FirstOrDefault(); if (DeptDetails != null) { trantypes = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 200 && x.TrxT_Department_FK == DeptDetails.Dep_Id).FirstOrDefault(); } var Haulier = (TLADM_CottonHauliers)cmbTransporter.SelectedItem; var TransDet = (TLSPN_CottonTransactions)cmbLotNo.SelectedItem; int noBales = 0; //------------------------------------------------------------------------------------------- // Up date the records from DataGridView....If Not in Edit Mode //-------------------------------------------------- if (!_EditMode) { var LastNumber = context.TLADM_LastNumberUsed.Find(1); if (LastNumber != null) { LastNumber.col2 += 1; } foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[1].Value == null || (bool)row.Cells[1].Value == false) { continue; } bales = context.TLSPN_CottonReceivedBales.Find((int)row.Cells[0].Value); if (bales != null) { if ((bool)row.Cells[1].Value == true) { bales.CoBales_CottonReturned = true; bales.CoBales_CottonSequence = Convert.ToInt32(txtReturnNoteNumber.Text); noBales += 1; try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); success = false; } } } } } else { foreach (DataGridViewRow row in dataGridView1.Rows) { if ((bool)row.Cells[1].Value == false) { bales = context.TLSPN_CottonReceivedBales.Find((int)row.Cells[0].Value); if (bales != null) { bales.CoBales_CottonReturned = false; bales.CoBales_CottonSequence = 0; try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); success = false; } } } else { noBales += 1; } } } //---------------------------------------------------------------- // Now onto the main transaction // Edit Mode plays a role!!!!! //------------------------------------------------------------------- TLSPN_CottonTransactions CTS = new TLSPN_CottonTransactions(); if (_EditMode) { var prev = (TLSPN_CottonTransactions)cmbPrevious.SelectedItem; if (prev != null) { CTS = context.TLSPN_CottonTransactions.Find(prev.cotrx_pk); } } //------------------------------------------------------------------ CTS.cotrx_ContractNo_Fk = CottonContract.CottonCon_Pk; CTS.cotrx_Customer_FK = null; CTS.cotrx_GrossAveBaleWeight = (Convert.ToDecimal(txtGrossWeightReturned.Text) / noBales); CTS.cotrx_GrossWeight = Convert.ToDecimal(txtGrossWeightReturned.Text); CTS.cotrx_LotNo = TransDet.cotrx_LotNo; CTS.cotrx_NetWeight = Convert.ToDecimal(txtNettWeightReturned.Text); CTS.cotrx_NoBales = noBales; CTS.cotrx_Notes = string.Empty; CTS.cotrx_Haulier_FK = Haulier.Haul_Pk; CTS.cotrx_Return_No = Convert.ToInt32(txtReturnNoteNumber.Text); CTS.cotrx_Supplier_FK = Supplier.Cotton_Pk; CTS.cotrx_TransDate = dtpDateReturned.Value; CTS.cotrx_TranType = trantypes.TrxT_Pk; CTS.cotrx_VehReg = txtVehReg.Text; CTS.cotrx_WeighBridgeEmpty = Convert.ToDecimal(txtWeighBridgeEmpty.Text); CTS.cotrx_WeighBridgeFull = Convert.ToDecimal(txtWeighBridgeFull.Text); CTS.cotrx_WriteOff = true; CTS.cottrx_NettAveBaleWeight = Convert.ToDecimal(txtNettWeightReturned.Text) / noBales; CTS.cotrx_NettPerWB = CTS.cotrx_WeighBridgeFull - CTS.cotrx_WeighBridgeEmpty; //---------------------------------------------------------------------------------- if (!_EditMode) { context.TLSPN_CottonTransactions.Add(CTS); } try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); success = false; } //---------------------------------------------------------------------- } if (success) { MessageBox.Show("Records stored to database successfully"); var ReturnNo = Convert.ToInt32(txtReturnNoteNumber.Text); frmViewReport vRep = new frmViewReport(3, ReturnNo); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); SetUp(); } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var errorM = core.returnMessage(MandSelected, true, MandatoryFields); if (!string.IsNullOrEmpty(errorM)) { MessageBox.Show(errorM); return; } var cnt = RowsSelected.Where(x => x == false).Count(); if (cnt == RowsSelected.Count()) { MessageBox.Show("Please select at least one row from the grid as shown"); return; } var CottonRec = (TLSPN_CottonTransactions)cmbLotNo.SelectedItem; var ContractDetails = (TLADM_CottonContracts)cmbContractNo.SelectedItem; var CustomerDetails = (TLADM_CustomerFile)cmbCustomerName.SelectedItem; //Dont forget last number used //---------------------------------------------- using (var context = new TTI2Entities()) { //Hard Coded at the moment // See Table TLADM_TranactionType for a complete List of the Transaction Type Per Department //-------------------------------------------------------------------------------------------------- var SequenceNo = Convert.ToInt32(txtDeliveryNo.Text); var LastNumber = context.TLADM_LastNumberUsed.Find(1); if (LastNumber != null) { LastNumber.col4 += 1; } // 0 // 1 Selected // 2 Bales Numeric // 3 MIC Decimal // 4 kgs Decimal // 5 Staple Decimal int NoBales = 0; decimal Mass = 0.00M; decimal Gross = 0.00M; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[1].Value == null || (bool)row.Cells[1].Value == false) { continue; } TLSPN_CottonReceivedBales bales = context.TLSPN_CottonReceivedBales.Find((int)row.Cells[0].Value); if (bales != null) { bales.CoBales_CottonSold = true; bales.CoBales_CottonSequence = SequenceNo; NoBales += 1; Mass += (decimal)row.Cells[4].Value; Gross += (decimal)row.Cells[6].Value; try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } TLSPN_CottonTransactions cotTrans = new TLSPN_CottonTransactions(); var haul = (TLADM_CottonHauliers)comboTransporter.SelectedItem; cotTrans.cotrx_TransDate = dtpDateDelivered.Value; cotTrans.cotrx_ContractNo_Fk = ContractDetails.CottonCon_Pk; cotTrans.cotrx_LotNo = Convert.ToInt32(cmbLotNo.SelectedValue); cotTrans.cotrx_NetWeight = Mass; cotTrans.cotrx_GrossWeight = Mass; cotTrans.cotrx_NoBales = NoBales; cotTrans.cotrx_Haulier_FK = haul.Haul_Pk; cotTrans.cotrx_VehReg = txtVehReg.Text; cotTrans.cotrx_WeighBridgeFull = Convert.ToDecimal(txtWeighBridgeFull.Text); cotTrans.cotrx_WeighBridgeEmpty = Convert.ToDecimal(txtWeighBridgeEmpty.Text); cotTrans.cotrx_NettPerWB = cotTrans.cotrx_WeighBridgeFull - cotTrans.cotrx_WeighBridgeEmpty; cotTrans.cottrx_NettAveBaleWeight = Mass / NoBales; cotTrans.cotrx_GrossAveBaleWeight = Gross / NoBales; cotTrans.cotrx_Return_No = SequenceNo; cotTrans.cotrx_Customer_FK = CustomerDetails.Cust_Pk; cotTrans.cotrx_Supplier_FK = ContractDetails.CottonCon_ConSupplier_FK; cotTrans.cotrx_Notes = txtCustOrderNo.Text; cotTrans.cotrx_WriteOff = true; //------------------------------------------------------------------------- // Consult Table TLADM_TranTypes //---------------------------------------------------------------------------- var DeptDetails = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "SPIN").FirstOrDefault(); var Trantype = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 300 && x.TrxT_Department_FK == DeptDetails.Dep_Id).FirstOrDefault(); if (Trantype != null) { cotTrans.cotrx_TranType = Trantype.TrxT_Pk; } try { if (!_EditMode) { context.TLSPN_CottonTransactions.Add(cotTrans); } context.SaveChanges(); Setup(); frmViewReport vRep = new frmViewReport(5, SequenceNo); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); MessageBox.Show("Data saved to database successfully"); btnPickList.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } } btnSave.Enabled = false; } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var cust = (TLADM_CustomerFile)cmboCustomerFile.SelectedItem; if (cust == null) { MessageBox.Show("Please select a customer number"); return; } using (var context = new TTI2Entities()) { var LNU = context.TLADM_LastNumberUsed.Find(1); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[1].Value.ToString() == bool.FalseString) { continue; } TLSPN_YarnWaste yw = new TLSPN_YarnWaste(); var index = (int)row.Cells[0].Value; yw = context.TLSPN_YarnWaste.Find(index); if (yw != null) { yw.TLYW_Customer_FK = cust.Cust_Pk; yw.TLYW_DateDisposed = dtpSales.Value; yw.TLYW_SalesTransactionNO = LNU.col13; yw.TLYW_Disposed = true; var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("SPIN")).FirstOrDefault(); if (Dept != null) { var TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1300).FirstOrDefault(); if (TranType != null) { yw.TLYW_TransactionType_Out = TranType.TrxT_Pk; } } } } try { LNU.col13 += 1; context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); frmViewReport vRep = new frmViewReport(21, LNU.col13 - 1); 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 btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { if (_RepNo == 1) { frmViewReport vRep = new frmViewReport(8, dateTimePicker1.Value); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } else if (_RepNo == 2) { ReportOptions ropt = new ReportOptions(); if (PerSupplier.Checked) { ropt.SelectionOption = 1; var selected = (TLADM_Cotton)cmbBoxSupplier.SelectedItem; if (selected != null) { ropt.Supplier_FK = selected.Cotton_Pk; ropt.SupplierDetail = selected.Cotton_Description; } } else if (AllSuppliers.Checked) { ropt.SelectionOption = 2; } else if (ContractStartDate.Checked) { ropt.SelectionOption = 3; ropt.DateSelected = Convert.ToDateTime(dateTimePicker2.Value.ToShortDateString()); } else if (ContactsBaleStore.Checked) { ropt.SelectionOption = 4; } else if (LotsByTruck.Checked) { MessageBox.Show("Option currently still under development" + Environment.NewLine + " Please consult the system developer"); return; } if (ropt.SelectionOption > 0) { frmViewReport vRep = new frmViewReport(6, ropt); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } else { MessageBox.Show("Please select the appropriate option"); } } else if (_RepNo == 3) { frmViewReport vRep = new frmViewReport(17, dateTimePicker1.Value); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } }