private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; int repNo = 0; if (_OptionNo == 1) { repNo = 6; } else { repNo = 7; } if (oBtn != null) { CSVServices csvService = new CSVServices(); if (RBStockOH.Checked) { csvService.SOHClassification = true; } else if (RBStockAvail.Checked) { csvService.SOHClassification = false; } else if (rbBoxesReturned.Checked) { csvService.SOHBoxReturned = true; } else { csvService.SplitBoxOnly = true; } csvService.DateIntoStock = dtpDateinStock.Value; if (rbGradeA.Checked) { QueryParms.GradeA = true; } else { QueryParms.GradeA = false; } if (rbDiscontinued.Checked) { QueryParms.Discontinued = true; } frmCSViewRep vRep = new frmCSViewRep(repNo, QueryParms, csvService); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); comboColours.Items.Clear(); comboSizes.Items.Clear(); comboStyles.Items.Clear(); comboWhses.Items.Clear(); frmStockOnHand_Load(this, null); } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; Repository repo = new Repository(); CustomerServicesParameters parms = new CustomerServicesParameters(); CSVServices svces = new CSVServices(); int TransNumber = 0; if (oBtn != null && formloaded) { var SelectedTransporter = (TLADM_Transporters)cmboTransporters.SelectedItem; if (SelectedTransporter == null) { MessageBox.Show("Please select a transporter"); return; } using (var context = new TTI2Entities()) { var selected = (TLADM_CustomerFile)cmboCustomers.SelectedItem; if (selected == null) { MessageBox.Show("Please select a customer from the drop down box"); return; } parms.Customers.Add(repo.LoadCustomers(selected.Cust_Pk)); var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("CSV")).FirstOrDefault(); if (Dept != null) { var LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); if (LNU != null) { TransNumber = LNU.col4; LNU.col4 += 1; txtDeliveryNo.Text = "F" + LNU.col4.ToString().PadLeft(5, '0'); } } int Fk = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { if ((bool)row.Cells[1].Value == false) { continue; } // Find the record the allocated file //---------------------------------------------------- var pk = (int)row.Cells[0].Value; parms.OrdersAllocated.Add(repo.LoadOrderAllocated(pk)); var Allocated = context.TLCSV_OrderAllocated.Find(pk); if (Allocated != null) { Allocated.TLORDA_Delivered = true; Allocated.TLORDA_DeliveredDate = DateTime.Now; Allocated.TLORDA_DelTransNumber = TransNumber; Allocated.TLORDA_Transporter = string.Empty; Allocated.TLORDA_Transporter_FK = SelectedTransporter.TLTRNS_Pk; Allocated.TLORDA_PLStockOrder = false; Fk = (int)row.Cells[6].Value; var soh = context.TLCSV_StockOnHand.Where(x => x.TLSOH_PickListNo == Fk && !x.TLSOH_Sold).ToList(); foreach (var rec in soh) { rec.TLSOH_Sold = true; rec.TLSOH_SoldDate = DateTime.Now; rec.TLSOH_Customer_Fk = selected.Cust_Pk; rec.TLSOH_DNListNo = TransNumber; rec.TLSOH_DNListDate = DateTime.Now; var POD = context.TLCSV_PuchaseOrderDetail.Find(rec.TLSOH_POOrderDetail_FK); if (POD != null) { POD.TLCUSTO_Delivered = true; POD.TLCUSTO_DeliveredDate = DateTime.Now; POD.TLCUSTO_DeliveryNumber = TransNumber; POD.TLCUSTO_QtyDelivered_ToDate += rec.TLSOH_BoxedQty; if (POD.TLCUSTO_Qty - POD.TLCUSTO_QtyDelivered_ToDate <= 0) { POD.TLCUSTO_Closed = true; } } } //Make this a global transaction //=========================================================== var RePackTransactions = context.TLCSV_RePackTransactions.Where(x => x.REPACT_PurchaseOrder_FK == Allocated.TLORDA_POOrder_FK).ToList(); foreach (var RePackTransaction in RePackTransactions) { var RePackConfig = context.TLCSV_RePackConfig.Find(RePackTransaction.REPACT_RePackConfig_FK); if (RePackConfig != null) { RePackConfig.PORConfig_SizeBoxQty_Delivered += RePackTransaction.REPACT_BoxedQty; } } } } try { context.SaveChanges(); MessageBox.Show("data successfully saved to database"); dataGridView1.Rows.Clear(); cmboCustomers.SelectedValue = -1; svces.TransNumber = TransNumber; svces.DateIntoStock = DateTime.Now; svces.DNReprint = false; frmCSViewRep vRep = new frmCSViewRep(10, parms, svces); 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; TLCSV_OrderAllocated OrderAllocated = null; Repository repo = new Repository(); CSVServices services = new CSVServices(); shirtParameters = new CustomerServicesParameters(); if (oBtn != null && formloaded) { var WareHouse = (TLADM_WhseStore)cmboWareHouse.SelectedItem; if (WareHouse == null) { MessageBox.Show("Please select a warehouse from the drop down box"); return; } if (txtCustomerRef.Text.Length == 0) { MessageBox.Show("Please enter a customer reference"); return; } if (txtReasons.Text.Length == 0) { MessageBox.Show("Please enter the reason these goods are being returned"); return; } if (txtApprovedBy.Text.Length == 0) { MessageBox.Show("Please enter the name of the approver"); return; } //---------------------------------------------------------------------------------- using (var context = new TTI2Entities()) { foreach (DataGridViewRow row in dataGridView1.Rows) { if ((bool)row.Cells[1].Value == false) { continue; } OrderAllocated = new TLCSV_OrderAllocated(); var Pk = (int)row.Cells[0].Value; OrderAllocated = context.TLCSV_OrderAllocated.Find(Pk); if (OrderAllocated != null) { OrderAllocated.TLORDA_Returned = true; OrderAllocated.TLORDA_ReturnCustRef = txtCustomerRef.Text; OrderAllocated.TLORDA_ApprovedBy = txtApprovedBy.Text; OrderAllocated.TLORDA_ReturnNumber = TransNumber; OrderAllocated.TLORDA_ReturnedDate = dtpTransactionDate.Value; shirtParameters.OrdersAllocated.Add(repo.LoadOrderAllocated(Pk)); } } foreach (DataGridViewRow row in dataGridView2.Rows) { if ((bool)row.Cells[1].Value == false) { continue; } var ReSold = (bool)row.Cells[2].Value; int Pk = (int)row.Cells[0].Value; var soh = context.TLCSV_StockOnHand.Find(Pk); if (soh != null) { int BoxedQty = (int)row.Cells[7].Value; soh.TLSOH_ReturnedBoxQty = BoxedQty; soh.TLSOH_BoxedQty = BoxedQty; soh.TLSOH_WareHouse_FK = WareHouse.WhStore_Id; soh.TLSOH_ReturnNumber = TransNumber; soh.TLSOH_ReturnedDate = dtpTransactionDate.Value; if (!ReSold) { soh.TLSOH_Returned = true; soh.TLSOH_Grade = "B"; } else { soh.TLSOH_Picked = false; soh.TLSOH_PickListDate = null; soh.TLSOH_PickListNo = 0; soh.TLSOH_Sold = false; soh.TLSOH_DNListDate = null; soh.TLSOH_DNListNo = 0; soh.TLSOH_Grade = "A"; soh.TLSOH_SoldDate = null; soh.TLSOH_WareHousePickList = 0; soh.TLSOH_WareHouseDeliveryNo = 0; } } } try { var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("CSV")).FirstOrDefault(); if (Dept != null) { var LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); if (LNU != null) { TransNumber = LNU.col5; LNU.col5 += 1; } } //------------------------------------------------------- // //----------------------------------------------------------- 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 = "Customer Services - Stock Returned"; DailyLog.TLDL_AuthorisedBy = txtApprovedBy.Text;; DailyLog.TLDL_Comments = txtCustomerRef.Text; context.TLADM_DailyLog.Add(DailyLog); context.SaveChanges(); MessageBox.Show("Data successfully saved to the database"); dataGridView1.Rows.Clear(); dataGridView2.Rows.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } services.ApprovedBy = txtApprovedBy.Text; services.Reasons = txtReasons.Text; services.ReturnDate = dtpTransactionDate.Value; services.CustomerRef = txtCustomerRef.Text; services.WareHouse = WareHouse.WhStore_Id; frmCSViewRep vRep = new frmCSViewRep(11, shirtParameters, services); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); frmCustomerReturns_Load(this, null); } } }