Пример #1
0
        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);
        }
Пример #2
0
 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;
 }
Пример #3
0
 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);
             }
         }
     }
                
 }
Пример #4
0
 public static bool UpdateDiscount(Discount a)
 {
     return DiscountData.UpdateDiscount(a);
 }
Пример #5
0
 public static bool AddDiscount(Discount a)
 {
     return DiscountData.AddDiscount(a);
 }