private void btnSave_Clicked(object sender, RoutedEventArgs e) { if (txtName.Text.Count() == 0 || txtEmail.Text.Count() == 0 || txtPhone.Text.Count() == 0 || txtAddress.Text.Count() == 0) { lblNotice.Content = "Please fill all information."; lblNotice.Visibility = Visibility.Visible; return; } int temp; bool isNumeric = Int32.TryParse(txtPhone.Text, out temp); if (!isNumeric) { lblNotice.Content = "Phone isn't number!"; lblNotice.Visibility = Visibility.Visible; return; } CustomerBUS bus = new CustomerBUS(); CustomerDTO result = new CustomerDTO(); result.ID = ID; result.Name = txtName.Text; result.Email = txtEmail.Text; result.Phone = txtPhone.Text; result.CoopDay = lblCoopday.Content.ToString(); result.Address = txtAddress.Text; result.Paid = Int32.Parse(lblPaid.Content.ToString()); bus.UpdateCustomer(result); this.Close(); }
private void btnUpdateCus_Click(object sender, EventArgs e) { if (txtCName.Text != "" && txtCPhone.Text != "" && txtCEmail.Text != "" && txtCAddress.Text != "") { int CustomerID = Convert.ToInt32(txtCID.Text); string CutomerName = txtCName.Text; string PhoneNumber = txtCPhone.Text; string Email = txtCEmail.Text; string Address = txtCAddress.Text; //CustomerDTO customer_DTO = new CustomerDTO(txtCName.Text, txtCPhone.Text, txtCEmail.Text, txtCAddress.Text); if (customer_bus.UpdateCustomer(CustomerID, CutomerName, PhoneNumber, Email, Address)) { MessageBox.Show("Editing success"); CustomerManagement_Load(sender, e); ClearData(); } else { MessageBox.Show("Editing fail"); } } else { MessageBox.Show("Please fill required data"); } }
private void btnUpdate_Click(object sender, EventArgs e) { string id, pass, name, address, email, phone, status; int accumulation; id = txtID.Text; pass = txtPass.Text; name = txtName.Text; address = txtAddress.Text; email = txtEmail.Text; phone = txtPhone.Text; status = txtStatus.Text; accumulation = Convert.ToInt32(txtAccumulation.Text); int RowsOfNumber = 0; try { CustomerBUS cus = new CustomerBUS(); RowsOfNumber = cus.UpdateCustomer(id, pass, name, address, email, phone, status, accumulation); } catch (Exception ex) { MessageBox.Show("Lỗi " + ex.Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (RowsOfNumber != 0) { MessageBox.Show("Bạn vừa Sửa thành công nhân viên có mã: " + txtID.Text, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Loading(); } }
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(); }