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; var BL = new tb_plla_pdt_tabla17BL(); var BE = new tb_plla_pdt_tabla17(); txtcodigo.Text = BL.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString(); txtdescripcion.Focus(); }
private void btngrabar_Click(object sender, EventArgs e) { if (U_Validacion()) { var BL = new tb_plla_pdt_tabla17BL(); var BE = new tb_plla_pdt_tabla17(); BE.motfinperiodid = txtcodigo.Text.Trim(); BE.norden = 1; BE.incluir_blanco = 0; tmpcursor = BL.GetAll_Consulta(VariablesPublicas.EmpresaID, BE).Tables[0]; if (u_n_opsel == 1) { while (1 == 1) { BE.motfinperiodid = txtcodigo.Text.Trim(); 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) { var BLMX = new tb_plla_pdt_tabla17BL(); var BEMX = new tb_plla_pdt_tabla17(); 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]["motfinperiodid"] = txtcodigo.Text; } tmpcursor.Rows[0]["motfinperiodname"] = txtdescripcion.Text.Trim(); tmpcursor.AcceptChanges(); if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor)) { seguridadlog(); U_CancelarEdicion(0); } else { Frm_Class.ShowError(BL.Sql_Error, this); } } }