Ejemplo n.º 1
0
 private void buttonGuardar_Click(object sender, EventArgs e)
 {
     if (AccesoInternet() == false)
     {
         MessageBox.Show("No hay internet, intente en un momento"); return;
     }
     if (textBoxNuevoPrecio.Text == "")
     {
         MessageBox.Show("Actualice la informacion");
         return;
     }
     if (!cotizacionElegida.AsignarValores(this))
     {
         labelError.Visible = true;
         return;
     }
     cotizacionElegida.idProducto = productoElegido.Id;
     cotizacionElegida.fecha      = fecha2.Value;
     cotizacionElegida.tipoMoneda = moneda2.Text;
     labelError.Visible           = false;
     cotizacionElegida.Insert();
     if (cotizacionElegida.Error != "")
     {
         MessageBox.Show(cotizacionElegida.Error);
         return;
     }
     productoElegido.PrecioAlmacen = precioNew;
     productoElegido.FECHA_FACTURA = fecha2.Value.Date;
     productoElegido.Update("Id");
 }
Ejemplo n.º 2
0
        private void actualizarRespaldos()
        {
            #region ACTUALIZAR RESPALDOS

            DataTable dtProductoStock = queryProductosStock();
            labelListaProductos.Text += dtProductoStock.Rows.Count.ToString();

            DataTable dtProductosPU = productosPU();
            labelProductPU.Text += dtProductosPU.Rows.Count.ToString();

            int[] Respaldados   = new int[2000];
            int[] AlgunRespaldo = new int[2000];
            int   i2            = 0;

            foreach (DataRow dr in dtProductoStock.Rows)
            {
                int iDprodcuto = Convert.ToInt32(dr["Id"]);

                DataTable dtRespaldo1 = queryRespaldoProductos(iDprodcuto);

                if (dtRespaldo1.Rows.Count > 0)
                {
                    productos producto   = new productos(iDprodcuto);
                    int[]     cantActual = new int[100];
                    int       i          = 0;
                    foreach (DataRow dr2 in dtRespaldo1.Rows)
                    {
                        cantActual[i] = Convert.ToInt32(dr2["cantidad_actual"]);
                        i++;
                    }

                    producto.stock_respaldado = cantActual.Sum();
                    producto.Update("Id");

                    if (producto.STOCK == cantActual.Sum())
                    {
                        Respaldados[i2] = 1;
                    }
                    if (producto.STOCK > cantActual.Sum())
                    {
                        AlgunRespaldo[i2] = 1;
                    }
                }

                i2++;
            }

            labelProductRespaldados.Text += Respaldados.Sum().ToString() + " Con algun Respaldo: " + AlgunRespaldo.Sum().ToString();

            dataGridView1.DataSource = queryProductos();

            #endregion ACTUALIZAR RESPALDOS
        }
