private void Search() { SaleBusiness saleBusiness = new SaleBusiness(); dgvHistory.DataSource = saleBusiness.HistorySearch(txtSearch.Text, dtpAt.Value, dtpTo.Value, chbActive.Checked); dgvHistory.Refresh(); }
private void btnConfirmSale_Click(object sender, EventArgs e) { Sale sale = new Sale(); sale.User = new User(); sale.User.Id = Properties.Settings.Default.userId; sale.Total = Convert.ToDouble(txtTotalSale.Text); sale.Discount = Convert.ToDouble(txtDiscount.Text); sale.Products = new List <Product>(); foreach (DataGridViewRow row in dgvItems.Rows) { Product product = new Product(); product.Id = Convert.ToInt32(row.Cells["id_product"].Value); product.Quantity = Convert.ToInt32(row.Cells["quantity"].Value); product.SalePrice = Convert.ToDouble(row.Cells["unit_price"].Value); sale.Products.Add(product); } SaleBusiness saleBusiness = new SaleBusiness(); int idSale = saleBusiness.Create(sale); MessageBox.Show("Venda Código " + idSale + " registrada com sucesso!"); }
public string registerSale(string idClient, string phonesQuantities, string total, string key) { EncryptionMethods em = new EncryptionMethods(); string conn = WebConfigurationManager.ConnectionStrings["KeggPhonesConnectionString"].ToString(); ClientBusiness cb = new ClientBusiness(conn); SaleBusiness sb = new SaleBusiness(conn); PhoneSaleBusiness psb = new PhoneSaleBusiness(conn); PhoneBusiness pb = new PhoneBusiness(conn); Client client = cb.getClientById(Int32.Parse(em.decrypting(idClient, key))); Sale sale = new Sale(0, client, Int32.Parse(em.decrypting(total, key)), DateTime.Today.ToString()); int r = sb.insertSale(sale); sale.IdSale = r; string phonesQ = em.decrypting(phonesQuantities, key); string[] phones = phonesQ.Split('#'); for (int i = 0; i < phones.Length; i++) { string[] data = phones[i].Split(';'); Phone phone = pb.getPhoneById(Int32.Parse(data[0])); PhoneSale ps = new PhoneSale(0, phone, sale, Int32.Parse(data[1])); psb.insertPhoneSale(ps); } string response = "1"; return(em.encrypt(response, key)); }
/// <summary> /// Construtor padrão. /// </summary> /// <param name="lstProducts">Lista de produtos que será vendida</param> public FormConfirmSale(List <Product> lstProducts) { InitializeComponent(); this.lstProducts = lstProducts; this.saleBusiness = new SaleBusiness(); CalculateSubtotal(); }
public ActionResult InsertProductAtShoppingCart(Products products) { var prods = pBusiness.getProductsAndShoppingList(); saleBusiness = new SaleBusiness(products); saleBusiness.AddProductToShoppingCart(); ViewBag.Name = new CurrentUser().getUserSession().name; ViewBag.Message = "Produto Adicionado ao Carrinho!"; return(View("../Menu/Index", prods)); }
public ActionResult ListAllShoppingCart() { ViewBag.Message = ""; saleBusiness = new SaleBusiness(); var result = saleBusiness.getListShoppingCart(); ViewBag.Name = new CurrentUser().getUserSession().name; ViewBag.Message = "ListAllShoppingCart"; return(View(result)); }
public ActionResult DeleteProductToShoppingCart(int id) { new SaleBusiness(id).DeleteProductToShoppingCart(); ViewBag.Message = ""; saleBusiness = new SaleBusiness(); var result = saleBusiness.getListShoppingCart(); ViewBag.Name = new CurrentUser().getUserSession().name; ViewBag.Message = "ListAllShoppingCart"; return(View("ListAllShoppingCart", result)); }
public static void Init() { Console.Clear(); using (var context = new EntitiesContext()) { while (true) { ShowOptions(); var selectedOption = GetSelectedOption(); if (selectedOption == SelectedOption.Exit) { break; } switch (selectedOption) { case SelectedOption.RegisterSale: new SaleBusiness(context).RegisterSale(); break; case SelectedOption.WatchSales: var sales = new SaleBusiness(context).DaySalesReport(); ShowDayReport(sales); break; case SelectedOption.FindProduct: var salesFiltered = new SaleBusiness(context).SearchProductInDailyReport(); ShowDayReport(salesFiltered); break; case SelectedOption.RegisterClient: new ClientBusiness(context).RegisterClient(); break; default: Console.WriteLine("Opción inválida \n\n"); break; } } } }
/// <summary> /// Construtor padrão. /// </summary> public FormSaleByDate() { InitializeComponent(); this.saleBusiness = new SaleBusiness(); }
public void generateClientReport() { Document doc = new Document(PageSize.A4, 10, 10, 10, 10); string filename = Path.GetFullPath("C:/Users/Brayan/Source/Repos/CoreVises/CoreVises/ReportsPDF/Report" + Guid.NewGuid().ToString().Substring(0, 7) + "_" + DateTime.Today.Date.ToString("yyyy-MM-dd") + ".pdf"); FileStream file = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); PdfWriter.GetInstance(doc, file); doc.Open(); Paragraph pTitle = new Paragraph(new Phrase("Kegg Phones", FontFactory.GetFont("ARIAL", 16, iTextSharp.text.Font.BOLD))); pTitle.Alignment = Element.ALIGN_CENTER; Paragraph pReport = new Paragraph(new Phrase("Report: Best clients of the month", FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.NORMAL))); pReport.Alignment = Element.ALIGN_JUSTIFIED; Paragraph pDate = new Paragraph(new Phrase("Date Report: " + DateTime.Now.ToString("d"), FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.NORMAL))); pDate.Alignment = Element.ALIGN_JUSTIFIED; Image waterMaker = Image.GetInstance("C:/Users/Brayan/Source/Repos/CoreVises/CoreVises/Images/KeggPhonesImage.png"); waterMaker.SetAbsolutePosition(100, 300); waterMaker.ScalePercent(75); Paragraph pSpace = new Paragraph(" "); PdfPTable informationTable = new PdfPTable(3); informationTable.WidthPercentage = 100; PdfPCell clName = new PdfPCell(new Phrase("Client name", FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.BOLD))); clName.BorderWidth = 0.75f; PdfPCell clEmail = new PdfPCell(new Phrase("Email", FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.BOLD))); clEmail.BorderWidth = 0.75f; PdfPCell clPurcahsing = new PdfPCell(new Phrase("Tales purchases", FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.BOLD))); clPurcahsing.BorderWidth = 0.75f; informationTable.AddCell(clName); informationTable.AddCell(clEmail); informationTable.AddCell(clPurcahsing); SaleBusiness psb = new SaleBusiness("Data Source = 163.178.107.130; Initial Catalog = KeggPhones; User Id = sqlserver; Password = saucr.12"); Object[] values = psb.getBestClients(); List <Client> clients = (List <Client>)values[0]; List <int> quantities = (List <int>)values[1]; for (int i = 0; i < clients.Count; i++) { Client clientTemp = clients[i]; clName = new PdfPCell(new Phrase(clientTemp.Name + " " + clientTemp.LastName_1 + " " + clientTemp.LastName_2, FontFactory.GetFont("ARIAL", 10, iTextSharp.text.Font.NORMAL))); clName.BorderWidth = 0.75f; clEmail = new PdfPCell(new Phrase(clientTemp.Email, FontFactory.GetFont("ARIAL", 10, iTextSharp.text.Font.NORMAL))); clEmail.BorderWidth = 0.75f; clPurcahsing = new PdfPCell(new Phrase("$" + quantities[i], FontFactory.GetFont("ARIAL", 10, iTextSharp.text.Font.NORMAL))); clPurcahsing.BorderWidth = 0.75f; informationTable.AddCell(clName); informationTable.AddCell(clEmail); informationTable.AddCell(clPurcahsing); } doc.Add(pTitle); doc.Add(pReport); doc.Add(pDate); doc.Add(waterMaker); doc.Add(pSpace); doc.Add(pSpace); doc.Add(informationTable); doc.Close(); Process.Start(filename); }