示例#1
0
        void Costo_Almacen_Rancho()
        {
            try
            {
                string[,] SubCategorias =
                {
                    {"Fungicidas","101"},
                    {"Insecticidas","102"},
                    {"Nematicidas","103"},
                    {"Herbicidas","104"},
                    {"Foliares","105"},
                    {"Adherentes","106"},
                    {"Bactericidas","107"},
                    {"Fertilizantes","108"},
                    {"Mejoradores de Suelos","109"},
                    {"Repelentes","110"}
                };

                WindowsFormsApplication1.FuncionesProductos funciones = new WindowsFormsApplication1.FuncionesProductos();
                Thread Hilo1 = new Thread(new ThreadStart(wait));
                Hilo1.Start();
                dataGridView1.Rows.Clear();
                this.WindowState = FormWindowState.Maximized;

                List<ListRanchos> objRanchos = new List<ListRanchos>();
                objRanchos = fnFunciones.cargaRanchos(objRanchos);

                showColumn("", -1);
                for (int Columnas = 0; Columnas < objRanchos.Count; Columnas++)
                    showColumn(objRanchos[Columnas].Rancho, Columnas);

                //COLOCACION Y ORDENAMIENTO DE LAS FILAS

                for (int cat = 0; cat < 0.5 * SubCategorias.Length; cat++)
                {
                    int ban = 0;
                    List<WindowsFormsApplication1.ListProductos> objProducto = new List<WindowsFormsApplication1.ListProductos>();
                    objProducto = funciones.llenarProducto(objProducto, SubCategorias[cat, 1]);

                    foreach (WindowsFormsApplication1.ListProductos producto in objProducto)
                    {
                        int n = dataGridView1.Rows.Add();
                        if (ban == 0)
                        {
                            dataGridView1.Rows[n].Cells[0].Value = SubCategorias[cat, 0];
                            int columna = 0;
                            foreach (ListRanchos rancho in objRanchos)
                            {
                                columna += 1;
                                dataGridView1.Rows[n].Cells[columna].Value = "-";
                            }
                            ban = 1;
                        }
                        else
                        {
                            dataGridView1.Rows[n].Cells[0].Value = producto.Producto + " " + producto.UM;
                        }

                    }
                }

                //BUSQUEDA EN LAS SALIDAS Y COLOCACION DE COSTOS SEGUN EL AGROQUIMICO Y EL RANCHO

                for (int fila = 0; fila < dataGridView1.Rows.Count; fila++)
                {

                    string producto = dataGridView1.Rows[fila].Cells[0].Value.ToString();

                    int es_sub_cat = 0;
                    //VERIFICA QUE NO SE TRATE DEL NOMBRE DE LA CATEGORIA
                    for (int j = 0; j < 0.5 * SubCategorias.Length; j++)
                        if (producto == SubCategorias[j, 0])
                        {
                            es_sub_cat = 1;
                            break;
                        }

                    if (es_sub_cat == 0)
                    {
                        List<SalidaCosto> objSalida = new List<SalidaCosto>();
                        objSalida = fnFunciones.fillSalidas(objSalida, ExtraerCodigoProducto(producto));
                        //objSalida = fnFunciones.fillSalidas(objSalida, "100101005");
                        //double importe = 0;
                        //foreach (SalidaCosto salida in objSalida)
                        //    importe += salida.Importe;
                        //dataGridView1.Rows[fila].Cells[1].Value = importe + " " + producto;

                        foreach (SalidaCosto salida in objSalida)
                        {
                            int columna = 0;
                            foreach(ListRanchos rancho in objRanchos)
                            {
                                columna += 1;
                                if (salida.Rancho == rancho.Rancho)
                                {
                                    double var = 0;
                                    try
                                    {
                                        var = Convert.ToDouble(dataGridView1.Rows[fila].Cells[columna].Value);
                                    }
                                    catch (Exception exs)
                                    {
                                        //MessageBox.Show("Error en la Celda[" + columna + "," + fila + "]");
                                        var = 0;
                                    }
                                    finally
                                    {
                                        dataGridView1.Rows[fila].Cells[columna].Value = var + Math.Round(salida.Importe, 2);
                                    }
                                }
                            }
                        }
                    }
                }

                Hilo1.Abort();
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message + ". Error"); }
        }
