Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (dtRemito.Rows.Count <= 0)
     {
         MessageBox.Show("Debe selecionar al menos un producto", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         Remito remito = new Remito();
         remito.Fecha = System.DateTime.Today;
         remito.Productos = new List<Producto>();
         for (int i = 0; i < dtRemito.Rows.Count; i++)
         {
             Producto aux = new Producto();
             aux = Devuelve.Producto((Convert.ToInt32(dtRemito.Rows[i]["IdProducto"])));
             aux.Stock = Convert.ToInt32(dtRemito.Rows[i]["Cantidad"]);
             remito.Productos.Add(aux);
             foreach (Proveedor p in Devuelve.Proveedores())
             {
                 if (cbProveedor.Text == p.Nombre)
                     remito.IdProveedor = p.Id;
             }
         }
         remito.IdPedido = Convert.ToInt32(cbPedido.Text);
         try
         {
             Agrega.Remito(remito);
             MessageBox.Show("Remito registrado con exito", "Operacion completa");
         }
         catch (Exception e2)
         {
             MessageBox.Show(e2.Message, "Se produjo el siguiente error");
         }
     }
 }
Пример #2
0
        static public List <Entidades.Notificacion> Notificaciones()
        {
            List <Entidades.Notificacion> l = new List <Entidades.Notificacion>();

            Conexion.OpenConnection();
            string       query   = "Select* from producto Where cantidad <= minimo";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Prepare();
            MySqlDataReader reader = comando.ExecuteReader();

            while (reader.Read())
            {
                Entidades.Producto p = new Entidades.Producto();
                p.Cantidad   = reader.GetDouble("cantidad");
                p.IdProducto = reader.GetString("idProducto");
                p.Nombre     = reader.GetString("nombre");
                p.Minimo     = reader.GetDouble("minimo");

                Entidades.Notificacion n = new Entidades.Notificacion();
                n.Titulo    = "Producto Agotado\n" + "Codigo: " + p.IdProducto + "\nDescripcion: " + p.Nombre;
                n.Contenido = "El producto presenta cantidades\ninferiores a las recomedadas\nen el inventario" + "\nCodigo: " + p.IdProducto + "\nDescripcion: " + p.Nombre + "\nCantidad actual :" + p.Cantidad + "\nCantidad minima recomendada: " + p.Minimo;
                l.Add(n);
            }
            Conexion.CloseConnection();
            return(l);
        }
