Exemplo n.º 1
0
 private void carga()
 {
     dtDevoluciones.Rows.Clear();
     Models.Dev_prov  devo        = new Models.Dev_prov();
     Models.Providers proveedores = new Models.Providers();
     using (devo)
     {
         List <Models.Dev_prov> dev = devo.get_devoluciones();
         if (dev.Count > 0)
         {
             foreach (Models.Dev_prov item in dev)
             {
                 using (proveedores)
                 {
                     List <Models.Providers> prov = proveedores.getProviderbyId(item.Id_proveedor);
                     dtDevoluciones.Rows.Add(item.Id, item.Fecha, prov[0].Name, item.Estado);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        private void Devo_Load(object sender, EventArgs e)
        {
            Models.Dev_prov devoluciones = new Models.Dev_prov();
            using (devoluciones)
            {
                List <Models.Dev_prov> listas = devoluciones.get_devolucionesbyfolio(Folio);
                if (listas.Count > 0)
                {
                    txtFolio.Text  = listas[0].Id.ToString();
                    txtMotivo.Text = listas[0].Motivo;
                    txtTotal.Text  = listas[0].Total.ToString();
                }
            }

            Models.det_dev_prov detallado = new Models.det_dev_prov();
            Models.Product      productos = new Models.Product();
            using (detallado)
            {
                List <Models.det_dev_prov> list = detallado.get_detalles(Folio);
                if (list.Count > 0)
                {
                    foreach (Models.det_dev_prov item in list)
                    {
                        Cuantos = Cuantos + 1;
                        using (productos)
                        {
                            List <Models.Product> producto = productos.getProductById(item.Id_producto);

                            dtDevoluciones.Rows.Add(item.Id, item.Cantidad, producto[0].Code1, producto[0].Description, item.Pu, (item.Pu * item.Cantidad), item.Estado);
                            if (item.Estado == true)
                            {
                                dtDevoluciones.Rows[dtDevoluciones.Rows.Count - 1].Cells["recibido"].ReadOnly = true;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            Models.Configuration configuracion = new Models.Configuration();
            Models.Dev_prov      devoluciones  = new Models.Dev_prov();
            Models.Providers     proveedores   = new Models.Providers();
            using (configuracion)
            {
                List <Models.Configuration> config = configuracion.getConfiguration();
                Font font   = new Font("Verdana", 8, FontStyle.Regular);
                int  y      = 70;
                var  format = new StringFormat()
                {
                    Alignment = StringAlignment.Center
                };
                double cambio = 0;
                if (config[0].Logo_ticket != "")
                {
                    if (File.Exists(config[0].Logo_ticket))
                    {
                        Image logo = Image.FromFile(config[0].Logo_ticket);
                        e.Graphics.DrawImage(logo, new Rectangle(0, 00, 250, 70));
                    }
                }

                string fecha = "";
                using (devoluciones)
                {
                    List <Models.Dev_prov> listas = devoluciones.get_devolucionesbyfolio(Folio_guardado);
                    fecha = listas[0].Fecha;
                    List <Models.Providers> providers = proveedores.getProviderbyId(listas[0].Id_proveedor);
                    if (providers.Count > 0)
                    {
                        y = y + 10;
                        e.Graphics.DrawString(providers[0].Name, font, Brushes.Black, 125, y, format);
                        y = y + 10;
                        e.Graphics.DrawString(providers[0].RFC, font, Brushes.Black, 125, y, format);
                        y = y + 10;
                        string calle = providers[0].Street + " " + providers[0].Ext_number;
                        if (providers[0].Int_number != "")
                        {
                            calle += "-" + providers[0].Int_number;
                        }
                        e.Graphics.DrawString(calle, font, Brushes.Black, 125, y, format);
                        y = y + 10;
                        e.Graphics.DrawString(providers[0].Muni + " " + providers[0].State, font, Brushes.Black, 125, y, format);
                        y = y + 10;
                        e.Graphics.DrawString("Telefono" + providers[0].Tel, font, Brushes.Black, 125, y, format);
                    }
                }

                format = new StringFormat()
                {
                    Alignment = StringAlignment.Far
                };
                y = y + 10;
                e.Graphics.DrawString("___________________________________________", font, Brushes.Black, 0, y);


                y = y + 15;
                e.Graphics.DrawString("Devolucion: " + Folio_guardado.ToString(), font, Brushes.Black, 0, y);
                y = y + 15;
                e.Graphics.DrawString("Fecha: " + fecha.ToString(), font, Brushes.Black, 0, y);
                y = y + 20;
                e.Graphics.DrawString("Cant.", font, Brushes.Black, 50, y, format);
                e.Graphics.DrawString("P/U.", font, Brushes.Black, 120, y, format);

                e.Graphics.DrawString("IMPTE.", font, Brushes.Black, 220, y, format);
                y = y + 10;
                e.Graphics.DrawString("___________________________________________", font, Brushes.Black, 0, y);

                double totali = 0;
                Models.det_dev_prov detallado = new Models.det_dev_prov();
                Models.Product      productos = new Models.Product();
                using (detallado)
                {
                    List <Models.det_dev_prov> list = detallado.get_detalles(Folio_guardado);
                    if (list.Count > 0)
                    {
                        foreach (Models.det_dev_prov item in list)
                        {
                            using (productos)
                            {
                                List <Models.Product> producto = productos.getProductById(item.Id_producto);


                                y = y + 30;
                                e.Graphics.DrawString(producto[0].Description, font, Brushes.Black, 10, y);
                                e.Graphics.DrawString(item.Cantidad.ToString(), font, Brushes.Black, 50, y + 10, format);
                                e.Graphics.DrawString(string.Format("{0:#,0.00}", item.Pu), font, Brushes.Black, 120, y + 10, format);

                                e.Graphics.DrawString(string.Format("{0:#,0.00}", (item.Pu * item.Cantidad)), font, Brushes.Black, 220, y + 10, format);
                                totali = totali + 1;
                            }
                        }
                    }
                }
                y = y + 15;
                e.Graphics.DrawString("___________________________________________", font, Brushes.Black, 0, y);
                y = y + 15;
                e.Graphics.DrawString("Total", font, Brushes.Black, 120, y, format);

                e.Graphics.DrawString("$ " + string.Format("{0:#,0.00}", txtTotal.Text), font, Brushes.Black, 220, y, format);
            }
            Folio_guardado = 0;
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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();
        }