public static EstadoOperacion eliminarMensajeTransaccional(MENSAJE_TRANSACCIONAL MensajeTransaccional) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "DELETE FROM MENSAJE_TRANSACCIONAL" + " WHERE MTR_CODIGO = @codigo"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", MensajeTransaccional.MTR_CODIGO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion eliminarTransformacion(TRANSFORMACION Transformacion) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "DELETE FROM TRANSFORMACION" + " WHERE TRM_CODIGO = @codigo"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", Transformacion.TRM_CODIGO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion eliminarTabla(TABLA tabla) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "EliminarTabla"; DbCommand Comando = contexto.CreateCommand(query, CommandType.StoredProcedure); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", tabla.TBL_CODIGO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (DbException dbex) { return new EstadoOperacion(false, dbex.Message, dbex); } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarColumna(COLUMNA Columna) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { Columna.COL_CODIGO = 0; string query = "InsertarColumna"; DbCommand Comando = crearComando(contexto, Columna, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (DbException ex) { return new EstadoOperacion(false, ex.Message, ex, false); } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion eliminarValoresTabla(string tabla, int Id) { string query = "delete from " + tabla + " where ID=" + Id.ToString(); try { using (Switch contexto = new Switch()) { DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); using (contexto.CreateConeccionScope()) { if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion eliminarCriptografiaCampo(CRIPTOGRAFIA_CAMPO CriptografiaCampo) { try { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "DELETE FROM CRIPTOGRAFIA_CAMPO" + " WHERE CRC_CODIGO =@codigo;"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", CriptografiaCampo.CRC_CODIGO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion eliminarTransformacionCampo(TRANSFORMACION_CAMPO transformacionCampo) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "DELETE FROM TRANSFORMACION_CAMPO" + " WHERE TRM_CODIGO=@transaccion_codigo" + " AND CAM_CODIGO_CAMPO_DESTINO=@campoDestino_codigo" + " AND MEN_CODIGO_MENSAJE_DESTINO=@mensajeDestino_codigo"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@transformacion_codigo", transformacionCampo.TRM_CODIGO)); Comando.Parameters.Add(Factoria.CrearParametro("@campoDestino_codigo", transformacionCampo.CAM_CODIGO_CAMPO_DESTINO)); Comando.Parameters.Add(Factoria.CrearParametro("@mensajeDestino_codigo", transformacionCampo.MEN_CODIGO_MENSAJE_DESTINO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion eliminarValidacionCampo(VALIDACION_CAMPO vcampo) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "DELETE FROM [VALIDACON_CAMPO] " + "WHERE [VLC_CODIGO] = @codigo"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", vcampo.VLC_CODIGO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarParametroTransformacionCampo(PARAMETRO_TRANSFORMACION_CAMPO parametroTransformacionCampo) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { parametroTransformacionCampo.PTC_CODIGO = (from c in contexto.PARAMETRO_TRANSFORMACION_CAMPO orderby c.PTC_CODIGO descending select c.PTC_CODIGO).FirstOrDefault() + 1; string query = "INSERT INTO PARAMETRO_TRANSFORMACION_CAMPO" + "(PTC_CODIGO" + ",TRM_CODIGO" + ",CAM_CODIGO_CAMPO_DESTINO" + ",MEN_CODIGO_MENSAJE_DESTINO" + ",CAM_CODIGO_CAMPO_ORIGEN" + ",MEN_CODIGO_MENSAJE_ORIGEN" + ",PTC_POSICION_INICIAL" + ",PTC_LONGITUD" + ",TBL_CODIGO" + ",COL_CODIGO_ORIGEN" + ",COL_CODIGO_DESTINO" + ",PTC_TIPO)" + "VALUES" + "(@codigo" + ",@transformacion_codigo" + ",@campoDestino_codigo" + ",@mensajeDestino_codigo" + ",@campoOrigen_codigo" + ",@mensajeOrigen_codigo" + ",@posicionInicial" + ",@longitud" + ",@tabla" + ",@columnaOrigen_codigo" + ",@columnaDestino_codigo" + ",@tipoParametroTransformacionCampo_codigo)"; DbCommand Comando = crearComando(contexto, parametroTransformacionCampo, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarTransformacionCampo(TRANSFORMACION_CAMPO transformacionCampo) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "INSERT INTO TRANSFORMACION_CAMPO" + "(TRM_CODIGO" + ",CAM_CODIGO_CAMPO_DESTINO" + ",MEN_CODIGO_MENSAJE_DESTINO" + ",TCM_COMPONENTE" + ",TCM_CLASE" + ",TCM_METODO" + ",TCM_TIPO" + ",TCM_PROCEDIMIENTO" + ",TCM_VALOR_CONSTANTE" + ",TCM_FUNCIONALIDAD_ESTANDAR)" + "VALUES" + "(@transformacion_codigo" + ",@campoDestino_codigo" + ",@mensajeDestino_codigo" + ",@componente" + ",@clase" + ",@metodo" + ",@tipoTransformacion_codigo" + ",@procedimiento" + ",@valorConstante" + ",@funcionalidadEstandar_codigo)"; DbCommand Comando = crearComando(contexto, transformacionCampo, query); Comando.Parameters.Add(Factoria.CrearParametro("@tieneParametros", 0)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static object EjecutarProcedure(string procedure, string parametro) { using (Switch contexto = new Switch()) { using (SqlCommand Comando = (SqlCommand)contexto.CreateCommand(procedure, CommandType.StoredProcedure)) { Comando.Parameters.Add("@input", SqlDbType.VarChar, 500).Value = parametro; Comando.Parameters.Add("@output", SqlDbType.VarChar, 500).Direction = ParameterDirection.Output; using (contexto.CreateConeccionScope()) { Comando.ExecuteNonQuery(); return Comando.Parameters["@output"].Value; } } } }
public static EstadoOperacion eliminarDinamicaCriptografia(DINAMICA_CRIPTOGRAFIA DinamicaCriptografia) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "DELETE FROM DINAMICA_CRIPTOGRAFIA" + " WHERE DNC_CODIGO = @codigo"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", DinamicaCriptografia.DNC_CODIGO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (DbException e) { DbExceptionProduct exception = Factoria.CrearException(e); if (exception.ForeignKeyError()) { return new EstadoOperacion(false, "La Dinamica Criptografia tiene Campos Criptografía y no se puede eliminar", e, true); } else { return new EstadoOperacion(false, e.Message, e); } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion eliminarMensaje(MENSAJE Mensaje) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "DELETE FROM MENSAJE" + " WHERE MEN_CODIGO = @codigo"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", Mensaje.MEN_CODIGO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (DbException e) { DbExceptionProduct exception = Factoria.CrearException(e); if (exception.ForeignKeyError()) { return new EstadoOperacion(false, "El Mensaje esta siendo utilizado por la aplicación y no se puede eliminar", e, true); } else { return new EstadoOperacion(false, e.Message, e); } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion eliminarCampoPlantilla(CAMPO_PLANTILLA CampoPlantilla) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "DELETE FROM [CAMPO_PLANTILLA]" + " WHERE [CMP_CODIGO] = @codigo"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", CampoPlantilla.CMP_CODIGO)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (DbException e) { DbExceptionProduct exception = Factoria.CrearException(e); if (exception.ForeignKeyError()) { return new EstadoOperacion(false, "El Campo Plantilla corresponde a un campo en el sistema y no se puede eliminar", e, true); } else { return new EstadoOperacion(false, e.Message, e); } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarMensaje(MENSAJE Mensaje) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { Mensaje.MEN_CODIGO = (from c in contexto.MENSAJE orderby c.MEN_CODIGO descending select c.MEN_CODIGO).FirstOrDefault() + 1; string query = "INSERT INTO MENSAJE" + "(MEN_CODIGO" + ",MEN_DESCRIPCION" + ",MEN_NOMBRE" + ",GMJ_CODIGO)" + "VALUES" + "(@codigo" + ",@descripcion" + ",@nombre" + ",@grupomensaje_codigo)"; DbCommand Comando = MensajeDA.crearComando(contexto, Mensaje, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarMensajeTransaccional(MENSAJE_TRANSACCIONAL MensajeTransaccional) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { MensajeTransaccional.MTR_CODIGO = (from c in contexto.MENSAJE_TRANSACCIONAL orderby c.MTR_CODIGO descending select c.MTR_CODIGO).FirstOrDefault() + 1; string query = "INSERT INTO MENSAJE_TRANSACCIONAL"+ "(MTR_CODIGO"+ ",MTR_NOMBRE"+ ",MEN_CODIGO"+ ",CNM_CODIGO)"+ "VALUES"+ "(@codigo"+ ",@nombre"+ ",@mensaje_codigo"+ ",@condicionmensaje_codigo)"; DbCommand Comando = MensajeTransaccionalDA.crearComando(contexto, MensajeTransaccional, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarDinamicaCriptografia(DINAMICA_CRIPTOGRAFIA DinamicaCriptografia) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { DinamicaCriptografia.DNC_CODIGO = (from c in contexto.DINAMICA_CRIPTOGRAFIA orderby c.DNC_CODIGO descending select c.DNC_CODIGO).FirstOrDefault() + 1; string query = "INSERT INTO DINAMICA_CRIPTOGRAFIA" + "(DNC_CODIGO" + ",DNC_NOMBRE" + ",DNC_TIPO" + ",MEN_CODIGO)" + "VALUES " + "(@codigo" + ",@nombre" + ",@tipo" + ",@mensaje_codigo)"; DbCommand Comando = crearComando(contexto, DinamicaCriptografia, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarTransformacion(TRANSFORMACION Transformacion) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { Transformacion.TRM_CODIGO = (from c in contexto.TRANSFORMACION orderby c.TRM_CODIGO descending select c.TRM_CODIGO).FirstOrDefault() + 1; string query = "INSERT INTO TRANSFORMACION" + "(TRM_CODIGO" + ",TRM_NOMBRE" + ",MEN_CODIGO_MENSAJE_ORIGEN" + ",MEN_CODIGO_MENSAJE_DESTINO)" + "VALUES" + "(@codigo" + ",@nombre" + ",@mensajeorigen_codigo" + ",@mensajedestino_codigo)"; DbCommand Comando = crearComando(contexto, Transformacion, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static string ejecutarTransformacionProcedimiento(string nombreProcedimiento,string parametro) { string resultado = null; try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { DbCommand Comando = contexto.CreateCommand(nombreProcedimiento, CommandType.StoredProcedure); Comando.Parameters.Add(Factoria.CrearParametro("@entrada", parametro)); Comando.Parameters.Add(Factoria.CrearParametro("@salida", ParameterDirection.Output)); Comando.ExecuteNonQuery(); resultado = Comando.Parameters["@salida"].Value.ToString(); } } } catch (Exception) { } return resultado; }
public static EstadoOperacion modificarValidacionCampo(VALIDACION_CAMPO vcampo) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "UPDATE [VALIDACION_CAMPO]" + "SET [VLC_INCLUSION_EXCLUSION] = @incexc" + ",[VLC_CONDICION] = @condicion" + ",[VLC_VALOR] = @valor" + ",[TBL_CODIGO] = @tabla" + ",[COL_CODIGO] = @columna" + ",[VLC_PROCEDIMIENTO] = @procedimiento" + " WHERE [VLC_CODIGO] = @codigo;"; DbCommand Comando = contexto.CreateCommand(query, CommandType.Text); Comando.Parameters.Add(Factoria.CrearParametro("@codigo", vcampo.VLC_CODIGO)); Comando.Parameters.Add(Factoria.CrearParametro("@incexc", vcampo.VLC_INCLUSION_EXCLUSION)); if (vcampo.VLC_CONDICION != null) Comando.Parameters.Add(Factoria.CrearParametro("@condicion", vcampo.VLC_CONDICION)); else Comando.Parameters.Add(Factoria.CrearParametro("@condicion", DBNull.Value)); if (vcampo.VLC_VALOR != null) Comando.Parameters.Add(Factoria.CrearParametro("@valor", vcampo.VLC_VALOR)); else Comando.Parameters.Add(Factoria.CrearParametro("@valor", DBNull.Value)); if (vcampo.TABLA != null) Comando.Parameters.Add(Factoria.CrearParametro("@tabla", vcampo.TABLA.TBL_CODIGO)); else Comando.Parameters.Add(Factoria.CrearParametro("@tabla", DBNull.Value)); if (vcampo.COLUMNA != null) Comando.Parameters.Add(Factoria.CrearParametro("@columna", vcampo.COLUMNA.COL_CODIGO)); else Comando.Parameters.Add(Factoria.CrearParametro("@columna", DBNull.Value)); if (vcampo.VLC_PROCEDIMIENTO != null) Comando.Parameters.Add(Factoria.CrearParametro("@procedimiento", vcampo.VLC_PROCEDIMIENTO)); else Comando.Parameters.Add(Factoria.CrearParametro("@procedimiento", DBNull.Value)); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarCriptografiaCampo(CRIPTOGRAFIA_CAMPO CriptografiaCampo) { try { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { int idCriptografiaCampo = (from c in contexto.CRIPTOGRAFIA_CAMPO where c.DINAMICA_CRIPTOGRAFIA.DNC_CODIGO == CriptografiaCampo.DINAMICA_CRIPTOGRAFIA.DNC_CODIGO orderby c.CRC_CODIGO descending select c.CRC_CODIGO).FirstOrDefault() + 1; CriptografiaCampo.CRC_CODIGO = idCriptografiaCampo; string insert = "INSERT INTO CRIPTOGRAFIA_CAMPO" + "(CRC_CODIGO" + ",DNC_CODIGO" + ",CAM_CODIGO_RESULTADO" + ",MEN_CODIGO_RESULTADO" + ",CAM_CODIGO_LLAVE_1" + ",MEN_CODIGO_LLAVE_1" + ",CAM_CODIGO_LLAVE_2" + ",MEN_CODIGO_LLAVE_2" + ",CRC_LLAVE_1" + ",CRC_LLAVE_2" + ",CRC_TIPO_LLAVE_1" + ",CRC_TIPO_LLAVE_2" + ",CRC_SEGUNDA_LLAVE" + ",CRC_ALGORITMO" + ",CRC_OPERACION_LLAVE)" + " VALUES " + "(@codigo" + ",@dinamica_codigo" + ",@campoResultado_codigo" + ",@mensajeResultado_codigo" + ",@campoLlave1_codigo" + ",@mensajeLlave1_codigo" + ",@campoLlave2_codigo" + ",@mensajeLlave2_codigo" + ",@llave1" + ",@llave2" + ",@tipoLlave1" + ",@tipoLlave2" + ",@segundaLlave" + ",@algoritmo" + ",@operacionLlave)"; DbCommand Comando = crearComando(contexto, CriptografiaCampo, insert); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion modificarDinamicaCriptografia(DINAMICA_CRIPTOGRAFIA DinamicaCriptografia) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "UPDATE DINAMICA_CRIPTOGRAFIA" + " SET DNC_NOMBRE = @nombre" + ",DNC_TIPO = @tipo" + " WHERE DNC_CODIGO = @codigo"; DbCommand Comando = crearComando(contexto, DinamicaCriptografia, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static DataTable ObtenerValoresTabla(string tabla) { DbFactory Factoria = DataAccessFactory.ObtenerProveedor(); DataTable dataTable = new DataTable(); using (Switch contexto = new Switch()) { using (DbCommand Comando = contexto.CreateCommand("Select * from " + tabla, CommandType.Text)) { using (DbDataAdapter adapter = Factoria.CrearDataAdapter()) { adapter.SelectCommand = Comando; using (contexto.CreateConeccionScope()) { adapter.Fill(dataTable); } return dataTable; } } } }
public static EstadoOperacion modificarValoresTabla(string tabla, List<string> columnasTabla, List<string> valoresTabla, int Id) { string queryUpdate = GenerarUpdateQuery(tabla, columnasTabla, valoresTabla, Id); try { using (Switch contexto = new Switch()) { DbCommand Comando = contexto.CreateCommand(queryUpdate, CommandType.Text); using (contexto.CreateConeccionScope()) { if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion modificarTabla(TABLA tabla) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "ModificarTabla"; DbCommand Comando = crearComando(contexto, tabla, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (DbException ex) { return new EstadoOperacion(false, ex.Message, ex, false); } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarValoresTabla(string tabla, List<string> columnasTabla, List<string> valoresTabla) { string queryMaxId = "Select max(ID)+1 from " + tabla; try { using (Switch contexto = new Switch()) { DbCommand Comando = contexto.CreateCommand(queryMaxId, CommandType.Text); using (contexto.CreateConeccionScope()) { object Id = Comando.ExecuteScalar(); int NuevoId = 1; if (Id != DBNull.Value) { NuevoId = (int)Id; } string queryInsert = GenerarInsertQuery(tabla, columnasTabla, valoresTabla, NuevoId); Comando.CommandText = queryInsert; if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion modificarCampoPlantilla(CAMPO_PLANTILLA CampoPlantilla) { if (!CampoPlantilla.CMP_CABECERA) { CAMPO_PLANTILLA CampoPlantillaAnterior = DataAccess.Mensajeria.CampoPlantillaDA.obtenerCampoPlantillaSinRelaciones(CampoPlantilla.CMP_CODIGO); if (CampoPlantilla.CMP_POSICION_RELATIVA != CampoPlantillaAnterior.CMP_POSICION_RELATIVA) { if (DataAccess.Mensajeria.CampoPlantillaDA. obtenerCampoPlantillaPorPosicionRelativaPorGrupoMensaje(CampoPlantilla.CMP_POSICION_RELATIVA, CampoPlantilla.GRUPO_MENSAJE.GMJ_CODIGO) != null) { return new EstadoOperacion(false, "La Posición Relativa ya ha sido asignada", null, true); } } } try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "UPDATE [CAMPO_PLANTILLA]" + " SET [CMP_NOMBRE] = @nombre" + ",[CMP_LONGITUD] = @longitud" + ",[CMP_SELECTOR] = @selector" + ",[CMP_VARIABLE] = @variable" + ",[CMP_PROTEGIDO_LOG] = @protegidolog" + ",[CMP_POSICION_RELATIVA]= @posicionrelativa" + ",[CMP_LONGITUD_CABECERA]= @longitudCabecera" + ",[CMP_ALMACENADO] = @almacenado" + ",[CMP_CABECERA] = @cabecera" + ",[CMP_BITMAP] = @bitmap" + ",[CMP_TRANSACCIONAL] = @transaccional" + ",[TDT_CODIGO] = @tipodato_codigo" + " WHERE [CMP_CODIGO] = @codigo"; DbCommand Comando = CampoPlantillaDA.crearComando(contexto, CampoPlantilla, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (SqlException ex) { return new EstadoOperacion(false, ex.Errors[0].Message, ex, true); } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion modificarTransformacion(TRANSFORMACION Transformacion) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { string query = "UPDATE TRANSFORMACION" + " SET TRM_NOMBRE = @nombre" + ",MEN_CODIGO_MENSAJE_ORIGEN = @mensajeorigen_codigo" + ",MEN_CODIGO_MENSAJE_DESTINO = @mensajedestino_codigo" + " WHERE TRM_CODIGO = @codigo"; DbCommand Comando = crearComando(contexto, Transformacion, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarCampoPlantilla(CAMPO_PLANTILLA CampoPlantilla) { if (!CampoPlantilla.CMP_CABECERA) { if (DataAccess.Mensajeria.CampoPlantillaDA. obtenerCampoPlantillaPorPosicionRelativaPorGrupoMensaje(CampoPlantilla.CMP_POSICION_RELATIVA, CampoPlantilla.GRUPO_MENSAJE.GMJ_CODIGO) != null) { return new EstadoOperacion(false, "La Posición Relativa ya ha sido asignada", null, true); } } try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { CampoPlantilla.CMP_CODIGO = (from c in contexto.CAMPO_PLANTILLA orderby c.CMP_CODIGO descending select c.CMP_CODIGO).FirstOrDefault() + 1; string query = "INSERT INTO [CAMPO_PLANTILLA]" + "([CMP_CODIGO]" + ",[CMP_NOMBRE]" + ",[CMP_LONGITUD]" + ",[CMP_SELECTOR]" + ",[CMP_VARIABLE]" + ",[CMP_PROTEGIDO_LOG]" + ",[CMP_ALMACENADO]" + ",[CMP_POSICION_RELATIVA]" + ",[CMP_LONGITUD_CABECERA]" + ",[GMJ_CODIGO]" + ",[CMP_CABECERA]" + ",[CMP_BITMAP]" + ",[CMP_TRANSACCIONAL]" + ",[TDT_CODIGO])" + "VALUES" + "(@codigo" + ",@nombre" + ",@longitud" + ",@selector" + ",@variable" + ",@protegidolog" + ",@almacenado" + ",@posicionrelativa" + ",@longitudCabecera" + ",@grupomensaje_codigo" + ",@cabecera" + ",@bitmap" + ",@transaccional" + ",@tipodato_codigo)"; DbCommand Comando = CampoPlantillaDA.crearComando(contexto, CampoPlantilla, query); if (Comando.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }
public static EstadoOperacion insertarValidacionCampo(VALIDACION_CAMPO vcampo) { try { using (Switch contexto = new Switch()) { using (contexto.CreateConeccionScope()) { int idValidacionCampo = (from c in contexto.VALIDACION_CAMPO orderby c.VLC_CODIGO descending select c.VLC_CODIGO).FirstOrDefault() + 1; vcampo.VLC_CODIGO = idValidacionCampo; string insert = "INSERT INTO [VALIDACION_CAMPO]" + "([VLC_CODIGO]" + ",[GRV_CODIGO]" + ",[MEN_CODIGO]" + ",[CAM_CODIGO]" + ",[VLC_INCLUSION_EXCLUSION]" + ",[VLC_CONDICION]" + ",[VLC_VALOR]" + ",[TBL_CODIGO]" + ",[COL_CODIGO]" + ",[VLC_PROCEDIMIENTO])" + " VALUES(@codigo,@grupo,@mensaje,@campo,@incexc,@condicion,@valor,@tabla,@columna,@procedimiento)"; SqlCommand ComandoInsert = (SqlCommand)contexto.CreateCommand(insert, CommandType.Text); ComandoInsert.Parameters.Add(new SqlParameter("@codigo", vcampo.VLC_CODIGO)); ComandoInsert.Parameters.Add(new SqlParameter("@grupo", vcampo.GRV_CODIGO)); ComandoInsert.Parameters.Add(new SqlParameter("@mensaje", vcampo.MEN_CODIGO)); ComandoInsert.Parameters.Add(new SqlParameter("@campo", vcampo.CAM_CODIGO)); ComandoInsert.Parameters.Add(new SqlParameter("@incexc", vcampo.VLC_INCLUSION_EXCLUSION)); if (vcampo.VLC_CONDICION != null) ComandoInsert.Parameters.Add(new SqlParameter("@condicion", vcampo.VLC_CONDICION)); else ComandoInsert.Parameters.Add(new SqlParameter("@condicion", DBNull.Value)); if (vcampo.VLC_VALOR != null) ComandoInsert.Parameters.Add(new SqlParameter("@valor", vcampo.VLC_VALOR)); else ComandoInsert.Parameters.Add(new SqlParameter("@valor", DBNull.Value)); if (vcampo.TABLA != null) ComandoInsert.Parameters.Add(new SqlParameter("@tabla", vcampo.TABLA.TBL_CODIGO)); else ComandoInsert.Parameters.Add(new SqlParameter("@tabla", DBNull.Value)); if (vcampo.COLUMNA != null) ComandoInsert.Parameters.Add(new SqlParameter("@columna", vcampo.COLUMNA.COL_CODIGO)); else ComandoInsert.Parameters.Add(new SqlParameter("@columna", DBNull.Value)); if (vcampo.VLC_PROCEDIMIENTO != null) ComandoInsert.Parameters.Add(new SqlParameter("@procedimiento", vcampo.VLC_PROCEDIMIENTO)); else ComandoInsert.Parameters.Add(new SqlParameter("@procedimiento", DBNull.Value)); if (ComandoInsert.ExecuteNonQuery() != 1) { return new EstadoOperacion(false, null, null); } return new EstadoOperacion(true, null, null); } } } catch (Exception e) { return new EstadoOperacion(false, e.Message, e); } }