public static bool AddSupplier(Supplier a) { string sql = "sp_InsertSupplier"; SqlParameter SupName = new SqlParameter("@SupName", a.SupName); SqlParameter SupAddress = new SqlParameter("@SupAddress", a.SupAddress); SqlParameter SupPhone = new SqlParameter("@SupPhone", a.SupPhone); return DataProvider.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, SupName, SupAddress, SupPhone); }
public static Supplier GetbySupplierName(string name) { string sql = "sp_GetSupplier"; SqlParameter Name = new SqlParameter("@SupName", name); SqlDataReader dr = DataProvider.ExecuteQueryWithDataReader(sql, CommandType.StoredProcedure, Name); if (dr.HasRows) { dr.Read(); Supplier a = new Supplier(); a.SupID = dr.GetInt32(0); a.SupName = dr.GetString(1); a.SupAddress = dr.GetString(2); a.SupPhone = dr.GetString(3); return a; } else return null; }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (isValid()) { if (isUpdate) { lblName.Content = "Update Supplier"; try { Supplier sup = new Supplier(); sup.SupID = SupID; sup.SupName = txtSupName.Text; sup.SupAddress = txtAddress.Text; sup.SupPhone = txtPhone.Text; SupplierBL.UpdateSupplier(sup); System.Windows.Forms.MessageBox.Show("Success"); this.Close(); } catch (Exception h) { System.Windows.Forms.MessageBox.Show("Error " + h.Message); } } else { try { Supplier sup = new Supplier(); sup.SupName = txtSupName.Text; sup.SupAddress = txtAddress.Text; sup.SupPhone = txtPhone.Text; SupplierBL.AddSupplier(sup); System.Windows.Forms.MessageBox.Show("Success"); this.Close(); } catch (Exception h) { System.Windows.Forms.MessageBox.Show("Error " + h.Message); } } } }
public static bool UpdateSupplier(Supplier a) { return SupplierData.UpdateSupplier(a); }
public static bool AddSupplier(Supplier a) { return SupplierData.AddSupplier(a); }