Exemplo n.º 1
0
 // lägg till pallstansning
 public void PsListView_InsertItem(PalletStatement palletStatement)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Service.SavePalletStatement(palletStatement);
             Session["succes"] = "pallstansningen sparades";
             Response.Redirect("/Pages/Default.aspx");
         }
         catch (Exception)
         {
             ModelState.AddModelError(String.Empty, "oväntat fel när pallstansningen skulle Läggas till.");
         }
     }
 }
Exemplo n.º 2
0
        public void SavePalletStatement(PalletStatement palletStatement)
        {
            // Validera affärsreglerna
            var validationContext = new ValidationContext(palletStatement);
            var validationResults = new List <ValidationResult>();

            if (!Validator.TryValidateObject(palletStatement, validationContext, validationResults, true))
            {
                var ex = new ValidationException("Pallstansningen kunde inte sparas.");
                ex.Data.Add("ValidationResults", validationResults);
                throw ex;
            }

            if (palletStatement.PsID == 0)
            {
                PalletStatementDAL.InsertPalletStatement(palletStatement);
            }
            else
            {
                PalletStatementDAL.UpdatePalletStatement(palletStatement);
            }
        }
Exemplo n.º 3
0
        // Redigera en pallstansning
        public void UpdatePalletStatement(PalletStatement palletStatement)
        {
            using (var conn = CreateConnection())
            {
                try
                {
                    var cmd = new SqlCommand("dbo.usp_UpdatePalletStatement", conn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@PsID", SqlDbType.Int, 4).Value = palletStatement.PsID;
                    cmd.Parameters.Add("@CustomerNUM", SqlDbType.Int, 4).Value = palletStatement.CustomerNUM;
                    cmd.Parameters.Add("@OutDate", SqlDbType.DateTime).Value = palletStatement.OutDate;
                    cmd.Parameters.Add("@InDate", SqlDbType.DateTime).Value = palletStatement.InDate;
                    cmd.Parameters.Add("@Apallet", SqlDbType.Int, 4).Value = palletStatement.Apallet;
                    cmd.Parameters.Add("@Bpallet", SqlDbType.Int, 4).Value = palletStatement.Bpallet;
                    cmd.Parameters.Add("@ApalletOUT", SqlDbType.Int, 4).Value = palletStatement.ApalletOUT;

                    conn.Open();

                    cmd.ExecuteNonQuery();

                }
                catch
                {
                    throw new ArgumentException("Fel vid anslutning till databasen");
                }

            }
        }
Exemplo n.º 4
0
        public void SavePalletStatement(PalletStatement palletStatement)
        {
            // Validera affärsreglerna
            var validationContext = new ValidationContext(palletStatement);
            var validationResults = new List<ValidationResult>();
            if (!Validator.TryValidateObject(palletStatement, validationContext, validationResults, true))
            {
                var ex = new ValidationException("Pallstansningen kunde inte sparas.");
                ex.Data.Add("ValidationResults", validationResults);
                throw ex;
            }

            if (palletStatement.PsID == 0)
            {
                PalletStatementDAL.InsertPalletStatement(palletStatement);
            }
            else
            {
                PalletStatementDAL.UpdatePalletStatement(palletStatement);
            }
        }