/// <summary> /// Constructor para inicializar atributos y elementos del formulario /// </summary> public Especies_Form() { try { species = new ESPECIE(); specieBL = new SpeciesBL(Program.ContextData); group = new GroupBL(Program.ContextData); InitializeComponent(); pn_listado.Show(); pn_crear.Hide(); pn_editar.Hide(); pn_detalle.Hide(); pn_cargarImg.Hide(); specieBSource.DataSource = specieBL.GetSpecies(); grupoComercialBSource.DataSource = group.GetGroups(); criterioCbx.SelectedIndex = 1; grupoEcoCbx.SelectedIndex = 0; state = "especie"; //this.txt_DMC.Text="0,5"; this.project = null; } catch (Exception ex) { Error_Form er = new Error_Form(ex.Message); er.Show(); } }
public Listar_Datos_Formulario_Form(FORMULARIO form, int selectIndex) { InitializeComponent(); specie = new SpeciesBL(Program.ContextData); quality = new QualityBL(Program.ContextData); state = new StateBL(Program.ContextData); notimberLine = new NonTimberLineBL(Program.ContextData); inventoryLine = new InventoryLineBL (Program.ContextData); regenerationLine = new RegenerationLineBL(Program.ContextData); this.form = form; especieBS.DataSource = specie.GetSpecies(); calidadBS.DataSource = quality.GetQualities(); estadoSanitarioBS.DataSource = state.GetStates(); lineaInventarioBS.DataSource = form.LINEAINVENTARIO.Count == 0 ? new List<LINEAINVENTARIO>() : form.LINEAINVENTARIO; lineaInventarioDGW.DataSource = lineaInventarioBS; regeneracionBS.DataSource = form.LINEAREGENERACION.Count == 0 ? new List<LINEAREGENERACION>() : form.LINEAREGENERACION; regeneracionDGW.DataSource = regeneracionBS; noMaderablesBS.DataSource = form.LINEANOMADERABLES.Count == 0 ? new List<LINEANOMADERABLES>() : form.LINEANOMADERABLES; noMaderablesDGW.DataSource = noMaderablesBS; criterioInvCbx.SelectedIndex = 0; criterioNoMaderCbx.SelectedIndex = 0; criterioRegenCbx.SelectedIndex = 0; lineasTab.SelectedIndex = selectIndex; }
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 Crear_Editar_Formulario_Form(FORMULARIO f) { InitializeComponent(); modified = false; if (f == null) newForm = new FORMULARIO(); else newForm = f; project = new ProjectBL(Program.ContextData); species = new SpeciesBL(Program.ContextData); stratums = new StratumBL(Program.ContextData); quality = new QualityBL(Program.ContextData); state = new StateBL(Program.ContextData); form = new FormBL(Program.ContextData); lineInv = new InventoryLineBL(Program.ContextData); lineRegen = new RegenerationLineBL(Program.ContextData); lineNonTimber = new NonTimberLineBL(Program.ContextData); typeUses = new TypeUseBL(Program.ContextData); int countEspecies = ((PROYECTO)Program.Cache.Get("project")).ESPECIE.ToList().Count; if (countEspecies != 0) especieBS.DataSource = ((PROYECTO)Program.Cache.Get("project")).ESPECIE.ToList().OrderBy(e => e.NOMCOMUN); else { MessageBox.Show("No existen especies asociadas a este proyecto, seleccione uno o mas especies.", "Parametros insuficiente.", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } List<ESTRATO> listStratums = new List<ESTRATO>(); foreach(LISTADODEESTRATOS list in ((PROYECTO)Program.Cache.Get("project")).LISTADODEESTRATOS) { listStratums.Add(list.ESTRATO); } estratoBS.DataSource =listStratums; if (estratoBS.Count != 0) estratoCbx.SelectedItem = (ESTRATO)estratoBS.Current; else estratoBS.Add(new ESTRATO() { DESCRIPESTRATO = "Diseño muestral simple." }); calidadBS.DataSource = quality.GetQualities(); estadoSanitarioBS.DataSource = state.GetStates(); tipoUsoBS.DataSource=typeUses.GetTypeUse(); tipoDeUsosLbc.DataSource = tipoUsoBS; tipoDeUsosLbc.DisplayMember ="DESCRIPCION"; tipoDeUsosLbc.ValueMember = "NOMBRETIPOUSO"; List<KeyValuePair<string, string>> data = new List<KeyValuePair<string, string>>(); data.Add(new KeyValuePair<string, string>("BFB", "Bifurcacion Abajo de la A.P.")); data.Add(new KeyValuePair<string, string>("NBF", "Ninguna Bifurcacion")); tipoArbolCbx.DataSource = data; tipoArbolCbx.DisplayMember = "Value"; tipoArbolCbx.ValueMember = "Key"; tipoArbolCbx.SelectedValue = "NBF"; newLineNoTimber = new LINEANOMADERABLES(); if (f == null) { noMaderableBS.DataSource = new List<LINEANOMADERABLES>(); regeneracionBS.DataSource = new List<LINEAREGENERACION>(); lineaInvBS.DataSource = new List<LINEAINVENTARIO>(); USUARIO user = (USUARIO)Program.Cache.Get("user"); PROYECTO p = (PROYECTO)Program.Cache.Get("project"); responsableTxt.Text = user.NOMBRES + " " + user.APELLIDOS; proyectoTxt.Text = p.LUGAR; } else { noMaderableBS.DataSource = newForm.LINEANOMADERABLES.ToList(); regeneracionBS.DataSource = newForm.LINEAREGENERACION.ToList(); lineaInvBS.DataSource = newForm.LINEAINVENTARIO.ToList(); responsableTxt.Text = f.USUARIO.NOMBRES + " " + f.USUARIO.APELLIDOS; proyectoTxt.Text = f.PROYECTO.LUGAR; datosTabControl.Enabled = true; guardarformularioBtn.Text = "Actualizar formulario"; finalDpk.Enabled = true; finalDpk.Value = (System.DateTime)newForm.HORAFINAL; inicioDpk.Enabled = false; this.Text = "Editando formulario e introduciendo datos"; lineaInvBS.AddNew(); regeneracionBS.AddNew(); noMaderableBS.AddNew(); } PROYECTO py = (PROYECTO)Program.Cache.Get("project"); if (py.TIPODISENOMUESTRAL.NOMTIPODISEMUEST.ToString() == "SI") { estratoCbx.Enabled = false; } if(f!=null)formularioBS.DataSource = f; else formularioBS.DataSource = newForm; modified = true; }
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(); } }
private void reporteValorComercial() { try{ Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); Column1.HeaderText = "Valor comercial"; Column1.Name = "valorComercial"; Column1.SortMode = DataGridViewColumnSortMode.NotSortable; DtgDatos.Columns.Add(Column1); Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); Column1.HeaderText = "Variable"; Column1.Name = "ColVariable"; Column1.SortMode = DataGridViewColumnSortMode.NotSortable; DtgDatos.Columns.Add(Column1); decimal posClase = this.DIM; for (int i = 0; i < NumClass; i++) { Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); Column1.HeaderText = posClase + " - " + (posClase + rangeDAP); Column1.Name = "Clase" + (i + 1); DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); dataGridViewCellStyle1.Format = "0.000###"; Column1.DefaultCellStyle = dataGridViewCellStyle1; Column1.SortMode = DataGridViewColumnSortMode.NotSortable; DtgDatos.Columns.Add(Column1); posClase = posClase + rangeDAP; } Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); Column1.HeaderText = "Mayores a " + posClase; Column1.Name = "ClaseMayores"; Column1.SortMode = DataGridViewColumnSortMode.NotSortable; DtgDatos.Columns.Add(Column1); Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); Column1.HeaderText = "Total"; Column1.Name = "Clase" + (nUd_NumClases.Value + 3); Column1.SortMode = DataGridViewColumnSortMode.NotSortable; DtgDatos.Columns.Add(Column1); SpeciesBL SpBL = new SpeciesBL(Program.ContextData); GroupBL groupBL = new GroupBL(Program.ContextData); InventoryLineBL lnBL = new InventoryLineBL(Program.ContextData); decimal[] totalConteoClase = new decimal[NumClass + 1]; decimal[] totalABClase = new decimal[NumClass + 1]; decimal[] totalVolComClase = new decimal[NumClass + 1]; decimal[] totalVolTotClase = new decimal[NumClass + 1]; ArrayList RowsData = new ArrayList(); List<GRUPOCOMERCIAL> ListGC = groupBL.GetGroups().ToList(); this.progressBar.Value = 0; this.progressBar.Minimum = 0; this.progressBar.Maximum = ListGC.Count; foreach (GRUPOCOMERCIAL gc in ListGC) { string RowConteo = "", RowAB = " ,Area Basal,", RowVolCom = " ,Volumen comercial,", RowVolTot = " ,Volumen total,"; decimal totalConteo = 0, totalAB = 0, totalVolCom = 0, totalVolTot = 0; RowConteo += gc.DESCRIPGRUPO + ", Densidad,"; List<REPORTECLASESDIAMETRICAS> resultReportCD = new List<REPORTECLASESDIAMETRICAS>(); decimal ValorClase = this.DIM; for (int i = 0; i <= NumClass; i++, ValorClase = ValorClase + rangeDAP) { REPORTECLASESDIAMETRICAS rpCD = new REPORTECLASESDIAMETRICAS(); foreach (ESPECIE sp in project.ESPECIE.Where(p => p.GRUPOCOM == gc.GRUPOCOM)) { if (i == NumClass) { rpCD.CLASE = "otros"; rpCD = lnBL.searchDiametricClass(sp.CODESP, project.NROPROY, tipoClaseCbx.Text, ValorClase, -1, rpCD); } else { rpCD.CLASE = i + " - " + (i + rangeDAP); rpCD = lnBL.searchDiametricClass(sp.CODESP, project.NROPROY, tipoClaseCbx.Text, ValorClase, ValorClase + rangeDAP, rpCD); } } rpCD.PORCENTAJE = rpCD.TOTAL * 100; if (rpCD.CONTEO > 0) { rpCD.AREABASAL = rpCD.AREABASAL / rpCD.CONTEO; rpCD.VOLUMENCOMERCIAL = rpCD.VOLUMENCOMERCIAL/ rpCD.CONTEO; rpCD.VOLUMENTOTAL = rpCD.VOLUMENTOTAL / rpCD.CONTEO; } RowConteo += Decimal.Round(rpCD.CONTEO, 4) + ","; RowAB += Decimal.Round(rpCD.AREABASAL, 4).ToString().Replace(",", ".") + ","; RowVolCom += Decimal.Round(rpCD.VOLUMENCOMERCIAL, 4).ToString().Replace(",", ".") + ","; RowVolTot += Decimal.Round(rpCD.VOLUMENTOTAL, 4).ToString().Replace(",", ".") + ","; totalConteo += rpCD.CONTEO; totalAB += rpCD.AREABASAL; totalVolCom += rpCD.VOLUMENCOMERCIAL; totalVolTot += rpCD.VOLUMENTOTAL; //Se realiza para los totales por clase de densidad,AB, vol totalConteoClase[i] += rpCD.CONTEO; totalABClase[i] += rpCD.AREABASAL; totalVolComClase[i] += rpCD.VOLUMENCOMERCIAL; totalVolTotClase[i] += rpCD.VOLUMENTOTAL; } //Se hace fuera del for porque en este for se lleva todos los valores de esa especie para cada clase diametrica y todas las variables //entonces ahora se lleva los valores de la especie y las clases diametricas if (opcionCheck.Checked) { RowConteo += Decimal.Round(totalConteo, 4).ToString().Replace(",", ".") + ","; RowAB += Decimal.Round(totalAB, 4).ToString().Replace(",", ".") + ","; RowVolCom += Decimal.Round(totalVolCom, 4).ToString().Replace(",", ".") + ","; RowVolTot += Decimal.Round(totalVolTot, 4).ToString().Replace(",", ".") + ","; RowsData.Add(RowConteo); RowsData.Add(RowAB); RowsData.Add(RowVolCom); RowsData.Add(RowVolTot); } else { if (totalConteo > 0) { RowConteo += Decimal.Round(totalConteo, 4).ToString().Replace(",", ".") + ","; RowAB += Decimal.Round(totalAB, 4).ToString().Replace(",", ".") + ","; RowVolCom += Decimal.Round(totalVolCom, 4).ToString().Replace(",", ".") + ","; RowVolTot += Decimal.Round(totalVolTot, 4).ToString().Replace(",", ".") + ","; RowsData.Add(RowConteo); RowsData.Add(RowAB); RowsData.Add(RowVolCom); RowsData.Add(RowVolTot); } } this.progressBar.Value++; } string RowTotalC = "TOTALES,Densidad,", RowTotalAB = " ,Area Basal,", RowTotalVolCom = " ,Volumen comercial,", RowTotalVolTot = " ,Volumen comercial,"; foreach (decimal d in totalConteoClase) { RowTotalC += decimal.Round(d, 4).ToString().Replace(",", ".") + ","; } foreach (decimal d in totalABClase) { RowTotalAB += decimal.Round(d, 4).ToString().Replace(",", ".") + ","; } foreach (decimal d in totalVolComClase) { RowTotalVolCom += decimal.Round(d, 4).ToString().Replace(",", ".") + ","; } foreach (decimal d in totalVolTotClase) { RowTotalVolTot += decimal.Round(d, 4).ToString().Replace(",", ".") + ","; } RowTotalC += Decimal.Round(totalConteoClase.Sum(), 4).ToString().Replace(",", ".") + ","; RowTotalAB += Decimal.Round(totalABClase.Sum(), 4).ToString().Replace(",", ".") + ","; RowTotalVolCom += Decimal.Round(totalVolComClase.Sum(), 4).ToString().Replace(",", ".") + ","; RowTotalVolTot += Decimal.Round(totalVolTotClase.Sum(), 4).ToString().Replace(",", ".") + ","; Column1 = new DataGridViewTextBoxColumn(); Column1.HeaderText = "Porcentaje"; Column1.Name = "Clase" + (nUd_NumClases.Value + 4); Column1.SortMode = DataGridViewColumnSortMode.NotSortable; DtgDatos.Columns.Add(Column1); int numCampos = 3; for (int i = 0; i < RowsData.Count; i = i + 4) { //Se arregla la fila que corresponde a la densidad string cadena = (string)RowsData[i]; string[] fila = cadena.Split(','); decimal total = decimal.Parse(fila[NumClass + numCampos].Replace('.', ',')); decimal p = 0; if (totalConteoClase.Sum() > 0) p = ((total) / totalConteoClase.Sum()) * 100; string result = cadena + decimal.Round(p, 2).ToString().Replace(',', '.') + ""; DtgDatos.Rows.Add(result.Split(',')); //Se arregla la fila que corresponde la area basal cadena = (string)RowsData[i + 1]; fila = cadena.Split(','); total = decimal.Parse(fila[NumClass + numCampos].Replace('.', ',')); p = 0; if (totalConteoClase.Sum() > 0) p = (total / totalABClase.Sum()) * 100; result = cadena + decimal.Round(p, 2).ToString().Replace(',', '.') + ""; DtgDatos.Rows.Add(result.Split(',')); //Se arregla la fila que corresponde al volumen comercial cadena = (string)RowsData[i + 2]; fila = cadena.Split(','); total = decimal.Parse(fila[NumClass + numCampos].Replace('.', ',')); p = 0; if (totalConteoClase.Sum() > 0) p = (total / totalVolComClase.Sum()) * 100; result = cadena + decimal.Round(p, 2).ToString().Replace(',', '.') + ""; DtgDatos.Rows.Add(result.Split(',')); //Se arregla la fila que corresponde al volumen total cadena = (string)RowsData[i + 3]; fila = cadena.Split(','); total = decimal.Parse(fila[NumClass + numCampos].Replace('.', ',')); p = 0; if (totalConteoClase.Sum() > 0) p = (total / totalVolTotClase.Sum()) * 100; result = cadena + decimal.Round(p, 2).ToString().Replace(',', '.') + ""; DtgDatos.Rows.Add(result.Split(',')); } DtgDatos.AutoResizeColumns(); DtgDatos.Rows.Add(RowTotalC.Split(',')); DtgDatos.Rows.Add(RowTotalAB.Split(',')); DtgDatos.Rows.Add(RowTotalVolCom.Split(',')); DtgDatos.Rows.Add(RowTotalVolTot.Split(',')); DtgDatos.Refresh(); } catch (Exception ex) { Error_Form er = new Error_Form(ex.Message); er.MdiParent = this.MdiParent; er.Show(); } }