public void SaveCustomer(frmCustomerDetail frmCustomerDetail) { try { string name = frmCustomerDetail.getCustomerName().Text; string phone = frmCustomerDetail.getCustomerPhone().Text; string address = frmCustomerDetail.getAddress().Text; bool isValid = checkCustomerField(name, phone, address); if (isValid) { TblCustomerDTO dto = new TblCustomerDTO() { idCustomer = frmCustomerDetail.getCustomerID(), name = name, phone = phone, address = address }; if (frmCustomerDetail.isAddNew()) { customerModel.addCustomer(dto); LoadCustomers(); } else { customerModel.updateCustomer(dto); LoadCustomers(); } MessageBox.Show(MessageUtil.SAVE_SUCCESS); } } catch (Exception) { MessageBox.Show(MessageUtil.ERROR + " Save Customer!"); } }
public void UpdateCustomer() { frmCustomerDetail customerDetail = new frmCustomerDetail(false, form); //get customer detail from frmSaleManager customerDetail.setCustomerId(form.getCustomerId().Text); customerDetail.getCustomerName().Text = form.getCustomerName().Text; customerDetail.getCustomerPhone().Text = form.getCustomerPhone().Text; customerDetail.getAddress().Text = form.getCustomerAddress().Text; //show customerDetail form DialogResult r = customerDetail.ShowDialog(); }