示例#2
0
        void costo_agroquimico_lote_ha()
        {
            try
            {
                string[,] SubCategorias =
                {
                    {"Fungicidas","101"},
                    {"Insecticidas","102"},
                    {"Nematicidas","103"},
                    {"Herbicidas","104"},
                    {"Foliares","105"},
                    {"Adherentes","106"},
                    {"Bactericidas","107"},
                    {"Fertilizantes","108"},
                    {"Mejoradores de Suelos","109"},
                    {"Repelentes","110"}
                };

                WindowsFormsApplication1.FuncionesProductos funciones = new WindowsFormsApplication1.FuncionesProductos();
                Thread Hilo1 = new Thread(new ThreadStart(wait));
                Hilo1.Start();
                dataGridView1.Rows.Clear();
                this.WindowState = FormWindowState.Maximized;

                List<ListRanchos> objRanchos = new List<ListRanchos>();
                objRanchos = fnFunciones.cargaRanchos(objRanchos);

                showColumn("Rancho/Lote/Ha", -1);
                for (int Columnas = 0; Columnas < 0.5 * SubCategorias.Length; Columnas++)
                    showColumn(SubCategorias[Columnas, 0], Columnas);

                //COLOCACION Y ORDENAMIENTO DE LAS FILAS

                for (int ran = 0; ran < objRanchos.Count; ran++)
                {
                    int ban = 0;
                    List<ListLotes> objLote = new List<ListLotes>();
                    objLote = fnFunciones.cargaListalotes(objLote, objRanchos[ran].Clave);

                    foreach (ListLotes lote in objLote)
                    {
                        int n = dataGridView1.Rows.Add();
                        if (ban == 0)
                        {
                            dataGridView1.Rows[n].Cells[0].Value = objRanchos[ran].Rancho;

                            for (int Columnas = 1; Columnas <= 0.5 * SubCategorias.Length; Columnas++)
                                dataGridView1.Rows[n].Cells[Columnas].Value = "-";
                            ban = 1;
                        }
                        else
                        {
                            dataGridView1.Rows[n].Cells[0].Value = lote.Clave + " | " + lote.Hectareaje;
                        }

                    }
                }

                //BUSQUEDA EN LAS SALIDAS Y COLOCACION DE COSTOS SEGUN EL AGROQUIMICO Y EL RANCHO
                string ranch = "";
                for (int fila = 0; fila < dataGridView1.Rows.Count; fila++)
                {

                    string celda = dataGridView1.Rows[fila].Cells[0].Value.ToString();

                    bool es_rancho = false;
                    //VERIFICA QUE NO SE TRATE DEL NOMBRE DEL RANCHO
                    for (int j = 0; j < objRanchos.Count; j++)
                        if (celda == objRanchos[j].Rancho)
                        {
                            es_rancho = true;
                            ranch = objRanchos[j].Rancho;
                            break;
                        }

                    if (!es_rancho)
                    {
                        List<SalidaCosto> objSalida = new List<SalidaCosto>();
                        objSalida = fnFunciones.fillSalidas(objSalida, ranch, celda.Substring(0, 4));
                        //objSalida = fnFunciones.fillSalidas(objSalida, "100101005");
                        //double importe = 0;
                        //foreach (SalidaCosto salida in objSalida)
                        //    importe += salida.Importe;
                        //dataGridView1.Rows[fila].Cells[1].Value = importe + " " + producto;

                        foreach (SalidaCosto salida in objSalida)
                        {

                            for(int columna = 1 ;columna <= 0.5 * SubCategorias.Length; columna++)
                            {
                                string prod_cat = salida.Producto.Substring(3, 3);
                                string sub__cat = SubCategorias[columna - 1, 1];
                                if (salida.Producto.Substring(3, 3) == SubCategorias[columna - 1, 1])
                                {
                                    double var = 0;
                                    try
                                    {
                                        var = Convert.ToDouble(dataGridView1.Rows[fila].Cells[columna].Value);
                                    }
                                    catch (Exception exs)
                                    {
                                        //MessageBox.Show("Error en la Celda[" + columna + "," + fila + "]");
                                        var = 0;
                                    }
                                    finally
                                    {
                                        dataGridView1.Rows[fila].Cells[columna].Value = var + Math.Round(salida.Importe, 2);
                                    }
                                }
                            }
                        }
                    }
                }

                Hilo1.Abort();
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message + ". Error"); }
        }