Esempio n. 1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                entProducto     p  = new entProducto();
                entCategoria    c  = new entCategoria();
                entUnidadMedida um = new entUnidadMedida();
                entProveedor    pr = new entProveedor();
                p.Id_Prod    = Convert.ToInt32(txtIdP.Text);
                p.categoria  = c;
                p.proveedor  = pr;
                p.unidmedida = um;
                DialogResult r = MessageBox.Show("¿Desea eliminar Registro seleccionado?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (r == DialogResult.Yes)
                {
                    int i = ProductoServices.Instancia.MantenimientoProducto(p, 3);
                    MessageBox.Show("Registro eliminado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                ControlBotones("P", true, false, false, false, false, true);
                ac.BloquearText(this.tbcProducto, false);
                CargarGridProducto();
            }
            catch (ApplicationException ae) { MessageBox.Show(ae.Message, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
 private void btnGuardarC_Click(object sender, EventArgs e)
 {
     try
     {
         entCategoria c           = new entCategoria();
         int          tipoedicion = 1;
         if (txtidC.Text != "")
         {
             tipoedicion = 2; c.Id_Cat = Convert.ToInt32(txtidC.Text);
         }
         c.Nombre_Cat          = txtNombreC.Text;
         c.Descripcion_Cat     = txtDescripcionC.Text;
         c.UsuarioCreacion_Cat = idUsuario;
         c.UsuarioUpdate_Cat   = idUsuario;
         int i = ProductoServices.Instancia.MantenimientoCategoria(c, tipoedicion);
         MessageBox.Show("¡Registro Correcto!", "Mensaje",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         ControlBotones("C", true, false, false, false, false, true);
         ac.BloquearText(this.tbcCategoria, false);
         CargarGrid();
         LlenarCombos();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public entCategoria BuscarCategoria(int Cat_id)
        {
            SqlCommand    cmd = null;
            SqlDataReader dr  = null;
            entCategoria  c   = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spBuscarCategoria", cn);
                cmd.Parameters.AddWithValue("@prmidCat", Cat_id);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    c                 = new entCategoria();
                    c.Id_Cat          = Convert.ToInt32(dr["Id_Cat"]);
                    c.Codigo_Cat      = dr["Codigo_Cat"].ToString();
                    c.Nombre_Cat      = dr["Nombre_Cat"].ToString();
                    c.Descripcion_Cat = dr["Descripcion_Cat"].ToString();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(c);
        }
        public List <entCategoria> ListarCategoria()
        {
            SqlCommand          cmd   = null;
            SqlDataReader       dr    = null;
            List <entCategoria> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("spListarCategoria", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entCategoria>();
                while (dr.Read())
                {
                    entCategoria c = new entCategoria();
                    c.Id_Cat          = Convert.ToInt32(dr["Id_Cat"]);
                    c.Codigo_Cat      = dr["Codigo_Cat"].ToString();
                    c.Nombre_Cat      = dr["Nombre_Cat"].ToString();
                    c.Descripcion_Cat = dr["Descripcion_Cat"].ToString();
                    Lista.Add(c);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
Esempio n. 5
0
 public int MantenimientoCategoria(entCategoria c, int tipoedicion)
 {
     try
     {
         entCategoria cat = new entCategoria();
         cat = c;
         String cadXml = "";
         cadXml += "<categoria ";
         cadXml += "idcategoria='" + cat.Id_Cat + "' ";
         cadXml += "nombre='" + cat.Nombre_Cat + "' ";
         cadXml += "descripcion='" + cat.Descripcion_Cat + "' ";
         cadXml += "usuariocreacion='" + cat.UsuarioCreacion_Cat + "' ";
         cadXml += "usuarioupdate='" + cat.UsuarioUpdate_Cat + "' ";
         cadXml += "tipoedicion='" + tipoedicion + "'/>";
         cadXml  = "<root>" + cadXml + "</root>";
         int i = datProducto.Instancia.MantenimientoCategoria(cadXml);
         if (i <= 0)
         {
             throw new ApplicationException("No se pudo completar la acción, Intentelo otra vez");
         }
         return(i);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public List <entCategoria> ListarCatGorias(Int32 id_GrupCom)
        {
            SqlCommand          cmd   = null;
            SqlDataReader       dr    = null;
            List <entCategoria> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spCategoria", cn);
                cmd.Parameters.AddWithValue("@id_grup_com", id_GrupCom);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entCategoria>();
                while (dr.Read())
                {
                    entCategoria c = new entCategoria();
                    c.Cat_Id          = Convert.ToInt32(dr["Cat_Id"]);
                    c.Cat_Codigo      = dr["Cat_Codigo"].ToString();
                    c.Cat_Nombre      = dr["Cat_Nombre"].ToString();
                    c.Cat_Descripcion = dr["Cat_Descripcion"].ToString();
                    Lista.Add(c);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }

            return(Lista);
        }
        public List <entProducto> ListarProductoIndicador(String codigo, int id_cat, int rango)
        {
            SqlCommand         cmd   = null;
            List <entProducto> Lista = null;
            SqlDataReader      dr    = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spListarProdStatus", cn);
                cmd.Parameters.AddWithValue("@prmCodigo", codigo);
                cmd.Parameters.AddWithValue("@prmcat", id_cat);
                cmd.Parameters.AddWithValue("@prmstockrango", rango);

                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entProducto>();
                while (dr.Read())
                {
                    entProducto p = new entProducto();
                    p.Id_Prod           = Convert.ToInt32(dr["Id_Prod"]);
                    p.Codigo_Prod       = dr["Codigo_Prod"].ToString();
                    p.Nombre_Prod       = dr["Nombre_Prod"].ToString();
                    p.PrecioCompra_Prod = Convert.ToDouble(dr["PrecioCompra_Prod"]);
                    p.Precio_Prod       = Convert.ToDouble(dr["Precio_Prod"]);
                    p.Stock_Prod        = Convert.ToInt32(dr["Stock_Prod"]);
                    p.StockProm_Prod    = Convert.ToInt32(dr["StockProm_Prod"]);
                    p.StockMin_Prod     = Convert.ToInt32(dr["StockMin_Prod"]);

                    entCategoria c = new entCategoria();
                    c.Nombre_Cat = dr["Nombre_Cat"].ToString();
                    p.categoria  = c;
                    entUnidadMedida um = new entUnidadMedida();
                    um.Abreviatura_Umed = dr["Abreviatura_Umed"].ToString();
                    p.unidmedida        = um;
                    entMaterial m = new entMaterial();
                    m.Nombre   = dr["Nombre_Material"].ToString();
                    p.material = m;
                    Lista.Add(p);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
        public entProducto BuscarProducto(int id_producto)
        {
            SqlCommand    cmd = null;
            SqlDataReader dr  = null;
            entProducto   p   = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spBuscarProducto", cn);
                cmd.Parameters.AddWithValue("@prmId_Prod", id_producto);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    p                   = new entProducto();
                    p.Id_Prod           = Convert.ToInt32(dr["Id_Prod"]);
                    p.Codigo_Prod       = dr["Codigo_Prod"].ToString();
                    p.Nombre_Prod       = dr["Nombre_Prod"].ToString();
                    p.Marca_Prod        = dr["Marca_Prod"].ToString();
                    p.PrecioCompra_Prod = Convert.ToDouble(dr["PrecioCompra_Prod"].ToString());
                    p.Precio_Prod       = Convert.ToDouble(dr["Precio_Prod"].ToString());
                    p.Stock_Prod        = Convert.ToInt32(dr["Stock_Prod"]);
                    p.StockProm_Prod    = Convert.ToInt32(dr["StockProm_Prod"]);
                    p.StockMin_Prod     = Convert.ToInt32(dr["StockMin_Prod"]);
                    entCategoria c = new entCategoria();
                    c.Id_Cat    = Convert.ToInt32(dr["Id_Cat"]);
                    p.categoria = c;
                    entUnidadMedida um = new entUnidadMedida();
                    um.Id_Umed   = Convert.ToInt32(dr["Id_Umed"]);
                    p.unidmedida = um;
                    entProveedor pr = new entProveedor();
                    pr.Id_Proveedor = Convert.ToInt32(dr["Id_Proveedor"]);
                    p.proveedor     = pr;
                    entMaterial m = new entMaterial();
                    m.Id       = Convert.ToInt32(dr["Id_Material"]);
                    p.material = m;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(p);
        }
        public List <entProducto> BuscarProductoAvanzada(int tip_entrada, String valor_entrada)
        {
            SqlCommand         cmd   = null;
            SqlDataReader      dr    = null;
            List <entProducto> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spBuscarProdAvanzada", cn);
                cmd.Parameters.AddWithValue("@prmTipEntrada", tip_entrada);
                cmd.Parameters.AddWithValue("@prmValorEntrada", valor_entrada);

                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entProducto>();
                while (dr.Read())
                {
                    entProducto p = new entProducto();
                    p.Id_Prod     = Convert.ToInt32(dr["Id_Prod"]);
                    p.Codigo_Prod = dr["Codigo_Prod"].ToString();
                    p.Nombre_Prod = dr["Nombre_Prod"].ToString();
                    p.Marca_Prod  = dr["Marca_Prod"].ToString();
                    p.Precio_Prod = Convert.ToDouble(dr["Precio_Prod"].ToString());
                    p.Stock_Prod  = Convert.ToInt32(dr["Stock_Prod"]);
                    entCategoria c = new entCategoria();
                    c.Nombre_Cat = dr["Nombre_Cat"].ToString();
                    p.categoria  = c;
                    entUnidadMedida um = new entUnidadMedida();
                    um.Descripcion_Umed = dr["Descripcion_Umed"].ToString();
                    p.unidmedida        = um;
                    entMaterial m = new entMaterial();
                    m.Nombre   = dr["Nombre_Material"].ToString();
                    p.material = m;
                    Lista.Add(p);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
Esempio n. 10
0
 private void dgvCategoria_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         int          id_cate = Convert.ToInt32(dgvCategoria.CurrentRow.Cells[0].Value);
         entCategoria c       = null;
         c                    = ProductoServices.Instancia.BuscrCategoria(id_cate);
         txtidC.Text          = c.Id_Cat.ToString();
         txtCodigoC.Text      = c.Codigo_Cat;
         txtNombreC.Text      = c.Nombre_Cat;
         txtDescripcionC.Text = c.Descripcion_Cat;
         ControlBotones("C", true, true, false, true, false, true);
         ac.BloquearText(this.tbcCategoria, false);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 11
0
 public entCategoria BuscrCategoria(int cat_id)
 {
     try
     {
         if (cat_id.ToString() == "")
         {
             throw new ApplicationException("Debe seleccionar un registro de la lista");
         }
         entCategoria c = null;
         c = datProducto.Instancia.BuscarCategoria(cat_id);
         if (c == null)
         {
             throw new ApplicationException("No se encontro el registro en BD");
         }
         return(c);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 12
0
        public List <entProducto> ListarProducto()
        {
            SqlCommand         cmd   = null;
            List <entProducto> Lista = null;
            SqlDataReader      dr    = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("spListarProducto", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entProducto>();
                while (dr.Read())
                {
                    entProducto p = new entProducto();
                    p.Id_Prod     = Convert.ToInt32(dr["Id_Prod"]);
                    p.Codigo_Prod = dr["Codigo_Prod"].ToString();
                    p.Nombre_Prod = dr["Nombre_Prod"].ToString();
                    p.Marca_Prod  = dr["Marca_Prod"].ToString();
                    entCategoria c = new entCategoria();
                    c.Nombre_Cat = dr["Nombre_Cat"].ToString();
                    p.categoria  = c;
                    entUnidadMedida um = new entUnidadMedida();
                    um.Descripcion_Umed = dr["Descripcion_Umed"].ToString();
                    p.unidmedida        = um;
                    entProveedor pr = new entProveedor();
                    pr.RazSocial_Proveedor = dr["RazSocial_Proveedor"].ToString();
                    p.proveedor            = pr;
                    Lista.Add(p);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
Esempio n. 13
0
        public List <entProducto> ListaProd()
        {
            SqlCommand         cmd   = null;
            SqlDataReader      dr    = null;
            List <entProducto> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("spListaProducto", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entProducto>();
                while (dr.Read())
                {
                    entProducto p = new entProducto();
                    p.Pro_ID          = Convert.ToInt32(dr["Pro_ID"]);
                    p.Pro_Codigo      = dr["Pro_Codigo"].ToString();
                    p.Pro_Nombre      = dr["Pro_Nombre"].ToString();
                    p.Pro_Descripcion = dr["Pro_Descripcion"].ToString();
                    p.Pro_Imagen      = dr["Pro_Imagen"].ToString();
                    entCategoria c = new entCategoria();
                    c.Cat_Id     = Convert.ToInt32(dr["Cat_Id"]);
                    c.Cat_Nombre = dr["Cat_Nombre"].ToString();
                    p.Categoria  = c;
                    entPrecio pr = new entPrecio();
                    pr.Pre_ID       = Convert.ToInt32(dr["Pre_ID"]);
                    pr.Pre_producto = Convert.ToDouble(dr["Pre_producto"]);
                    p.Precio        = pr;
                    Lista.Add(p);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
Esempio n. 14
0
        public entProducto BucsaProd(int idprod)
        {
            SqlCommand    cmd = null;
            SqlDataReader dr  = null;
            entProducto   p   = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spBuscaProducto", cn);
                cmd.Parameters.AddWithValue("@idprod", idprod);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    p                 = new entProducto();
                    p.Pro_ID          = Convert.ToInt32(dr["Pro_ID"]);
                    p.Pro_Nombre      = dr["Pro_Nombre"].ToString();
                    p.Pro_Codigo      = dr["Pro_Codigo"].ToString();
                    p.Pro_Descripcion = dr["Pro_Descripcion"].ToString();
                    p.Pro_Imagen      = dr["Pro_Imagen"].ToString();
                    entCategoria c = new entCategoria();
                    c.Cat_Id    = Convert.ToInt32(dr["Cat_Id"]);
                    p.Categoria = c;
                    entPrecio pr = new entPrecio();
                    pr.Pre_ID       = Convert.ToInt32(dr["Pre_ID"]);
                    pr.Pre_producto = Convert.ToDouble(dr["Pre_producto"]);
                    p.Precio        = pr;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(p);
        }
Esempio n. 15
0
        private void btnEliminarC_Click(object sender, EventArgs e)
        {
            try
            {
                entCategoria c = new entCategoria();
                c.Id_Cat = Convert.ToInt32(txtidC.Text);
                DialogResult r = MessageBox.Show("¿Desea eliminar categoria seleccionada?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (r == DialogResult.Yes)
                {
                    int i = ProductoServices.Instancia.MantenimientoCategoria(c, 3);
                    MessageBox.Show("Registro eliminado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                ControlBotones("C", true, false, false, false, false, true);
                ac.BloquearText(this.tbcCategoria, false);
                CargarGrid();
                LlenarCombos();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 16
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(Convert.ToString(cboCategoria.SelectedValue)))
                {
                    throw new ApplicationException("Deber tener seleccionada una Categoria");
                }
                else if (String.IsNullOrEmpty(Convert.ToString(cboProveedor.SelectedValue)))
                {
                    throw new ApplicationException("Deber tener seleccionado un Proveedor");
                }
                else if (String.IsNullOrEmpty(Convert.ToString(cboUnidMed.SelectedValue)))
                {
                    throw new ApplicationException("Deber tener seleccionada una Unidad de Medida ");
                }


                entProducto p           = new entProducto();
                int         tipoedicion = 1;
                if (txtIdP.Text != "")
                {
                    tipoedicion = 2; p.Id_Prod = Convert.ToInt32(txtIdP.Text);
                }
                p.Nombre_Prod = txtNombre.Text;
                p.Marca_Prod  = txtMarca.Text;
                if (txtPrecioCompra.Text == "")
                {
                    p.PrecioCompra_Prod = 0;
                }
                else
                {
                    p.PrecioCompra_Prod = Convert.ToDouble(txtPrecioCompra.Text);
                }
                if (txtPrecioVenta.Text == "")
                {
                    p.Precio_Prod = 0;
                }
                else
                {
                    p.Precio_Prod = Convert.ToDouble(txtPrecioVenta.Text);
                }
                if (txtStock.Text == "")
                {
                    p.Stock_Prod = 0;
                }
                else
                {
                    p.Stock_Prod = Convert.ToInt32(txtStock.Text);
                }
                if (txtStockPromedio.Text == "")
                {
                    p.StockProm_Prod = 0;
                }
                else
                {
                    p.StockProm_Prod = Convert.ToInt32(txtStockPromedio.Text);
                }
                if (txtStockMin.Text == "")
                {
                    p.StockMin_Prod = 0;
                }
                else
                {
                    p.StockMin_Prod = Convert.ToInt32(txtStockMin.Text);
                }
                entCategoria c = new entCategoria();
                c.Id_Cat    = Convert.ToInt32(cboCategoria.SelectedValue);
                p.categoria = c;
                entUnidadMedida um = new entUnidadMedida();
                um.Id_Umed   = Convert.ToInt32(cboUnidMed.SelectedValue);
                p.unidmedida = um;
                entProveedor pr = new entProveedor();
                pr.Id_Proveedor = Convert.ToInt32(cboProveedor.SelectedValue);
                p.proveedor     = pr;
                entMaterial m = new entMaterial();
                m.Id       = Convert.ToInt32(cboMaterial.SelectedValue);
                p.material = m;

                p.UsuarioCreacion_Prod = idUsuario;
                p.UsuarioUpdate_Prod   = idUsuario;
                int i = ProductoServices.Instancia.MantenimientoProducto(p, tipoedicion);
                MessageBox.Show("¡Registro Correcto!", "Mensaje",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                ControlBotones("P", true, false, false, false, false, true);
                ac.BloquearText(this.tbcProducto, false);
                CargarGridProducto();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }