예제 #1
0
        private void btnUpdateCustomerDetails_Click(object sender, EventArgs e)
        {
            try
            {
                Customer obj = new Customer();
                obj.ID = Convert.ToInt32(txtEditID.Text);
                obj.FirstName = txtEditFirstName.Text;
                obj.LastName = txtEditLastName.Text;
                obj.Address = txtEditAddress.Text;
                obj.City = txtEditCity.Text;
                obj.State = txtEditState.Text;
                obj.Country = txtEditCountry.Text;
                obj.Email = txtEditAddress.Text;
                obj.Phone = txtEditPhone.Text;
                obj.mobile = txtEditMobile.Text;

                cstomerService.Update(obj);
                ClearCustomerEditFields();

                MessageBox.Show(this, "Sucessfully Updated Customer Details", "Suceed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error On Update Customer :" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void btnAddCustomer_Click(object sender, EventArgs e)
        {
            CustomerService cusService = new CustomerService();

            try
            {
                Customer obj = new Customer()
                    {
                        ID = Convert.ToInt32(txtID.Text),
                        FirstName = txtFirstName.Text,
                        LastName = txtLastName.Text,
                        Address = txtAddress.Text,
                        City = txtCity.Text,
                        State = txtState.Text,
                        Country = txtCountry.Text,
                        Email = txtEmail.Text,
                        Phone = txtPhone.Text,
                        mobile = txtMobile.Text
                    };

                cusService.AddNew(obj);
                ClearNewCustomerFields();
                MessageBox.Show(this, "Customer Added.", "Succeed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Customer Insert Fail : " + ex.Message);
            }
        }
예제 #3
0
 /// <summary>
 /// Create a new Customer object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 public static Customer CreateCustomer(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.String address)
 {
     Customer customer = new Customer();
     customer.ID = id;
     customer.FirstName = firstName;
     customer.LastName = lastName;
     customer.Address = address;
     return customer;
 }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCustomers(Customer customer)
 {
     base.AddObject("Customers", customer);
 }