Esempio n. 1
0
        public IEnumerable <ECategorias> GetAll(bool status)
        {
            using (SqlConnection cnx = new SqlConnection())
            {
                cnx.ConnectionString = MiCadena.CadenaCnx();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "usp_Categorias_getAll";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Estado", status);
                cmd.Connection = cnx;
                cnx.Open();

                var reader = cmd.ExecuteReader();

                var lista = new List <ECategorias>();
                while (reader.Read())
                {
                    lista.Add(new ECategorias
                    {
                        ID          = Convert.ToInt32(reader["ID"]),
                        Nombre      = (reader["Nombre"].ToString()),
                        Descripcion = (reader["Descripcion"].ToString()),
                        //  Estado = Convert.ToBoolean(reader["Estado"]),
                    });
                }


                return(lista);
            }
        }
Esempio n. 2
0
        public IEnumerable <EProveedor> GetAll(bool status)
        {
            using (SqlConnection cnx = new SqlConnection())
            {
                cnx.ConnectionString = MiCadena.CadenaCnx();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "usp_Proveedor_getAll";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Estado", status);
                cmd.Connection = cnx;
                cnx.Open();

                var reader = cmd.ExecuteReader();

                var lista = new List <EProveedor>();
                while (reader.Read())
                {
                    lista.Add(new EProveedor
                    {
                        ID           = Convert.ToInt32(reader["ID"]),
                        Razon_social = (reader["RazonSocial"].ToString()),
                        RUC          = (reader["Ruc"].ToString()),
                        Direccion    = (reader["Direccion"].ToString()),
                        Telefono     = (reader["Telefono"].ToString()),
                        Mail         = (reader["Mail"].ToString()),
                        //  Estado = Convert.ToBoolean(reader["Estado"]),
                    });
                }


                return(lista);
            }
        }
Esempio n. 3
0
        public int Delete(int id)
        {
            using (SqlConnection cnx = new SqlConnection())
            {
                cnx.ConnectionString = MiCadena.CadenaCnx();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "usp_Categoria_IDelete";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@ID", id);

                cmd.Connection = cnx;
                cnx.Open();


                int filasafectadas = cmd.ExecuteNonQuery();

                return(filasafectadas);
            }
        }
Esempio n. 4
0
        public int Create(ECategorias t)
        {
            using (SqlConnection cnx = new SqlConnection())
            {
                cnx.ConnectionString = MiCadena.CadenaCnx();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "usp_Categoria_ICreate";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Nombre", t.Nombre);
                cmd.Parameters.AddWithValue("@Descripcion", t.Descripcion);
                cmd.Parameters.AddWithValue("@Estado", t.Estado);
                cmd.Connection = cnx;
                cnx.Open();


                int filasafectadas = cmd.ExecuteNonQuery();

                return(filasafectadas);
            }
        }
Esempio n. 5
0
        public int Create(EProveedor t)
        {
            using (SqlConnection cnx = new SqlConnection())
            {
                cnx.ConnectionString = MiCadena.CadenaCnx();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "usp_Proveedor_ICreate";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@RazonSocial", t.Razon_social);
                cmd.Parameters.AddWithValue("@RUC", t.RUC);
                cmd.Parameters.AddWithValue("@Direccion", t.Direccion);
                cmd.Parameters.AddWithValue("@Telefono", t.Telefono);
                cmd.Parameters.AddWithValue("@Mail", t.Mail);
                cmd.Parameters.AddWithValue("@Estado", t.Estado);
                cmd.Connection = cnx;
                cnx.Open();


                int filasafectadas = cmd.ExecuteNonQuery();

                return(filasafectadas);
            }
        }