예제 #1
0
 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);
 }
예제 #2
0
 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;
 }
예제 #3
0
 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);
             }
         }
     }
 }
예제 #4
0
 public static bool UpdateSupplier(Supplier a)
 {
     return SupplierData.UpdateSupplier(a);
 }
예제 #5
0
 public static bool AddSupplier(Supplier a)
 {
     return SupplierData.AddSupplier(a);
 }