Пример #3
0
        static public List <Entidades.Notificacion> Notificaciones()
        {
            List <Entidades.Notificacion> l = new List <Entidades.Notificacion>();

            Conexion.OpenConnection();
            string       query   = "Select* from producto Where cantidad <= minimo";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Prepare();
            MySqlDataReader reader = comando.ExecuteReader();

            while (reader.Read())
            {
                Entidades.Producto p = new Entidades.Producto();
                p.Cantidad   = reader.GetDouble("cantidad");
                p.IdProducto = reader.GetString("idProducto");
                p.Nombre     = reader.GetString("nombre");
                p.Minimo     = reader.GetDouble("minimo");

                Entidades.Notificacion n = new Entidades.Notificacion();

                l.Add(n);
            }
            Conexion.CloseConnection();
            return(l);
        }
 public void crearProducto()
 {
     buscarUltimoCodigo();
     Producto prod = new Producto()
     {
         CODProducto = codProducto,
         Nombre = nombreProducto,
         Categoria = categoria,
         Descripcion = descripcion,
         Unidad = unidad,
         StockRiesgo = stockRiesgo,
         precio = precio,
         precioMayorista= precioMayorista,
         tipoMaquina = maquina,
         tiempoProduccion = tiempo,
         foto = foto,
         UnidadTiempo = unidadTiempo,
         cantidadProductos = cantProductos
     };
     try
     {
         ProductoDAO.Insert(prod);
     }
     catch (ApplicationException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Пример #5
0
        static public Entidades.Producto buscarProducto(string id)
        {
            Conexion.OpenConnection();
            Entidades.Producto p       = new Entidades.Producto();
            string             query   = "Select* from producto Where idProducto = @idProducto";
            MySqlCommand       comando = new MySqlCommand(query, Conexion.Connection);

            comando.Parameters.AddWithValue("@idProducto", id);
            comando.Prepare();
            MySqlDataReader reader = comando.ExecuteReader();

            while (reader.Read())
            {
                p.Cantidad          = reader.GetDouble("cantidad");
                p.Costo             = reader.GetDouble("costo");
                p.IdProducto        = reader.GetString("idProducto");
                p.IngredienteActivo = reader.GetString("ingredienteActivo");
                p.Maximo            = reader.GetDouble("maximo");
                p.Minimo            = reader.GetDouble("minimo");
                p.Nombre            = reader.GetString("nombre");
                p.Tipo             = reader.GetString("tipo");
                p.Unidad           = reader.GetString("unidad");
                p.Dias             = reader.GetInt32("dias");
                p.NumRegistro      = reader.GetString("numRegistro");
                p.PeriodoReingreso = reader.GetInt32("periodoReingreso");
                Conexion.CloseConnection();
                return(p);
            }
            //retorna valores nulos en caso de no encontrar coincidencias
            Conexion.CloseConnection();
            return(p);
        }
Пример #6
0
        private void abmProducto_Load(object sender, EventArgs e)
        {
            estado = ABM.Nada;
            categorias = Devuelve.Categorias();
            proveedores = Devuelve.Proveedores();
            auxProduct = new Producto();

            foreach (Proveedor pr in proveedores)
            {
                cbProveedor.Items.Add(pr.Nombre);
            }

            cbCatModifProd.Items.Add("Todo");
            foreach (Categoria c in categorias)
            {
                cbCatModifProd.Items.Add(c.Descripcion);
                cbCategoria.Items.Add(c.Descripcion);
            }

            cbTalleModificPr.Items.Add("Todo");
            foreach (String p in Enum.GetNames(typeof(eTalle)))
            {
                cbTalleModificPr.Items.Add(p);
                cbTalle.Items.Add(p);
            }

            cbTalleModificPr.SelectedIndex = 0;
            cbCatModifProd.SelectedIndex = 0;
        }
        private void btn_agregar_a_factura_Click(object sender, EventArgs e)
        {
            if (dgv_detalle.Rows.Count >= 1)
            {
                  List<DetalleFactura> detalle = new List<DetalleFactura>();

                  for (int c = 0; c < dgv_detalle.RowCount; c++)
                    {
                      DetalleFactura de = new DetalleFactura();
                      Producto p = new Producto();
                      UnidadMedida u = new  UnidadMedida();

                      p.idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value;
                      p.CODProducto = (int)dgv_detalle.Rows[c].Cells["codigo"].Value;
                      p.Nombre = (string )dgv_detalle.Rows[c].Cells["nombreproductodetalle"].Value;
                      u.Nombre = (string)dgv_detalle.Rows[c].Cells["unidadmedida"].Value;
                      p.Unidad = u;
                      p.precio  = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;
                      de.cantidad = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value);
                      de.producto = p;
                      detalle.Add(de);
                    }

                Vista.iniciador.detalle = detalle;
                Close();
                Dispose();
            }
        }
Пример #8
0
        public static Entidades.Producto TraerProducto(int id)
        {
            Entidades.Producto objEntidadProducto = new Entidades.Producto();
            string             strSQL             = "Select * from productos where idProducto=" + id;
            SqlConnection      objConexion        = new SqlConnection(Conexion.strConexion);
            SqlCommand         comTraerUno        = new SqlCommand(strSQL, objConexion);
            SqlDataReader      drProducto;

            objConexion.Open();                       // abro conexion
            drProducto = comTraerUno.ExecuteReader(); // cargo datareader con la ejecucion del command
            if (drProducto.Read())
            {
                objEntidadProducto.IdProducto  = Convert.ToInt32(drProducto["IdProducto"]);
                objEntidadProducto.Descripcion = drProducto["Descripcion"].ToString();
                objEntidadProducto.PrecioPer   = Convert.ToDecimal(drProducto["PrecioSoles"]);
                objEntidadProducto.Peso        = Convert.ToDouble(drProducto["Peso"]);
                objEntidadProducto.Stock       = Convert.ToInt32(drProducto["Stock"]);

                Entidades.TiposEnum tipoProducto = new Entidades.TiposEnum();
                Enum.TryParse(drProducto["TipoProducto"].ToString(), out tipoProducto);
                objEntidadProducto.TipoProducto = tipoProducto;

                Entidades.MarcasEnum marca = new Entidades.MarcasEnum();
                Enum.TryParse(drProducto["Marca"].ToString(), out marca);
                objEntidadProducto.Marca = marca;
            }
            return(objEntidadProducto);
        }
Пример #9
0
 private void ctrlABM1_Alta(object sender)
 {
     auxProduct = new Producto();
     estado = ABM.Alta;
     pnlBuscaProducto.Enabled = false;
     pnlEditaProducto.Enabled = true;
     limpia();
 }
Пример #10
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            try
            {
                string id = this.txtId.Text;
                id = id == "" ? "0" : id;


                switch (this.cmbProducto.SelectedIndex)
                {
                case 0:
                    this.p = new Pincel(int.Parse(id), "Pincel", this.txtMarca.Text,
                                        (int)numericUpDownStock.Value, float.Parse(this.txtPrecio.Text),
                                        (ETipoPincel)Enum.Parse(typeof(ETipoPincel), this.cmbDescripcion.Text.ToString()));

                    this.DialogResult = DialogResult.OK;
                    break;

                case 1:
                    this.p = new Pintura(int.Parse(id), "Pintura", this.txtMarca.Text,
                                         (int)numericUpDownStock.Value, float.Parse(this.txtPrecio.Text),
                                         (ETipoPintura)Enum.Parse(typeof(ETipoPintura), this.cmbDescripcion.Text.ToString()));

                    this.DialogResult = DialogResult.OK;
                    break;

                case 2:
                    this.p = new Bastidor(int.Parse(id), "Bastidor", this.txtMarca.Text,
                                          (int)numericUpDownStock.Value, float.Parse(this.txtPrecio.Text),
                                          (ETamaño)Enum.Parse(typeof(ETamaño), this.cmbDescripcion.Text.ToString()));

                    this.DialogResult = DialogResult.OK;
                    break;

                default:
                    MessageBox.Show("No se seleccionó un producto.");
                    break;
                }
                if (Validar())
                {
                    int    nuevaCodigo = int.Parse(this.txtId.Text);
                    string nuevaMarca  = this.txtMarca.Text;
                    int    nuevoStock  = (int)this.numericUpDownStock.Value;
                    float  nuevoPrecio = float.Parse(this.txtPrecio.Text);

                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #11
0
        public Agregar(Entidades.Producto p)
            : this()
        {
            this.p = p;

            this.txtId.Text = p.Codigo.ToString();
            //producto
            //descripcion
            this.txtMarca.Text            = p.Marca;
            this.numericUpDownStock.Value = p.Stock;
            this.txtPrecio.Text           = p.Precio.ToString();
        }
Пример #12
0
        static public void eliminar(Entidades.Producto p)
        {
            Conexion.OpenConnection();

            string       query   = "DELETE from producto WHERE idProducto = @idProducto";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Parameters.AddWithValue("@idProducto", p.IdProducto);
            comando.Prepare();

            comando.ExecuteNonQuery();

            Conexion.CloseConnection();
        }
Пример #13
0
        public static void actualizarStock(DetallePedido detPedido, SqlConnection con, SqlTransaction trans, Pedido pedido, List<Producto> productosConPocaMP)
        {
            DataTable ProductosIntermedio;
            DataTable MateriaPrima;
            DataTable DetallePlan;
            int idProductoFinal = 0;
            int idProductoIntermedio = 0;
            double cantidad = 0;

            idProductoFinal = detPedido.producto.idProducto;//OBTENEMOS EL ID DEL PRODUCTO FINAL
            cantidad = detPedido.cantidad;//OBTENEMOS LA CANTIDAD DE PRODUCTOS
            if (ProductoDAO.verificarProductoPlanificado(pedido.fechaNecesidad.Date, idProductoFinal, con,trans) == true)//PREGUNTAMOS SI PARA ESE PRODUCTO YA HAY UN DETALLE DEL PLAN PARA ESA FECHA Y ES TRUE
            {
                DetallePlan = DetallePlanProduccionDAO.GetDetallePlanXProducto(idProductoFinal, pedido.fechaNecesidad.Date,con, trans);//OBTENEMOS LOS DATOS DEL DETALLE DEL PLAN

                actualizarDetallePlanYPedidoXPlan(DetallePlan, pedido.idPedido, con, trans, cantidad);

                MateriaPrima = ProductoDAO.GetMateriaPrima(idProductoFinal,trans,con);//CARGAMOS EN LA TABLA LOS DATOS DE LAS MATERIAS PRIMAS
                DataTable MateriaPrimaXIntermedio = new DataTable();
                ProductosIntermedio = ProductoDAO.GetProductoIntermedio(idProductoFinal,con,trans);//CARGAMOS EN LA TABLA LOS DATOS DE LOS PRODUCTOS INTERMEDIO

                obtenerMateriasPrimas(MateriaPrima, MateriaPrimaXIntermedio, ProductosIntermedio, cantidad, idProductoFinal, con, trans, productosConPocaMP);
            }
            else
            {
                if (ProductoDAO.verificarPlanSinProducto(pedido.fechaNecesidad.Date, idProductoFinal, con, trans) == true)//PREGUNTAMOS SI PARA ESE PRODUCTO YA HAY UN DETALLE DEL PLAN PARA ESA FECHA Y ES TRUE
                {
                    Producto prodNuevo = new Producto();
                    prodNuevo.idProducto = idProductoFinal;
                    DetallePlanProduccion detallePlanProduccion = new DetallePlanProduccion()
                    {
                        fechaProduccion = pedido.fechaNecesidad,
                        idPlan = PlanMaestroProduccionDAO.obtenerIdPlan(pedido.fechaNecesidad.Date),
                        cantidadPLan = 0,
                        producto = prodNuevo,
                        cantidadPedido = double.Parse(cantidad.ToString())
                    };

                    cargarNuevoDetallePlanYPedidoXPlan(detallePlanProduccion, con, trans, pedido);

                    MateriaPrima = ProductoDAO.GetMateriaPrima(idProductoFinal,trans,con);//CARGAMOS EN LA TABLA LOS DATOS DE LAS MATERIAS PRIMAS
                    DataTable MateriaPrimaXIntermedio = new DataTable();
                    ProductosIntermedio = ProductoDAO.GetProductoIntermedio(idProductoFinal,con,trans);//CARGAMOS EN LA TABLA LOS DATOS DE LOS PRODUCTOS INTERMEDIO

                    obtenerMateriasPrimas(MateriaPrima, MateriaPrimaXIntermedio, ProductosIntermedio, cantidad, idProductoFinal, con, trans, productosConPocaMP);
                }
            }
        }
Пример #14
0
        public EN.Producto GetProducto(string nombreProducto)
        {
            EN.Producto  p     = new EN.Producto();
            BR.Productos other = db.Productos.Where(x => x.nombreProducto == nombreProducto).FirstOrDefault();

            p.Categoria      = other.Categoria.nombreCat;
            p.idCategoria    = other.idCategoria;
            p.idProducto     = other.idProducto;
            p.idProvedor     = other.Provedores.nombreProv;
            p.nombreProducto = other.nombreProducto;
            p.img            = other.img;
            p.Precio         = other.Precio;
            p.stock          = other.stock;

            return(p);
        }
Пример #15
0
 public iEntidad buscaPorId(int id)
 {
     ManejaCategoria manejaCategoria = new ManejaCategoria();
     DataRow aux = manejador.ConsultarId("Select * from Productos WHERE `IdProducto`='" + id + "';");
     Producto res = new Producto();
     ManejaProveedor x = new ManejaProveedor();
     res.Id = Convert.ToInt32(aux["IdProducto"]);
     res.Descripcion = aux["Descripcion"].ToString();
     res.PrecioCosto = (float)aux["PrecioCosto"];
     res.Stock = Convert.ToInt32(aux["Stock"].ToString());
     res.StockMinimo = Convert.ToInt32(aux["StockMinimo"]);
     res.CoefUtil = (float)aux["CoefUtil"];
     res.IdCategoria = Convert.ToInt32(aux["IdCategoria"].ToString());
     res.Talle = aux["Talle"].ToString();
     res.Estado = Convert.ToBoolean(aux["Estado"]);
     res.Proveedor =(Proveedor)x.buscaPorId(Convert.ToInt32(aux["IdProveedor"]));
     return res;
 }
Пример #16
0
        private void btnVender_Click(object sender, EventArgs e)
        {
            int i = this.dgvGrilla.SelectedRows[0].Index;

            DataRow fila = this.dt.Rows[i];

            int    codigo = int.Parse(fila["id"].ToString());
            string nombre = fila["nombre"].ToString();
            string marca  = fila["marca"].ToString();
            int    stock  = int.Parse(fila["stock"].ToString());
            float  precio = float.Parse(fila["precio"].ToString());

            Entidades.Producto p = new Entidades.Producto(codigo, nombre, marca, stock, precio);

            Vender formVender = new Vender(p);

            formVender.Show();
        }
Пример #17
0
        public static void Agregar(Entidades.Producto producto)
        {
            string        strSP       = "proc_alta_producto";
            SqlConnection objConexion = new SqlConnection(Conexion.strConexion);
            SqlCommand    comAlta     = new SqlCommand(strSP, objConexion);

            comAlta.CommandType = CommandType.StoredProcedure;
            comAlta.Parameters.AddWithValue("@TipoProducto", producto.TipoProducto.ToString());
            comAlta.Parameters.AddWithValue("@Marca", producto.Marca.ToString());
            comAlta.Parameters.AddWithValue("@Descripcion", producto.Descripcion);
            comAlta.Parameters.AddWithValue("@Peso", producto.Peso);
            comAlta.Parameters.AddWithValue("@Stock", producto.Stock);
            comAlta.Parameters.AddWithValue("@PrecioPer", producto.PrecioPer);
            comAlta.Parameters.AddWithValue("@PrecioUs", producto.PrecioUs);
            comAlta.Parameters.AddWithValue("@PrecioArs", producto.PrecioArs);
            objConexion.Open();
            comAlta.ExecuteNonQuery();
            objConexion.Close();
        }
Пример #18
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            int i = this.dgvGrilla.SelectedRows[0].Index;

            DataRow fila = this.dt.Rows[i];

            int    codigo = int.Parse(fila["id"].ToString());
            string nombre = fila["nombre"].ToString();
            string marca  = fila["marca"].ToString();
            int    stock  = int.Parse(fila["stock"].ToString());
            float  precio = float.Parse(fila["precio"].ToString());

            Entidades.Producto p = new Entidades.Producto(codigo, nombre, marca, stock, precio);

            if (MessageBox.Show("¿Seguro que quiere eliminar el producto?",
                                "Eliminar producto", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) != DialogResult.OK)
            {
                fila.Delete();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);
                Entidades.Producto producto = Controlador.drProducto.drObtenerProducto(id);

                Entidades.Categoria cat = Controlador.drCategoria.drObtenerCategoria(producto.Categoria);

                decimal d = producto.Precio;
                producto.Nombre = TextBox1.Text;
                producto.Descripcion = TextBox2.Text;
                producto.DescripcionCorta = TextBox3.Text;
                cat.Nombre = producto.Categoria.ToString();
                cat.Nombre = TextBox4.Text;
                producto.Precio = Convert.ToDecimal(TextBox5.Text);

                drProducto.drEditarProducto(producto);
                Response.Redirect("frmPrincipal.aspx");
            }
        }
Пример #20
0
        static public void modificar(Entidades.Producto p)
        {
            Conexion.OpenConnection();

            string       query   = "UPDATE producto SET nombre = @nombre, ingredienteActivo = @ingredienteActivo, unidad = @unidad, cantidad = @cantidad, minimo = @minimo, maximo = @maximo, costo = @costo, tipo = @tipo, dias = @dias WHERE idProducto = @idProducto";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Parameters.AddWithValue("@idProducto", p.IdProducto);
            comando.Parameters.AddWithValue("@nombre", p.Nombre);
            comando.Parameters.AddWithValue("@ingredienteActivo", p.IngredienteActivo);
            comando.Parameters.AddWithValue("@unidad", p.Unidad);
            comando.Parameters.AddWithValue("@cantidad", p.Cantidad);
            comando.Parameters.AddWithValue("@minimo", p.Minimo);
            comando.Parameters.AddWithValue("@maximo", p.Maximo);
            comando.Parameters.AddWithValue("@costo", p.Costo);
            comando.Parameters.AddWithValue("@tipo", p.Tipo);
            comando.Parameters.AddWithValue("@dias", p.Dias);
            comando.Prepare();
            comando.ExecuteNonQuery();

            Conexion.CloseConnection();
        }
Пример #21
0
        public List <EN.Producto> GetProductos(int id)
        {
            List <EN.Producto> productos = new List <EN.Producto>();

            var query = db.Productos.Where(x => x.idCategoria == id);

            foreach (var item in query)
            {
                EN.Producto p = new EN.Producto();
                p.Categoria      = item.Categoria.nombreCat;
                p.idCategoria    = item.idCategoria;
                p.idProducto     = item.idProducto;
                p.idProvedor     = item.Provedores.nombreProv;
                p.nombreProducto = item.nombreProducto;
                p.img            = item.img;
                p.Precio         = item.Precio;
                p.stock          = item.stock;

                productos.Add(p);
            }

            return(productos);
        }
 private void btn_eliminar_Click(object sender, EventArgs e)
 {
     if (dgv_Productos_X_Proveedores.SelectedRows.Count != 0)
     {
         Persona per = new Persona();
         Producto prod = new Producto();
         per.idPersona = int.Parse(dgv_Productos_X_Proveedores.SelectedRows[0].Cells["nroProv2"].Value.ToString());
         per.RazonSocial = dgv_Productos_X_Proveedores.SelectedRows[0].Cells["proveedor2"].Value.ToString();
         productoXProveedor.proveedor = per;
         prod.idProducto = int.Parse(dgv_Productos_X_Proveedores.SelectedRows[0].Cells["idProducto2"].Value.ToString());
         prod.Nombre =dgv_Productos_X_Proveedores.SelectedRows[0].Cells["producto2"].Value.ToString();
         productoXProveedor.producto = prod;
         productoXProveedor.fechaPrecio = Convert.ToDateTime(dgv_Productos_X_Proveedores.SelectedRows[0].Cells["fechaPrecio"].Value.ToString());
         if (MessageBox.Show("Esta seguro de querer eliminar el producto: " + productoXProveedor.producto.Nombre + " del Proveedor: " + productoXProveedor.proveedor.RazonSocial, "ATENCION", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
         {
             ProductoXProveedorDAO.Delete(productoXProveedor);
             MessageBox.Show("Producto Por Proveedor: " + prod.Nombre + " de " + per.RazonSocial + " ELIMINADO con exito", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.None);
             cargarGrilla();
             limpiar();
             esNuevo = true;
         }
     }
 }
Пример #23
0
        static public void insertar(Entidades.Producto p)
        {
            Conexion.OpenConnection();

            string       query   = "insert into producto (idProducto, nombre, ingredienteActivo, unidad, cantidad, minimo, maximo, costo, tipo, dias) values(@idProducto, @nombre, @ingredienteActivo, @unidad, @cantidad, @minimo, @maximo, @costo, @tipo, @dias)";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Parameters.AddWithValue("@idProducto", p.IdProducto);
            comando.Parameters.AddWithValue("@nombre", p.Nombre);
            comando.Parameters.AddWithValue("@ingredienteActivo", p.IngredienteActivo);
            comando.Parameters.AddWithValue("@unidad", p.Unidad);
            comando.Parameters.AddWithValue("@cantidad", p.Cantidad);
            comando.Parameters.AddWithValue("@minimo", p.Minimo);
            comando.Parameters.AddWithValue("@maximo", p.Maximo);
            comando.Parameters.AddWithValue("@costo", p.Costo);
            comando.Parameters.AddWithValue("@tipo", p.Tipo);
            comando.Parameters.AddWithValue("@dias", p.Dias);

            comando.Prepare();
            comando.ExecuteNonQuery();

            Conexion.CloseConnection();
        }
Пример #24
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            int i = this.dgvGrilla.SelectedRows[0].Index;

            DataRow fila = this.dt.Rows[i];

            int    codigo = int.Parse(fila["id"].ToString());
            string nombre = fila["nombre"].ToString();
            string marca  = fila["marca"].ToString();
            int    stock  = int.Parse(fila["stock"].ToString());
            float  precio = float.Parse(fila["precio"].ToString());

            Entidades.Producto p = new Entidades.Producto(codigo, nombre, marca, stock, precio);

            Agregar formEditar = new Agregar(p);

            if (formEditar.ShowDialog() == DialogResult.OK)
            {
                fila["nombre"] = formEditar.Producto.Nombre;
                fila["marca"]  = formEditar.Producto.Marca;
                fila["stock"]  = formEditar.Producto.Stock;
                fila["precio"] = formEditar.Producto.Precio;
            }
        }
        private void btn_quitar_Click(object sender, EventArgs e)
        {
            if (dgv_detalle.Rows.Count > 0)
            {
                if (dgv_detalle.SelectedRows.Count > 0)
                {

                    Producto producto = new Producto();

                    producto.idProducto = (int)dgv_detalle.Rows[dgv_detalle.CurrentRow.Index].Cells["idProductodetalle"].Value;
                    producto.cantidadProductos = Convert.ToDouble(dgv_detalle.Rows[dgv_detalle.CurrentRow.Index].Cells["cantidad"].Value);

                    dgv_detalle.Rows.Remove(dgv_detalle.CurrentRow);
                    calcularMontoTotal();
                }
                if (dgv_detalle.RowCount > 0)
                    dgv_detalle.ClearSelection();
            }
        }
Пример #26
0
        private void btn_quitar_Click(object sender, EventArgs e)
        {
            if (dgv_detalle.Rows.Count > 0)
            {
                if (dgv_detalle.CurrentRow.Cells["reservado"].Value.ToString() == "SI")
                {
                    Producto producto = new Producto();

                    producto.idProducto = (int)dgv_detalle.Rows[dgv_detalle.CurrentRow.Index].Cells["idProductodetalle"].Value;
                    producto.cantidadProductos = Convert.ToDouble(dgv_detalle.Rows[dgv_detalle.CurrentRow.Index].Cells["cantidad"].Value);

                    productosEliminados.Add(producto);
                }

                dgv_detalle.Rows.Remove(dgv_detalle.CurrentRow);

                calcularMontoTotal();
                cargarGrillaProductos();
            }
        }
Пример #27
0
 public void Modificar(Entidades.Producto producto)
 {
     Datos.Producto.Modificar(producto);
 }
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            if (_estado == estados.nuevo)
            {
                if (dgv_detalle.Rows.Count >= 1)
                {
                    List<DetalleOrdenCompra> detalle = new List<DetalleOrdenCompra>();

                    for (int c = 0; c < dgv_detalle.RowCount; c++)
                    {
                        DetalleOrdenCompra de = new DetalleOrdenCompra();
                        Producto p = new Producto();

                        p.idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value;
                        p.precio = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;

                        de.cantidad = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value);
                        de.precio = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;
                        de.subTotal = (double)dgv_detalle.Rows[c].Cells["sub"].Value;

                        de.producto = p;

                        detalle.Add(de);
                    }
                    Persona prov = new Persona();
                    prov.idPersona = (int)cmb_proveedores.SelectedValue;
                    OrdenDeCompra oc = new OrdenDeCompra()
                      {
                          detalleOrdenCompra = detalle,
                          proveedor = prov,
                          monto = Convert.ToDouble(txt_monto_total.Text),
                          fechaOrden = dtp_creacion_OT.Value.Date

                      };
                    try
                    {
                        OrdenDeCompraDAO.Insert(oc);
                        MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        limpiarCampos();
                        btn_guardar.Enabled = false;

                    }
                    catch (ApplicationException ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }

                }
                else
                {
                    MessageBox.Show("La orden de compra no tiene productos, Por favor carguelos", "ATENCION");
                }

            }
        }
Пример #29
0
 public void Agregar(Entidades.Producto producto)
 {
     Datos.Producto.Agregar(producto);
 }
        private void dgv_Productos_X_Proveedores_Click(object sender, EventArgs e)
        {
            if (dgv_Productos_X_Proveedores.SelectedRows.Count != 0)
            {
                for (int i = 0; i < dgv_productos.Rows.Count; i++)
                {
                    if (dgv_Productos_X_Proveedores.CurrentRow.Cells["idProducto2"].Value.ToString() == dgv_productos.Rows[i].Cells["idProducto"].Value.ToString())
                    {
                        dgv_productos.Rows[i].Selected = true;
                        break;
                    }
                }

                for (int i = 0; i < dgv_proveedores.Rows.Count; i++)
                {
                    if (dgv_Productos_X_Proveedores.CurrentRow.Cells["nroProv2"].Value.ToString() == dgv_proveedores.Rows[i].Cells["idPersona"].Value.ToString())
                    {
                        dgv_proveedores.Rows[i].Selected = true;
                        break;
                    }
                }
                txt_precio_proveedor.Text = dgv_Productos_X_Proveedores.CurrentRow.Cells["precioProducto"].Value.ToString();
                lbl_unidad.Text = "x " + dgv_Productos_X_Proveedores.CurrentRow.Cells["unidad2"].Value.ToString();
                esNuevo = false;
                prodXProvViejo.fechaPrecio = Convert.ToDateTime(dgv_Productos_X_Proveedores.CurrentRow.Cells["fechaPrecio"].Value);
                prodXProvViejo.precioProveedor = Convert.ToDouble(dgv_Productos_X_Proveedores.CurrentRow.Cells["precioProducto"].Value.ToString());
                Producto p = new Producto();
                p.idProducto = Convert.ToInt32(dgv_Productos_X_Proveedores.CurrentRow.Cells["idProducto2"].Value.ToString());
                prodXProvViejo.producto = p;
                Persona per = new Persona();
                per.idPersona = Convert.ToInt32(dgv_Productos_X_Proveedores.CurrentRow.Cells["nroProv2"].Value.ToString());
                prodXProvViejo.proveedor = per;
            }
        }
Пример #31
0
 public DetalleVenta(Venta v,Producto p)
 {
     venta = v;
     producto = p;
 }
        private void dgv_estructuraOT_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if ((int)dgv_estructuraOT.CurrentRow.Cells["idCategoria"].Value == 2 && (int)dgv_estructuraOT.CurrentRow.Cells["Estado"].Value == 0)
            {
                GestionOTIntermedio gestion = new GestionOTIntermedio();
                Producto pro = new Producto();
                pro.Nombre = dgv_estructuraOT.CurrentRow.Cells["Producto"].Value.ToString();
                pro.idProducto = (int)dgv_estructuraOT.CurrentRow.Cells["idPro"].Value;
                pro.cantidadProductos = (double)dgv_estructuraOT.CurrentRow.Cells["cantidad"].Value;
                pro.Unidad = new UnidadMedida() { Nombre = dgv_estructuraOT.CurrentRow.Cells["unidad"].Value.ToString() };
                pro.tiempoProduccion = (double)dgv_estructuraOT.CurrentRow.Cells["duracion"].Value;
                DataGridViewRow fila = dgv_estructuraOT.CurrentRow;

                gestion._infoPlan = infoPlan;
                gestion._ordenesHijas = ordenhija;
                gestion._prodInt = pro;
                gestion.ShowDialog();

                if (gestion._estado==estados.guardado)
                {
                    fila.DefaultCellStyle.BackColor = Color.LightGreen;
                    fila.Cells["Estado"].Value = 1;
                }

                if (iniciador.otHija!=null)
                {
                    ordenhija.Add(iniciador.otHija);
                }
                verificarEstados();
            }
        }
        private void dgv_OTproductosPadres_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_OTproductosPadres.CurrentCell is DataGridViewButtonCell)
                {
                    if (dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].DefaultCellStyle.BackColor != Color.LightGreen)
                    {
                        if (tieneHijosFinalizados() == true)
                        {
                            try
                            {
                                double cant = (double)dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["cantidad"].Value;
                                if (dgv_OTproductosPadres.CurrentRow.Cells["cantiReal"].Value != String.Empty)
                                {
                                    double cantidadPlan = 0;
                                    double cantidadPedido = DetallePlanProduccionDAO.GetCantidadPedidosParaOT((int)dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["idProducto"].Value, Convert.ToDateTime(dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["fechaCreacion"].Value));
                                    cantidadPlan = cant - cantidadPedido;
                                    DateTime fecha = Convert.ToDateTime(dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["fechaCreacion"].Value);

                                    OrdenDeTrabajo orden = new OrdenDeTrabajo();
                                    orden.idOrdenTrabajo = int.Parse(dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["idOrden"].Value.ToString());
                                    Producto prod = new Producto();
                                    prod.idProducto = int.Parse(dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["idProducto"].Value.ToString());
                                    prod.Nombre = dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["nomProducto"].Value.ToString();
                                    UnidadMedida unidad = new UnidadMedida();
                                    unidad.Nombre = dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["unidad"].Value.ToString();
                                    prod.Unidad = unidad;
                                    orden.fechaCreacion = fecha;
                                    orden.producto = prod;
                                    orden.cantidad = cant;
                                    ActualizarStock act = new ActualizarStock(orden, cantidadPedido,cantidadPlan);
                                    act.ShowDialog();
                                    if (orden.estado != null)
                                    {
                                        if (orden.estado.Nombre == "LISTO")
                                        {
                                            MessageBox.Show("Finalizado con éxito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                            dgv_OTproductosPadres.CurrentRow.DefaultCellStyle.BackColor = Color.LightGreen;
                                            dgv_OTproductosPadres.CurrentRow.Cells["cantiReal"].Value = orden.cantidadReal;
                                            cargarGrilla();
                                        }
                                    }
                                }
                            }
                            catch (FormatException ex)
                            {

                                MessageBox.Show("Ingrese solo números", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                            }
                            catch (ApplicationException ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            }

                        }
                        else
                        {
                            MessageBox.Show("Primero debe Finalizar las Ordenes de Trabajo de los Productos Intermedios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                        }

                    }

            }
        }
        public static List<Producto> GetAllSinEstructura()
        {
            Acceso ac = new Acceso();

            List<Producto> productos = new List<Producto>();

            string sql = "SELECT codProducto, nombre, descripcion, precio, categoria, unidad, stockDeRiesgo, idCategoria, descCat, idUnidad, descUni, idProducto, idTipoMaquinaria, tipoMaquinaria from CONSULTA_PRODUCTOS P where (idCategoria = 1 OR idCategoria = 2) AND NOT EXISTS (Select 1 From CONSULTA_ESTRUCTURA_PRODUCTOS C where C.idProducto = P.idProducto)";
            SqlCommand cmd = new SqlCommand();
            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                Producto p;
                Categoria c;
                UnidadMedida u;
                TipoMaquinaria TM;

                while (dr.Read())
                {
                    u = new UnidadMedida();

                    u.IDUnidad = Convert.ToInt32(dr["idUnidad"]);
                    u.Nombre = dr["unidad"].ToString();
                    u.Descripcion = dr["descUni"].ToString();

                    c = new Categoria();
                    c.IDCategoria = Convert.ToInt32(dr["idCategoria"]);
                    c.Nombre = dr["categoria"].ToString();
                    c.Descripcion = dr["descCat"].ToString();

                    TM = new TipoMaquinaria();

                    TM.idTipoMaquinaria = Convert.ToInt32(dr["idTipoMaquinaria"].ToString());
                    TM.Nombre = dr["tipoMaquinaria"].ToString();

                    p = new Producto();

                    p.CODProducto = Convert.ToInt32(dr["codProducto"]);
                    p.Nombre = dr["nombre"].ToString();
                    p.Categoria = c;
                    p.Descripcion = dr["descripcion"].ToString();
                    p.Unidad = u;
                    p.StockRiesgo = Convert.ToInt32(dr["stockDeRiesgo"]);
                    p.precio = Convert.ToDouble(dr["precio"]);
                    p.idProducto = Convert.ToInt32(dr["idProducto"]);
                    p.tipoMaquina = TM;

                    //p.foto = (Image)(dr["foto"]);

                    productos.Add(p);

                }

            }

            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }

            return productos;
        }
        private void dgv_OTproductosHijos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_OTproductosHijos.CurrentCell is DataGridViewButtonCell)
            {
                if (dgv_OTproductosHijos.Rows[dgv_OTproductosHijos.CurrentRow.Index].DefaultCellStyle.BackColor != Color.LightGreen)
                {
                    try
                    {
                        double canti = (double)dgv_OTproductosHijos.Rows[dgv_OTproductosHijos.CurrentRow.Index].Cells["cant"].Value;
                        OrdenDeTrabajo orden = new OrdenDeTrabajo();
                        orden.idOrdenTrabajo = (int)dgv_OTproductosHijos.Rows[dgv_OTproductosHijos.CurrentRow.Index].Cells["idOT"].Value;
                        Producto prod = new Producto();
                        prod.idProducto =(int)dgv_OTproductosHijos.Rows[dgv_OTproductosHijos.CurrentRow.Index].Cells["idProd"].Value;
                        prod.Nombre = dgv_OTproductosHijos.Rows[dgv_OTproductosHijos.CurrentRow.Index].Cells["poductoDetalle"].Value.ToString();
                        UnidadMedida unidad = new UnidadMedida();
                        unidad.Nombre = dgv_OTproductosHijos.Rows[dgv_OTproductosHijos.CurrentRow.Index].Cells["unidadMedida"].Value.ToString();
                        prod.Unidad = unidad;
                        orden.producto = prod;
                        orden.cantidad = canti;
                        ActualizarStock act = new ActualizarStock(orden);
                        act.ShowDialog();
                        if (orden.estado != null)
                        {
                            if (orden.estado.Nombre == "LISTO")
                            {
                                MessageBox.Show("Finalizado con éxito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                dgv_OTproductosHijos.CurrentRow.DefaultCellStyle.BackColor = Color.LightGreen;
                                dgv_OTproductosHijos.CurrentRow.Cells["cantReal"].Value = orden.cantidadReal;
                            }
                        }
                    }
                    catch (ApplicationException ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                    catch (FormatException ex)
                    {

                        MessageBox.Show("Ingrese solo números", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                    }

                }

             }
            dgv_OTproductosHijos.ClearSelection();
        }
        public static List<DetalleOrdenCompra> GetDetalleXOrdenDeCompra(int oc)
        {
            Acceso ac = new Acceso();

            List<DetalleOrdenCompra> detalles = new List<DetalleOrdenCompra>();

            string sql = "SELECT * from CONSULTAR_DETALLE_ORDEN_COMPRA where idOrdenCompra = @oc";
            SqlCommand cmd = new SqlCommand();
            cmd.Parameters.AddWithValue("@oc", oc);
            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                DetalleOrdenCompra d;
                Producto p;
                UnidadMedida u;
                OrdenDeCompra o;

                while (dr.Read())
                {
                    o = new OrdenDeCompra();
                    o.idOrdenCompra = Convert.ToInt32(dr["idOrdenCompra"]);

                    u = new UnidadMedida();

                    u.IDUnidad = Convert.ToInt32(dr["idUnidadMedida"]);
                    u.Nombre = dr["Unidad"].ToString();

                    p = new Producto();

                    p.Nombre = dr["nombre"].ToString();
                    p.Unidad = u;
                    p.idProducto = Convert.ToInt16(dr["idProducto"]);
                    p.StockDisponible = Convert.ToDouble(dr["stockDisponible"]);
                    p.StockRiesgo = Convert.ToDouble(dr["stockdeRiesgo"]);
                    p.StockActual = Convert.ToDouble(dr["stockactual"]);
                    p.StockReservado = Convert.ToDouble(dr["stockreservado"]);

                    d = new DetalleOrdenCompra();

                    d.cantidad = Convert.ToDouble(dr["cantidad"]);
                    d.producto = p;
                    d.precio = Convert.ToDouble(dr["precio"]);
                    d.subTotal = Convert.ToDouble(dr["subTotal"]);
                    d.cantidadRealIngresada = Convert.ToDouble(dr["cantidadRealIngresada"]);
                    d.ordenCompra = o;

                    detalles.Add(d);

                }

            }
            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }

            return detalles;
        }
Пример #37
0
        private void dgv_detalle_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_detalle.CurrentCell is DataGridViewButtonCell )
            {
                float cantidadNecesaria = 0;
                int idProducto = 0;
                float cantidadDisponible = 0;

                cantidadNecesaria = float.Parse(dgv_detalle.CurrentRow.Cells[3].Value.ToString());
                idProducto = (int)dgv_detalle.CurrentRow.Cells[6].Value;
                cantidadDisponible = ProductoDAO.getStockDisponible(idProducto);

                if (dgv_detalle.CurrentRow.Cells["reservado"].Value.ToString() == "NO")
                {
                    if (ProductoDAO.verificarProductoPlanificado(dtp_fecha_necesidad.Value.Date, idProducto) == false)
                    {
                        if (cantidadNecesaria <= cantidadDisponible)
                        {
                            dgv_detalle.CurrentRow.Cells["reservado"].Value = "SI";
                            dgv_detalle.CurrentRow.Cells["idestado"].Value = 25;

                            ///////// MODIFICO LA GRILLA CON LA DIFERENCIA DEL STOCK DISPONIBLE - CANTIDAD RESERVADA
                            for (int a = 0; a < dgv_productos_finales.RowCount; a++)
                            {
                                if (dgv_productos_finales.Rows[a].Cells["idProducto"].Value.ToString() == dgv_detalle.CurrentRow.Cells["idProductoDetalle"].Value.ToString())
                                {
                                    dgv_productos_finales.Rows[a].Cells["stockDisp"].Value = float.Parse(dgv_productos_finales.Rows[a].Cells["stockDisp"].Value.ToString()) - float.Parse(dgv_detalle.CurrentRow.Cells["cantidad"].Value.ToString());
                                }
                            }
                            /////////////////////////////////////////////////////////////////////////////

                            int resul = -1;
                            for (int c = 1; c < dgv_detalle.RowCount - 1; c++)
                            {
                                if (productosEliminados.Count>=1 && productosEliminados.ElementAt(c).idProducto.Equals(dgv_detalle.CurrentRow.Cells["idProductodetalle"].Value))
                                {
                                    resul = c;
                                    return;
                                }
                            }
                            if (resul != -1)
                            {
                                productosEliminados.RemoveAt(resul);
                            }
                        }
                        else
                        {
                            MessageBox.Show("No se puede reservar esa cantidad", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }

                    }
                    else
                    {
                        MessageBox.Show("No se puede reservar, ya se planifico su producción", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }

                else
                {
                    ///////// MODIFICO LA GRILLA CON LA SUMA DEL STOCK DISPONIBLE + CANTIDAD QUE DEJO DE RESERVAR

                    if (dgv_detalle.CurrentRow.Cells["reservado"].Value.ToString() == "SI")
                    {
                        for (int a = 0; a < dgv_productos_finales.RowCount; a++)
                        {
                            if (dgv_productos_finales.Rows[a].Cells["idProducto"].Value.ToString() == dgv_detalle.CurrentRow.Cells["idProductoDetalle"].Value.ToString())
                            {
                                dgv_productos_finales.Rows[a].Cells["stockDisp"].Value = float.Parse(dgv_productos_finales.Rows[a].Cells["stockDisp"].Value.ToString()) + float.Parse(dgv_detalle.CurrentRow.Cells["cantidad"].Value.ToString());
                            }
                        }
                    }
                    /////////////////////////////////////////////////////////////////////////////
                    dgv_detalle.CurrentRow.Cells["reservado"].Value = "NO";
                    dgv_detalle.CurrentRow.Cells["idestado"].Value = 26;

                    Producto producto = new Producto();
                    producto.idProducto = (int)dgv_detalle.Rows[dgv_detalle.CurrentRow.Index].Cells["idProductodetalle"].Value;
                    producto.cantidadProductos = Convert.ToDouble(dgv_detalle.Rows[dgv_detalle.CurrentRow.Index].Cells["cantidad"].Value);

                    int resul = -1;
                    for (int c = 1; c < dgv_detalle.RowCount - 1; c++)
                    {
                        if (productosEliminados.Count >= 1 && productosEliminados.ElementAt(c).idProducto.Equals(dgv_detalle.CurrentRow.Cells["idProductodetalle"].Value))
                        {
                            resul = c;
                            return;
                        }
                    }
                    if (resul != -1)
                    {
                        productosEliminados.Add(producto);
                    }

                }
            }
        }
Пример #38
0
 public Gaseosa(Producto prod, float litros)
     : this((int)prod, prod.Precio, prod.Marca, litros)
 {
     // Reutilización de código.
 }
Пример #39
0
 public lineaItem(Producto _ITEM, int _Cantidad, decimal _Precio)
 {
     item     = _ITEM;
     precio   = _Precio;
     cantidad = _Cantidad;
 }
Пример #40
0
 public DetalleVenta()
 {
     venta = new Venta();
     producto = new Producto();
 }
Пример #41
0
 public Gaseosa(Producto prod, float litros)
     : this((int)prod, prod.Precio, prod.Marca, litros)
 {
 }
        private void cmb_productos_SelectionChangeCommitted(object sender, EventArgs e)
        {
            if ((int)cmb_productos.SelectedValue!=0)
            {
                int idProducto = Convert.ToInt32(cmb_productos.SelectedValue);
                Producto p = new Producto();
                infoPlan = new DetallePlanProduccion();
                infoPlan = DetallePlanProduccionDAO.GetDetallePlanXProductoParaOT((int)cmb_productos.SelectedValue, dtp_creacion_OT.Value.Date);

                p = ProductoDAO.GetByIdProd(idProducto, dtp_creacion_OT.Value.Date);
                lbl_cant.Text = p.cantidadAProd.ToString();
                lbl_unidad.Text = p.Unidad.Nombre;
                lbl_tiempo.Text = ((Convert.ToDouble(lbl_cant.Text) * p.tiempoProduccion) / p.cantidadProductos).ToString();
                List<DetalleProducto> dp = new List<DetalleProducto>();

                try
                {
                    dp = EstructuraProductoDAO.GetAll(idProducto);
                }
                catch (ApplicationException ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }

                cargarGrillaDetalleProducto(dp);
            }
        }
Пример #43
0
        public List<iEntidad> Todo()
        {
            DataTable aux = manejador.Consultar("Select * from Productos;");
            List<iEntidad> aux2 = new List<iEntidad>();
            ManejaCategoria manejaCategoria = new ManejaCategoria();
            ManejaProveedor x = new ManejaProveedor();
            foreach (DataRow i in aux.Rows)
            {
                Producto res = new Producto();
                res.Id = Convert.ToInt32(i["IdProducto"]);
                res.Descripcion = i["Descripcion"].ToString();
                res.PrecioCosto = (float)i["PrecioCosto"];
                res.Stock = Convert.ToInt32(i["Stock"].ToString());
                res.StockMinimo = Convert.ToInt32(i["StockMinimo"]);
                res.CoefUtil = (float)i["CoefUtil"];
                res.IdCategoria =Convert.ToInt32(i["IdCategoria"].ToString());
                res.Talle = i["Talle"].ToString();
                res.Estado = Convert.ToBoolean(i["Estado"]);

                res.Proveedor = (Proveedor)x.buscaPorId(Convert.ToInt32(i["IdProveedor"]));
                aux2.Add(res);
            }
            return aux2;
        }
Пример #44
0
        public static List<DetalleFactura> GetDetalleFactura(int idFactura)
        {
            Acceso ac = new Acceso();

            List<DetalleFactura> detalles = new List<DetalleFactura>();

            string sql = "SELECT * from CONSULTAR_DETALLE_FACTURA where idFactura = @id";
            SqlCommand cmd = new SqlCommand();
            cmd.Parameters.AddWithValue("@id", idFactura);
            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                DetalleFactura detalle;
                Producto producto;
                Producto productoPedido;
                UnidadMedida unidad;
                UnidadMedida unidadPedido;

                while (dr.Read())
                {
                    unidad = new UnidadMedida();
                    unidadPedido = new UnidadMedida();

                    unidad.Nombre = dr["unidadProducto"].ToString();
                    unidadPedido.Nombre = dr["unidadProdPedido"].ToString();

                    producto = new Producto();
                    productoPedido = new Producto();

                    producto.Unidad = unidad;
                    producto.Nombre = dr["nombreProd"].ToString();
                    producto.idProducto = Convert.ToInt32(dr["idProducto"]);

                    productoPedido.Unidad = unidadPedido;
                    productoPedido.Nombre = dr["nombreProdPedido"].ToString();
                    productoPedido.idProducto = Convert.ToInt32(dr["idProductoPedido"]);

                    detalle = new DetalleFactura();

                    detalle.cantidad = Convert.ToDouble(dr["cantidad"]);
                    detalle.producto = producto;
                    detalle.detPedido = new DetallePedido() { producto = productoPedido };
                    detalle.subTotal = Convert.ToDouble(dr["subtotal"]);
                    detalle.iva = Convert.ToDouble(dr["iva"]);
                    detalle.idDetalle = Convert.ToInt32(dr["idDetalleFactura"]);

                    detalles.Add(detalle);

                }

            }
            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }

            return detalles;
        }
