Exemplo n.º 1
0
        private void dgvConceptos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int periodo = 0;
            if (cmbPeriodo.Text == "SEMANAL")
                periodo = 7;
            else if (cmbPeriodo.Text == "QUINCENAL")
                periodo = 15;

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Conceptos.Core.ConceptosHelper ch = new Conceptos.Core.ConceptosHelper();
            ch.Command = cmd;

            Conceptos.Core.ConceptosEmpresa ce = new Conceptos.Core.ConceptosEmpresa();
            ce.idempresa = GLOBALES.IDEMPRESA;
            ce.periodo = periodo;
            ce.idconcepto = int.Parse(dgvConceptos.Rows[e.RowIndex].Cells[0].Value.ToString());

            if (e.ColumnIndex == 3) // 0 is the first column, specify the valid index of ur gridview
            {
                bool value = (bool)dgvConceptos.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue;
                ce.asignacion = value;
            }

            try
            {
                cnx.Open();
                ch.actualizaAsignacionConcepto(ce);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception)
            {
                MessageBox.Show("Error: Al actualizar la asignación del concepto", "Error");
                cnx.Dispose();
            }
        }