Пример #1
0
        public Crear_Proyecto_Form()
        {
            try
            {
                InitializeComponent();
                this.ControlBox = false;
                criterioCbx.SelectedIndex = 0;
                newProject = new PROYECTO();
                confianzaTextBox.Text = "95";
                limiteInfTxt.Text = "0,1";
                areaFustalesTxt.Text = "1";
                factorFormaTxt.Text = "0,65";
                areaMuestrearTxt.Text = "0";
                numeroParcelasMuestraTxt.Text = "0";
                numeroParcelasTxt.Text = "0";
                AreaTotalTxt.Text = "0";
                tamParcelaTxt.Text = "0";
                formulate = new FormulateBL(Program.ContextData);
                formulaBS.DataSource = formulate.GetFormulates();
                newProject.NROFORMULA = formulaBS.Count != 0 ? ((FORMULA)formulaBS.Current).NROFORMULA : Guid.Empty;
                project = new ProjectBL(Program.ContextData);
                estratoDGW.Columns[2].DefaultCellStyle.Format = "0.000##";
                typeExample = new TypeSampleDesignBl(Program.ContextData);
                objetiveInventory = new ObjectiveInventoryBL(Program.ContextData);
                stratum = new StratumBL(Program.ContextData);
                species = new SpeciesBL(Program.ContextData);
                costBL = new CostBL(Program.ContextData);
                objetivoInventarioBS.DataSource = objetiveInventory.GetObjectiveInventories();
                newProject.NOMBRETIPOINV = objetivoInventarioBS.Count != 0 ? ((OBJETIVOINVENTARIO)objetivoInventarioBS.Current).NOMBRETIPOINV : null;
                tipoDisenoBS.DataSource = typeExample.GetTypeSampleDesignList();
                newProject.NOMTIPODISEMUEST = tipoDisenoBS.Count != 0 ? ((TIPODISENOMUESTRAL)tipoDisenoBS.Current).NOMTIPODISEMUEST : null;
                estratoBS.DataSource = stratum.GetStratums();
                estratoDGW.DataSource = estratoBS;
                especieBS.DataSource = species.GetSpecies();
                especiesDGW.DataSource = especieBS;
                proyectoBS.DataSource = project.GetProjectsFree(null);
                proyectoDGW.DataSource = proyectoBS;
                costoBS.DataSource = costBL.GetCosts();
                costoDGW.DataSource = costoBS;
                listProjectsByStage = new List<PROYECTOSPORETAPA>();
                tipoDisenoCbx.SelectedValue = "SI";
                TipoProyectoCbx.SelectedIndex = 0;
                nuevoProyectoBS.DataSource = newProject;

                foreach (Control ctl in crearProyectoTab.TabPages["costosTabP"].Controls) ctl.Enabled = true;
            }
            catch (Exception ex)
            {
                Error_Form errorForm = new Error_Form(ex.Message);
                errorForm.MdiParent = ParentForm;
                errorForm.Show();
            }
        }
        public Arbol_Proyectos_Por_Etapas_Form(PROYECTO project)
        {
            InitializeComponent();
            typeExample = new TypeSampleDesignBl(Program.ContextData);
            objetiveInventory = new ObjectiveInventoryBL(Program.ContextData);
            tipoDisenoBS.DataSource = typeExample.GetTypeSampleDesignList();
            objetivoInventarioBS.DataSource = objetiveInventory.GetObjectiveInventories();

            List<KeyValuePair<string, string>> data = new List<KeyValuePair<string, string>>();
            data.Add(new KeyValuePair<string, string>("IN", "Independiente"));
            data.Add(new KeyValuePair<string, string>("CR", "Contenedor"));
            TipoProyectoCbx.DataSource = data;
            TipoProyectoCbx.DisplayMember = "Value";
            TipoProyectoCbx.ValueMember = "Key";

            proyectoBS.DataSource = project;
            numeroFormulariosTxt.Text = project.FORMULARIO.Count.ToString();
            int lineasInv = 0;
            int lineasRegen = 0;
            int lineasNoMader = 0;
            foreach (FORMULARIO frm in project.FORMULARIO)
            {
                lineasInv += frm.LINEAINVENTARIO.Count;
                lineasRegen += frm.LINEAREGENERACION.Count;
                lineasNoMader += frm.LINEANOMADERABLES.Count;
            }
            numeroLineasInvTxt.Text = lineasInv.ToString();
            numeroLinRegenTxt.Text = lineasRegen.ToString();
            numeroLineasNoMadTxt.Text = lineasNoMader.ToString();
            TipoProyectoCbx.SelectedValue = project.TIPOPROYECTO;

            proyectosVariasEtapasTvw.Nodes.Clear();
            proyectosVariasEtapasTvw.BeginUpdate();
            TreeNode node;
            node = proyectosVariasEtapasTvw.Nodes.Add(project.LUGAR);
            node.Tag = project;
            LoadTree(node);
            proyectosVariasEtapasTvw.EndUpdate();
            proyectosVariasEtapasTvw.Refresh();
            proyectosVariasEtapasTvw.ExpandAll();
        }
