Exemple #1
0
 public static bool Update(CustomerClassDiscount customerClassDiscount)
 {
     try
     {
         using (var conn = new MySqlConnection(Globals.CONN_STR))
         {
             conn.Open();
             var sql = @"UPDATE customer_class_discount 
                         set end_date =@end_date,
                         discount_per=@discount_per, 
                         modified_at=CURRENT_TIMESTAMP,
                         modified_by=@modified_by 
                         WHERE class_id = @class_id 
                         And start_date = @start_date";
             var cmd = new MySqlCommand(sql, conn);
             cmd.Parameters.AddWithValue("class_id", customerClassDiscount.MasterClass.ClassId);
             cmd.Parameters.AddWithValue("start_date", customerClassDiscount.StartDate);
             cmd.Parameters.AddWithValue("end_date", customerClassDiscount.EndDate);
             cmd.Parameters.AddWithValue("discount_per", customerClassDiscount.DiscountPer);
             cmd.Parameters.AddWithValue("modified_by", customerClassDiscount.ModifiedBy);
             var affRow = cmd.ExecuteNonQuery();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
        public static bool Insert(CustomerClassDiscount customerClassDiscount)
        {
            try
            {
                using (var conn = new MySqlConnection(Globals.CONN_STR))
                {
                    conn.Open();
                    var sql = @"INSERT INTO customer_class_discount
                                    (class_id, start_date, end_date, 
                                    discount_per, create_by) 
                                    VALUES 
                                     (@class_id, @start_date, @end_date, 
                                    @discount_per, @create_by) ";

                    var cmd = new MySqlCommand(sql, conn);
                    cmd.Parameters.AddWithValue("class_id", customerClassDiscount.MasterClass.ClassId);
                    cmd.Parameters.AddWithValue("start_date", customerClassDiscount.StartDate);
                    cmd.Parameters.AddWithValue("end_date", customerClassDiscount.EndDate);
                    cmd.Parameters.AddWithValue("discount_per", customerClassDiscount.DiscountPer);
                    cmd.Parameters.AddWithValue("create_by", customerClassDiscount.CreateBy);
                    var affRow = cmd.ExecuteNonQuery();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }