예제 #1
0
        public static int EliminarEnvase(EnvaseNE eNE)
        {
            IDbConnection con = CapaDA.DBComun.Conexion();

            con.Open();
            SqlCommand Comand = new SqlCommand("Delete Envase WHERE IDEnvase=@IDEnvase", con as SqlConnection);

            Comand.Parameters.Add(new SqlParameter("@NombreEnvase", eNE.NombreEnvase));
            Comand.Parameters.Add(new SqlParameter("@IDEnvase", eNE.IDEnvase));

            int Resultado = Comand.ExecuteNonQuery();

            con.Close();
            return(Resultado);
        }
예제 #2
0
        public List <EnvaseNE> LlenarComboEnvase()
        {
            IDbConnection con = DBComun.Conexion();

            con.Open();
            SqlCommand      _Command = new SqlCommand("SELECT NombreEnvase From Envase", con as SqlConnection);
            IDataReader     reader   = _Command.ExecuteReader();
            List <EnvaseNE> Lista    = new List <EnvaseNE>();

            while (reader.Read())
            {
                EnvaseNE ObjetoEnvaseNE = new EnvaseNE();
                ObjetoEnvaseNE.IDEnvase     = reader.GetInt32(0);
                ObjetoEnvaseNE.NombreEnvase = reader.GetString(1);

                Lista.Add(ObjetoEnvaseNE);
            }
            con.Close();
            return(Lista);
        }
예제 #3
0
        public static int AgregarEnvase(EnvaseNE eNE)
        {
            IDbConnection con = CapaDA.DBComun.Conexion();

            con.Open();
            try{
                SqlCommand Comand = new SqlCommand("IF NOT EXISTS (SELECT IDEnvase FROM Envase WHERE IDEnvase = @IDEnvase) INSERT INTO Envase (IDEnvase, NombreEnvase) VALUES (@IDEnvase, @NombreEnvase)", con as SqlConnection);
                Comand.Parameters.Add(new SqlParameter("@IDEnvase", eNE.IDEnvase));
                Comand.Parameters.Add(new SqlParameter("@NombreEnvase", eNE.NombreEnvase));

                int Resultado = Comand.ExecuteNonQuery();
                con.Close();
                return(Resultado);
            }

            catch (Exception ex)
            {
                Console.WriteLine("Error" + ex);
                return(1);
            }
        }
예제 #4
0
        public List <EnvaseNE> TraerUltimoIDEnvase()
        {
            IDbConnection con = DBComun.Conexion();

            con.Open();
            SqlCommand _Command = new SqlCommand("SELECT( max(IDEnvase)+1) from Envase", con as SqlConnection);
            // _Command.CommandType = CommandType.StoredProcedure;
            IDataReader     reader = _Command.ExecuteReader();
            List <EnvaseNE> Lista  = new List <EnvaseNE>();

            while (reader.Read())
            {
                EnvaseNE ObjetoEnvaseNE = new EnvaseNE();

                ObjetoEnvaseNE.IDEnvase = reader.GetInt32(0);

                Lista.Add(ObjetoEnvaseNE);
            }
            con.Close();
            return(Lista);
        }
예제 #5
0
 public int EliminarEnvase(EnvaseNE env)
 {
     return(EnvaseDA.EliminarEnvase(env));
 }
예제 #6
0
 public int ModificarEnvase(EnvaseNE env)
 {
     return(EnvaseDA.ModificarEnvase(env));
 }
예제 #7
0
 public int AgregarEnvase(EnvaseNE env)
 {
     return(CapaDA.EnvaseDA.AgregarEnvase(env));
 }