Exemplo n.º 1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (CheckValid() && addNew)
         {
             Customer re = new Customer()
             {
                 FirstName = txtFirstname.Text,
                 LastName  = txtLastname.Text,
                 Address   = txtAdress.Text,
                 Country   = cbCountry.SelectedItem.ToString(),
                 Email     = txtEmail.Text,
                 Phone     = txtPhone.Text,
                 RegisTime = DateTime.Now,
                 StaffID   = StaffID,
             };
             if (ManagerDAL.AddNewCustomer(re))
             {
                 ManagerDAL.AddNewLog(new Log()
                 {
                     StaffID = StaffID, ActionTime = DateTime.Now, Main = "Add new Customer: " + txtCusID.Text
                 });
                 MessageBox.Show("Add successful!");
                 BindingStatus = false;
                 LoadData();
                 addNew = false;
             }
             else
             {
                 MessageBox.Show("Add failed!");
             }
         }
         else
         {
             MessageBox.Show("Invalid to Add!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }