示例#1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!this.ValidateChildren())
            {
                ClientHelper.ShowRequiredMessage("Customer Code, Company Name");
            }
            else if (hasDuplicate)
            {
                ClientHelper.ShowDuplicateMessage("Customer Code");
            }
            else
            {
                CustomerColumnModel model = new CustomerColumnModel()
                {
                    Id            = CustomerId,
                    Address       = AddressTextbox.Text.Trim(),
                    Agent         = AgentTextbox.Text.Trim(),
                    CompanyName   = CompanyNameTextbox.Text.Trim(),
                    ContactPerson = ContactPersonTextbox.Text.Trim(),
                    CustomerCode  = CodeTextbox.Text.Trim(),
                    FaxNumber     = FaxTextbox.Text.Trim(),
                    PaymentTerms  = int.Parse(PaymentTextbox.Text),
                    TIN           = TINTextbox.Text.Trim(),
                    PhoneNumber   = PhoneTextbox.Text.Trim(),
                    IsDeleted     = false
                };

                if (CustomerId == 0)
                {
                    this.customerController.InsertCustomer(model);
                    ClientHelper.ShowSuccessMessage("Customer successfully added.");
                }
                else
                {
                    this.customerController.UpdateCustomer(model);
                    ClientHelper.ShowSuccessMessage("Customer successfully updated.");
                }

                ClearForm();
                CodeTextbox.Focus();

                if (CustomerUpdated != null)
                {
                    CustomerUpdated(sender, e);
                }
            }
        }
示例#2
0
 private void ClearForm()
 {
     if (CustomerId == 0)
     {
         IdTextbox.Text = "0";
         AddressTextbox.Clear();
         AgentTextbox.Clear();
         CompanyNameTextbox.Clear();
         ContactPersonTextbox.Clear();
         CodeTextbox.Clear();
         FaxTextbox.Clear();
         PaymentTextbox.Text = "0";
         TINTextbox.Clear();
         PhoneTextbox.Clear();
     }
     else
     {
         LoadCustomerDetails();
     }
 }