示例#1
0
        public int Existencias(int idProducto)
        {
            String error = "";
            String query = "SELECT * FROM inout " +
                           "WHERE ID_PRODUCTO=" + idProducto + " ORDER BY CATALOGO ASC";

            DataTable dt    = BaseDatosSQL.Tabla(query, ref error);
            int       stock = 0;

            if (dt.Rows.Count > 0)
            {
                int[] entradA = new int[10000];
                int[] salidA  = new int[10000];
                int   i       = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    entradA[i] = Convert.ToInt32(dr["ENTRADA"]);
                    salidA[i]  = Convert.ToInt32(dr["SALIDA"]);
                    i++;
                }

                stock = entradA.Sum() - salidA.Sum();
            }

            return(stock);
        }
        public static List <PRODUCTOS> GetExistentes()
        {
            List <PRODUCTOS> lista = new List <PRODUCTOS>();

            String query = "SELECT * FROM PRODUCTOS ORDER BY CATALOGO ASC";

            String error = "";

            DataTable dt = BaseDatosSQL.Tabla(query, ref error);

            foreach (DataRow dr in dt.Rows)
            {
                lista.Add(new PRODUCTOS(dr));
            }
            return(lista);
        }