Ejemplo n.º 3
0
        private void FormProductoSpec_Load(object sender, EventArgs e)
        {
            tablacodigos = prdoducto_codigos.tabla(CATALOGO.Text, productoSeleccionadoi.Id.ToString());
            string rutaDataSheet = @"DataSheet\" + productoSeleccionadoi.CATALOGO + ".pdf";

            if (File.Exists(rutaDataSheet))
            {
                buttonDataSheet.BackColor      = System.Drawing.Color.GreenYellow;
                productoSeleccionadoi.ADJUNTOS = productoSeleccionadoi.CATALOGO;
                productoSeleccionadoi.Update("Id");
            }
            if (productoSeleccionadoi.DOCUMENTOS != "")
            {
                button3.BackColor = System.Drawing.Color.GreenYellow;
            }
            button2.Visible = false;
            if (AccesoInternet() == false)
            {
                MessageBox.Show("No hay internet, intente en un momento"); return;
            }
            if (productoSeleccionadoi == null)
            {
                nuevo2 = true;
                productoSeleccionadoi = new productos();
            }
            productoSeleccionadoi.MostrarValores(this, false);
            DESCRIPCION.Text = productoSeleccionadoi.DESCRIPCION;
            double precio_oferta = productoSeleccionadoi.PrecioAlmacen;

            if (productoSeleccionadoi.STOCKMUERTO == 1)
            {
                ckmuerto.Checked = true;
                precio_oferta    = Math.Round(precio_oferta * 0.5, 2);
            }
            double porcentaje37 = precio_oferta * 1.37;
            double porcentaje50 = precio_oferta * 1.5;

            PrecioAlmacen.Text      = precio_oferta.ToString();
            textBox37.Text          = porcentaje37.ToString();
            textBox50.Text          = porcentaje50.ToString();
            labelActualizacion.Text = productoSeleccionadoi.FECHA_FACTURA.ToShortDateString();
            DateTime oldDate = productoSeleccionadoi.FECHA_FACTURA;
            DateTime newDate = DateTime.Now;
            // Difference in days, hours, and minutes.
            TimeSpan ts = newDate - oldDate;
            // Difference in days.
            int differenceInDays = ts.Days;

            //MessageBox.Show(newDate.Date.ToShortDateString()+"   "+oldDate.Date.ToShortDateString()+"   "+ differenceInDays.ToString());
            rutaImagen = @"IMAGEN\" + productoSeleccionadoi.CATALOGO + ".jpg";
            if (File.Exists(rutaImagen))
            {
                fs = new FileStream(rutaImagen, FileMode.Open, FileAccess.Read);
                Bitmap imagen     = (Bitmap)System.Drawing.Image.FromStream(fs);
                double ladoMaximo = 450;
                double factorReduccion;
                double factorAltoAncho = (double)imagen.Height / (double)imagen.Width;
                if (imagen.Width > ladoMaximo || imagen.Height > 450)
                {
                    if (factorAltoAncho >= 1)
                    {
                        factorReduccion = 450 / imagen.Height;
                    }
                    else
                    {
                    }
                }
                pictureBox1.Image = imagen;
                fs.Close();
            }
            else
            {
                fs = new FileStream(rutaLogo, FileMode.Open, FileAccess.Read);
                pictureBox1.Image = System.Drawing.Image.FromStream(fs);
                fs.Close();
            }
            int diferencia = 0;

            /*if (DateTime.Now.Month < 4)
             *  diferencia = 90;
             * else if (DateTime.Now.Month == 4)
             *  diferencia = 90;
             * else if (DateTime.Now.Month == 5)
             *  diferencia = 90;
             * else if (DateTime.Now.Month == 6)
             *  diferencia = 90;
             * else if (DateTime.Now.Month ==7)
             *  diferencia = 120;
             * else if (DateTime.Now.Month == 8)
             *  diferencia = 150;
             * else if (DateTime.Now.Month > 8)
             *  diferencia = 180;*/
            diferencia = 180;
            if (differenceInDays > diferencia)
            {
                PrecioAlmacen.Visible = false;
                textBox37.Visible     = false;
                textBox50.Visible     = false;
            }
            if (productoSeleccionadoi.STOCKMUERTO == 1)
            {
                PrecioAlmacen.Visible = true;
                textBox37.Visible     = true;
                textBox50.Visible     = true;
            }
            DbObject db     = new DbObject();
            string   cambio = db.datoinfla();

            /* if (productoSeleccionadoi.STOCK == 0)
             * {
             *   labelAdvertencia1.Visible = true;
             *   PrecioAlmacen.Visible = false;
             *   textBox37.Visible = false;
             *   textBox50.Visible = false;
             * }*/
            /*if (cambio == "0")
             * {
             *  labelAdvertencia1.Visible = true;
             *  labelAdvertencia1.Text = "Agrege el porcentaje de inflacion";
             *  PrecioAlmacen.Visible = false;
             *  textBox37.Visible = false;
             *  textBox50.Visible = false;
             * }*/
            // MessageBox.Show(DateTime.Now.Month.ToString());
            //MessageBox.Show(productoSeleccionadoi.Id.ToString());
            ADJUNTOS.Text = productoSeleccionadoi.ADJUNTOS;
            var a1 = productoSeleccionadoi.ADJUNTOS;

            string[] adjuntos = a1.Split(',');
            for (int i = 0; i < adjuntos.Count(); i++)//mustra adjuntos
            {
                if (adjuntos[i] != "")
                {
                    //comboBox1.Items.Add(adjuntos[i]);
                }
            }
        }
