Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Deseas efecturar el inventario", "Inventario", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Models.Product productos = new Models.Product();
                double         nuevo;
                foreach (DataGridViewRow row in dtPoroductos.Rows)
                {
                    using (productos)
                    {
                        List <Models.Product> prod = productos.getProductById(Convert.ToInt16(row.Cells["id"].Value.ToString()));
                        double antes_inventario    = prod[0].Existencia;


                        nuevo = Convert.ToInt16(row.Cells["cantidad"].Value.ToString());
                        while (prod[0].Parent != "0")
                        {
                            nuevo = nuevo * Convert.ToInt16(prod[0].C_unidad);
                            prod  = productos.getProductById(Convert.ToInt16(prod[0].Parent));
                        }
                        double nuevo_inventario = antes_inventario + nuevo;

                        productos.Existencia = nuevo_inventario;
                        productos.Id         = Convert.ToInt16(row.Cells["id"].Value.ToString());
                        productos.update_inventary();
                    }
                }
                dtPoroductos.Rows.Clear();
                MessageBox.Show("Efectuado con exito");
                txtCodigo.Focus();
            }
        }
Ejemplo n.º 2
0
        private void devolucion()
        {
            Models.Devolutions devolucion = new Models.Devolutions();
            Models.Log         historial  = new Models.Log();
            using (devolucion)
            {
                devolucion.Fecha    = dtFecha.Text + " 00:00:00";
                devolucion.Autorizo = id_usuario;
                devolucion.Total    = Convert.ToDouble(txtTotal.Text);
                devolucion.create();
                List <Models.Devolutions> devo = devolucion.get_lastdevocion(dtFecha.Text + " 00:00:00", id_usuario, Convert.ToDouble(txtTotal.Text));

                Models.det_devolution detalles = new Models.det_devolution();
                using (detalles)
                {
                    detalles.Id_devolucion = devo[0].Id;
                    Folio_guardado         = devo[0].Id;
                    Models.Product productos = new Models.Product();
                    foreach (DataGridViewRow row in dtProductos.Rows)
                    {
                        detalles.Cantidad    = Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                        detalles.Id_producto = Convert.ToInt16(row.Cells["id_producto"].Value.ToString());
                        detalles.Pu          = Convert.ToDouble(row.Cells["pu"].Value.ToString());
                        detalles.Almacen     = row.Cells["almacen"].Value.ToString();
                        detalles.create_det();

                        using (historial)
                        {
                            historial.Id_usuario  = Convert.ToInt32(Inicial.id_usario);
                            historial.Descripcion = "el usuairo " + id_usuario + " autorizo la devolucion de " + row.Cells["cantidad"].Value.ToString() + " " + row.Cells["descripcion"].Value.ToString();
                            historial.createLog();
                        }

                        using (productos)
                        {
                            productos.Id = Convert.ToInt16(row.Cells["id_producto"].Value.ToString());
                            List <Models.Product> produ = productos.getProductById(Convert.ToInt16(row.Cells["id_producto"].Value.ToString()));
                            if (row.Cells["almacen"].Value.ToString() == "Devolucion")
                            {
                                productos.Devoluciones = produ[0].Devoluciones + Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                                productos.update_devoluciones();
                            }
                            else
                            {
                                productos.Existencia = produ[0].Existencia + Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                                productos.update_inventary();
                            }
                        }
                    }
                }
            }
            imprimir();
            limpiar();
            MessageBox.Show("Se guardo con exito la devolucion");
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Models.Dev_prov       devo       = new Models.Dev_prov();
            Models.det_dev_prov   detalles   = new Models.det_dev_prov();
            Models.Product        productos  = new Models.Product();
            Models.det_devolution det_devolu = new Models.det_devolution();
            Models.Log            historial  = new Models.Log();
            using (devo)
            {
                devo.Id_proveedor = Convert.ToInt32(txtId_proveedor.Text);
                devo.Total        = Convert.ToDouble(txtTotal.Text);
                devo.Estado       = false;
                devo.Motivo       = txtMotivo.Text;
                devo.create_dev();
                string mensaje = "se envio una devolucion a " + txtProveedor.Text + "<br/>";
                List <Models.Dev_prov> ultimo = devo.get_lastdevolucion(Convert.ToInt32(txtId_proveedor.Text), Convert.ToDouble(txtTotal.Text), txtMotivo.Text);
                Folio_guardado = ultimo[0].Id;
                using (detalles)
                {
                    foreach (DataGridViewRow row in dtProductos.Rows)
                    {
                        detalles.Id_devolucion = ultimo[0].Id;
                        detalles.Id_producto   = Convert.ToInt32(row.Cells["id"].Value.ToString());
                        detalles.Cantidad      = Convert.ToDouble(row.Cells["cantidad"].Value.ToString());

                        detalles.Pu     = Convert.ToDouble(row.Cells["p_u"].Value.ToString());
                        detalles.Estado = false;
                        detalles.create_det();
                        using (historial)
                        {
                            historial.Id_usuario  = Convert.ToInt32(Inicial.id_usario);
                            historial.Descripcion = "se envio " + row.Cells["cantidad"].Value.ToString() + " del producto " + row.Cells["desripcion"].Value.ToString() + " como devolucion al proveedor " + txtProveedor.Text;
                            historial.createLog();
                        }
                        mensaje += row.Cells["cantidad"].Value.ToString() + " -- " + row.Cells["desripcion"].Value.ToString() + "<br/>";
                        if (row.Cells["folios"].Value is null)
                        {
                            using (productos)
                            {
                                List <Models.Product> producto = productos.getProductById(Convert.ToInt32(row.Cells["id"].Value.ToString()));
                                productos.Existencia = producto[0].Existencia - Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                                productos.Id         = Convert.ToInt32(row.Cells["id"].Value.ToString());
                                productos.update_inventary();
                            }
                        }
                        else
                        {
                            using (productos)
                            {
                                productos.Id = Convert.ToInt32(row.Cells["id"].Value.ToString());
                                List <Models.Product> produ = productos.getProductById(Convert.ToInt32(row.Cells["id"].Value.ToString()));
                                productos.Devoluciones = produ[0].Devoluciones - Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                                productos.update_devoluciones();
                            }


                            char     delimitar = ',';
                            string[] folios    = row.Cells["folios"].Value.ToString().Split(delimitar);
                            int      cuantos   = folios.Count();
                            for (int i = 0; i < cuantos; i++)
                            {
                                using (det_devolu)
                                {
                                    det_devolu.Id_producto   = Convert.ToInt32(row.Cells["id"].Value.ToString());
                                    det_devolu.Id_devolucion = Convert.ToInt32(folios[i]);
                                    det_devolu.enviar();
                                }
                            }
                        }
                    }
                }

                mensaje += "con un total de $" + txtTotal.Text;
                intercambios intercambios = new intercambios();
                intercambios.enviar_correo("", mensaje, "Envio de devolucion");
            }
            imprimir();
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialogo = MessageBox.Show("¿Desea agregar las devoluciones al inventario para su venta?",
                                                   "Devoluciones", MessageBoxButtons.YesNo, MessageBoxIcon.Question);


            int llegaron = 0;

            Models.det_dev_prov detallado = new Models.det_dev_prov();
            Models.Product      productos = new Models.Product();
            Models.Log          historial = new Models.Log();
            using (detallado)
            {
                foreach (DataGridViewRow row in dtDevoluciones.Rows)
                {
                    if (Convert.ToBoolean(row.Cells["recibido"].Value) == true)
                    {
                        if (!row.Cells.IsReadOnly)
                        {
                            if (dialogo == DialogResult.Yes)
                            {
                                using (productos)
                                {
                                    if (row.Cells["recibido"].ReadOnly == true)
                                    {
                                    }
                                    else
                                    {
                                        List <Models.Product> producto = productos.getProductBycode1(row.Cells["codigo"].Value.ToString());
                                        productos.Existencia = producto[0].Existencia + Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                                        productos.Id         = producto[0].Id;
                                        productos.update_inventary();

                                        using (historial)
                                        {
                                            historial.Id_usuario  = Convert.ToInt32(Inicial.id_usario);
                                            historial.Descripcion = "se regreso " + row.Cells["cantidad"].Value.ToString() + " del producto " + row.Cells["descripcion"].Value.ToString();
                                            historial.createLog();
                                        }
                                    }
                                }
                            }
                        }
                        llegaron     = llegaron + 1;
                        detallado.Id = Convert.ToInt32(row.Cells["id"].Value);
                        detallado.recibir();
                    }
                }
            }
            Models.Dev_prov devolu = new Models.Dev_prov();
            using (devolu)
            {
                if (llegaron == Cuantos)
                {
                    devolu.Estado = true;
                    devolu.Id     = Folio;
                    devolu.termina_dev();
                }
            }


            this.Close();
        }