示例#1
0
        // DAO -- update Customer
        public bool DAOupdateCustomer(Customer customer)
        {
            try
            {
                // connect
                GetConnection();

                // update pserson
                SqlCommand cmd;
                cmd = new SqlCommand(updatePsersonQuery, con);
                cmd.Parameters.AddWithValue("@ID", customer.ID);
                cmd.Parameters.AddWithValue("@Name", customer.Name);
                cmd.Parameters.AddWithValue("@Address", customer.Address);
                cmd.Parameters.AddWithValue("@Telephone_Number", customer.Telephone_Number);

                // get new id 
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                // update Employee
                cmd = new SqlCommand(updateCustomerQuery, con);
                cmd.Parameters.AddWithValue("@CID", customer.ID);
                cmd.Parameters.AddWithValue("@Email", customer.Email);
                if (customer.DateOfBirth != null)
                    cmd.Parameters.AddWithValue("@DateOfBirth", customer.DateOfBirth);
                else
                    cmd.Parameters.AddWithValue("@DateOfBirth", DBNull.Value);
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                // close
                con.Close();
                con.Dispose();

                return true;
            }
            catch (Exception ex)
            {
                throw new CanoeException("DAOupdateCustomer", ex.Message);
            }
        }
示例#2
0
文件: Manage.cs 项目: kayshoji/C-.Net
 // update Customer
 public bool updateDAOCustomer(Customer customer)
 {
     db = new DatabaseAccess();
     db.DAOupdateCustomer(customer);
     return true;
 }
示例#3
0
文件: Manage.cs 项目: kayshoji/C-.Net
 public Customer makeCustomer(String name, String address, int telephone_number,
     String email, String dateOfBirth)
 {
     DateTime? d = new DateTime();
     if (dateOfBirth.Length > 0)
         d = DateTime.ParseExact(dateOfBirth, "ddMMyyyy", null);
     else
         d = null;
     Customer customer = new Customer(
         name,
         address,
         telephone_number,
         email,
         d
     );
     return customer;
 }
示例#4
0
文件: Manage.cs 项目: kayshoji/C-.Net
 // insert Customer
 public bool insertDAOCustomer(Customer customer)
 {
     db = new DatabaseAccess();
     db.DAOinsertCustomer(customer);
     return true;
 }
示例#5
0
        // select customer event 
        private void dataGridViewCustomer_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                // get current row
                DataGridViewRow row = dataGridViewCustomer.CurrentRow;

                // get setlect customer
                int cid = int.Parse(row.Cells[1].Value.ToString());
                customer = manage.searchDAOCustomer(cid);

                // set setlect customer
                txtSelectCustomerID.Text = customer.CID.ToString();
                txtSelectCustomerName.Text = customer.Name;
                txtSelectCustomerAddress.Text = customer.Address;
                txtSelectCustomerTel.Text = customer.Telephone_Number.ToString();
                txtSelectCustomerEmail.Text = customer.Email;
                if (customer.DateOfBirth != null)
                    txtSelectCustomerBirth.Text = customer.DateOfBirth.ToString();
                else
                    txtSelectCustomerBirth.Text = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }