Exemple #1
0
        public void AgregarEtapa(LoteProduccion l, LoteEtapa.EtapasProduccion e)
        {
            SqlConnection connection = null;
            SqlCommand    cmd        = null;

            try
            {
                connection = GetConnection();
                connection.Open();
                cmd = connection.CreateCommand();

                cmd.CommandText = "INSERT INTO [Produccion].[LotesEtapas] (OrdenadoPor,FechaOrdenamiento,Lote,Etapa) VALUES (" + Environment.NewLine +
                                  "@OrdenadoPor," + Environment.NewLine +
                                  "GETDATE()," + Environment.NewLine +
                                  "@Lote," + Environment.NewLine +
                                  "@Etapa" + Environment.NewLine +
                                  ")" + Environment.NewLine +
                                  "SELECT CAST(SCOPE_IDENTITY() as int)";

                cmd.Parameters.AddWithValue("@OrdenadoPor", Session.UsuarioEnCurso.IdUsuario);
                cmd.Parameters.AddWithValue("@Lote", l.IdLoteProduccion);
                cmd.Parameters.AddWithValue("@Etapa", (int)e);

                int id = (int)cmd.ExecuteScalar();
                l.Add(new LoteEtapa()
                {
                    IdLoteEtapa = id, OrdenadoPor = Session.UsuarioEnCurso, Etapa = e
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                    connection.Dispose();
                }
            }
        }
Exemple #2
0
        public void CerrarEtapa(LoteProduccion l, LoteEtapa.EtapasProduccion e)
        {
            SqlConnection connection = null;
            SqlCommand    cmd        = null;

            try
            {
                connection = GetConnection();
                connection.Open();
                cmd = connection.CreateCommand();

                cmd.CommandText = "UPDATE [Produccion].[LotesEtapas] " +
                                  "SET " +
                                  "AutorizadoPor = @AutorizadoPor, " +
                                  "FechaAutorizacion = GETDATE() " +
                                  "WHERE Lote = @Lote AND Etapa = @Etapa";

                cmd.Parameters.AddWithValue("@AutorizadoPor", Session.UsuarioEnCurso.IdUsuario);
                cmd.Parameters.AddWithValue("@Lote", l.IdLoteProduccion);
                cmd.Parameters.AddWithValue("@Etapa", e);

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                    connection.Dispose();
                }
            }
        }