Example #1
0
        private void dataHistoryPeriodo_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            selccionValor         = true;
            btnCreate.Text        = "Modificar Periodo";
            Fill                  = dataHistoryPeriodo.CurrentCell.RowIndex;
            ValorPeriodo          = dataHistoryPeriodo[1, Fill].Value.ToString().Trim();
            Ano                   = dataHistoryPeriodo[4, Fill].Value.ToString();
            Mes                   = dataHistoryPeriodo[5, Fill].Value.ToString();
            Periodo               = dataHistoryPeriodo[6, Fill].Value.ToString();
            dtpEventInitial.Value = Convert.ToDateTime(dataHistoryPeriodo[2, Fill].Value.ToString().Trim());
            dtpDatenEnd.Value     = Convert.ToDateTime(dataHistoryPeriodo[3, Fill].Value.ToString().Trim());
            cboAno.Text           = dataHistoryPeriodo[4, Fill].Value.ToString().Trim();
            cboMes.Text           = dataHistoryPeriodo[5, Fill].Value.ToString().Trim();
            cboPeriodo.Text       = dataHistoryPeriodo[6, Fill].Value.ToString().Trim();

            if (dataHistoryPeriodo[7, Fill].Value != null && Convert.ToDecimal(dataHistoryPeriodo[7, Fill].Value.ToString().Trim()) > 0)
            {
                txtOnzasFundidas.Text = dataHistoryPeriodo[7, Fill].Value.ToString().Trim();
            }
            else
            {
                txtOnzasFundidas.Text = string.Empty;
            }

            if (dataHistoryPeriodo[9, Fill].Value != null && Convert.ToDecimal(dataHistoryPeriodo[9, Fill].Value.ToString().Trim()) > 0)
            {
                txtRecuperacion.Text = dataHistoryPeriodo[9, Fill].Value.ToString().Trim();
            }
            else
            {
                txtRecuperacion.Text = string.Empty;
            }

            if (dataHistoryPeriodo[8, Fill].Value != null && Convert.ToDecimal(dataHistoryPeriodo[8, Fill].Value.ToString().Trim()) > 0)
            {
                txtOnzasRecuperadas.Text = dataHistoryPeriodo[8, Fill].Value.ToString().Trim();
            }
            else
            {
                txtOnzasRecuperadas.Text = string.Empty;
            }

            if (Convert.ToBoolean(dataHistoryPeriodo[10, Fill].Value.ToString().Trim()))
            {
                label17.Text                = "Abierto";
                btnCerrarPe.Enabled         = true;
                btnCerrarPe.Enabled         = true;
                dtpEventInitial.Enabled     = true;
                dtpDatenEnd.Enabled         = true;
                cboAno.Enabled              = true;
                cboMes.Enabled              = true;
                cboPeriodo.Enabled          = true;
                txtOnzasFundidas.Enabled    = true;
                txtRecuperacion.Enabled     = true;
                txtOnzasRecuperadas.Enabled = true;
            }
            else
            {
                label17.Text                = "Cerrado";
                btnCerrarPe.Enabled         = false;
                dtpEventInitial.Enabled     = false;
                dtpDatenEnd.Enabled         = false;
                cboAno.Enabled              = false;
                cboMes.Enabled              = false;
                cboPeriodo.Enabled          = false;
                txtOnzasFundidas.Enabled    = false;
                txtRecuperacion.Enabled     = false;
                txtOnzasRecuperadas.Enabled = false;
            }

            var read = ConsultaEntidades.DetallePeriodos("SpConsulta_Tablas", "DetallePeriodo", dataHistoryPeriodo[1, Fill].Value.ToString().Trim(), 0, string.Empty);

            dataDetailPeriodo.DataSource       = read;
            dataDetailPeriodo.Columns[0].Width = 40;
            dataDetailPeriodo.Columns[1].Width = 40;

            dataDetailPeriodo.Columns[2].Width = 40;
            dataDetailPeriodo.Columns["Toneladas"].DefaultCellStyle.Format    = "##,##.00";
            dataDetailPeriodo.Columns["Toneladas"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            dataDetailPeriodo.Columns["Onzas"].DefaultCellStyle.Format    = "##,##.00";
            dataDetailPeriodo.Columns["Onzas"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            dataDetailPeriodo.Columns["Tenor"].DefaultCellStyle.Format    = "##,##.00";
            dataDetailPeriodo.Columns["Tenor"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            var suma = read.Select(c => c.Toneladas).Sum();

            txtToneladas.Text = suma.Value.ToString("##.00");

            suma          = read.Select(c => c.Tenor).Sum();
            txtTenor.Text = suma.Value.ToString("##.00");

            suma          = read.Select(c => c.Onzas).Sum();
            txtOnzas.Text = suma.Value.ToString("##.00");
            dataDetailPeriodo.AutoResizeColumns();
        }