public static bool AddDiscount(Discount a) { string sql = "sp_InsertDiscount"; SqlParameter Rate = new SqlParameter("@Rate", a.Rate); SqlParameter DateStart = new SqlParameter("@DateStart", a.DateStart); SqlParameter DateEnd = new SqlParameter("@DateEnd", a.DateEnd); return DataProvider.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, Rate, DateStart, DateEnd); }
public static Discount GetbyDay(DateTime date) { string sql = "sp_GetDiscount"; SqlParameter DayStart = new SqlParameter("@Date", date); SqlDataReader dr = DataProvider.ExecuteQueryWithDataReader(sql, CommandType.StoredProcedure, DayStart); if (dr.HasRows) { dr.Read(); Discount a = new Discount(); a.CodeID = dr.GetInt32(0); a.Rate = dr.GetInt32(1); a.DateStart = dr.GetDateTime(2); a.DateEnd = dr.GetDateTime(3); return a; } else return null; }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (isValid()) { if (isUpdate) { lblName.Content = "Update Discount"; try { Discount dis = new Discount(); dis.CodeID = DisID; dis.Rate = int.Parse(txtRate.Text); dis.DateStart = (DateTime)dpStart.SelectedDate; dis.DateEnd = (DateTime)dpEnd.SelectedDate; DiscountBL.UpdateDiscount(dis); System.Windows.Forms.MessageBox.Show("Success"); this.Close(); } catch (Exception h) { System.Windows.Forms.MessageBox.Show("Error " + h.Message); } } else { try { Discount dis = new Discount(); dis.Rate = int.Parse(txtRate.Text); dis.DateStart = DateTime.Parse(dpStart.Text.ToString()); dis.DateEnd = (DateTime)dpEnd.SelectedDate; DiscountBL.AddDiscount(dis); System.Windows.Forms.MessageBox.Show("Success"); this.Close(); } catch (Exception h) { System.Windows.Forms.MessageBox.Show("Error " + h.Message); } } } }
public static bool UpdateDiscount(Discount a) { return DiscountData.UpdateDiscount(a); }
public static bool AddDiscount(Discount a) { return DiscountData.AddDiscount(a); }