public Boolean Procesar() { try { Boolean bolResult = false; int codigoSRI = Convert.ToInt32(txt_id.Text); txt_descripcion.Focus(); if (validar()) { tipoCodSRI = UCTC.get_Dato(); get_Info(); if (_Accion == Cl_Enumeradores.eTipo_action.grabar) { codSRI_inf.IdUsuario = param.IdUsuario; codSRI_inf.Fecha_Transac = param.Fecha_Transac; codSRI_inf.nom_pc = param.nom_pc; codSRI_inf.ip = param.ip; if (codSRI_Bus.GrabarDB(codSRI_inf, ref id)) { txt_id.Text = id.ToString(); codigoSRI = id; cp_codigo_SRI_x_CtaCble_Info info = new cp_codigo_SRI_x_CtaCble_Info(); info.IdEmpresa = param.IdEmpresa; info.idUsuario = codSRI_inf.IdUsuario; info.fecha_UltMod = codSRI_inf.Fecha_Transac; info.nom_pc = codSRI_inf.nom_pc; info.ip = codSRI_inf.ip; info.idCodigo_SRI = id; info.IdCtaCble = ucCtaCble.get_PlanCtaInfo().IdCtaCble; if (info.IdCtaCble != null) { codcta.GuardarDB(info); string smensaje = string.Format(Core.Erp.Recursos.Properties.Resources.msgDespues_Grabar, "El Código SRI", id); MessageBox.Show(smensaje, param.Nombre_sistema); } bolResult = true; LimpiarDatos(); } else { string smensaje = string.Format(Core.Erp.Recursos.Properties.Resources.msgError_Grabar); MessageBox.Show(smensaje, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (_Accion == Cl_Enumeradores.eTipo_action.actualizar) { codSRI_inf.IdUsuarioUltMod = param.IdUsuario; codSRI_inf.Fecha_UltMod = param.Fecha_Transac; if (codSRI_Bus.ModificarDB(codSRI_inf)) { cp_codigo_SRI_x_CtaCble_Info info = new cp_codigo_SRI_x_CtaCble_Info(); info.IdEmpresa = param.IdEmpresa; info.idUsuario = codSRI_inf.IdUsuarioUltMod; info.fecha_UltMod = codSRI_inf.Fecha_UltMod; info.nom_pc = param.nom_pc; info.ip = param.ip; info.idCodigo_SRI = codSRI_inf.IdCodigo_SRI; info.IdCtaCble = ucCtaCble.get_PlanCtaInfo().IdCtaCble; if (info.IdCtaCble != null) { codcta.ModificarDB(info); string smensaje = string.Format(Core.Erp.Recursos.Properties.Resources.msgDespues_Modificar, "El Código SRI", codSRI_inf.IdCodigo_SRI); MessageBox.Show(smensaje, param.Nombre_sistema); } bolResult = true; LimpiarDatos(); } else { string smensaje = string.Format(Core.Erp.Recursos.Properties.Resources.msgError_Modificar); MessageBox.Show(smensaje, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (_Accion == Cl_Enumeradores.eTipo_action.Anular) { codSRI_inf.IdUsuarioUltAnu = param.IdUsuario; codSRI_inf.Fecha_UltAnu = param.Fecha_Transac; if (MessageBox.Show("¿Está seguro que desea anular dicho Código SRI?", "Anulación de Código SRI", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { FrmGe_MotivoAnulacion ofrm = new FrmGe_MotivoAnulacion(); ofrm.ShowDialog(); codSRI_inf.MotivoAnulacion = ofrm.motivoAnulacion; if (codSRI_Bus.AnularDB(codSRI_inf)) { string smensaje = string.Format(Core.Erp.Recursos.Properties.Resources.msgDespues_Anular, "El Código SRI", codSRI_inf.IdCodigo_SRI); MessageBox.Show(smensaje, param.Nombre_sistema); ucGe_Menu.Visible_bntAnular = false; bolResult = true; } else { string smensaje = string.Format(Core.Erp.Recursos.Properties.Resources.msgError_Anular); MessageBox.Show(smensaje, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } return(bolResult); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
public void Grabar() { try { int codigoSRI = Convert.ToInt32(txt_id.Text); txt_descripcion.Focus(); List <cp_codigo_SRI_x_CtaCble_Info> lista = getGrid(); if (lista == null) { MessageBox.Show("Una de las Cuentas no la ingresó Correctamente"); return; } if (dtp_valiDesde.Value > dtp_valiHasta.Value) { MessageBox.Show("La fecha Válido Desde no debe ser mayor a la fecha Válido Hasta", "Datos erróneos"); return; } if (txt_descripcion.Text == "") { MessageBox.Show("Descripción sin dato..", "Favor ingrese dato"); return; } if (txt_cod_SRI.Text == "") { MessageBox.Show("Código SRI sin dato..", "Favor ingrese dato"); return; } tipoCodSRI = UCTC.get_Dato(); get_Info(); int id = 0; cp_codigo_SRI_Bus codSRI_Bus = new cp_codigo_SRI_Bus(); if (_Accion == Cl_Enumeradores.eTipo_action.grabar) { codSRI_inf.IdUsuario = param.IdUsuario; codSRI_inf.Fecha_Transac = param.Fecha_Transac; codSRI_inf.nom_pc = param.nom_pc; codSRI_inf.ip = param.ip; if (codSRI_Bus.GrabarDB(codSRI_inf, ref id)) { txt_id.Text = id.ToString(); codigoSRI = id; MessageBox.Show("Grabado Exitosamente ok", "Operación Exitosa"); this.Parent.Parent.Dispose(); } else { MessageBox.Show("Error al Grabar", "Operación Fallida"); } } if (_Accion == Cl_Enumeradores.eTipo_action.actualizar) { codSRI_inf.IdUsuarioUltMod = param.IdUsuario; codSRI_inf.Fecha_UltMod = param.Fecha_Transac; if (codSRI_Bus.ModificarDB(codSRI_inf)) { MessageBox.Show("Actualizado Exitosamente ok", "Operación Exitosa"); this.Parent.Parent.Dispose(); } else { MessageBox.Show("Error al Actualizar", "Operación Fallida"); } } if (_Accion == Cl_Enumeradores.eTipo_action.Anular) { codSRI_inf.IdUsuarioUltAnu = param.IdUsuario; codSRI_inf.Fecha_UltAnu = param.Fecha_Transac; if (codSRI_Bus.AnularDB(codSRI_inf)) { MessageBox.Show("Anulado Exitosamente ok", "Operación Exitosa"); this.Parent.Parent.Dispose(); } else { MessageBox.Show("Error al Anular", "Operación Fallida"); } } codSRI_Bus.ModificarDB(lista, Convert.ToInt32(codigoSRI)); } catch (Exception ex) { string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString()); } }