Пример #3
0
        public void importarExcelFuncional(ToolStripProgressBar bar)
        {
            try
            {
                bar.Visible = true;
                OpenFileDialog fichero = new OpenFileDialog();
                fichero.Filter = "Excel (*.xls)|*.xls;*.xlsx";
                //ArrayList lstDatos = new ArrayList(); ;

                stratum = new ESTRATO();

                ProjectBL pyBl = new ProjectBL(Program.ContextData);
                FormBL formBl = new FormBL(Program.ContextData);
                InventoryLineBL lineInvBl = new InventoryLineBL(Program.ContextData);
                listStratumsAdded = new ArrayList();

                USUARIO user = (USUARIO)Program.Cache.Get("user");

                if (user != null)
                {
                    try
                    {
                        if (fichero.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            //PROYECTO project;
                            //PROYECTO py = pyBl.GetProject(project.NROPROY);
                            bar.Visible = true;
                            bar.Value = 0;

                            //declaramos las variables que necesitamos para poder abrir un archivo excel
                            excel.Application aplicacion;
                            excel.Workbook libros_trabajo;
                            excel.Worksheet hojas_trabajo;
                            excel.Range exlRange;

                            aplicacion = new excel.Application();

                            //Asignamos el libro que sera abierot
                            libros_trabajo = aplicacion.Workbooks.Open(fichero.FileName, 0, true, 5, "", "", true, excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

                            hojas_trabajo = (excel.Worksheet)libros_trabajo.Worksheets.get_Item(3);
                            exlRange = hojas_trabajo.UsedRange;
                            //Recorremos el archivo excel como si fuera una matriz
                            //leemos los proyectos que se encuentran en la hoja
                            bar.Maximum = exlRange.Rows.Count - 2;

                            for (int i = 2; i <= exlRange.Rows.Count; i++)
                            {

                                string lugar = "" + (exlRange.Cells[i, 1] as excel.Range).Value + "";
                                string tamanioParcela = "" + (exlRange.Cells[i, 2] as excel.Range).Value + "";
                                string tamanioSupTotal = "" + (exlRange.Cells[i, 3] as excel.Range).Value + "";
                                string areaderegeneracion = "" + (exlRange.Cells[i, 4] as excel.Range).Value + "";
                                string factorForma = "" + (exlRange.Cells[i, 5] as excel.Range).Value + "";
                                //string numeroEtapas = "" + (exlRange.Cells[i, 6] as excel.Range).Value + "";
                                string descripcion = "" + (exlRange.Cells[i, 7] as excel.Range).Value + "";
                                string TipoDisenio = "" + (exlRange.Cells[i, 8] as excel.Range).Value + "";
                                string Objetivo = "" + (exlRange.Cells[i, 9] as excel.Range).Value + "";
                                string confianza = "" + (exlRange.Cells[i, 10] as excel.Range).Value + "";
                                if (pyBl.GetProjectByPlace(lugar) == null)
                                {
                                    // area muestreada = multiplicar el numero de parcelas por el tamaño de la parcela
                                    // intensidad de muestreo = dividir el area muestreada entre el tamaño total del area a muestrear
                                    PROYECTO py = new PROYECTO();
                                    py.NROPROY = Guid.NewGuid();
                                    py.LUGAR = lugar;
                                    decimal tam = 0, factor = 0, tamSupTotal = 0, conf = 0;
                                    int areaReg = 0;
                                    decimal.TryParse(tamanioParcela.Replace(".", ","), out tam);
                                    py.TAMANO = tam;
                                    decimal.TryParse(tamanioSupTotal.Replace(".", ","), out tamSupTotal);
                                    py.SUPTOT = tamSupTotal;
                                    int.TryParse(areaderegeneracion, out areaReg);
                                    py.AREAFUSTALESPORPARCELA = areaReg;
                                    decimal.TryParse(factorForma.Replace(".", ","), out factor);
                                    py.FACTORDEFORMA = factor;
                                    py.ETAPA = 0;
                                    py.DESCRIPCION = descripcion;
                                    decimal.TryParse(confianza.Replace(".", ","), out conf);
                                    py.CONFIANZA = conf;
                                    TypeSampleDesignBl desingType = new TypeSampleDesignBl(Program.ContextData);
                                    ObjectiveInventoryBL objInvBl = new ObjectiveInventoryBL(Program.ContextData);
                                    if (TipoDisenio.Equals("Estratificado")) py.NOMTIPODISEMUEST = "ES";
                                    else if (TipoDisenio.Equals("Simple")) py.NOMTIPODISEMUEST = "SI";
                                    if (Objetivo.Equals("Maderable")) py.NOMBRETIPOINV = "MD";
                                    else if (Objetivo.Equals("No Maderable")) py.NOMBRETIPOINV = "NM";
                                    py.FECHA = DateTime.Now;
                                    py.TIPOPROYECTO = "CR";
                                    py.NROFORMULA = Guid.Parse("ED52569E-5CFD-454F-9F8B-9429A47C829F");
                                    py.SUPMUE = 0;
                                    py.INTMUE = 0;
                                    py.LIMITINFDAP = 10;
                                    py.USUARIO = user;
                                    py.NROUSUARIO = user.NROUSUARIO;
                                    pyBl.InsertProject(py);
                                    string result = pyBl.SaveChanges();

                                    if (!result.Equals(""))
                                    {
                                        Error_Form errorForm = new Error_Form(result);
                                        ToolStrip menu = bar.GetCurrentParent();
                                        Principal_Form parent = (Principal_Form)menu.Parent;
                                        errorForm.MdiParent = (Form)parent;
                                        errorForm.Show();
                                        return;
                                    }
                                    bar.Increment(1);
                                }

                            }

                            exlRange = hojas_trabajo.UsedRange;

                            this.loadSpecies(bar, 2);

                            //recorremos el archivo para leer las lineas de inventario que estan en el libro
                            hojas_trabajo = (excel.Worksheet)libros_trabajo.Worksheets.get_Item(1);

                            //Definimos el el rango de celdas que seran leidas
                            exlRange = hojas_trabajo.UsedRange;

                            int posStratum = 0, posBloque = 0, posNomCom = 0, posFam = 0, posNomCien = 0, posParcela = 0, posCodCal = 0, posNumArb = 0;
                            //Recorremos el archivo excel como si fuera una matriz
                            string sValor = "";
                            posBloque = 1;
                            posStratum = 2;
                            posParcela = 3;
                            posNumArb = 4;
                            posNomCom = 5;
                            posNomCien = 6;
                            posFam = 7;
                            posCodCal = 11;
                            sValor = "" + (exlRange.Cells[3, posParcela] as excel.Range).Value + "";
                            int Numparcera = int.Parse(sValor); // se obtiene el numero de la parcela inicial

                            //fijar el valor maximo con el numero de registros a insertar en la barra de progreso
                            bar.Value = 0;
                            bar.Maximum = exlRange.Rows.Count - 3;

                            PROYECTO project = new PROYECTO();
                            form = new FORMULARIO();
                            string bloque = "" + (exlRange.Cells[3, posBloque] as excel.Range).Value + ""; // obtenemos el numero o nombre del bloque inicial
                            project = pyBl.GetProjectByPlace(bloque); // obtenermos el proyecto que tiene asociado ese bloque
                            FormBL FBl = new FormBL(Program.ContextData); //Creamos el BL del formulario
                            int numParcelas = 0; // operador que se utiliza para contabilizar cuantas parcelas tiene asociadas el proyecto

                            for (int i = 3; i <= exlRange.Rows.Count; i++)
                            {
                                //obtenemos los datos correspodientes a linea de inventario y formulario
                                string numPar = "" + (exlRange.Cells[i, posParcela] as excel.Range).Value + ""; //obtenemos el numero de la parcela
                                string nomEst = "" + (exlRange.Cells[i, posStratum] as excel.Range).Value + ""; //obtenermos el nombre del estrato
                                string numBloque = "" + (exlRange.Cells[i, posBloque] as excel.Range).Value + ""; //obtenermos obtenemos el numero de bloque

                                //stratum.DESCRIPESTRATO = "" + (exlRange.Cells[i, posStratum] as excel.Range).Value + "";
                                stratum = new ESTRATO(); // creamos una instancia de estrato
                                stratum = stratumBl.GetStratumByDescription(nomEst); // fijamos el estrato obtenido de la base de datos con el nomEst

                                //sql1 = "INSERT INTO FORMULARIO ( NROFORMULARIO, NROUSUARIO, NROPROY, FECHACREACION, LINEA, CODEST, PARCELA) VALUES ( NEWID()," +user.NROUSUARIO+"," +project.NROPROY+"," +  +","+linea+",";
                                //Validamos si estamos en el mismo bloque esto para si se cambio de bloque o proyecto guardarle a este el numero de parcelas, intensidad de muestreo
                                // y superficie muestreada, al igual que abrir el siguiente proyecto con el valor del bloque
                                if (!bloque.Equals(numBloque))
                                {
                                    bloque = numBloque; // fijamos la operador bloque en el  bloque en el que se esta ahora
                                    project.SUPMUE = numParcelas * project.TAMANO;
                                    project.INTMUE = (project.SUPMUE / project.SUPTOT) * 100;
                                    pyBl.UpdateProject(project);
                                    string result = pyBl.SaveChanges();
                                    if (!result.Equals(""))
                                    {
                                        Error_Form errorForm = new Error_Form(result);
                                        ToolStrip menu = bar.GetCurrentParent();
                                        Principal_Form parent = (Principal_Form)menu.Parent;
                                        errorForm.MdiParent = (Form)parent;
                                        errorForm.Show();
                                        return;
                                    }
                                    numParcelas = 0;
                                    project = pyBl.GetProjectByPlace(bloque);
                                }
                                //stratum = Program.ContextData.ESTRATO.;
                                if (stratum == null && nomEst != "" && nomEst != "Estrato simple")
                                {
                                    stratum = new ESTRATO();
                                    stratum.CODEST = (stratumBl.GetStratums()).Count<ESTRATO>() + 1;
                                    stratum.DESCRIPESTRATO = nomEst;
                                    //stratumBl.InsertStratum(stratum);
                                }

                                if (Numparcera != int.Parse(numPar) || i == 3) // se valida si se ha cambiado de numero de parcela esto para crear un nuevo formulario o si se esta en la primera linea para crear el primer formulario
                                {
                                    numParcelas++;
                                    Numparcera = int.Parse(numPar);
                                    form = new FORMULARIO();
                                    form.NROFORMULARIO = Guid.NewGuid();
                                    form.NROUSUARIO = user.NROUSUARIO;
                                    form.NROPROY = project.NROPROY;
                                    form.FECHACREACION = DateTime.Now;
                                    form.LINEA = int.Parse(numBloque);
                                    form.PARCELA = int.Parse(numPar);
                                    if (stratum == null) form.CODEST = null;
                                    else form.CODEST = stratum.CODEST;
                                    //FBl.InsertForm(form);
                                }
                                else
                                { // si esta en la misma parcela ahora hay que validar si el estrato esta en null para crearlo
                                    // se valida si se trata de un estrato diferente en la misma parcela entonces se crea un nuevo formulario con ese estrato
                                    if (project.NOMTIPODISEMUEST == "ES")
                                    {
                                        if (form.CODEST != stratum.CODEST)
                                        {
                                            form = new FORMULARIO();
                                            form.NROFORMULARIO = Guid.NewGuid();
                                            form.NROUSUARIO = user.NROUSUARIO;
                                            form.NROPROY = project.NROPROY;
                                            form.FECHACREACION = DateTime.Now;
                                            form.LINEA = int.Parse(numBloque);
                                            form.PARCELA = int.Parse(numPar);
                                            if (stratum == null) form.CODEST = null;
                                            else form.CODEST = stratum.CODEST;
                                            //FBl.InsertForm(form);
                                        }
                                    }
                                }

                                project.FORMULARIO.Add(form);// asociammos el formulario a el proyecto

                                if (project.NOMTIPODISEMUEST == "ES")
                                {
                                    //Se va asociar el estrato a la lista de estratos del proyecto, validando si este estrato ya se encuentra en la lista entonces no hace nada si no lo agregamos
                                    if (existStratum(stratum, project) == -1)
                                    {
                                        LISTADODEESTRATOS lS = new LISTADODEESTRATOS();
                                        lS.ESTRATO = stratum;
                                        lS.CODEST = stratum.CODEST;
                                        lS.NROPROY = project.NROPROY;
                                        lS.PROYECTO = project;
                                        lS.PESO = this.returnweight(stratum.DESCRIPESTRATO,3); // se lee el excel para saber cual es el peso para ese estrato en ese proyecto
                                        project.LISTADODEESTRATOS.Add(lS);
                                        if (project.LISTADODEESTRATOS.Count >= 2) // cambiamos el tipo de diseño si se tiene  en la lista de estratos 2 o mas
                                        {
                                            project.NOMTIPODISEMUEST = "ES";
                                        }
                                        //pyBl.UpdateProject(project);
                                    }
                                }
                                // se debe cargar el codigo de la especie por eso se leen los datos de nombre cientifico y comun

                                string familia = "" + (exlRange.Cells[i, posFam] as excel.Range).Value + "";
                                string nomCom = "" + (exlRange.Cells[i, posNomCom] as excel.Range).Value + "";
                                string nomCien = "" + (exlRange.Cells[i, posNomCien] as excel.Range).Value + "";

                                specie = new ESPECIE();
                                //se busca la especie por nombre cientifico y nombre comun si no se encuentra una especie se crea con los valores
                                specie = specieBl.GetSpecieByComNameAndScienName(nomCom, nomCien);
                                if (specie == null)
                                {
                                    specie = new ESPECIE();
                                    specie.CODESP = Guid.NewGuid();
                                    //specie.DIAMMINCORTE = 0;
                                    specie.FAMILIA = familia;
                                    specie.GRUPOCOM = "SV";
                                    specie.NOMCIENTIFICO = nomCien;
                                    specie.NOMCOMUN = nomCom;
                                    //specieBl.InsertSpecie(specie);
                                }
                                //Se verifica el listado de las especies asociadas a el proyecto si la especie ya esta en la list no se hace nada si no esta se agrega
                                if (!project.ESPECIE.Contains(specie))
                                {
                                    project.ESPECIE.Add(specie);
                                    //pyBl.UpdateProject(project);// se manda a actualizar el proyecto porque se modifico la lista de especies
                                }
                                //Se van a cargar los datos de la linea de inventario
                                string numArb = "" + (exlRange.Cells[i, posNumArb] as excel.Range).Value + "";
                                LINEAINVENTARIO lineInv = new LINEAINVENTARIO();
                                lineInv.LINEAINV = Guid.NewGuid();
                                lineInv.NROFORMULARIO = form.NROFORMULARIO;
                                lineInv.CODESP = specie.CODESP;
                                lineInv.ESTADO = "AS";

                                int numArbol = -1;
                                bool band = int.TryParse(numArb, out numArbol);
                                if (int.TryParse(numArb, out numArbol))
                                {
                                    lineInv.NROARB = numArbol;
                                    lineInv.TIPOARBOL = "NBF";
                                }
                                else
                                {
                                    int.TryParse(numArb.Remove(numArb.Length - 1), out numArbol);
                                    lineInv.NROARB = numArbol;
                                    lineInv.TIPOARBOL = "BFB";
                                }
                                int j = 8;
                                decimal cap = 0, altCom = 0, altTot = 0;

                                if (Decimal.TryParse(((exlRange.Cells[i, j] as excel.Range).Value + "").Replace(".", ","), out cap)) lineInv.CAP = cap;
                                if (Decimal.TryParse(((exlRange.Cells[i, j + 1] as excel.Range).Value + "").Replace(".", ","), out altTot)) lineInv.ALTTOT_M = altTot;
                                if (Decimal.TryParse(((exlRange.Cells[i, j + 2] as excel.Range).Value + "").Replace(".", ","), out altCom)) lineInv.ALTCOMER_M = altCom;
                                QualityBL quality = new QualityBL(Program.ContextData);
                                lineInv.CODCALIDAD = (quality.getQualityByDescription("Regular")).CODCALIDAD; // si no se especifica la calidad se la coloca por defecto en regular,

                                if (("" + (exlRange.Cells[i, j + 3] as excel.Range).Value + "").Equals("x")) lineInv.CODCALIDAD = (quality.getQualityByDescription("Bueno")).CODCALIDAD; //si la calidad es buena
                                else
                                    if (("" + (exlRange.Cells[i, j + 5] as excel.Range).Value + "").Equals("x")) lineInv.CODCALIDAD = (quality.getQualityByDescription("Malo")).CODCALIDAD;//si la calidad es mala

                                if (("" + (exlRange.Cells[i, j + 6] as excel.Range).Value + "").Equals("x"))   //si la una linea maderable y el uso pertenece a alimenticia
                                {
                                    LINEANOMADERABLES lineInvNM = new LINEANOMADERABLES();
                                    NonTimberLineBL lineInvNMBl = new NonTimberLineBL(Program.ContextData);
                                    TypeUseBL typeUseBl = new TypeUseBL(Program.ContextData);
                                    lineInvNM.LINEANMAD = Guid.NewGuid();
                                    lineInvNM.NROFORMULARIO = form.NROPROY;
                                    lineInvNM.OBSERVACIONES = "" + (exlRange.Cells[i, j + 9] as excel.Range).Value + "";
                                    form.LINEANOMADERABLES.Add(lineInvNM);
                                    lineInvNM.TIPODEUSO.Add(typeUseBl.GetTypeUse("AL"));
                                    form.LINEANOMADERABLES.Add(lineInvNM);
                                    //lineInvNMBl.InsertNonTimberLine(lineInvNM);
                                    //formBl.UpdateForm(form);
                                }
                                else
                                {
                                    if (("" + (exlRange.Cells[i, j + 7] as excel.Range).Value + "").Equals("x")) //si la una linea maderable y el uso pertenece a artesanal
                                    {
                                        LINEANOMADERABLES lineInvNM = new LINEANOMADERABLES();
                                        NonTimberLineBL lineInvNMBl = new NonTimberLineBL(Program.ContextData);
                                        TypeUseBL typeUseBl = new TypeUseBL(Program.ContextData);
                                        lineInvNM.LINEANMAD = Guid.NewGuid();
                                        lineInvNM.NROFORMULARIO = form.NROPROY;
                                        lineInvNM.OBSERVACIONES = (exlRange.Cells[i, j + 9] as excel.Range).Value + "";
                                        form.LINEANOMADERABLES.Add(lineInvNM);
                                        lineInvNM.TIPODEUSO.Add(typeUseBl.GetTypeUse("AR"));
                                        form.LINEANOMADERABLES.Add(lineInvNM);
                                        //lineInvNMBl.InsertNonTimberLine(lineInvNM);
                                        //formBl.UpdateForm(form);
                                    }
                                    else
                                    {
                                        if (("" + (exlRange.Cells[i, j + 8] as excel.Range).Value + "").Equals("x"))  //si la una linea maderable y el uso pertenece a medicinal
                                        {
                                            LINEANOMADERABLES lineInvNM = new LINEANOMADERABLES();
                                            NonTimberLineBL lineInvNMBl = new NonTimberLineBL(Program.ContextData);
                                            TypeUseBL typeUseBl = new TypeUseBL(Program.ContextData);
                                            lineInvNM.LINEANMAD = Guid.NewGuid();
                                            lineInvNM.NROFORMULARIO = form.NROPROY;
                                            lineInvNM.OBSERVACIONES = (exlRange.Cells[i, j + 9] as excel.Range).Value + "";
                                            form.LINEANOMADERABLES.Add(lineInvNM);
                                            lineInvNM.TIPODEUSO.Add(typeUseBl.GetTypeUse("MD"));
                                            form.LINEANOMADERABLES.Add(lineInvNM);
                                            //lineInvNMBl.InsertNonTimberLine(lineInvNM);
                                            //formBl.UpdateForm(form);
                                        }
                                    }
                                }

                                lineInv.DAP = lineInv.CAP / Convert.ToDecimal(Math.PI);
                                lineInv.AREABASAL = (lineInv.DAP * lineInv.DAP) * (Convert.ToDecimal(Math.PI) / 4);
                                lineInv.VOLTOT = (lineInv.ALTTOT_M * lineInv.AREABASAL * project.FACTORDEFORMA);
                                lineInv.VOLCOM = (lineInv.ALTCOMER_M * lineInv.AREABASAL * project.FACTORDEFORMA);
                                form.LINEAINVENTARIO.Add(lineInv);

                                string result1 = lineInvBl.SaveChanges();
                                if (!result1.Equals(""))
                                {
                                    Error_Form errorForm = new Error_Form(result1);
                                    ToolStrip menu = bar.GetCurrentParent();
                                    Principal_Form parent = (Principal_Form)menu.Parent;
                                    errorForm.MdiParent = (Form)parent;
                                    errorForm.Show();
                                    return;
                                }
                                //lineInvBl.InsertInventoryLine(lineInv);
                                //lineInvBl.SaveChanges();
                                bar.Increment(1);

                                //sql = "INSERT INTO LINEAINVENTARIO ( LINEAINV, NROFORMULARIO, CODCALIDAD, ESTADO, CODESP, NROARB, ALTCOMER_M, ALTTOT_M, AREABASAL, VOLCOM, VOLTOT, CAP, DAP, TIPOARBOL) VALUES ( NEWID(), '";
                            }
                            if (numParcelas > 0)
                            {
                                project.SUPMUE = numParcelas * project.TAMANO;
                                project.INTMUE = (project.SUPMUE / project.SUPTOT) * 100;
                                pyBl.UpdateProject(project);
                                string result = pyBl.SaveChanges();
                                if (!result.Equals(""))
                                {
                                    Error_Form errorForm = new Error_Form(result);
                                    ToolStrip menu = bar.GetCurrentParent();
                                    Principal_Form parent = (Principal_Form)menu.Parent;
                                    errorForm.MdiParent = (Form)parent;
                                    errorForm.Show();
                                    return;
                                }
                                numParcelas = 0;
                            }
                            MessageBox.Show("Los datos se importaron correctamente", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            bar.Visible = false;
                            //cerramos el libro y la aplicacion
                            libros_trabajo.Close();
                            aplicacion.Quit();
                        }
                        bar.Visible = false;
                    }
                    catch (Exception ex)
                    {
                        bar.Visible = false;
                        Error_Form errorForm = new Error_Form(ex.Message);
                        ToolStrip menu = bar.GetCurrentParent();
                        Principal_Form parent = (Principal_Form)menu.Parent;
                        errorForm.MdiParent = (Form)parent;
                        errorForm.Show();
                    }

                }
                else MessageBox.Show("Ningun usuario ha iniciado sesion. Por favor inicie session.", "Operacion invalida", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                bar.Visible = false;
                Error_Form errorForm = new Error_Form(ex.Message);
                ToolStrip menu = bar.GetCurrentParent();
                Principal_Form parent = (Principal_Form)menu.Parent;
                errorForm.MdiParent = (Form)parent;
                errorForm.Show();
            }
        }
Пример #4
0
 private bool loadProject(int p)
 {
     hojas_trabajo = (excel.Worksheet)libros_trabajo.Worksheets.get_Item(p);
     exlRange = hojas_trabajo.UsedRange;
     for (int i = 2; i <= exlRange.Rows.Count; i++)
     {
         string lugar = "" + (exlRange.Cells[i, 1] as excel.Range).Value + "";
         string tamanioParcela = "" + (exlRange.Cells[i, 2] as excel.Range).Value + "";
         string tamanioSupTotal = "" + (exlRange.Cells[i, 3] as excel.Range).Value + "";
         string areaderegeneracion = "" + (exlRange.Cells[i, 4] as excel.Range).Value + "";
         string factorForma = "" + (exlRange.Cells[i, 5] as excel.Range).Value + "";
         string descripcion = "" + (exlRange.Cells[i, 7] as excel.Range).Value + "";
         string TipoDisenio = "" + (exlRange.Cells[i, 8] as excel.Range).Value + "";
         string Objetivo = "" + (exlRange.Cells[i, 9] as excel.Range).Value + "";
         string confianza = "" + (exlRange.Cells[i, 10] as excel.Range).Value + "";
         string tamanioMuestra = "" + (exlRange.Cells[i, 11] as excel.Range).Value + "";
         if (pyBl.GetProjectByPlace(lugar) == null)
         {
             // area muestreada = multiplicar el numero de parcelas por el tamaño de la parcela
             // intensidad de muestreo = dividir el area muestreada entre el tamaño total del area a muestrear
             newProject = new PROYECTO();
             newProject.NROPROY = Guid.NewGuid();
             newProject.LUGAR = lugar;
             decimal tam = 0, factor = 0, tamSupTotal = 0, conf = 0, tamMuestra = 0;
             int areaReg = 0;
             decimal.TryParse(tamanioParcela.Replace(".", ","), out tam);
             newProject.TAMANO = tam;
             decimal.TryParse(tamanioSupTotal.Replace(".", ","), out tamSupTotal);
             newProject.SUPTOT = tamSupTotal;
             int.TryParse(areaderegeneracion, out areaReg);
             newProject.AREAFUSTALESPORPARCELA = areaReg;
             decimal.TryParse(factorForma.Replace(".", ","), out factor);
             newProject.FACTORDEFORMA = factor;
             newProject.ETAPA = 0;
             newProject.DESCRIPCION = descripcion;
             decimal.TryParse(confianza.Replace(".", ","), out conf);
             newProject.CONFIANZA = conf;
             TypeSampleDesignBl desingType = new TypeSampleDesignBl(Program.ContextData);
             ObjectiveInventoryBL objInvBl = new ObjectiveInventoryBL(Program.ContextData);
             if (TipoDisenio.Equals("Estratificado")) newProject.NOMTIPODISEMUEST = "ES";
             else if (TipoDisenio.Equals("Simple")) newProject.NOMTIPODISEMUEST = "SI";
             if (Objetivo.Equals("Maderable")) newProject.NOMBRETIPOINV = "MD";
             else if (Objetivo.Equals("No Maderable")) newProject.NOMBRETIPOINV = "NM";
             decimal.TryParse(tamanioMuestra.Replace(".", ","), out tamMuestra);
             newProject.NUMEROPARCELASAMUESTREAR = tamMuestra;
             newProject.FECHA = DateTime.Now;
             newProject.TIPOPROYECTO = "CR";
             newProject.NROFORMULA = Guid.Parse("ED52569E-5CFD-454F-9F8B-9429A47C829F");
             newProject.SUPMUE = 0;
             newProject.INTMUE = 0;
             newProject.LIMITINFDAP = 0.1m;
             newProject.USUARIO = user;
             newProject.NROUSUARIO = user.NROUSUARIO;
             pyBl.InsertProject(newProject);
             return true;
         }
         else
         {
             DialogResult myResult = MessageBox.Show("El proyecto que quiere importar se encuentra en el sistema ¿Desea continuar con la importación de datos?", "Mensaje de confirmacion", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
             if (myResult == DialogResult.OK)
             {
                 newProject = pyBl.GetProjectByPlace(lugar);
                 return true;
             }
         }
     }
     return false;
 }
Пример #5
0
        public Actualizar_Proyectos_Form()
        {
            try
            {
                InitializeComponent();
                this.ControlBox = false;
                project = new ProjectBL(Program.ContextData);
                typeExample = new TypeSampleDesignBl(Program.ContextData);
                objetiveInventory = new ObjectiveInventoryBL(Program.ContextData);
                stratum = new StratumBL(Program.ContextData);
                species = new SpeciesBL(Program.ContextData);
                form = new FormBL(Program.ContextData);
                formulateBL = new FormulateBL(Program.ContextData);
                costBL = new CostBL(Program.ContextData);

                PROYECTO p = (PROYECTO)Program.Cache.Get("project");

                proyectoBS.DataSource = p;

                proyectosBS.DataSource = project.GetProjects(p);
                proyectoDGW.DataSource = proyectosBS;

                objetivoInventarioBS.DataSource = objetiveInventory.GetObjectiveInventories();
                tipoObjetivoCbx.DataSource = objetivoInventarioBS;
                List<KeyValuePair<string, string>> data = new List<KeyValuePair<string, string>>();
                data.Add(new KeyValuePair<string, string>("IN", "Independiente"));
                data.Add(new KeyValuePair<string, string>("CR", "Contenedor"));
                TipoProyectoCbx.DataSource = data;
                TipoProyectoCbx.DisplayMember = "Value";
                TipoProyectoCbx.ValueMember = "Key";
                TipoProyectoCbx.SelectedValue = p.TIPOPROYECTO;

                criterioCbx.SelectedIndex = 0;
                tipoDisenoBS.DataSource = typeExample.GetTypeSampleDesignList();
                tipoDisenoCbx.DataSource = tipoDisenoBS;

                especieBS.DataSource = species.GetSpecies();
                especiesDGW.DataSource = especieBS;

                formulariosBS.DataSource = p.FORMULARIO;
                formulariosDGW.DataSource = formulariosBS;

                costoBS.DataSource = costBL.GetCosts();
                costoDGW.DataSource = costoBS;

                //formulaBS.DataSource = formulateBL.GetFormulates();
                //formularComboBox.DataSource = formulaBS;
                formularComboBox.DataSource = formulateBL.GetFormulates();
                formularComboBox.SelectedValue = p.NROFORMULA;

                //formularComboBox.SelectedItem = p.FORMULA;
                expresionTxt.Text = p.FORMULA.EXPRESION;

                estratoBS.DataSource = stratum.GetStratums();
                estratoDGW.DataSource = estratoBS;

                numeroEtapasTxt.Text = p.ETAPA.ToString();

                confianzaTxt.Text = p.CONFIANZA.ToString();
                tamParcelaTxt.Text = p.TAMANO.ToString();
                numeroParcelasTxt.Text = p.NUMEROPARCELAS.ToString();
                numeroParcelasMuestraTxt.Text = p.NUMEROPARCELASAMUESTREAR.ToString();
                limiteInfTxt.Text = p.LIMITINFDAP.ToString();
                intMuestreoTxt.Text = p.INTMUE.ToString();
                AreaTotalTxt.Text = p.SUPTOT.ToString();
                areaMuestrearTxt.Text = p.SUPMUE.ToString();
                areaFustalesTxt.Text = p.AREAFUSTALESPORPARCELA.ToString();
                factorFormaTxt.Text = p.FACTORDEFORMA.ToString();

                this.modificate = false;
            }
            catch (Exception ex)
            {
                Error_Form errorForm = new Error_Form(ex.Message);
                errorForm.MdiParent = ParentForm;
                errorForm.Show();
            }
        }
Пример #6
0
        public Ver_Reporte_Form(List<SampleDesignItem> datos, List<string> opciones)
        {
            InitializeComponent();
            try
            {
                tStudentTable = new TStudentBL(Program.ContextData);
                stratums = new StratumBL(Program.ContextData);
                project = new PROYECTO();
                PROYECTO currentProject = (PROYECTO)Program.Cache.Get("project");
                //Cargando datos del proyecto al reporte
                if (project != null)
                {
                    TypeSampleDesignBl tipoDiseno = new TypeSampleDesignBl(Program.ContextData);
                    ObjectiveInventoryBL objetivoInventario = new ObjectiveInventoryBL(Program.ContextData);
                    project.NOMTIPODISEMUEST = tipoDiseno.GetTypeSampleDesign(currentProject.NOMTIPODISEMUEST).DESCRIPTIPODISEMUEST;
                    project.NOMBRETIPOINV = objetivoInventario.GetObjectiveInventory(currentProject.NOMBRETIPOINV).DESCRIPOBJETINV;
                    project.INTMUE = Math.Round(currentProject.INTMUE, 3);
                    project.TAMANO = Math.Round(currentProject.TAMANO, 3);
                    project.DESCRIPCION = currentProject.DESCRIPCION;
                    project.LUGAR = currentProject.LUGAR;
                    project.FECHA = currentProject.FECHA;
                    project.SUPMUE = Math.Round(currentProject.SUPMUE, 3);
                    project.SUPTOT = Math.Round(currentProject.SUPTOT, 3);
                    Decimal confianza = currentProject.CONFIANZA != null ? (decimal)currentProject.CONFIANZA : 0;
                    project.CONFIANZA = Math.Round(confianza, 3);
                    this.estratificado = currentProject.LISTADODEESTRATOS.Count != 0 ? true : false;
                    proyectoBS.DataSource = project;
                }
                Dictionary<string, object> resultados = new Dictionary<string, object>();
                if (datos.Count != 0)
                {
                    double tamanoParcela = project != null ? (double)project.TAMANO : 1;
                    double totalParcelas = project != null ? (int)(project.SUPTOT / project.TAMANO) : 0;
                    int totalParcelasMuestra = datos.Count;
                    double superficieTotal =  project != null ?(double)project.SUPTOT:0;
                    RESULTADOMUESTREO resultado;
                    TOTALESMUESTREOESTRATIFICADOS totales;
                    TSTUDENT resulttStudent = tStudentTable.GetTStudent((decimal)(1 - currentProject.CONFIANZA / 100), (totalParcelasMuestra - 1));
                    TSTUDENT tStudent = resulttStudent != null ? resulttStudent : new TSTUDENT();
                    if (!estratificado)
                    {
                        //
                        SampleDesign diseno = new SampleDesign(currentProject, tStudent, datos, totalParcelasMuestra, totalParcelas, 0);
                        resultados = diseno.Execute(0);
                        //Cargando resultado de los datos al reporte
                        if (opciones.Contains("NA"))
                        {
                            resultado = new RESULTADOMUESTREO();
                            resultado.VARIABLE = "Numero de arboles (#)";
                            resultado.TOTAL = superficieTotal * Math.Round((double)resultados["Mean"], 3);
                            resultado.PROMEDIO = Math.Round((double)resultados["Mean"], 3);
                            resultado.DESVIACIONESTANDAR = Math.Round((double)resultados["StandardDeviation"], 3);
                            resultado.COEFICIENTEDEVARIACION = Math.Round((double)resultados["VariationCoefficient"], 3);
                            resultado.ERRORDESVIACION = Math.Round((double)resultados["StandardError"], 3);
                            resultado.ERRORABSOLUTOMUESTREO = Math.Round((double)resultados["AbsoulteErrorSample"], 3);
                            resultado.LIMITEINF = Math.Round((double)resultados["LowLimit"], 3);
                            resultado.LIMITESUP = Math.Round((double)resultados["HightLimit"], 3);
                            resultado.ERRORRELATIVO = Math.Round((double)resultados["RelativeErrorSample"], 3);
                            resultadosBS.Add(resultado);
                        }
                        if (opciones.Contains("AB"))
                        {
                            resultados = diseno.Execute(3);
                            resultado = new RESULTADOMUESTREO();
                            resultado.VARIABLE = "Area Basal (Mtrs2)";
                            resultado.TOTAL = superficieTotal * Math.Round((double)resultados["Mean"], 3);
                            resultado.PROMEDIO = Math.Round((double)resultados["Mean"], 3);
                            resultado.DESVIACIONESTANDAR = Math.Round((double)resultados["StandardDeviation"], 3);
                            resultado.COEFICIENTEDEVARIACION = Math.Round((double)resultados["VariationCoefficient"], 3);
                            resultado.ERRORDESVIACION = Math.Round((double)resultados["StandardError"], 3);
                            resultado.ERRORABSOLUTOMUESTREO = Math.Round((double)resultados["AbsoulteErrorSample"], 3);
                            resultado.LIMITEINF = Math.Round((double)resultados["LowLimit"], 3);
                            resultado.LIMITESUP = Math.Round((double)resultados["HightLimit"], 3);
                            resultado.ERRORRELATIVO = Math.Round((double)resultados["RelativeErrorSample"], 3);
                            resultadosBS.Add(resultado);
                        }
                        if (opciones.Contains("VC"))
                        {
                            resultados = diseno.Execute(1);
                            resultado = new RESULTADOMUESTREO();
                            resultado.VARIABLE = "Volumen Comercial (Mtrs3)";
                            resultado.TOTAL = superficieTotal * Math.Round((double)resultados["Mean"], 3);
                            resultado.PROMEDIO = Math.Round((double)resultados["Mean"], 3);
                            resultado.DESVIACIONESTANDAR = Math.Round((double)resultados["StandardDeviation"], 3);
                            resultado.COEFICIENTEDEVARIACION = Math.Round((double)resultados["VariationCoefficient"], 3);
                            resultado.ERRORDESVIACION = Math.Round((double)resultados["StandardError"], 3);
                            resultado.ERRORABSOLUTOMUESTREO = Math.Round((double)resultados["AbsoulteErrorSample"], 3);
                            resultado.LIMITEINF = Math.Round((double)resultados["LowLimit"], 3);
                            resultado.LIMITESUP = Math.Round((double)resultados["HightLimit"], 3);
                            resultado.ERRORRELATIVO = Math.Round((double)resultados["RelativeErrorSample"], 3);
                            resultadosBS.Add(resultado);
                        }
                        if (opciones.Contains("VT"))
                        {
                            resultados = diseno.Execute(2);
                            resultado = new RESULTADOMUESTREO();
                            resultado.VARIABLE = "Volumen Total (Mtrs3)";
                            resultado.TOTAL = superficieTotal * Math.Round((double)resultados["Mean"], 3);
                            resultado.PROMEDIO = Math.Round((double)resultados["Mean"], 3);
                            resultado.DESVIACIONESTANDAR = Math.Round((double)resultados["StandardDeviation"], 3);
                            resultado.COEFICIENTEDEVARIACION = Math.Round((double)resultados["VariationCoefficient"], 3);
                            resultado.ERRORDESVIACION = Math.Round((double)resultados["StandardError"], 3);
                            resultado.ERRORABSOLUTOMUESTREO = Math.Round((double)resultados["AbsoulteErrorSample"], 3);
                            resultado.LIMITEINF = Math.Round((double)resultados["LowLimit"], 3);
                            resultado.LIMITESUP = Math.Round((double)resultados["HightLimit"], 3);
                            resultado.ERRORRELATIVO = Math.Round((double)resultados["RelativeErrorSample"], 3);
                            resultadosBS.Add(resultado);
                        }
                    }
                    else
                    {
                        //Cargar datos del analisis de los datos estratificados al proyecto
                        SampleDesign diseno = new SampleDesign(currentProject, tStudent, datos, totalParcelasMuestra, totalParcelas, 1);
                        //Cargando resultado de los datos al reporte
                        Dictionary<string, object> resultadosTemporales = null;
                        if (opciones.Contains("NA"))
                        {
                            resultados = diseno.Execute(0);
                            foreach (KeyValuePair<string, object> resultStratum in resultados)
                            {
                                resultadosTemporales = (Dictionary<string, object>)resultStratum.Value;
                                resultado = new RESULTADOMUESTREO();
                                if (resultStratum.Key != "totales")
                                {
                                    ESTRATO stratum = stratums.GetStratum(int.Parse(resultStratum.Key));
                                    resultado.ESTRATO = stratum != null ? stratum.DESCRIPESTRATO : resultStratum.Key;
                                    resultado.PESOESTRATO = Math.Round((double)resultadosTemporales["Weight"], 3);
                                    resultado.VARIABLE = "Numero de arboles (#)";
                                    resultado.N = resultadosTemporales["N"].ToString();
                                    resultado.TOTAL = totalParcelas * Math.Round((double)resultadosTemporales["Mean"], 3);
                                    resultado.TOTALPORHECTAREA = resultado.TOTAL / (double)currentProject.SUPTOT;
                                    resultado.PROMEDIO = Math.Round((double)resultadosTemporales["Mean"], 3);
                                    resultado.DESVIACIONESTANDAR = Math.Round((double)resultadosTemporales["StandardDeviation"], 3);
                                    resultado.COEFICIENTEDEVARIACION = Math.Round((double)resultadosTemporales["VariationCoefficient"], 3);
                                    resultado.ERRORDESVIACION = Math.Round((double)resultadosTemporales["StandardError"], 3);
                                    resultado.ERRORABSOLUTOMUESTREO = Math.Round((double)resultadosTemporales["AbsoulteErrorSample"], 3);
                                    resultado.LIMITEINF = Math.Round((double)resultadosTemporales["LowLimit"], 3);
                                    resultado.LIMITESUP = Math.Round((double)resultadosTemporales["HightLimit"], 3);
                                    resultado.ERRORRELATIVO = Math.Round((double)resultadosTemporales["RelativeErrorSample"], 3);
                                    resultadosBS.Add(resultado);
                                }
                            }
                            //TODO:añadir total los cuales se encuntran al final
                            resultadosTemporales = (Dictionary<string, object>)resultados.Last().Value;
                            totales = new TOTALESMUESTREOESTRATIFICADOS();
                            totales.VARIABLE = "Numero de arboles (#)";
                            totales.TOTALPROMEDIOESTRATIFICADO = Math.Round((double)resultadosTemporales["Mean"], 3);
                            totales.TOTALDESESTANDARESTRATIFICADO = Math.Round((double)resultadosTemporales["StandardError"], 3);
                            totales.TOTALERRORMUESTREO = Math.Round((double)resultadosTemporales["AbsoulteErrorSample"], 3);
                            totales.TOTALERRRORELATIVO = Math.Round((double)resultadosTemporales["RelativeErrorSample"], 3);
                            totalEstratificadoBS.Add(totales);
                        }
                        if (opciones.Contains("AB"))
                        {
                            resultados = diseno.Execute(3);
                            //Cargando resultado de los datos al reporte
                            foreach (KeyValuePair<string, object> resultStratum in resultados)
                            {
                                resultadosTemporales = (Dictionary<string, object>)resultStratum.Value;
                                resultado = new RESULTADOMUESTREO();
                                if (resultStratum.Key != "totales")
                                {
                                    ESTRATO stratum = stratums.GetStratum(int.Parse(resultStratum.Key));
                                    resultado.ESTRATO = stratum != null ? stratum.DESCRIPESTRATO : resultStratum.Key;
                                    resultado.PESOESTRATO = Math.Round((double)resultadosTemporales["Weight"], 3);
                                    resultado.N = resultadosTemporales["N"].ToString();
                                    resultado.VARIABLE = "Area Basal (Mtrs2)";
                                    resultado.TOTAL = totalParcelas * Math.Round((double)resultadosTemporales["Mean"], 3);
                                    resultado.TOTALPORHECTAREA = resultado.TOTAL / (double)currentProject.SUPTOT;
                                    resultado.PROMEDIO = Math.Round((double)resultadosTemporales["Mean"], 3);
                                    resultado.DESVIACIONESTANDAR = Math.Round((double)resultadosTemporales["StandardDeviation"], 3);
                                    resultado.COEFICIENTEDEVARIACION = Math.Round((double)resultadosTemporales["VariationCoefficient"], 3);
                                    resultado.ERRORDESVIACION = Math.Round((double)resultadosTemporales["StandardError"], 3);
                                    resultado.ERRORABSOLUTOMUESTREO = Math.Round((double)resultadosTemporales["AbsoulteErrorSample"], 3);
                                    resultado.LIMITEINF = Math.Round((double)resultadosTemporales["LowLimit"], 3);
                                    resultado.LIMITESUP = Math.Round((double)resultadosTemporales["HightLimit"], 3);
                                    resultado.ERRORRELATIVO = Math.Round((double)resultadosTemporales["RelativeErrorSample"], 3);
                                    resultadosBS.Add(resultado);
                                }
                            }
                            resultadosTemporales = (Dictionary<string, object>)resultados.Last().Value;
                            totales = new TOTALESMUESTREOESTRATIFICADOS();
                            totales.VARIABLE = "Area Basal (Mtrs2)";
                            totales.TOTALPROMEDIOESTRATIFICADO = Math.Round((double)resultadosTemporales["Mean"], 3);
                            totales.TOTALDESESTANDARESTRATIFICADO = Math.Round((double)resultadosTemporales["StandardError"], 3);
                            totales.TOTALERRORMUESTREO = Math.Round((double)resultadosTemporales["AbsoulteErrorSample"], 3);
                            totales.TOTALERRRORELATIVO = Math.Round((double)resultadosTemporales["RelativeErrorSample"], 3);
                            totalEstratificadoBS.Add(totales);
                        }
                        if (opciones.Contains("VC"))
                        {
                            resultados = diseno.Execute(1);
                            //Cargando resultado de los datos al reporte
                            foreach (KeyValuePair<string, object> resultStratum in resultados)
                            {
                                resultadosTemporales = (Dictionary<string, object>)resultStratum.Value;
                                resultado = new RESULTADOMUESTREO();
                                if (resultStratum.Key != "totales")
                                {
                                    ESTRATO stratum = stratums.GetStratum(int.Parse(resultStratum.Key));
                                    resultado.ESTRATO = stratum != null ? stratum.DESCRIPESTRATO : resultStratum.Key;
                                    resultado.PESOESTRATO = Math.Round((double)resultadosTemporales["Weight"], 3);
                                    resultado.N =resultadosTemporales["N"].ToString();
                                    resultado.VARIABLE = "Volumen Comercial (Mtrs3)";
                                    resultado.TOTAL = totalParcelas * Math.Round((double)resultadosTemporales["Mean"], 3);
                                    resultado.TOTALPORHECTAREA = resultado.TOTAL / (double)currentProject.SUPTOT;
                                    resultado.PROMEDIO = Math.Round((double)resultadosTemporales["Mean"], 3);
                                    resultado.DESVIACIONESTANDAR = Math.Round((double)resultadosTemporales["StandardDeviation"], 3);
                                    resultado.COEFICIENTEDEVARIACION = Math.Round((double)resultadosTemporales["VariationCoefficient"], 3);
                                    resultado.ERRORDESVIACION = Math.Round((double)resultadosTemporales["StandardError"], 3);
                                    resultado.ERRORABSOLUTOMUESTREO = Math.Round((double)resultadosTemporales["AbsoulteErrorSample"], 3);
                                    resultado.LIMITEINF = Math.Round((double)resultadosTemporales["LowLimit"], 3);
                                    resultado.LIMITESUP = Math.Round((double)resultadosTemporales["HightLimit"], 3);
                                    resultado.ERRORRELATIVO = Math.Round((double)resultadosTemporales["RelativeErrorSample"], 3);
                                    resultadosBS.Add(resultado);
                                }
                            }
                            resultadosTemporales = (Dictionary<string, object>)resultados.Last().Value;
                            totales = new TOTALESMUESTREOESTRATIFICADOS();
                            totales.VARIABLE = "Volumen Comercial (Mtrs3)";
                            totales.TOTALPROMEDIOESTRATIFICADO = Math.Round((double)resultadosTemporales["Mean"], 3);
                            totales.TOTALDESESTANDARESTRATIFICADO = Math.Round((double)resultadosTemporales["StandardError"], 3);
                            totales.TOTALERRORMUESTREO = Math.Round((double)resultadosTemporales["AbsoulteErrorSample"], 3);
                            totales.TOTALERRRORELATIVO = Math.Round((double)resultadosTemporales["RelativeErrorSample"], 3);
                            totalEstratificadoBS.Add(totales);
                        }
                        if (opciones.Contains("VT"))
                        {
                            resultados = diseno.Execute(2);
                            //Cargando resultado de los datos al reporte
                            foreach (KeyValuePair<string, object> resultStratum in resultados)
                            {
                                resultadosTemporales = (Dictionary<string, object>)resultStratum.Value;
                                resultado = new RESULTADOMUESTREO();
                                if (resultStratum.Key != "totales")
                                {
                                    ESTRATO stratum = stratums.GetStratum(int.Parse(resultStratum.Key));
                                    resultado.ESTRATO = stratum != null ? stratum.DESCRIPESTRATO : resultStratum.Key;
                                    resultado.PESOESTRATO = Math.Round((double)resultadosTemporales["Weight"], 3);
                                    resultado.N = resultadosTemporales["N"].ToString();
                                    resultado.VARIABLE = "Volumen Total (Mtrs3)";
                                    resultado.TOTAL = totalParcelas * Math.Round((double)resultadosTemporales["Mean"], 3);
                                    resultado.TOTALPORHECTAREA = resultado.TOTAL / (double)currentProject.SUPTOT;
                                    resultado.PROMEDIO = Math.Round((double)resultadosTemporales["Mean"], 3);
                                    resultado.DESVIACIONESTANDAR = Math.Round((double)resultadosTemporales["StandardDeviation"], 3);
                                    resultado.COEFICIENTEDEVARIACION = Math.Round((double)resultadosTemporales["VariationCoefficient"], 3);
                                    resultado.ERRORDESVIACION = Math.Round((double)resultadosTemporales["StandardError"], 3);
                                    resultado.ERRORABSOLUTOMUESTREO = Math.Round((double)resultadosTemporales["AbsoulteErrorSample"], 3);
                                    resultado.LIMITEINF = Math.Round((double)resultadosTemporales["LowLimit"], 3);
                                    resultado.LIMITESUP = Math.Round((double)resultadosTemporales["HightLimit"], 3);
                                    resultado.ERRORRELATIVO = Math.Round((double)resultadosTemporales["RelativeErrorSample"], 3);
                                    resultadosBS.Add(resultado);
                                }
                            }
                            resultadosTemporales = (Dictionary<string, object>)resultados.Last().Value;
                            totales = new TOTALESMUESTREOESTRATIFICADOS();
                            totales.VARIABLE = "Volumen Total (Mtrs3)";
                            totales.TOTALPROMEDIOESTRATIFICADO = Math.Round((double)resultadosTemporales["Mean"], 3);
                            totales.TOTALDESESTANDARESTRATIFICADO = Math.Round((double)resultadosTemporales["StandardError"], 3);
                            totales.TOTALERRORMUESTREO = Math.Round((double)resultadosTemporales["AbsoulteErrorSample"], 3);
                            totales.TOTALERRRORELATIVO = Math.Round((double)resultadosTemporales["RelativeErrorSample"], 3);
                            totalEstratificadoBS.Add(totales);
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                Error_Form er = new Error_Form(ex.Message);
                er.MdiParent = this.MdiParent;
                er.Show();
            }
        }
Пример #7
0
 public Ver_Reporte_Form()
 {
     InitializeComponent();
     tStudentTable = new TStudentBL(Program.ContextData);
     stratums = new StratumBL(Program.ContextData);
     project = new PROYECTO();
     PROYECTO currentProject = (PROYECTO)Program.Cache.Get("project");
     //Cargando datos del proyecto al reporte
     if (currentProject != null)
     {
         TypeSampleDesignBl tipoDiseno = new TypeSampleDesignBl(Program.ContextData);
         ObjectiveInventoryBL objetivoInventario = new ObjectiveInventoryBL(Program.ContextData);
         project.NOMTIPODISEMUEST = tipoDiseno.GetTypeSampleDesign(currentProject.NOMTIPODISEMUEST).DESCRIPTIPODISEMUEST;
         project.NOMBRETIPOINV = objetivoInventario.GetObjectiveInventory(currentProject.NOMBRETIPOINV).DESCRIPOBJETINV;
         project.INTMUE = Math.Round(currentProject.INTMUE, 3);
         project.TAMANO = Math.Round(currentProject.TAMANO, 3);
         project.DESCRIPCION = currentProject.DESCRIPCION;
         project.LUGAR = currentProject.LUGAR;
         project.FECHA = currentProject.FECHA;
         project.SUPMUE = Math.Round(currentProject.SUPMUE, 3);
         project.SUPTOT = Math.Round(currentProject.SUPTOT, 3);
         Decimal confianza = currentProject.CONFIANZA != null ? (decimal)currentProject.CONFIANZA : 0;
         project.CONFIANZA = Math.Round(confianza, 3);
         proyectoBS.DataSource = project;
     }
 }