Exemplo n.º 1
0
        private bool set_articuloLote(string p_cdar, string p_lote, ref double p_uds, ref string p_men)
        {
            // modifica el diccionario coleccion_stock, añadiendo las unidades a un lote y artículo.
            // de momento dado un lote existente no lo permite.
            ar_stock vf_stock;

            try
            {   // Desde gsBase puede llegar una u delante del lote.
                if (!this.coleccion_stock.ContainsKey(p_cdar + p_lote))
                {
                    vf_stock = new ar_stock(p_cdar + p_lote, p_uds, p_cdar, p_lote);
                    this.coleccion_stock.Add(p_cdar + p_lote, vf_stock);
                }
                else
                {   // Puede que exista ya stock y se suma para poder usarlo
                    this.coleccion_stock[p_cdar + p_lote].stock += p_uds;
                }
            }
            catch (Exception e)
            {
                p_men = "Error en: " + p_cdar + " Lote: " + p_lote + " Sistema: " + e.ToString();
                return(false);
            }
            this.show_arStock(); // muestra el artíuclo en la lista.
            return(true);
        }
        private void get_arStock()
        {  // crea un diccionario de clave cdar+lote para el tratamiento de stock en la pda
            ar_stock vf_stock;
            double   vf_uds;
            double   vf_ar_udc;
            int      i, ix;
            List <List <string> > lista_ar_mma = new List <List <string> >();

            for (i = 0; i <= this.res.AV_LNA.Count - 1; i++)
            {
                vf_uds    = Convert.ToDouble(this.res.AV_LNA[i][3].Replace(".", ","));
                vf_ar_udc = Convert.ToDouble(this.res.AV_LNA[i][5].Replace(".", ","));
                // tratamiento de lotes en la linea del albarán.
                lista_ar_mma = this.get_arMMA(this.res.AV_LNA[i][1]); // Cambio en LNA, ahora en lotes vendrá una lista y no podemos asignar directamente
                for (ix = 0; ix <= lista_ar_mma.Count - 1; ix++)
                {
                    vf_uds   = Convert.ToDouble(lista_ar_mma[ix][1].Replace(".", ","));
                    vf_stock = new ar_stock(this.res.AV_LNA[i][0].ToString().Trim() + lista_ar_mma[ix][0].Replace("u", ""), vf_uds, vf_ar_udc, this.res.AV_LNA[i][6], this.res.AV_LNA[i][7]);
                    try
                    {   // Desde gsBase puede llegar una u delante del lote.
                        if (!this.coleccion_stock.ContainsKey(this.res.AV_LNA[i][0].ToString().Trim() + lista_ar_mma[ix][0].Replace("u", "")))
                        {
                            this.coleccion_stock.Add(this.res.AV_LNA[i][0].ToString().Trim() + lista_ar_mma[ix][0].Replace("u", ""), vf_stock);
                        }
                        else
                        {   // Puede que exista ya stock y se suma para poder usarlo
                            this.coleccion_stock[this.res.AV_LNA[i][0].ToString().Trim() + lista_ar_mma[ix][0]].stock += vf_uds;
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString(), "Error");
                        MessageBox.Show(this.res.AV_LNA[i][0].ToString().Trim() + " - " + lista_ar_mma[ix][0]);
                        MessageBox.Show(vf_stock.cdar_lote + vf_stock.stock);
                    }
                }

                // Tratamiento de los ar_mma:  // ar_mma = [[Lote,Stock]]
                lista_ar_mma = this.get_arMMA(this.res.AV_LNA[i][4]);
                for (ix = 0; ix <= lista_ar_mma.Count - 1; ix++)
                {
                    vf_uds   = Convert.ToDouble(lista_ar_mma[ix][1].Replace(".", ","));
                    vf_stock = new ar_stock(this.res.AV_LNA[i][0].ToString().Trim() + lista_ar_mma[ix][0].Replace("u", ""), vf_uds, vf_ar_udc, this.res.AV_LNA[i][6], this.res.AV_LNA[i][7]);
                    try
                    {
                        if (!this.coleccion_stock.ContainsKey(this.res.AV_LNA[i][0].ToString().Trim() + lista_ar_mma[ix][0].Replace("u", "")))
                        {
                            this.coleccion_stock.Add(this.res.AV_LNA[i][0].ToString().Trim() + lista_ar_mma[ix][0].Replace("u", ""), vf_stock);
                        }
                        else
                        {
                            this.coleccion_stock[this.res.AV_LNA[i][0].ToString().Trim() + lista_ar_mma[ix][0]].stock += vf_uds;
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString(), "Error");
                        MessageBox.Show(this.res.AV_LNA[i][0].ToString().Trim() + " - " + lista_ar_mma[ix][0]);
                        MessageBox.Show(vf_stock.cdar_lote + vf_stock.stock);
                    }
                }
            }
        }