private void btnSell_Clicked(object sender, RoutedEventArgs e) { if (txtAmount.Text.Count() == 0 || btnProduct.Content.ToString().Count() == 0 || btnCustomer.Content.ToString().Count() == 0) { lblNotice.Content = "Please fill all information."; lblNotice.Visibility = Visibility.Visible; return; } int amount; bool isNumeric = Int32.TryParse(txtAmount.Text, out amount); if (!isNumeric) { lblNotice.Content = "Amount isn't number!"; lblNotice.Visibility = Visibility.Visible; return; } ProductBUS bus = new ProductBUS(); ProductDTO result = bus.LoadOneProduct(Global.IDProduct); if (result.IvenNum < amount) { lblNotice.Content = $"There are just {result.IvenNum} crate in warehouse"; lblNotice.Visibility = Visibility.Visible; return; } result.IvenNum = result.IvenNum - amount; bus.UpdateProduct(result); CustomerBUS bUS = new CustomerBUS(); CustomerDTO customer = bUS.LoadOneCustomer(Global.IDCustomer); customer.Paid = customer.Paid + Int32.Parse(lblTotal.Content.ToString()); bUS.UpdateCustomer(customer); ExportBUS exportBUS = new ExportBUS(); ExportDTO export = new ExportDTO(); export.Amount = amount; export.Customer = Global.IDCustomer; export.DateOutput = lblDate.Content.ToString(); export.Product = Global.IDProduct; export.Total = Int32.Parse(lblTotal.Content.ToString()); exportBUS.AddNewExport(export); this.Close(); }
private void LoadInfo(int id) { CustomerBUS bus = new CustomerBUS(); CustomerDTO result = bus.LoadOneCustomer(id); txtID.Content = result.ID.ToString(); txtName.Text = result.Name; txtEmail.Text = result.Email; txtPhone.Text = result.Phone; lblCoopday.Content = result.CoopDay; txtAddress.Text = result.Address; lblPaid.Content = result.Paid.ToString(); }
private void LoadDiscount() { if (Global.IDCustomer == 0) { btnDiscount.Content = "0%"; return; } CustomerBUS bus = new CustomerBUS(); CustomerDTO customer = bus.LoadOneCustomer(Global.IDCustomer); //get today DateTime date = DateTime.UtcNow.Date; string today = date.ToString("MM/dd"); string year = date.ToString("yyyy"); //if today is customer's birthday if (customer.CoopDay.Contains(today) && !customer.CoopDay.Contains(year)) { discount = 4; btnDiscount.Content = "4%"; return; } if (customer.Paid >= 100000000) { discount = 2; btnDiscount.Content = "2%"; return; } if (customer.Paid >= 50000000) { discount = 1; btnDiscount.Content = "1%"; return; } discount = 0; btnDiscount.Content = "0%"; }