Exemple #1
0
        void cargargrid(string consulta = "select top(50) CodigoM as [Marca], CodigoP as [Producto], CodigoT as Tipo, Cantidad,Precio as [Precio x Uni.],Fecha from ventas")
        {
            AccesoDatos aq = new AccesoDatos();
            DataTable   t  = aq.ObtenerTabla("ventas", consulta);

            for (int i = 0; i < t.Columns.Count; i++)
            {
                if (i == 2)
                {
                    gv.Columns.Add("Detalle Producto", "Detalle Producto");
                }

                gv.Columns.Add(t.Columns[i].ColumnName, t.Columns[i].ColumnName);
            }

            for (int i = 0; i < t.Rows.Count; i++)
            {
                gv.Rows.Add();
                Producto p = new Producto(t.Rows[i][0].ToString(), t.Rows[i][1].ToString());
                gv.Rows[i].Cells[0].Value = Marca.Nombre_Marca(t.Rows[i][0].ToString());
                gv.Rows[i].Cells[1].Value = p.get_NombreP();
                gv.Rows[i].Cells[2].Value = p.get_DetalleP();
                gv.Rows[i].Cells[3].Value = t.Rows[i][2].ToString();
                gv.Rows[i].Cells[4].Value = t.Rows[i][3].ToString();
                gv.Rows[i].Cells[5].Value = t.Rows[i][4].ToString();
                gv.Rows[i].Cells[6].Value = t.Rows[i][5].ToString();
            }
            gv.ReadOnly = true;
        }
Exemple #2
0
        void cargargrid(string consulta)
        {
            DataTable t = new DataTable();

            gv.DataSource = null;
            gv.Columns.Clear();
            gv.Rows.Clear();
            t = aq.ObtenerTabla("grid", consulta);
            for (int i = 0; i < t.Columns.Count; i++)
            {
                gv.Columns.Add(t.Columns[i].ColumnName, t.Columns[i].ColumnName);
            }
            for (int i = 0; i < t.Rows.Count; i++)
            {
                gv.Rows.Add();
                gv.Rows[i].Cells["Marca"].Value = t.Rows[i]["Marca"].ToString();
                gv.Rows[i].Cells["Tipo"].Value  = t.Rows[i]["Tipo"].ToString();
                gv.Rows[i].Cells["Nombre del Producto"].Value  = t.Rows[i]["Nombre del Producto"].ToString();
                gv.Rows[i].Cells["Detalle del Producto"].Value = t.Rows[i]["Detalle del Producto"].ToString();
                gv.Rows[i].Cells["Stock"].Value           = t.Rows[i]["Stock"].ToString();
                gv.Rows[i].Cells["Precio"].Value          = t.Rows[i]["Precio"].ToString();
                gv.Rows[i].Cells["Codigo Producto"].Value = t.Rows[i]["Codigo Producto"].ToString();
            }
            for (int i = 0; i < gv.Columns.Count; i++)
            {
                gv.Columns[i].ReadOnly = true;
            }


            gv.Columns["Codigo Producto"].Visible = false;
            gv.Columns["Stock"].ReadOnly          = false;
            gv.Columns["Precio"].ReadOnly         = false;

            inicial = 1;
        }
Exemple #3
0
        static DataTable  todos_Productos()
        {
            string      consulta = "select * from ProductosxMarca";
            AccesoDatos aq       = new AccesoDatos();

            return(aq.ObtenerTabla("Productos", consulta));
        }
Exemple #4
0
        public static DataTable Todas_Marcas()
        {
            string consulta = "select CodigoM as [Codigo de Marca], NombreM as [Nombre de la Marca], " +
                              "detalleM as [Detalle] from marcas";
            AccesoDatos aq = new AccesoDatos();

            return(aq.ObtenerTabla("MarcasT", consulta));
        }
Exemple #5
0
        public int validar_Existe()
        {
            string      consulta = "select * from ProductosxMarca";
            AccesoDatos aq       = new AccesoDatos();

            try {
                DataTable t = aq.ObtenerTabla("Productos", consulta);

                for (int i = 0; i < t.Rows.Count; i++)
                {
                    if (t.Rows[i][0].ToString() == CodigoM && t.Rows[i][1].ToString() == CodigoP)
                    {
                        return(i);
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show("Error P1");
                Application.Exit();
            }
            return(-1);
        }
Exemple #6
0
        public Producto(string marcaC, string productoC)
        {
            string      consulta = "select * from ProductosxMarca where CodigoM='" + marcaC + "' and CodigoP='" + productoC + "'";
            AccesoDatos aq       = new AccesoDatos();
            DataTable   t        = aq.ObtenerTabla("Productos", consulta);

            try
            {
                if (t.Rows.Count != 0)
                {
                    CodigoM = t.Rows[0][0].ToString();
                    CodigoP = t.Rows[0][1].ToString();

                    CodigoT = t.Rows[0][2].ToString();


                    NombreP  = t.Rows[0][3].ToString();
                    DetalleP = t.Rows[0][4].ToString();
                    if (t.Rows[0][5].ToString() != "")
                    {
                        stock = int.Parse(t.Rows[0][5].ToString());
                    }
                    if (t.Rows[0][6].ToString() != "")
                    {
                        precio = t.Rows[0][6].ToString();
                    }
                }
                else
                {
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Error P2");
                //Application.Exit();

                MessageBox.Show(ex.ToString());
            }
        }
Exemple #7
0
        public static DataTable Todos_productos(string consulta = "select * from ProductosxMarca")
        {
            AccesoDatos aq = new AccesoDatos();

            return(aq.ObtenerTabla("productos", consulta));
        }