public static bool AddCustomer(Customer a) { string sql = "sp_InsertCustomer"; SqlParameter CusName = new SqlParameter("@CusName", a.CusName); SqlParameter CusAddress = new SqlParameter("@CusAddress", a.CusAddress); SqlParameter CusPhone = new SqlParameter("@CusPhone", a.CusPhone); return DataProvider.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, CusName, CusAddress, CusPhone); }
public static Customer GetbyCustomerName(string name) { string sql = "sp_GetCustomer"; SqlParameter Name = new SqlParameter("@CustomerName", name); SqlDataReader dr = DataProvider.ExecuteQueryWithDataReader(sql, CommandType.StoredProcedure, Name); if (dr.HasRows) { dr.Read(); Customer a = new Customer(); a.CusID = dr.GetInt32(0); a.CusName = dr.GetString(1); a.CusAddress = dr.GetString(2); a.CusPhone = dr.GetString(3); return a; } else return null; }
public static bool UpdateCustomer(Customer a) { return CustomerData.UpdateCustomer(a); }
public static bool AddCustomer(Customer a) { return CustomerData.AddCustomer(a); }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (isValid()) { if (isUpdate) { lblName.Content = "Update Customer"; try { Customer cus = new Customer(); cus.CusID = CusID; cus.CusName = txtName.Text; cus.CusAddress = txtAddress.Text; cus.CusPhone = txtPhoneNo.Text; CustomerBL.UpdateCustomer(cus); System.Windows.Forms.MessageBox.Show("Success"); this.Close(); } catch (Exception h) { System.Windows.Forms.MessageBox.Show("Error " + h.Message); } } else { try { Customer cus = new Customer(); cus.CusName = txtName.Text; cus.CusAddress = txtAddress.Text; cus.CusPhone = txtPhoneNo.Text; CustomerBL.AddCustomer(cus); System.Windows.Forms.MessageBox.Show("Success"); this.Close(); } catch (Exception h) { System.Windows.Forms.MessageBox.Show("Error " + h.Message); } } } }