Exemple #1
0
 public FAgeDiscount()
 {
     InitializeComponent();
     ageDiscountModel = new AgeDiscountModel();
     listDiscount     = new DataTable();
     rowIndex         = 0;
     seletedFunction  = 0;
     ageDiscount      = new AgeDiscount();
 }
        public bool updateAgeDiscount(AgeDiscount AgeDiscount)
        {
            bool          updated = false;
            SqlConnection connection;
            SqlCommand    command;
            string        sql = "UPDATE tbAgeDiscount SET MinAge = " + AgeDiscount.MinAge + ", MaxAge = " + AgeDiscount.MaxAge + ", Discount = " + AgeDiscount.DiscountRate + " WHERE DiscountId = " + AgeDiscount.DiscountId;

            try
            {
                connection = new ConnectDB().connectToSQL();
                command    = new SqlCommand(sql, connection);
                if (command.ExecuteNonQuery() == 1)
                {
                    updated = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            connection.Close();
            return(updated);
        }
        public bool insertAgeDiscount(AgeDiscount discount)
        {
            bool          inserted = false;
            SqlConnection connection;
            SqlCommand    command;
            string        sql = "INSERT INTO tbAgeDiscount VALUES(" + discount.MinAge + ", " + discount.MaxAge + ", " + discount.DiscountRate + ")";

            try
            {
                connection = new ConnectDB().connectToSQL();
                command    = new SqlCommand(sql, connection);
                if (command.ExecuteNonQuery() == 1)
                {
                    inserted = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            connection.Close();
            return(inserted);
        }