private void btnnuevo_Click(object sender, EventArgs e) { if (!(TabControl1.SelectedIndex == 0)) { TabControl1.SelectedIndex = 0; } u_n_opsel = 1; Blanquear(); U_RefrescaControles(); TabControl1.SelectedIndex = 0; TabControl1.SelectedIndex = 1; tb_plla_geneventospermisoBL BL = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BE = new tb_plla_geneventospermiso(); txtcodigo.Text = BL.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString(); chkactivo.Checked = true; cmbtipo.SelectedValue = "N"; txtdescripcion.Focus(); }
private void btngrabar_Click(object sender, EventArgs e) { if (U_Validacion()) { tb_plla_geneventospermisoBL BL = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BE = new tb_plla_geneventospermiso(); BE.eventoperid = txtcodigo.Text.Trim(); BE.norden = 1; tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (u_n_opsel == 1) { while (1 == 1) { tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (BL.Sql_Error.Length > 0) { Frm_Class.ShowError(BL.Sql_Error + "\r" + "Error al buscar código", this); return; } if (tmpcursor.Rows.Count > 0) { tb_plla_geneventospermisoBL BLMX = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BEMX = new tb_plla_geneventospermiso(); txtcodigo.Text = BLMX.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BEMX).Tables[0].Rows[0]["maximo_codigo"].ToString(); } else { break; } } tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; tmpcursor.Rows.Add(VariablesPublicas.InsertIntoTable(tmpcursor)); tmpcursor.Rows[0]["eventoperid"] = txtcodigo.Text.Trim(); } tmpcursor.Rows[0]["eventopername"] = txtdescripcion.Text.Trim(); tmpcursor.Rows[0]["planilla"] = 1; tmpcursor.Rows[0]["status"] = (chkactivo.Checked ? 1 : 0); tmpcursor.Rows[0]["rtpssunat"] = cmbcodsunat.SelectedValue; if (cmbtipo.SelectedValue != null) { tmpcursor.Rows[0]["tipoevento"] = cmbtipo.SelectedValue; } tmpcursor.AcceptChanges(); if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor)) { seguridadlog(); U_CancelarEdicion(0); } else { Frm_Class.ShowError(BL.Sql_Error, this); } } }