private void loadPeriodo(int anoPeriodo) { this.cboAno.DropDownStyle = ComboBoxStyle.DropDownList; this.cboMes.DropDownStyle = ComboBoxStyle.DropDownList; this.cboPeriodo.DropDownStyle = ComboBoxStyle.DropDownList; if (anoPeriodo == 0) { cboAno.Items.Clear(); var read = ConsultaEntidades.ObtenerPeriodos("SpConsulta_Tablas", "FechaPeriodo", "", anoPeriodo, string.Empty); var query = read.Select(c => c.FechaAplica).ToArray(); cboAno.Items.AddRange(query.ToArray()); cboAno.SelectedIndex = 0; anoPeriodo = Convert.ToInt32(cboAno.Items[0].ToString()); } var readHistory = ConsultaEntidades.ObtenerPeriodos("SpConsulta_Tablas", "PeriodoAno", "", anoPeriodo, string.Empty); dataHistoryPeriodo.DataSource = readHistory; if (dataHistoryPeriodo.Rows.Count > 0) { DateTime valorAnterior = Convert.ToDateTime(dataHistoryPeriodo.Rows[0].Cells[3].Value); dtpEventInitial.Value = valorAnterior.AddDays(1); dtpDatenEnd.Value = dtpEventInitial.Value.AddDays(1); } else { dtpEventInitial.Value = DateTime.Now; dtpDatenEnd.Value = DateTime.Now.AddDays(1); } dataHistoryPeriodo.Columns[0].Visible = false; dataHistoryPeriodo.Columns[10].DisplayIndex = 0; dataHistoryPeriodo.Columns[10].HeaderText = "Estado Abierto"; dataHistoryPeriodo.Columns[2].HeaderText = "Fecha Inicio"; dataHistoryPeriodo.Columns[3].HeaderText = "Fecha Fin"; dataHistoryPeriodo.Columns[4].HeaderText = "Año"; dataHistoryPeriodo.Columns[5].HeaderText = "Mes"; dataHistoryPeriodo.Columns[6].HeaderText = "Periodo"; dataHistoryPeriodo.Columns[7].HeaderText = "Onzas Fundidas"; dataHistoryPeriodo.Columns[8].HeaderText = "Onzas Recuperadas"; dataHistoryPeriodo.Columns[9].HeaderText = "Recuperación Planta"; dataHistoryPeriodo.Columns["RecuperacionPlanta"].DefaultCellStyle.Format = "##,##.00"; dataHistoryPeriodo.Columns["RecuperacionPlanta"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataHistoryPeriodo.Columns["OnzasFundidas"].DefaultCellStyle.Format = "##,##.00"; dataHistoryPeriodo.Columns["OnzasFundidas"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataHistoryPeriodo.Columns["OnzasRecuperadas"].DefaultCellStyle.Format = "##,##.00"; dataHistoryPeriodo.Columns["OnzasRecuperadas"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataHistoryPeriodo.Columns["AnoPeriodo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataHistoryPeriodo.Columns["MesPeriodo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataHistoryPeriodo.Columns["Periodo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataHistoryPeriodo.Columns["IdPeriodo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataHistoryPeriodo.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.dataHistoryPeriodo.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; dataHistoryPeriodo.AutoResizeColumns(); label17.Text = " - - "; btnCerrarPe.Enabled = false; }