private void btngrabar_Click(object sender, EventArgs e) { if (U_Validacion()) { if (u_n_opsel == 1) { var BL = new tb_plla_rubrospllacabBL(); var BE = new tb_plla_rubrospllacab(); BE.rubrocod = txtcodigo.Text.Trim(); tmptabla = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0]; if (tmptabla.Rows.Count > 0) { var BLMAX = new tb_plla_rubrospllacabBL(); var BEMAX = new tb_plla_rubrospllacab(); txtcodigo.Text = BLMAX.GetAll_MaxRubro(VariablesPublicas.EmpresaID.ToString(), BEMAX).Tables[0].Rows[0]["maximo_codigo"].ToString(); } tmptabla.Rows.Add(VariablesPublicas.InsertIntoTable(tmptabla)); tmptabla.Rows[0]["rubrocod"] = txtcodigo.Text.Trim(); tmptabla.Rows[0]["tipoplla"] = xtipplla; } else { var BL = new tb_plla_rubrospllacabBL(); var BE = new tb_plla_rubrospllacab(); BE.rubrocod = txtcodigo.Text.Trim(); tmptabla = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0]; } for (lc_contador = 0; lc_contador <= tabladetprestamos.Rows.Count - 1; lc_contador++) { tabladetprestamos.Rows[lc_contador]["rubrocod"] = txtcodigo.Text.Trim(); } tmptabla.Rows[0]["tiporubro"] = cmbtipo.SelectedValue; tmptabla.Rows[0]["rubroname"] = txtdescripcion.Text; tmptabla.AcceptChanges(); tabladetprestamos.AcceptChanges(); var BLIU = new tb_plla_rubrospllacabBL(); var BEIU = new tb_plla_rubrospllacab(); if (BLIU.Insert_Update(VariablesPublicas.EmpresaID, BEIU, tmptabla, tabladetprestamos)) { seguridadlog(); U_CancelarEdicion(0); } else { Frm_Class.ShowError(BLIU.Sql_Error, this); } } }
private void btneliminar_Click(object sender, EventArgs e) { if (Examinar.CurrentRow != null) { var xnomcampo = string.Empty; if (xnomcampo.Length == 0) { var BLC = new tb_plla_rubrospllacabBL(); var BEC = new tb_plla_rubrospllacab(); BEC.rubrocod = Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubrocod"].Value.ToString(); tmpconsulta = BLC.GetAll(VariablesPublicas.EmpresaID, BEC).Tables[0]; if (BLC.Sql_Error.Length == 0) { var message = "Desea eliminar Código " + tmpconsulta.Rows[0]["rubrocod"].ToString().Trim() + " - " + tmpconsulta.Rows[0]["rubroname"].ToString().Trim() + "...?"; var caption = "Mensaje del Sistema"; var buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { if (BLC.Eliminar(VariablesPublicas.EmpresaID, tmpconsulta)) { var BLL = new tb_co_seguridadlogBL(); var BEL = new tb_co_seguridadlog(); BEL.moduloid = Name; BEL.clave = VariablesPublicas.EmpresaID + Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubrocod"].Value.ToString(); BEL.cuser = VariablesPublicas.Usuar; BEL.fecha = DateTime.Now; BEL.pc = VariablesPublicas.userip; BEL.accion = "B"; BEL.detalle = "DESCRIPCION : BORRADO - ELIMINADO"; BLL.Insert(VariablesPublicas.EmpresaID.ToString(), BEL); Examinar.Rows.Remove(Examinar.CurrentRow); Examinar.Refresh(); } } } else { Frm_Class.ShowError(BLC.Sql_Error, this); } } else { MessageBox.Show(xnomcampo, "IMPOSIBLE ELIMINAR REGISTRO"); } } U_RefrescaControles(); }