private void frmSocioEconomico_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F2) { cerrar(); } if (this.principalActiva) { if (this.ventanaPrincipal.dtggrid.Rows.Count == 0) { h_sdepec sdepec = new h_sdepec(); int rowactual = this.ventanaPrincipal.dtggrid.Rows.Count; if (e.KeyCode == Keys.Insert && !globales.boolConsulta) { if (this.ventanaPrincipal.dtggrid.Rows.Count != 0) { return; } if (!this.conExpediente) { globales.MessageBoxExclamation("No se puede insertar registros a la solicitud sin expediente", "Aviso", globales.menuPrincipal); return; } DialogResult p = globales.MessageBoxQuestion("¿Deseas registrar una nuevo registro?", "Aviso", globales.menuPrincipal); if (p == DialogResult.No) { return; } this.esInsertar = true; this.ventanaPrincipal.dtggrid.Rows.Insert(0); this.ventanaPrincipal.dtggrid.Rows[0].Cells[0].Value = ""; this.ventanaPrincipal.dtggrid.Rows[0].Cells[1].Value = ""; this.ventanaPrincipal.dtggrid.Rows[0].Cells[2].Value = ""; this.ventanaPrincipal.dtggrid.Rows[0].Cells[3].Value = ""; this.ventanaPrincipal.dtggrid.Rows[0].Cells[4].Value = ""; this.ventanaPrincipal.dtggrid.Rows[0].DefaultCellStyle.BackColor = Color.FromArgb(200, 230, 201); h_sdepec depec = new h_sdepec(); depec.expediente = Convert.ToInt32(txtExpediente.Text); depec.sec = this.secuencia; dbaseORM orm = new dbaseORM(); depec = orm.insert <h_sdepec>(depec, true); this.ventanaPrincipal.dtggrid.Rows[0].Cells[5].Value = depec.id; this.ventanaPrincipal.dtggrid.CurrentCell = this.ventanaPrincipal.dtggrid.Rows[rowactual].Cells[0]; } } this.esInsertar = false; } else { } }
private void cellvalueChanged(object sender, DataGridViewCellEventArgs e) { if (editadoprogramadamente) { editadoprogramadamente = false; return; } int c = e.RowIndex; if (c == -1) { return; } if (this.esInsertar) { return; } editadoprogramadamente = true; this.ventanaPrincipal.dtggrid.Rows[this.row].Cells[1].Value = globales.convertInt(Convert.ToString(this.ventanaPrincipal.dtggrid.Rows[this.row].Cells[1].Value)); editadoprogramadamente = false; h_sdepec h = new h_sdepec(); h.expediente = Convert.ToInt32(txtExpediente.Text); h.sec = this.secuencia; h.id = Convert.ToInt32(this.ventanaPrincipal.dtggrid.Rows[this.row].Cells[5].Value); h.nom_depec = this.ventanaPrincipal.dtggrid.Rows[this.row].Cells[0].Value.ToString(); h.edad = Convert.ToInt32(this.ventanaPrincipal.dtggrid.Rows[this.row].Cells[1].Value); h.parentesco = Convert.ToString(this.ventanaPrincipal.dtggrid.Rows[this.row].Cells[2].Value); h.escolaridad = Convert.ToString(this.ventanaPrincipal.dtggrid.Rows[this.row].Cells[3].Value); h.ocupacion = Convert.ToString(this.ventanaPrincipal.dtggrid.Rows[this.row].Cells[4].Value); dbaseORM orm = new dbaseORM(); bool actualizado = orm.update <h_sdepec>(h); editadoprogramadamente = false; }
private void gridKey(object sender, KeyEventArgs e) { if (this.ventanaPrincipal.dtggrid.Rows.Count != 0) { h_sdepec sdepec = new h_sdepec(); int rowactual = this.ventanaPrincipal.dtggrid.Rows.Count; if (e.KeyCode == Keys.Insert && !globales.boolConsulta) { if (!this.conExpediente) { globales.MessageBoxExclamation("No se puede insertar registros a la solicitud sin expediente", "Aviso", globales.menuPrincipal); return; } DialogResult p = globales.MessageBoxQuestion("¿Deseas registrar una nuevo registro?", "Aviso", globales.menuPrincipal); if (p == DialogResult.No) { return; } this.esInsertar = true; this.ventanaPrincipal.dtggrid.Rows.Insert(rowactual); this.ventanaPrincipal.dtggrid.Rows[rowactual].Cells[0].Value = ""; this.ventanaPrincipal.dtggrid.Rows[rowactual].Cells[1].Value = ""; this.ventanaPrincipal.dtggrid.Rows[rowactual].Cells[2].Value = ""; this.ventanaPrincipal.dtggrid.Rows[rowactual].Cells[3].Value = ""; this.ventanaPrincipal.dtggrid.Rows[rowactual].Cells[4].Value = ""; this.ventanaPrincipal.dtggrid.Rows[rowactual].DefaultCellStyle.BackColor = Color.FromArgb(200, 230, 201); h_sdepec depec = new h_sdepec(); depec.expediente = Convert.ToInt32(txtExpediente.Text); depec.sec = this.secuencia; dbaseORM orm = new dbaseORM(); depec = orm.insert <h_sdepec>(depec, true); this.ventanaPrincipal.dtggrid.Rows[rowactual].Cells[5].Value = depec.id; this.ventanaPrincipal.dtggrid.CurrentCell = this.ventanaPrincipal.dtggrid.Rows[rowactual].Cells[0]; } } this.esInsertar = false; if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; try { e.SuppressKeyPress = true; int iColumn = this.ventanaPrincipal.dtggrid.CurrentCell.ColumnIndex; int iRow = this.ventanaPrincipal.dtggrid.CurrentCell.RowIndex; if (iColumn == this.ventanaPrincipal.dtggrid.ColumnCount - 1) { if (this.ventanaPrincipal.dtggrid.RowCount > (iRow + 1)) { this.ventanaPrincipal.dtggrid.CurrentCell = this.ventanaPrincipal.dtggrid[1, iRow + 1]; } else { //focus next control } } else { this.ventanaPrincipal.dtggrid.CurrentCell = this.ventanaPrincipal.dtggrid[iColumn + 1, iRow]; } } catch { } } }