private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { CSVServices svcs = new CSVServices(); if (cbSummarised.Checked) { svcs.PLSummarised = true; } if (cbPLStockOrders.Checked) { svcs.PLStockOrder = true; } frmCSViewRep VRep = new frmCSViewRep(9, QueryParms, svcs); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; VRep.ClientSize = new Size(w, h); VRep.ShowDialog(this); cmboWareHouses.Items.Clear(); cmboStyles.Items.Clear(); cmboSizes.Items.Clear(); cmboColours.Items.Clear(); frmOutStandingPL_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; CSVServices svces = new CSVServices(); if (oBtn != null && formloaded) { DateTime fDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); DateTime tDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); tDate = tDate.AddHours(23); svces.fromDate = fDate; svces.toDate = tDate; svces.Title = "Customer sales analysis (full detail) for the period "; if (rbSummarisedByCustomer.Checked) { svces.Title = "Customer sales analysis (summarised) for the period"; CustParameters.SummarisedSalesByCustomer = true; } else if (rbSummarisedForCompany.Checked) { CustParameters.SummarisedSalesByCompany = true; svces.Title = "Sales analysis (summarised for company) for the period"; } else if (rbRankedByStyle.Checked) { CustParameters.RankedByStyleColour = true; svces.Title = "Sales analysis ranked by Style, Colour for the period"; } else if (rbRankedByStyleColor.Checked) { CustParameters.RankedByStyleColourSize = true; svces.Title = "Sales analysis ranked by Style, Colour, Size for the period"; } else if (rbRankedByStyleSize.Checked) { CustParameters.RankedByStyleSize = true; svces.Title = "Sales analysis ranked by Style, Size for the period"; } frmCSViewRep vRep = new frmCSViewRep(13, CustParameters, svces); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); cmboColours.Items.Clear(); cmboCustomers.Items.Clear(); cmboSizes.Items.Clear(); cmboStyles.Items.Clear(); frmCustomerSales_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { CSVServices svcs = new CSVServices(); Button oBtn = sender as Button; if (oBtn != null) { if (UserDet._External) { if (parms.Customers.Count() == 0) { MessageBox.Show("Please select a Customer from the drop down list"); return; } } if (rbProvisionalOrdersOnly.Checked) { parms.IncludeProvisional = true; } parms.ClosedOrders = false; parms.AllPurchaseOrders = false; if (chkGroupByWeek.Checked) { parms.GroupByWeek = true; } if (rbBoth.Checked) { parms.Both = true; } frmCSViewRep VRep = new frmCSViewRep(8, parms, svcs); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; VRep.ClientSize = new Size(w, h); VRep.ShowDialog(this); comboCustomers.Items.Clear(); comboColours.Items.Clear(); comboSizes.Items.Clear(); comboStyles.Items.Clear(); frmDetailCustomerOrders_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && FormLoaded) { var csvService = new CSVServices(); var vRep = new frmCSViewRep(23, QueryParms, csvService); 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 = dtpFromDate.Value.Date; QueryParms.ToDate = dtpToDate.Value.Date; frmCSViewRep vRep = new frmCSViewRep(28, QueryParms); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && FormLoaded) { var SingleRow = (from Rows in dataGridView1.Rows.Cast <DataGridViewRow>() where (bool)Rows.Cells[1].Value == true select Rows).FirstOrDefault(); if (SingleRow == null) { MessageBox.Show("Please select at least one row to process"); return; } foreach (DataGridViewRow Row in dataGridView1.Rows) { if (!(bool)Row.Cells[1].Value) { continue; } QueryParms.OrdersAllocated.Add(Repo.LoadOrderAllocated((int)Row.Cells[0].Value)); } var services = new CSVServices(); frmCSViewRep vRep = new frmCSViewRep(24, QueryParms, services); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); QueryParms = new CustomerServicesParameters(); foreach (DataGridViewRow Row in dataGridView1.Rows) { if (!(bool)Row.Cells[1].Value) { continue; } Row.Cells[1].Value = false; } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; CSVServices services = new CSVServices(); if (oBtn != null && FormLoaded) { if (txtPurchaseOrder.Text.Length > 0) { using (var context = new TTI2Entities()) { var PurchaseOrder = context.TLCSV_PurchaseOrder.Where(x => x.TLCSVPO_PurchaseOrder == txtPurchaseOrder.Text).FirstOrDefault(); if (PurchaseOrder == null) { MessageBox.Show("Purchase Order Number not found"); return; } QueryParms.PurchaseOrders.Add(repo.LoadPurchaseOrder(PurchaseOrder.TLCSVPO_Pk)); } } else { var SelectedCustomer = (TLADM_CustomerFile)cmboCustomers.SelectedItem; if (SelectedCustomer == null) { MessageBox.Show("Please select a customer from the drop down box"); return; } QueryParms.Customers.Add(repo.LoadCustomers(SelectedCustomer.Cust_Pk)); } QueryParms.TransactHistory = Transactional; frmCSViewRep vRep = new frmCSViewRep(25, QueryParms, services); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); this.frmCustomerTransHistory_Load(this, null); this.txtPurchaseOrder.Text = string.Empty; } }
private void btnReprint_Click(object sender, EventArgs e) { Button oBtn = sender as Button; frmCSViewRep vRep = null; if (oBtn != null && FormLoaded) { if (_PickList) { CSVServices svces = new CSVServices(); svces.PLReprint = true; svces.DNReprint = false; svces.POCustomer_PK = PO.TLCSVPO_Customer_FK; var Pk = Convert.ToInt32(txtNo.Text); if (!RePackTran) { vRep = new frmCSViewRep(4, svces, Pk); } else { vRep = new frmCSViewRep(23, svces, Pk); } int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } else { CSVServices svces = new CSVServices(); svces.PLReprint = false; svces.DNReprint = true; var Pk = Convert.ToInt32(txtNo.Text); vRep = new frmCSViewRep(10, svces, 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) { Button oBtn = (Button)sender; if (oBtn != null && FormLoaded) { CSVServices csvService = new CSVServices(); frmCSViewRep vRep = new frmCSViewRep(16, parms, csvService); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); cmboWarehouses.Items.Clear(); frmBoxesDespatchedNoReceipted_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && FormLoaded) { CSVServices svcs = new CSVServices(); frmCSViewRep vRep = new frmCSViewRep(17, QueryParms, svcs); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); cmboColours.Items.Clear(); cmboCustomers.Items.Clear(); cmboStyles.Items.Clear(); cmboSizes.Items.Clear(); frmSelOutStandingOrders_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && formloaded) { CSVServices csvService = new CSVServices(); frmCSViewRep vRep = new frmCSViewRep(27, QueryParms, csvService); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); cmboColours.Items.Clear(); cmboCustomers.Items.Clear(); cmboSizes.Items.Clear(); cmboStyles.Items.Clear(); frmNegativeStock_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && FormLoaded) { if (QueryParms.Styles.Count == 0) { using (DialogCenteringService svcs = new DialogCenteringService(this)) { MessageBox.Show("Please select a style from the dropdown box"); return; } } if (QueryParms.Colours.Count == 0) { using (DialogCenteringService svcs = new DialogCenteringService(this)) { MessageBox.Show("Please select a colour from the dropdown box"); return; } } CSVServices csvService = new CSVServices(); frmCSViewRep vRep = new frmCSViewRep(26, QueryParms, csvService); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); cmboColours.Items.Clear(); cmboStyles.Items.Clear(); frmDaysSales_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { CSVServices svces = new CSVServices(); svces.PLReprint = true; foreach (DataGridViewRow row in dataGridView1.Rows) { if ((bool)row.Cells[1].Value == true) { var Pk = Convert.ToInt32(row.Cells[2].Value.ToString().Remove(0, 2)); frmCSViewRep vRep = new frmCSViewRep(4, svces, Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var oDgv = sender as DataGridView; if (oDgv.Focused && oDgv.CurrentCell is DataGridViewButtonCell) { int Pk = Convert.ToInt32(oDgv.Rows[e.RowIndex].Cells[2].Value.ToString().Remove(0, 2)); if (Pk != 0) { CSVServices svces = new CSVServices(); svces.PLReprint = true; svces.DNReprint = false; svces.POCustomer_PK = (int)oDgv.Rows[e.RowIndex].Cells[7].Value; frmCSViewRep vRep = new frmCSViewRep(4, svces, 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) { Button oBtn = sender as Button; if (oBtn != null && FormLoaded) { CSVServices csvService = new CSVServices(); frmCSViewRep vRep = new frmCSViewRep(14, QueryParms, csvService); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); comboColour.Items.Clear(); comboSizes.Items.Clear(); comboStyles.Items.Clear(); comboWareHouse.Items.Clear(); frmStockLists_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null) { CSVServices svces = new CSVServices(); svces.fromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); svces.toDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); svces.toDate = svces.toDate.AddHours(23); if (_DeliveryNote) { svces.DeliveryNote = _DeliveryNote; } frmCSViewRep vRep = new frmCSViewRep(15, svces); 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; 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); } } }
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 btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && FormLoaded) { var FromWhse = (TLADM_WhseStore)cmboFromwarehouse.SelectedItem; if (FromWhse == null) { MessageBox.Show("Please select a warehouse from which to transfer"); return; } var ToWhse = (TLADM_WhseStore)cmboTowareHouse.SelectedItem; if (ToWhse == null) { MessageBox.Show("Please select a warehousewhich to transfer too"); return; } if (FromWhse.WhStore_Id == ToWhse.WhStore_Id) { MessageBox.Show("Please select a different warehouse to transfer too"); return; } if (!TransferMode) { TransferMode = !TransferMode; btnSubmit.Text = "Transfer"; QueryParms.FromWhse = FromWhse.WhStore_Id; var Existing = repo.FromWareHouse(QueryParms); if (Existing.Count() == 0) { MessageBox.Show("No Records found for selection made", FromWhse.WhStore_Description); return; } using (var context = new TTI2Entities()) { foreach (var Record in Existing) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = Record.TLSOH_Pk; dataGridView1.Rows[index].Cells[1].Value = false; dataGridView1.Rows[index].Cells[2].Value = Record.TLSOH_BoxNumber; dataGridView1.Rows[index].Cells[3].Value = context.TLADM_Styles.Find(Record.TLSOH_Style_FK).Sty_Description; dataGridView1.Rows[index].Cells[4].Value = context.TLADM_Colours.Find(Record.TLSOH_Colour_FK).Col_Display; dataGridView1.Rows[index].Cells[5].Value = context.TLADM_Sizes.Find(Record.TLSOH_Size_FK).SI_Description; dataGridView1.Rows[index].Cells[6].Value = Record.TLSOH_BoxedQty; } } } else { var CountSelected = (from Rows in dataGridView1.Rows.Cast <DataGridViewRow>() where (bool)Rows.Cells[1].Value == true select Rows).Count(); if (CountSelected == 0) { MessageBox.Show("Please tick at least one box to be transferred"); return; } TransferMode = !TransferMode; btnSubmit.Text = "Submit"; using (var context = new TTI2Entities()) { //Need to create a Header Record in the file //======================================================= TLCSV_WhseTransfer WhseTransfer = new TLCSV_WhseTransfer(); var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "CSV").FirstOrDefault(); if (Dept != null) { var LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); if (LNU != null) { WhseTransfer.TLCSVWHT_Date = DateTime.Now; WhseTransfer.TLCSVWHT_PickList = true; WhseTransfer.TLCSVWHT_FromWhse_Fk = FromWhse.WhStore_Id; WhseTransfer.TLCSVWHT_ToWhse_Fk = ToWhse.WhStore_Id; WhseTransfer.TLCSVWHT_PickListDate = DateTime.Now; WhseTransfer.TLCSVWHT_PickListNo = LNU.col6; LNU.col6 += 1; context.TLCSV_WhseTransfer.Add(WhseTransfer); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (DataGridViewRow Row in dataGridView1.Rows) { if ((bool)Row.Cells[1].Value == false) { continue; } TLCSV_WhseTransferDetail WhDetail = new TLCSV_WhseTransferDetail(); WhDetail.TLCSVWHTD_WhseTranfer_FK = WhseTransfer.TLCSVWHT_Pk; WhDetail.TLCSVWHTD_TLSOH_Fk = (int)Row.Cells[0].Value; WhDetail.TLCSVWHTD_PickList = true; context.TLCSV_WhseTransferDetail.Add(WhDetail); } try { context.SaveChanges(); MessageBox.Show("Records successfully updated to database"); FormLoaded = false; frmCSViewRep vRep = new frmCSViewRep(18, WhseTransfer.TLCSVWHT_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; int TransNumber = 0; int MasterPk = 0; if (oBtn != null && formloaded) { using (var context = new TTI2Entities()) { var Dept = (TLADM_Departments)cmboDepartment.SelectedItem; if (Dept == null) { MessageBox.Show("Please select a from destination"); return; } var RecCount = dataGridView2.Rows.Cast <DataGridViewRow>().Where(x => (bool)x.Cells[1].Value == true).Count(); if (RecCount == 0) { MessageBox.Show("Please select a least one record to process"); return; } var LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); if (LNU != null) { TransNumber = LNU.col8; } var Whse = (TLADM_WhseStore)cmboWareHouse.SelectedItem; if (Whse != null) { } bool First = true; foreach (DataGridViewRow row in dataGridView1.Rows) { bool isChecked = (bool)row.Cells[1].Value; if (!isChecked) { continue; } if (First) { MasterPk = (int)row.Cells[0].Value; First = !First; } if (!chkSelectHistory.Checked) { TLCSV_BoxSelected Box = new TLCSV_BoxSelected(); var index = (int)row.Cells[0].Value; Box = context.TLCSV_BoxSelected.Find(index); if (Box != null) { Box.TLCSV_Despatched = true; Box.TLCSV_DespatchedDate = DateTime.Now; Box.TLCSV_DNDeails = "CDN" + TransNumber.ToString().PadLeft(5, '0'); Box.TLCSV_DNTransNumber = TransNumber; } } } foreach (DataGridViewRow rows in dataGridView2.Rows) { bool isChecked = (bool)rows.Cells[1].Value; if (!isChecked) { continue; } if (!chkSelectHistory.Checked) { var index = (int)rows.Cells[0].Value; TLCMT_CompletedWork comWork = context.TLCMT_CompletedWork.Find(index); if (comWork != null) { if (!isChecked) { comWork.TLCMTWC_Picked = false; comWork.TLCMTWC_PickList_FK = null; } else { comWork.TLCMTWC_Despatched = true; comWork.TLCMTWC_DepatchedList_FK = MasterPk; } } } } try { if (!chkSelectHistory.Checked) { LNU.col8 += 1; context.SaveChanges(); foreach (DataGridViewRow row in dataGridView1.Rows) { var index = (int)row.Cells[0].Value; var cnt = context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_PickList_FK == index && x.TLCMTWC_Picked).Count(); if (cnt == 0) { TLCSV_BoxSelected Box = new TLCSV_BoxSelected(); Box = context.TLCSV_BoxSelected.Find(index); if (Box != null) { context.TLCSV_BoxSelected.Remove(Box); } } } context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); } dataGridView1.Rows.Clear(); dataGridView2.Rows.Clear(); frmCSViewRep vRep = new frmCSViewRep(2, MasterPk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); if (chkSelectHistory.Checked) { chkSelectHistory.Checked = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var selected = (TLCSV_BoxSelected)cmboWareHouse.SelectedItem; if (selected == null) { MessageBox.Show("Please select a Delivery Note from the drop down box"); return; } var RecCount = dataGridView1.Rows.Cast <DataGridViewRow>().Where(x => (bool)x.Cells[1].Value == true).Count(); if (RecCount == 0) { MessageBox.Show("Please select a least one record to process"); return; } using (var context = new TTI2Entities()) { TLCSV_Movement move = new TLCSV_Movement(); move.TLMV_FromCMT_Fk = selected.TLCSV_From_FK; move.TLMV_ToWhse_FK = selected.TLCSV_To_FK; move.TLMV_TransactionNumber = 1; move.TLMV_TransDate = dtpTransDate.Value; move.TLMV_BoxSelected_FK = selected.TLCSV_Pk; move.TLMV_NoOfBoxes = 0; move.TLMV_BoxedQty = 0; move.TLMV_OriginalNumber = selected.TLCSV_DNDeails; var moveDetails = context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_DepatchedList_FK == selected.TLCSV_Pk).ToList(); if (moveDetails != null) { move.TLMV_NoOfBoxes = moveDetails.Count; move.TLMV_BoxedQty = moveDetails.Sum(x => x.TLCMTWC_Qty); } context.TLCSV_Movement.Add(move); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (DataGridViewRow row in dataGridView1.Rows) { bool isChecked = (bool)row.Cells[1].Value; if (isChecked) { TLCSV_StockOnHand OnHand = new TLCSV_StockOnHand(); OnHand.TLSOH_WareHouse_FK = selected.TLCSV_To_FK; OnHand.TLSOH_CMT_FK = (int)row.Cells[0].Value; OnHand.TLSOH_BoxSelected_FK = selected.TLCSV_Pk; OnHand.TLSOH_Movement_FK = move.TLMV_Pk; OnHand.TLSOH_DateIntoStock = dtpTransDate.Value; TLCMT_CompletedWork comWork = context.TLCMT_CompletedWork.Find((int)row.Cells[0].Value); if (comWork != null) { comWork.TLCMTWC_BoxReceiptedWhse = true; var Already = context.TLCSV_StockOnHand.Where(x => x.TLSOH_BoxNumber == comWork.TLCMTWC_BoxNumber).FirstOrDefault(); if (Already != null) { continue; } OnHand.TLSOH_BoxedQty = comWork.TLCMTWC_Qty; OnHand.TLSOH_Style_FK = comWork.TLCMTWC_Style_FK; OnHand.TLSOH_Colour_FK = comWork.TLCMTWC_Colour_FK; OnHand.TLSOH_Size_FK = comWork.TLCMTWC_Size_FK; OnHand.TLSOH_BoxNumber = comWork.TLCMTWC_BoxNumber; OnHand.TLSOH_Weight = comWork.TLCMTWC_Weight; OnHand.TLSOH_PastelNumber = comWork.TLCMTWC_PastelNumber; OnHand.TLSOH_CutSheet_FK = comWork.TLCMTWC_CutSheet_FK; if (comWork.TLCMTWC_PastelNumber.Length == 0) { OnHand.TLSOH_PastelNumber = context.TLADM_Styles.Find(comWork.TLCMTWC_Style_FK).Sty_PastelNo.ToString(); OnHand.TLSOH_PastelNumber += context.TLADM_Colours.Find(comWork.TLCMTWC_Colour_FK).Col_FinishedCode; OnHand.TLSOH_PastelNumber += "NG"; OnHand.TLSOH_PastelNumber += context.TLADM_Sizes.Find(comWork.TLCMTWC_Size_FK).SI_PastelNo; } OnHand.TLSOH_BoxType = comWork.TLCMTWC_BoxType_FK; OnHand.TLSOH_Grade = comWork.TLCMTWC_Grade; if (!comWork.TLCMTWC_Grade.Contains("A")) { var Assoc = context.TLADM_WareHouseAssociation.Where(X => X.TLWA_PrimaryWareHouse == selected.TLCSV_To_FK).FirstOrDefault(); if (Assoc != null) { OnHand.TLSOH_WareHouse_FK = (int)Assoc.TLWA_SecondaryWareHouse; } } else { OnHand.TLSOH_Is_A = true; } } context.TLCSV_StockOnHand.Add(OnHand); } } var Existing = context.TLCSV_BoxSelected.Where(x => x.TLCSV_DNTransNumber == selected.TLCSV_DNTransNumber).ToList(); foreach (var row in Existing) { TLCSV_BoxSelected Box = new TLCSV_BoxSelected(); Box = context.TLCSV_BoxSelected.Find(row.TLCSV_Pk); if (Box != null) { Box.TLCSV_Receipted = true; Box.TLCSV_DateReceipted = dtpTransDate.Value; } } try { context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); dataGridView1.Rows.Clear(); cmboWareHouse.DataSource = null; cmboWareHouse.DataSource = context.TLCSV_BoxSelected.Where(x => !x.TLCSV_Receipted).GroupBy(g => new { g.TLCSV_DNTransNumber }).Select(s => s.FirstOrDefault()).ToList(); cmboWareHouse.ValueMember = "TLCSV_Pk"; cmboWareHouse.DisplayMember = "TLCSV_DNDeails"; cmboWareHouse.SelectedValue = -1; frmCSViewRep vRep = new frmCSViewRep(3, selected.TLCSV_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; Repository repo = new Repository(); TLCSV_BoxSelected boxSelected; if (oBtn != null && Submit) { var Depts = (TLADM_Departments)cmboFrom.SelectedItem; if (Depts == null) { MessageBox.Show("Please select a CMT from from the drop down box"); return; } QueryParms.Depts.Add(repo.LoadDepart(Depts.Dep_Id)); var BoxesAvailable = repo.Query(QueryParms); if (BoxesAvailable.Count() == 0) { MessageBox.Show("There are no Boxes available"); return; } DGVResults.Rows.Clear(); using (var context = new TTI2Entities()) { foreach (var Box in BoxesAvailable) { var index = DGVResults.Rows.Add(); DGVResults.Rows[index].Cells[0].Value = Box.TLCMTWC_Pk; DGVResults.Rows[index].Cells[1].Value = false; DGVResults.Rows[index].Cells[2].Value = Box.TLCMTWC_BoxNumber; DGVResults.Rows[index].Cells[3].Value = Box.TLCMTWC_Qty; DGVResults.Rows[index].Cells[4].Value = Box.TLCMTWC_Weight; var Styles = context.TLADM_Styles.Find(Box.TLCMTWC_Style_FK); if (Styles != null) { DGVResults.Rows[index].Cells[5].Value = context.TLADM_CustomerFile.Find(Styles.Sty_Label_FK).Cust_Description; DGVResults.Rows[index].Cells[6].Value = Styles.Sty_Description; } DGVResults.Rows[index].Cells[7].Value = context.TLADM_Colours.Find(Box.TLCMTWC_Colour_FK).Col_Display; DGVResults.Rows[index].Cells[8].Value = context.TLADM_Sizes.Find(Box.TLCMTWC_Size_FK).SI_Description; } } DGVResults.Visible = true; label4.Visible = false; label5.Visible = false; label6.Visible = false; Submit = !Submit; btnSubmit.Text = "Process"; groupBox1.Text = "Results"; } else { //------------------------------------------------------------------- // 1st Has a to destination been selected // If No return //------------------------------------------------------------------------ var Dept = (TLADM_Departments)cmboFrom.SelectedItem; if (Dept == null) { MessageBox.Show("Error encountered" + Environment.NewLine + "Process aborted"); return; } var Whse = (TLADM_WhseStore)cmboTo.SelectedItem; if (Whse == null) { MessageBox.Show("Please select a TO Destination from the drop down box provided"); return; } var RecCount = DGVResults.Rows.Cast <DataGridViewRow>().Where(x => (bool)x.Cells[1].Value == true).Count(); if (RecCount == 0) { MessageBox.Show("Please select a least one record to process"); return; } using (var context = new TTI2Entities()) { //------------------------------------------------ // 1st Things first create a header record //------------------------------------------------------------------------- var LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); boxSelected = new TLCSV_BoxSelected(); boxSelected.TLCSV_TransDate = dateTimePicker1.Value; boxSelected.TLCSV_From_FK = Dept.Dep_Id; boxSelected.TLCSV_To_FK = Whse.WhStore_Id; if (LNU != null) { boxSelected.TLCSV_TransNumber = LNU.col6; LNU.col6 += 1; } boxSelected.TLCSV_PLDetails = "CP" + boxSelected.TLCSV_TransNumber.ToString().PadLeft(5, '0'); try { context.TLCSV_BoxSelected.Add(boxSelected); context.SaveChanges(); } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); return; } foreach (DataGridViewRow row in DGVResults.Rows) { if ((bool)row.Cells[1].Value == false) { continue; } TLCMT_CompletedWork comWork = new TLCMT_CompletedWork(); var index = (int)row.Cells[0].Value; comWork = context.TLCMT_CompletedWork.Find(index); if (comWork != null) { comWork.TLCMTWC_PickList_FK = boxSelected.TLCSV_Pk; comWork.TLCMTWC_Picked = true; comWork.TLCMTWC_ToWhse_FK = Whse.WhStore_Id; } } try { context.SaveChanges(); using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box { MessageBox.Show("Data successfully saved to the database"); } } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); return; } //---------------------------------------------------------------------- frmCSViewRep vRep = new frmCSViewRep(1, boxSelected.TLCSV_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); //----------------------------------------------------------------------- try { DialogResult res = MessageBox.Show(" Do you wish to send a confirmation email ", "Confirmation email", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //------------------------------------------------------------------- // We need to build up a data table of // boxes( stock ) transfered //------------------------------------------------------------------- DataTable dt = new DataTable(); dt.Columns.Add("BoxNumber", typeof(String)); dt.Columns["BoxNumber"].DefaultValue = string.Empty; dt.Columns.Add("Style", typeof(String)); dt.Columns["Style"].DefaultValue = string.Empty; dt.Columns.Add("Colour", typeof(String)); dt.Columns["Colour"].DefaultValue = string.Empty; dt.Columns.Add("Size", typeof(String)); dt.Columns["Size"].DefaultValue = string.Empty; dt.Columns.Add("Grade", typeof(String)); dt.Columns["Grade"].DefaultValue = string.Empty; dt.Columns.Add("Qty", typeof(int)); dt.Columns["Qty"].DefaultValue = 0; dt.Columns.Add("Weight", typeof(decimal)); dt.Columns["Weight"].DefaultValue = 0.0M; var BoxesTransfered = context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_PickList_FK == boxSelected.TLCSV_Pk).ToList(); foreach (var Box in BoxesTransfered) { DataRow dr = dt.NewRow(); dr[0] = Box.TLCMTWC_BoxNumber; dr[1] = context.TLADM_Styles.Find(Box.TLCMTWC_Style_FK).Sty_Description; dr[2] = context.TLADM_Colours.Find(Box.TLCMTWC_Colour_FK).Col_Description; dr[3] = context.TLADM_Sizes.Find(Box.TLCMTWC_Size_FK).SI_Description; dr[4] = Box.TLCMTWC_Grade; dr[5] = Box.TLCMTWC_Qty; dr[6] = Box.TLCMTWC_Weight; dt.Rows.Add(dr); } StringBuilder EMailAdd = new StringBuilder(); frmSeleEMailAddress EMailAddress = new frmSeleEMailAddress(); EMailAddress.ShowDialog(this); var Email = EMailAddress.EMailSelected; if (Email.ToString().Length > 0) { try { string ToWhse = context.TLADM_WhseStore.Find(boxSelected.TLCSV_To_FK).WhStore_Description; core.SendEmailtoContacts(Email.ToString(), dt, 2, dateTimePicker1.Value, ToWhse, boxSelected.TLCSV_PLDetails); MessageBox.Show("Email successfully despatched"); } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } else { MessageBox.Show("No Email address's selected or Email address's do not exist"); } } } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } DGVResults.Visible = false; groupBox1.Text = "Selection"; label4.Visible = true; label5.Visible = true; label6.Visible = true; Submit = !Submit; btnSubmit.Text = "Submit"; cmboStyles.Items.Clear(); cmboColours.Items.Clear(); cmboSizes.Items.Clear(); frmWareHouseTransfers_Load(this, null); } }
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); } }