Esempio n. 1
0
 public void TaxListView_InsertItem(Tax tax)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Service.UpdateTax(tax);
             //Session["Success"] = true;
             Response.RedirectToRoute("Settings");
         }
         catch (Exception)
         {
             ModelState.AddModelError(String.Empty, "Ett oväntat fel inträffade då Momsuppgiften skulle läggas till.");
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Updates taxes
        /// </summary>
        /// <param name="tax"></param>
        public void UpdateTax(Tax tax)
        {
            using (SqlConnection conn = CreateConnection())
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("appSchema.uspUpdateTax", conn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    conn.Open();
                    cmd.Parameters.Add("@TaxID", SqlDbType.Int, 4).Value = tax.TaxID;
                    cmd.Parameters.Add("@TaxValue", SqlDbType.Decimal).Value = tax.TaxValue;
                    cmd.ExecuteNonQuery();

                }
                catch
                {
                    throw new ApplicationException("An error occured in the data access layer.");
                }
            }
        }
Esempio n. 3
0
        public void UpdateTax(Tax tax)
        {

            ICollection<ValidationResult> validationResults;
            if (!tax.Validate(out validationResults))
            {
                var ex = new ValidationException("Objektet klarade inte valideringen.");
                ex.Data.Add("ValidationResults", validationResults);
                throw ex;
            }
            if (tax.TaxID == 0) // New post if ID is 0!
            {
                TaxDAL.InsertTax(tax);
            }
            else
            {
                TaxDAL.UpdateTax(tax);
            }
        }