Ejemplo n.º 4
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            if (dataGridView1.Rows[e.RowIndex].Cells[1].Value == DBNull.Value)
            {
                return;
            }
            int rowIndex = e.RowIndex;

            int    item     = Convert.ToInt32(dataGridView1.Rows[rowIndex].Cells[0].Value);
            string catalogo = dataGridView1.Rows[rowIndex].Cells[1].Value.ToString();

            osa_indiv        i       = new osa_indiv(item, osaSeleccionada.Id);
            productos        p       = new productos(i.ID_PRODUCTO2);
            inventariocostos invCost = new inventariocostos(i.ID_PRODUCTO2, true);

            FormDevolucion d = new FormDevolucion();

            d.labelProducto.Text     = "OSA no. " + osaSeleccionada.Id + ",  ITEM: " + item + ",  CATALOGO: " + catalogo;
            d.textBoxExistencia.Text = i.QTY2.ToString();
            d.existencia             = i.QTY2;
            d.stock = p.STOCK;
            d.ShowDialog();

            if (d.DialogResult == DialogResult.OK)
            {
                if (d.existencia < i.QTY2)
                {
                    #region WHILE DEVOLVER A iNVENTARIOCOSTOS
                    if (invCost.Id > 0)
                    {
                        int diferenciaOen = invCost.cantidad_oen - invCost.cantidad_actual;
                        int restaOsa      = i.QTY2 - d.existencia;

                        if (restaOsa <= diferenciaOen)
                        {
                            invCost.cantidad_actual += restaOsa;
                            invCost.Update("Id");
                        }
                        else
                        {
                            int qty = restaOsa;

                            invCost.cantidad_actual += diferenciaOen;
                            invCost.Update("Id");
                            qty -= diferenciaOen;

                            while (qty > 0)
                            {
                                inventariocostos invCost2 = new inventariocostos(i.ID_PRODUCTO2, true);
                                if (invCost2.Id > 0)
                                {
                                    int restaOen = invCost2.cantidad_oen - invCost2.cantidad_actual;
                                    if (qty <= restaOen)
                                    {
                                        invCost2.cantidad_actual += qty;
                                        invCost2.Update("Id");
                                        qty = 0;
                                    }
                                    else
                                    {
                                        invCost2.cantidad_actual += restaOen;
                                        invCost2.Update("Id");
                                        qty -= restaOen;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("No hay ordenes de entrada para este producto");
                                    qty = 0;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No hay ordenes de entrada para estos productos");
                    }

                    #endregion WHILE DEVOLVER A INVENTARIOcOSTOS

                    i.QTY2  = d.existencia;
                    p.STOCK = d.stock;
                    i.Update("Id");
                    p.Update("Id");

                    MessageBox.Show("Devolucion aplicada");
                    VerDGV(osaSeleccionada.Id);
                    foreach (DataGridViewRow fila in dataGridView1.Rows)
                    {
                        string cantidad = fila.Cells[2].ToString();
                        string cat      = fila.Cells[1].ToString();
                    }
                }
            }
            if (osaSeleccionada.idpoliza > 0)
            {
                double tot = 0;
                foreach (DataGridViewRow fila in dataGridView1.Rows)
                {
                    if (fila.Cells[3].Value != null)
                    {
                        string cantidad = fila.Cells[3].Value.ToString();
                        catalogo = fila.Cells[1].Value.ToString();
                        item     = Convert.ToInt32(dataGridView1.Rows[fila.Index].Cells[0].Value);
                        i        = new osa_indiv(item, osaSeleccionada.Id);
                        p        = new productos(i.ID_PRODUCTO2);
                        tot     += Convert.ToInt32(cantidad) * p.PrecioAlmacen;
                    }
                }
                polizasdb pol = new polizasdb(osaSeleccionada.idpoliza);
                pol.subtotal = tot;
                pol.egreso   = tot;
                pol.Update("folio");
            }
        }