Пример #45
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            int idPedido=0;

            if (dtp_fecha_necesidad.Value.Date >= DateTime.Now.Date)
            {
                if (dgv_detalle.Rows.Count >= 1)
                {
                    List<DetallePedido> detalle = new List<DetallePedido>();

                    for (int c = 0; c < dgv_detalle.RowCount; c++)
                    {
                        DetallePedido de = new DetallePedido();
                        Producto p = new Producto();
                        Estado est = new Estado();

                        p.idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value;
                        p.precio = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;

                        de.cantidad = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value);
                        de.precio = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;
                        if (dgv_detalle.Rows[c].Cells["reservado"].Value.ToString() == "NO")
                        {
                            de.reservado = false;
                            de.cantidadReservada = 0;
                            est.idEstado = 26;
                            if (estadoFormulario == estados.modificar && dgv_detalle.Rows[c].Cells["idestado"].Value!=null)
                            {
                                est.idEstado = (int)dgv_detalle.Rows[c].Cells["idestado"].Value;
                            }
                            de.Estado = est;

                        }
                        else {
                            de.reservado = true;
                            de.cantidadReservada = de.cantidad;
                            est.idEstado = 25;
                            de.Estado = est ;
                        }

                        de.producto = p;

                        detalle.Add(de);
                    }
                    if (estadoFormulario == estados.nuevo)
                    {
                        gestor.clienteSeleccionado(resultado);
                        gestor.tomarProductosSeleccionados(detalle);
                        gestor.fechaDeNecesidadTomada(dtp_fecha_necesidad.Value.Date);
                        gestor.dirEntregaTomada(txt_dir_entrega.Text);

                        if(!estanTodosReservados())
                        {
                            gestor.estado(1);
                        }
                        else{
                            gestor.estado(5);
                        }

                        try
                        {
                            List<Producto> productosConPocaMP = new List<Producto>();
                            idPedido = gestor.confirmacionTomada(productosConPocaMP);
                            ////////////// MOSTRAR LOS PRODUCTOS CON BAJO STOCK
                            if (productosConPocaMP.Count > 0)
                            {
                                string mensaje = "";
                                List<Producto> prodConPocoStock = new List<Producto>();
                                Boolean MPRepetida = false;
                                foreach (Producto Prod in productosConPocaMP)
                                {
                                    foreach (Producto P in prodConPocoStock)
                                    {
                                        if (P.idProducto == Prod.idProducto)
                                        {
                                            MPRepetida = true;
                                            break;
                                        }
                                    }
                                    if (MPRepetida == false)
                                    {
                                        mensaje += Environment.NewLine + Prod.Nombre.ToString();
                                        prodConPocoStock.Add(Prod);
                                    }

                                }
                                MessageBox.Show("Los siguientes productos estan con bajo stock: " + mensaje, "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            /////////////////////////////////////////////////////////////
                            MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                            limpiarCampos();
                        }
                        catch (ApplicationException ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        }
                    }
                    else
                    {
                        if (estadoFormulario == estados.modificar)
                        {
                            //foreach (Producto  pro in productosEliminados )
                            //{

                            //    ProductoDAO.UpdateStockReservadoYDisponibleEliminado(pro.idProducto,pro.cantidadProductos );

                            //}

                            gestor.tomarProductosSeleccionados(detalle);
                            gestor.fechaDeNecesidadTomada(dtp_fecha_necesidad.Value.Date);
                            gestor.dirEntregaTomada(txt_dir_entrega.Text);

                            if (!estanTodosReservados())
                            {
                                gestor.estado(1);
                            }
                            else
                            {
                                gestor.estado(5);
                            }

                            try
                            {

                                List<Producto> productosConPocaMP = new List<Producto>();
                                gestor.modificacionConfirmada(tablaAModificar, productosConPocaMP);
                                ////////////// MOSTRAR LOS PRODUCTOS CON BAJO STOCK
                                if (productosConPocaMP.Count > 0)
                                {
                                    string mensaje = "";
                                    List<Producto> prodConPocoStock = new List<Producto>();
                                    Boolean MPRepetida = false;
                                    foreach (Producto Prod in productosConPocaMP)
                                    {
                                        foreach (Producto P in prodConPocoStock)
                                        {
                                            if (P.idProducto == Prod.idProducto)
                                            {
                                                MPRepetida = true;
                                                break;
                                            }
                                        }
                                        if (MPRepetida == false)
                                        {
                                            mensaje += Environment.NewLine + Prod.Nombre.ToString();
                                            prodConPocoStock.Add(Prod);
                                        }

                                    }
                                    MessageBox.Show("Los siguientes productos estan con bajo stock: " + mensaje, "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                /////////////////////////////////////////////////////////////
                                MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                limpiarCampos();
                            }
                            catch (ApplicationException ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            }

                        }
                    }
                    cargarGrillaProductos();

                }
                else
                {
                    MessageBox.Show("Agrege productos al pedido", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
            }
            else
            {
                MessageBox.Show("La fecha de necesidad no puede ser anterior a la actual", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

            }
        }
Пример #46
0
 public string MostrarGaseosa()
 {
     return(Producto.MostrarProducto(this) + " " + this._litros);
 }
        public static List<DetallePlanProduccion> GetDetalleXPlan(int plan)
        {
            Acceso ac = new Acceso();

             List<DetallePlanProduccion> detalles = new List<DetallePlanProduccion>();

             string sql = "SELECT * from CONSULTA_DETALLE_PLAN_PRODUCCION where idPlan = @plan";
             SqlCommand cmd = new SqlCommand();
             cmd.Parameters.AddWithValue("@plan", plan );
             SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

             try
             {
                 conexion.Open();

                 cmd.Connection = conexion;
                 cmd.CommandText = sql;
                 cmd.CommandType = CommandType.Text;

                 SqlDataReader dr = cmd.ExecuteReader();

                 DetallePlanProduccion  d;
                 Producto p;
                 UnidadMedida u;
                 Categoria c;

                 while (dr.Read())
                 {

                     u = new UnidadMedida();

                     u.IDUnidad = Convert.ToInt32(dr["idUnidadMedida"]);
                     u.Nombre = dr["unidad"].ToString();

                     p = new Producto();

                     p.CODProducto = Convert.ToInt32(dr["codProducto"]);
                     p.Nombre = dr["nombre"].ToString();
                     p.Unidad = u;
                     p.idProducto = Convert.ToInt16(dr["idProducto"]);

                     d = new DetallePlanProduccion ();

                     d.cantidadPLan = Convert.ToInt32(dr["cantidadPLan"]);
                     d.cantidadPedido = Convert.ToInt32(dr["cantidadPedido"]);
                     d.fechaProduccion = Convert.ToDateTime(dr["fechaProduccion"]);
                     d.producto = p;

                     detalles.Add(d);

                 }

             }
             catch (InvalidOperationException ex)
             {
                 throw new ApplicationException(ex.Message);
             }
             catch (SqlException ex)
             {
                 throw new ApplicationException("Error en BD: " + ex.Message);
             }
             finally
             {
                 conexion.Close();
             }

             return detalles;
        }
Пример #48
0
 private virtual string  MostrarProducto(Producto p)
 {
     return("");
 }
Пример #49
0
        private void dgv_productos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Gestion_de_Producto gestProd = new Gestion_de_Producto();
            gestProd._estado = estados.modificar;

            Categoria cat = new Categoria()
            {
                IDCategoria = (int)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["codCategoria"].Value,
                Nombre = (string)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["cat"].Value,
            };
            UnidadMedida uni = new UnidadMedida()
            {
                IDUnidad = (int)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["idUnidad"].Value,
                Nombre = (string)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["Unidad"].Value,
            };
            TipoMaquinaria tm = new TipoMaquinaria ()
            {
                idTipoMaquinaria = (int)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["idTipoMaquinaria"].Value,
            };
            UnidadMedida  ut = new UnidadMedida ()
            {
                IDUnidad  = (int)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["idUnidadTiempo"].Value,
            };
            Producto prodModificar = new Producto()
            {
                CODProducto = (int)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["codigo"].Value,
                Nombre = (string)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["Nombre"].Value,
                Descripcion = (string)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["Desc"].Value,
                precio=(double)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["precio"].Value,
                StockRiesgo = (double )dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["stock_riesg"].Value,
                Categoria =cat,
                Unidad=uni,
                UnidadTiempo = ut,
                foto  = (Byte[])dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["foto"].Value,
                precioMayorista = (double)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["precioMayorista"].Value,
                tiempoProduccion = (double)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["tiempo"].Value,
                tipoMaquina = tm,
                cantidadProductos = (double)dgv_productos.Rows[dgv_productos.CurrentRow.Index].Cells["cantidadProductos"].Value,
            };

            gestProd._prodModificar=prodModificar;
            gestProd.ShowDialog();
            cargarGrilla();
        }
Пример #50
0
 public static Producto Producto(int id)
 {
     ManejaProducto manejaProducto = new ManejaProducto();
     Producto res = new Producto();
     res = (Producto)manejaProducto.buscaPorId(id);
     return res;
 }
Пример #51
0
 public static bool AgregarBD(this Producto pr)
 {
     return(true);
 }
Пример #52
0
 /// <summary>
 /// Constructor parametrizado
 /// </summary>
 /// <param name="producto"></param>
 /// <param name="cantidad"></param>
 public Carrito(Producto producto, int cantidad)
 {
     this.producto = producto;
     this.cantidad = cantidad;
 }
Пример #53
0
        private void btnAgregarCarrito_Click(object sender, EventArgs e)
        {
            if (dgvProductos.RowCount < 1 || dgvProductos.CurrentRow == null)
                MessageBox.Show("Debe selecionar un producto", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
            {
                //consigo el producto
                pr = Devuelve.Producto((int)dgvProductos.CurrentRow.Cells["IdProducto"].Value);
                //me fijo que alla suficiente stock
                if (pr.Stock >= nudCantidad.Value)
                {

                    bool existe = false;
                    int pos = 0;
                    foreach (Producto da in lista)
                    {
                        if (da.Id == pr.Id)
                        {
                            existe = true;
                            break;
                        }
                        pos++;
                    }

                    if (!existe)
                    {
                        int n = dgvVentas.Rows.Add();
                        dgvVentas.Rows[n].Cells["Descripcion"].Value = pr.Descripcion;
                        dgvVentas.Rows[n].Cells["Cant"].Value = nudCantidad.Value;
                        dgvVentas.Rows[n].Cells["Precio"].Value = pr.PrecioCosto * (1 + pr.CoefUtil);
                        dgvVentas.Rows[n].Cells["all"].Value = (pr.PrecioCosto * (1 + pr.CoefUtil)) * (int)nudCantidad.Value;

                        total += (pr.PrecioCosto * (1 + pr.CoefUtil)) * (int)nudCantidad.Value;

                        tbTotal.Text = total.ToString("#00.00#");

                        if (pr.StockMinimo > pr.Stock)
                            MessageBox.Show("Stock bajo de " + pr.Descripcion + "\ncantidad restante " + pr.Stock, "ALERTA", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        pr.Stock = (int)nudCantidad.Value;

                        lista.Add(pr);

                    }
                    else
                    {
                        lista[pos].Stock += Convert.ToInt32(nudCantidad.Value);
                        dgvVentas.Rows[pos].Cells["Cant"].Value = lista[pos].Stock;
                        dgvVentas.Rows[pos].Cells["all"].Value = (pr.PrecioCosto * (1 + pr.CoefUtil)) * lista[pos].Stock;
                        total += (pr.PrecioCosto * (1 + pr.CoefUtil)) * Convert.ToInt32(nudCantidad.Value);
                        tbTotal.Text = total.ToString("#00.00#");
                    }
                }

                else
                {
                    MessageBox.Show("Stock insuficiente \nPorfavor actualize el stock", "ALERTA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                if (rbTipoA.Checked)
                {
                    tbSubTotal.Text = (total - (total * (Convert.ToInt32(tbIva.Text)) / 100)).ToString("#00.00#");
                }
            }
        }
        private List<DetallePlanProduccion> crearDetalle()
        {
            List<DetallePlanProduccion> detalle = new List<DetallePlanProduccion>();

            foreach (TabPage tab in tab_dias.TabPages)
            {
                foreach (Control ctrl in tab.Controls)
                {

                    if (ctrl is DataGridView)
                    {

                        for (int c = 0; c < ((DataGridView)ctrl).RowCount; c++)
                        {
                            DetallePlanProduccion de = new DetallePlanProduccion();
                            Producto p = new Producto();
                            p.idProducto = (int)((DataGridView)ctrl).Rows[c].Cells[0].Value;
                            de.cantidadPLan = Convert.ToInt32(((DataGridView)ctrl).Rows[c].Cells[3].Value);
                            de.cantidadPedido = Convert.ToInt32(((DataGridView)ctrl).Rows[c].Cells[4].Value);
                            de.producto = p;

                            foreach (Control con in ctrl.Parent.Controls)
                            {
                                if (con is DateTimePicker)
                                {
                                    de.fechaProduccion = ((DateTimePicker)con).Value.Date;
                                }
                            }
                            detalle.Add(de);
                        }

                    }

                }
            }

            return detalle;
        }
        public static DetallePlanProduccion GetDetallePlanXProductoParaOT(int idProd, DateTime fecha)
        {
            Acceso ac = new Acceso();

             DetallePlanProduccion d;

             string sql = "SELECT * from CONSULTA_DETALLE_PLAN_PRODUCCION where idproducto = @idProd and fechaproduccion = @fecha";
             SqlCommand cmd = new SqlCommand();
             cmd.Parameters.AddWithValue("@idProd", idProd);
             cmd.Parameters.AddWithValue("@fecha", fecha);
             SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

             try
             {
                 conexion.Open();

                 cmd.Connection = conexion;
                 cmd.CommandText = sql;
                 cmd.CommandType = CommandType.Text;

                 SqlDataReader dr = cmd.ExecuteReader();

                 Producto p;

                     dr.Read();

                     p = new Producto();
                     p.Nombre = dr["nombre"].ToString();
                     p.idProducto = Convert.ToInt16(dr["idProducto"]);

                     d = new DetallePlanProduccion();
                     d.idPlan = Convert.ToInt32(dr["idPlan"]);
                     d.cantidadPLan = Convert.ToInt32(dr["cantidadPLan"]);
                     d.cantidadPedido = Convert.ToInt32(dr["cantidadPedido"]);
                     d.fechaProduccion = Convert.ToDateTime(dr["fechaProduccion"]);
                     d.producto = p;

             }
             catch (InvalidOperationException ex)
             {
                 throw new ApplicationException(ex.Message);
             }
             catch (SqlException ex)
             {
                 throw new ApplicationException("Error en BD: " + ex.Message);
             }
             finally
             {
                 conexion.Close();
             }

             return d;
        }