public bool Actualizar(ProductoConfiguracionEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"UPDATE productoconfiguracion SET idProducto = @idProducto, AplicarComisiones = @AplicarComisiones, MostrarContenidoDeObservacionesENFactura = @MostrarContenidoDeObservacionesENFactura, MostrarImagenAlFacturar = @MostrarImagenAlFacturar, PreguntarNumeroDeSerieAlFacturar = @PreguntarNumeroDeSerieAlFacturar, PreguntarFechaDeVencimientoAlFacturar = @PreguntarFechaDeVencimientoAlFacturar, PreguntarPorResetaAlFacturar =@PreguntarPorResetaAlFacturar, NoUsarComisionesParaEsteProducto = @NoUsarComisionesParaEsteProducto, UsarComisionesDefinidasEnElregistroDelVendedor = @UsarComisionesDefinidasEnElregistroDelVendedor, MontoFijoPorVenta = @MontoFijoPorVenta, PorcentajeDeLaVenta = @PorcentajeDeLaVenta, PorcentajeDeLaGanacia = @PorcentajeDeLaGanacia, Comision = @Comision, ComisionMaxima = @ComisionMaxima, idUsuarioModificacion = @idUsuarioModificacion, FechaDeModificacion = current_timestamp() WHERE idProductoConfiguracion = @idProductoConfiguracion;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idProductoConfiguracion", MySqlDbType.Int32)).Value = oRegistroEN.idProductoConfiguracion; Comando.Parameters.Add(new MySqlParameter("@idProducto", MySqlDbType.Int32)).Value = oRegistroEN.oProductoEN.idProducto; Comando.Parameters.Add(new MySqlParameter("@AplicarComisiones", MySqlDbType.Int32)).Value = oRegistroEN.AplicarComisiones; Comando.Parameters.Add(new MySqlParameter("@MostrarImagenAlFacturar", MySqlDbType.Int32)).Value = oRegistroEN.MostrarImagenAlFacturar; Comando.Parameters.Add(new MySqlParameter("@MostrarContenidoDeObservacionesENFactura", MySqlDbType.Int32)).Value = oRegistroEN.MostrarContenidoDeObservacionesENFactura; Comando.Parameters.Add(new MySqlParameter("@PreguntarNumeroDeSerieAlFacturar", MySqlDbType.Int32)).Value = oRegistroEN.PreguntarNumeroDeSerieAlFacturar; Comando.Parameters.Add(new MySqlParameter("@PreguntarFechaDeVencimientoAlFacturar", MySqlDbType.Int32)).Value = oRegistroEN.PreguntarFechaDeVencimientoAlFacturar; Comando.Parameters.Add(new MySqlParameter("@PreguntarPorResetaAlFacturar", MySqlDbType.Int32)).Value = oRegistroEN.PreguntarPorResetaAlFacturar; Comando.Parameters.Add(new MySqlParameter("@NoUsarComisionesParaEsteProducto", MySqlDbType.Int32)).Value = oRegistroEN.NoUsarComisionesParaEsteProducto; Comando.Parameters.Add(new MySqlParameter("@UsarComisionesDefinidasEnElregistroDelVendedor", MySqlDbType.Int32)).Value = oRegistroEN.UsarComisionesDefinidasEnElregistroDelVendedor; Comando.Parameters.Add(new MySqlParameter("@MontoFijoPorVenta", MySqlDbType.Int32)).Value = oRegistroEN.MontoFijoPorVenta; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDeLaVenta", MySqlDbType.Int32)).Value = oRegistroEN.PorcentajeDeLaVenta; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDeLaGanacia", MySqlDbType.Int32)).Value = oRegistroEN.PorcentajeDeLaGanacia; Comando.Parameters.Add(new MySqlParameter("@Comision", MySqlDbType.Decimal)).Value = oRegistroEN.Comision; Comando.Parameters.Add(new MySqlParameter("@ComisionMaxima", MySqlDbType.Decimal)).Value = oRegistroEN.ComisionMaxima; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioModificacion; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"UPDATE periodo set Desde = @Desde, Hasta = @Hasta, Nombre = @Nombre, Obsevaciones = @Obsevaciones, Estado = @Estado, IdUsuarioDeModificacion = @IdUsuarioDeModificacion, FechaDeModificacion = current_timestamp() where idPeriodo = @idPeriodo;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idPeriodo", MySqlDbType.Int32)).Value = oRegistroEN.idPeriodo; Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value = oRegistroEN.Desde; Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value = oRegistroEN.Hasta; Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@Obsevaciones", MySqlDbType.VarChar, oRegistroEN.Obsevaciones.Trim().Length)).Value = oRegistroEN.Obsevaciones.Trim(); Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value = oRegistroEN.Estado.Trim(); Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool ValidarSiElRegistroEstaVinculado(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.StoredProcedure; Comando.CommandText = "ValidarSiElRegistroEstaVinculado"; Comando.Parameters.Add(new MySqlParameter("@CampoABuscar_", MySqlDbType.VarChar, 200)).Value = "idPeriodo"; Comando.Parameters.Add(new MySqlParameter("@ValorCampoABuscar", MySqlDbType.Int32)).Value = oRegistroEN.idPeriodo; Comando.Parameters.Add(new MySqlParameter("@ExcluirTabla_", MySqlDbType.VarChar, 200)).Value = string.Empty; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); if (DT.Rows[0].ItemArray[0].ToString().ToUpper() == "NINGUNA".ToUpper()) { return(false); } else { this.Error = String.Format("La Operación: '{1}', {0} no se puede completar por que el registro: {0} '{2}', {0} se encuentra asociado con: {0} {3}", Environment.NewLine, TipoDeOperacion, InformacionDelRegistro(oRegistroEN), oTransaccionesAD.ConvertirValorDeLaCadena(DT.Rows[0].ItemArray[0].ToString())); DescripcionDeOperacion = this.Error; //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(EmpresaEN oRegistroEN, DatosDeConexionEN oDatos) { try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"insert into Empresa (Nombre, Direccion, Telefonos, NRuc, Logo, Celular, Email, SitioWeb, Descripcion) values (@Nombre, @Direccion, @Telefonos, @NRuc, @Logo, @Celular, @Email, @SitioWeb, @Descripcion); Select last_insert_id() as 'ID';"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@Direccion", MySqlDbType.VarChar, oRegistroEN.Direccion.Trim().Length)).Value = oRegistroEN.Direccion.Trim(); Comando.Parameters.Add(new MySqlParameter("@Telefonos", MySqlDbType.VarChar, oRegistroEN.Telefonos.Trim().Length)).Value = oRegistroEN.Telefonos.Trim(); Comando.Parameters.Add(new MySqlParameter("@NRuc", MySqlDbType.VarChar, oRegistroEN.NRuc.Trim().Length)).Value = oRegistroEN.NRuc.Trim(); Comando.Parameters.Add(new MySqlParameter("@Celular", MySqlDbType.VarChar, oRegistroEN.Celular.Trim().Length)).Value = oRegistroEN.Celular.Trim(); Comando.Parameters.Add(new MySqlParameter("@Email", MySqlDbType.VarChar, oRegistroEN.Email.Trim().Length)).Value = oRegistroEN.Email.Trim(); Comando.Parameters.Add(new MySqlParameter("@SitioWeb", MySqlDbType.VarChar, oRegistroEN.SitioWeb.Trim().Length)).Value = oRegistroEN.SitioWeb.Trim(); Comando.Parameters.Add(new MySqlParameter("@Descripcion", MySqlDbType.VarChar, oRegistroEN.Descripcion.Trim().Length)).Value = oRegistroEN.Descripcion.Trim(); Comando.Parameters.Add(new MySqlParameter("@Logo", MySqlDbType.Binary)).Value = oRegistroEN.ALogo; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.IdEmpresa = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); oTransaccionesAD.Agregar(oRegistroEN.oLoginEN.idUsuario, oRegistroEN.oLoginEN.NumeroIP, oRegistroEN.IdEmpresa, "AGREGAR", "INFORMACIÓN DE LA EMPRESA AGREGADA CORRECTAMENTE", "CORRECTA", DescripcionDeOperacion, oRegistroEN.oLoginEN.idUsuario, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); oTransaccionesAD.Agregar(oRegistroEN.oLoginEN.idUsuario, oRegistroEN.oLoginEN.NumeroIP, oRegistroEN.IdEmpresa, "AGREGAR", "ERROR AL AGREGAR LA INFORMACIÓN DE LA EMPRESA", "ERROR", DescripcionDeOperacion, oRegistroEN.oLoginEN.idUsuario, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(CuentaDeBancosEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @" INSERT INTO cuentadebancos (NumeroDeCuenta, Descripcion, idBancos, idUsuarioDeCreacion, FechaDeCreacion, idUsuarioModificacion, FechaDeModificacion) VALUES (@NumeroDeCuenta, @Descripcion, @idBancos, @idUsuarioDeCreacion, current_timestamp(), @idUsuarioModificacion, current_timestamp()); Select last_insert_id() as 'ID';"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@NumeroDeCuenta", MySqlDbType.VarChar, oRegistroEN.NumeroDeCuenta.Trim().Length)).Value = oRegistroEN.NumeroDeCuenta.Trim(); Comando.Parameters.Add(new MySqlParameter("@Descripcion", MySqlDbType.VarChar, oRegistroEN.Descripcion.Trim().Length)).Value = oRegistroEN.Descripcion.Trim(); Comando.Parameters.Add(new MySqlParameter("@idBancos", MySqlDbType.Int32)).Value = oRegistroEN.oBancosEN.idBancos; Comando.Parameters.Add(new MySqlParameter("@idUsuarioDeCreacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioDeCreacion; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioModificacion; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.idCuentaDeBancos = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool ValidarFechaDelRegistro(ProductoPromocionEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; switch (TipoDeOperacion.Trim().ToUpper()) { case "AGREGAR": /*Consultas = @"SELECT CASE WHEN EXISTS(SELECT idProductoPromocion FROM productopromocion where (SoloFecha(FechaDeInicio) >= SoloFecha(@FechaDeInicio) and SoloFecha(FechaDeInicio) <= SoloFecha(@FechaDeFinalizacion)) * or (SoloFecha(FechaDeFinalizacion) >= SoloFecha(@FechaDeInicio) and SoloFecha(FechaDeFinalizacion) <= SoloFecha(@FechaDeFinalizacion)) and idProducto = @idProducto) THEN 1 ELSE 0 END AS 'RES'"; * Comando.Parameters.Add(new MySqlParameter("@idProducto", MySqlDbType.Int32)).Value = oRegistroEN.oProductoEN.idProducto; * Comando.Parameters.Add(new MySqlParameter("@FechaDeInicio", MySqlDbType.DateTime)).Value = oRegistroEN.FechaDeInicio; * Comando.Parameters.Add(new MySqlParameter("@FechaDeFinalizacion", MySqlDbType.DateTime)).Value = oRegistroEN.FechaDeFinalizacion;*/ Consultas = @"SELECT CASE WHEN EXISTS(SELECT idProductoPromocion FROM productopromocion where (@FechaDeInicio between FechaDeInicio and FechaDeFinalizacion) or (@FechaDeFinalizacion between FechaDeInicio and FechaDeFinalizacion) and idProducto = @idProducto) THEN 1 ELSE 0 END AS 'RES'"; Comando.Parameters.Add(new MySqlParameter("@idProducto", MySqlDbType.Int32)).Value = oRegistroEN.oProductoEN.idProducto; Comando.Parameters.Add(new MySqlParameter("@FechaDeInicio", MySqlDbType.DateTime)).Value = oRegistroEN.FechaDeInicio; Comando.Parameters.Add(new MySqlParameter("@FechaDeFinalizacion", MySqlDbType.DateTime)).Value = oRegistroEN.FechaDeFinalizacion; break; case "ACTUALIZAR": Consultas = @"SELECT CASE WHEN EXISTS(SELECT idProductoPromocion FROM productopromocion where (SoloFecha(FechaDeInicio) >= SoloFecha(@FechaDeInicio) and SoloFecha(FechaDeInicio) <= SoloFecha(@FechaDeFinalizacion)) or (SoloFecha(FechaDeFinalizacion) >= SoloFecha(@FechaDeInicio) and SoloFecha(FechaDeFinalizacion) <= SoloFecha(@FechaDeFinalizacion)) and idProducto = @idProducto and idProductoPromocion <> @idProductoPromocion) THEN 1 ELSE 0 END AS 'RES'"; Comando.Parameters.Add(new MySqlParameter("@idProducto", MySqlDbType.Int32)).Value = oRegistroEN.oProductoEN.idProducto; Comando.Parameters.Add(new MySqlParameter("@idProductoPromocion", MySqlDbType.Int32)).Value = oRegistroEN.idProductoPromocion; Comando.Parameters.Add(new MySqlParameter("@FechaDeInicio", MySqlDbType.DateTime)).Value = oRegistroEN.FechaDeInicio; Comando.Parameters.Add(new MySqlParameter("@FechaDeFinalizacion", MySqlDbType.DateTime)).Value = oRegistroEN.FechaDeFinalizacion; break; default: throw new ArgumentException("La aperación solicitada no esta disponible"); } Comando.CommandText = Consultas; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); if (Convert.ToInt32(DT.Rows[0]["RES"].ToString()) > 0) { DescripcionDeOperacion = string.Format("Ya existe información de la Fecha del Registro dentro de nuestro sistema: {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); this.Error = DescripcionDeOperacion; return(true); } return(false); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "REGISTRO DUPLICADO DENTRO DE LA BASE DE DATOS", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"update ProveedorLaboratorio set idProveedor = @idProveedor, idLaboratorio = @idLaboratorio, idUsuarioModificacion = @idUsuarioModificacion, FechaDeModificacion = current_timestamp() where idProveedorLaboratorio = @idProveedorLaboratorio;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idProveedorLaboratorio", MySqlDbType.Int32)).Value = oRegistroEN.idProveedorLaboratorio; Comando.Parameters.Add(new MySqlParameter("@idProveedor", MySqlDbType.Int32)).Value = oRegistroEN.oProveedorEN.idProveedor; Comando.Parameters.Add(new MySqlParameter("@idLaboratorio", MySqlDbType.Int32)).Value = oRegistroEN.oLaboratorioEN.idLaboratorio; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.IdUsuarioDeModificacion; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(ContactoEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"update contacto set Nombre = @Nombre, Direccion = @Direccion, Telefono = @Telefono, Movil = @Movil, Observaciones = @Observaciones, Correo = @Correo, FechaDeCumpleanos = @FechaDeCumpleanos, Messenger = @Messenger, Skype = @Skype, Twitter = @Twitter, Facebook = @Facebook, Estado = @Estado, Foto = @Foto, idUsuarioModificacion = @idUsuarioModificacion, FechaDeModificacion = current_timestamp(), Sexo = @Sexo, Cedula = @Cedula where idContacto = @idContacto;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idContacto", MySqlDbType.Int32)).Value = oRegistroEN.idContacto; Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@Direccion", MySqlDbType.VarChar, oRegistroEN.Direccion.Trim().Length)).Value = oRegistroEN.Direccion.Trim(); Comando.Parameters.Add(new MySqlParameter("@Telefono", MySqlDbType.VarChar, oRegistroEN.Telefono.Trim().Length)).Value = oRegistroEN.Telefono.Trim(); Comando.Parameters.Add(new MySqlParameter("@Movil", MySqlDbType.VarChar, oRegistroEN.Movil.Trim().Length)).Value = oRegistroEN.Movil.Trim(); Comando.Parameters.Add(new MySqlParameter("@Observaciones", MySqlDbType.VarChar, oRegistroEN.Observaciones.Trim().Length)).Value = oRegistroEN.Observaciones.Trim(); Comando.Parameters.Add(new MySqlParameter("@Correo", MySqlDbType.VarChar, oRegistroEN.Correo.Trim().Length)).Value = oRegistroEN.Correo.Trim(); Comando.Parameters.Add(new MySqlParameter("@FechaDeCumpleanos", MySqlDbType.VarChar, oRegistroEN.FechaDeCumpleanos.Trim().Length)).Value = oRegistroEN.FechaDeCumpleanos.Trim(); Comando.Parameters.Add(new MySqlParameter("@Messenger", MySqlDbType.VarChar, oRegistroEN.Messenger.Trim().Length)).Value = oRegistroEN.Messenger.Trim(); Comando.Parameters.Add(new MySqlParameter("@Skype", MySqlDbType.VarChar, oRegistroEN.Skype.Trim().Length)).Value = oRegistroEN.Skype.Trim(); Comando.Parameters.Add(new MySqlParameter("@Twitter", MySqlDbType.VarChar, oRegistroEN.Twitter.Trim().Length)).Value = oRegistroEN.Twitter.Trim(); Comando.Parameters.Add(new MySqlParameter("@Facebook", MySqlDbType.VarChar, oRegistroEN.Facebook.Trim().Length)).Value = oRegistroEN.Facebook.Trim(); Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value = oRegistroEN.Estado.Trim(); Comando.Parameters.Add(new MySqlParameter("@Sexo", MySqlDbType.VarChar, oRegistroEN.Sexo.Trim().Length)).Value = oRegistroEN.Sexo.Trim(); Comando.Parameters.Add(new MySqlParameter("@Cedula", MySqlDbType.VarChar, oRegistroEN.Cedula.Trim().Length)).Value = oRegistroEN.Cedula.Trim(); Comando.Parameters.Add(new MySqlParameter("@Foto", MySqlDbType.Binary)).Value = oRegistroEN.AFoto; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(ContactoEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.StoredProcedure; Consultas = @"AgregarInformacionDelContacto"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idContacto_", MySqlDbType.Int32)).Value = oRegistroEN.idContacto; Comando.Parameters.Add(new MySqlParameter("@Codigo_", MySqlDbType.VarChar, oRegistroEN.Codigo.Trim().Length)).Value = oRegistroEN.Codigo.Trim(); Comando.Parameters.Add(new MySqlParameter("@Nombre_", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@Direccion_", MySqlDbType.VarChar, oRegistroEN.Direccion.Trim().Length)).Value = oRegistroEN.Direccion.Trim(); Comando.Parameters.Add(new MySqlParameter("@Telefono_", MySqlDbType.VarChar, oRegistroEN.Telefono.Trim().Length)).Value = oRegistroEN.Telefono.Trim(); Comando.Parameters.Add(new MySqlParameter("@Movil_", MySqlDbType.VarChar, oRegistroEN.Movil.Trim().Length)).Value = oRegistroEN.Movil.Trim(); Comando.Parameters.Add(new MySqlParameter("@Observaciones_", MySqlDbType.VarChar, oRegistroEN.Observaciones.Trim().Length)).Value = oRegistroEN.Observaciones.Trim(); Comando.Parameters.Add(new MySqlParameter("@Correo_", MySqlDbType.VarChar, oRegistroEN.Correo.Trim().Length)).Value = oRegistroEN.Correo.Trim(); Comando.Parameters.Add(new MySqlParameter("@FechaDeCumpleanos_", MySqlDbType.VarChar, oRegistroEN.FechaDeCumpleanos.Trim().Length)).Value = oRegistroEN.FechaDeCumpleanos.Trim(); Comando.Parameters.Add(new MySqlParameter("@Messenger_", MySqlDbType.VarChar, oRegistroEN.Messenger.Trim().Length)).Value = oRegistroEN.Messenger.Trim(); Comando.Parameters.Add(new MySqlParameter("@Skype_", MySqlDbType.VarChar, oRegistroEN.Skype.Trim().Length)).Value = oRegistroEN.Skype.Trim(); Comando.Parameters.Add(new MySqlParameter("@Twitter_", MySqlDbType.VarChar, oRegistroEN.Twitter.Trim().Length)).Value = oRegistroEN.Twitter.Trim(); Comando.Parameters.Add(new MySqlParameter("@Facebook_", MySqlDbType.VarChar, oRegistroEN.Facebook.Trim().Length)).Value = oRegistroEN.Facebook.Trim(); Comando.Parameters.Add(new MySqlParameter("@Estado_", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value = oRegistroEN.Estado.Trim(); Comando.Parameters.Add(new MySqlParameter("@Sexo_", MySqlDbType.VarChar, oRegistroEN.Sexo.Trim().Length)).Value = oRegistroEN.Sexo.Trim(); Comando.Parameters.Add(new MySqlParameter("@Cedula_", MySqlDbType.VarChar, oRegistroEN.Cedula.Trim().Length)).Value = oRegistroEN.Cedula.Trim(); Comando.Parameters.Add(new MySqlParameter("@Foto_", MySqlDbType.Binary)).Value = oRegistroEN.AFoto; Comando.Parameters.Add(new MySqlParameter("@idUsuarioDeCreacion_", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion_", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.Codigo = DT.Rows[0].ItemArray[0].ToString(); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(TransaccionTMPEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @" insert into transacciontmp (NumeroDeTransaccion, Fecha, Concepto, Valor, idTipoDeTransaccion, Estado, IdUsuarioDeCreacion, FechaDeCreacion, IdUsuarioDeModificacion, FechaDeModificacion) values (CrearNumeroDelaTransaccionPorTipo(@idTipoDeTransaccion), @Fecha, @Concepto, @Valor, @idTipoDeTransaccion, @Estado, @IdUsuarioDeCreacion, current_timestamp(), @IdUsuarioDeModificacion, current_timestamp()); Select idTransacciones, NumeroDeTransaccion from transacciontmp where idTransacciones = last_insert_id();"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@Fecha", MySqlDbType.DateTime)).Value = oRegistroEN.Fecha; Comando.Parameters.Add(new MySqlParameter("@Concepto", MySqlDbType.VarChar, oRegistroEN.Concepto.Trim().Length)).Value = oRegistroEN.Concepto.Trim(); Comando.Parameters.Add(new MySqlParameter("@Valor", MySqlDbType.Decimal)).Value = oRegistroEN.Valor; Comando.Parameters.Add(new MySqlParameter("@idTipoDeTransaccion", MySqlDbType.Int32)).Value = oRegistroEN.oTipoDeTransaccionEN.idTipoDeTransaccion; Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value = oRegistroEN.Estado.Trim(); Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeCreacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.idTransacciones = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); oRegistroEN.NumeroDeTransaccion = DT.Rows[0].ItemArray[0].ToString(); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Error al agregar el registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool AgregarUtilizandoLaMismaConexion(ContactoEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); MySqlTransaction oMySqlTransaction; oMySqlTransaction = Cnn.BeginTransaction(); try { String mensaje = ""; string Errores = string.Empty; //Debemos agrear la Entidad Correspondiente EntidadEN oEntidadEN = new EntidadEN(); oEntidadEN.oTipoDeEntidadEN.Nombre = "Contacto"; oEntidadEN.oTipoDeEntidadEN.NombreInterno = "contacto"; EntidadAD oEntidadAD = new EntidadAD(); if (oEntidadAD.Agregar(oEntidadEN, oDatos, ref Cnn, ref oMySqlTransaction)) { oRegistroEN.idContacto = oEntidadEN.idEntidad; Errores = EvaluarTextoError(Errores, "GUARDAR", oEntidadAD.Error); } else { mensaje = String.Format("Error : '{1}', {0} producido al intentar guardar la información en la Entidad. ", Environment.NewLine, oEntidadAD.Error); throw new System.ArgumentException(mensaje); } oEntidadAD = null; oEntidadEN = null; if (Agregar(oRegistroEN, oDatos, ref Cnn, ref oMySqlTransaction)) { oRegistroEN.idContacto = oEntidadEN.idEntidad; Errores = EvaluarTextoError(Errores, "GUARDAR", this.Error); } else { mensaje = String.Format("Error : '{1}', {0} producido al intentar guardar la información del concto. ", Environment.NewLine, this.Error); throw new System.ArgumentException(mensaje); } this.Error = Errores; oMySqlTransaction.Commit(); return(true); } catch (Exception ex) { this.Error = ex.Message; oMySqlTransaction.Rollback(); DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(TransaccionTMPEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"update transacciontmp set Fecha = @Fecha, Concepto = @Concepto, Valor = @Valor, idTipoDeTransaccion = @idTipoDeTransaccion, Estado = @Estado, IdUsuarioDeModificacion = @IdUsuarioDeModificacion, FechaDeModificacion = current_timestamp() where idTransacciones = @idTransacciones;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idTransacciones", MySqlDbType.Int32)).Value = oRegistroEN.idTransacciones; Comando.Parameters.Add(new MySqlParameter("@Fecha", MySqlDbType.DateTime)).Value = oRegistroEN.Fecha; Comando.Parameters.Add(new MySqlParameter("@Concepto", MySqlDbType.VarChar, oRegistroEN.Concepto.Trim().Length)).Value = oRegistroEN.Concepto.Trim(); Comando.Parameters.Add(new MySqlParameter("@Valor", MySqlDbType.Decimal)).Value = oRegistroEN.Valor; Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value = oRegistroEN.Estado.Trim(); Comando.Parameters.Add(new MySqlParameter("@idTipoDeTransaccion", MySqlDbType.Int32)).Value = oRegistroEN.oTipoDeTransaccionEN.idTipoDeTransaccion; Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Registro Actualizado", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la transacción TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Error al Actualizar", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(ContenedorEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @" insert into contenedor (idSeccion, Codigo, Nombre, Descripcion, idUsuarioDeCreacion, FechaDeCreacion, idUsuarioModificacion, FechaDeModificacion) values (@idSeccion, @Codigo, @Nombre, @Descripcion, @idUsuarioDeCreacion, current_timestamp(), @idUsuarioModificacion, current_timestamp()); Select last_insert_id() as 'ID'; "; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idSeccion", MySqlDbType.Int32)).Value = oRegistroEN.oSeccionEN.idSeccion; Comando.Parameters.Add(new MySqlParameter("@Codigo", MySqlDbType.VarChar, oRegistroEN.Codigo.Trim().Length)).Value = oRegistroEN.Codigo.Trim(); Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@Descripcion", MySqlDbType.VarChar, oRegistroEN.Descripcion.Trim().Length)).Value = oRegistroEN.Descripcion.Trim(); Comando.Parameters.Add(new MySqlParameter("@idUsuarioDeCreacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(ProductoConfiguracionEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @" insert into productoconfiguracion (idProducto, AplicarComisiones, MostrarContenidoDeObservacionesENFactura, MostrarImagenAlFacturar, PreguntarNumeroDeSerieAlFacturar, PreguntarFechaDeVencimientoAlFacturar, PreguntarPorResetaAlFacturar, NoUsarComisionesParaEsteProducto, UsarComisionesDefinidasEnElregistroDelVendedor, MontoFijoPorVenta, PorcentajeDeLaVenta, PorcentajeDeLaGanacia, Comision, ComisionMaxima, idUsuarioDeCreacion, FechaDeCreacion, idUsuarioModificacion, FechaDeModificacion) values (@idProducto, @AplicarComisiones, @MostrarContenidoDeObservacionesENFactura, @MostrarImagenAlFacturar, @PreguntarNumeroDeSerieAlFacturar, @PreguntarFechaDeVencimientoAlFacturar, @PreguntarPorResetaAlFacturar, @NoUsarComisionesParaEsteProducto, @UsarComisionesDefinidasEnElregistroDelVendedor, @MontoFijoPorVenta, @PorcentajeDeLaVenta, @PorcentajeDeLaGanacia, @Comision, @ComisionMaxima, @idUsuarioDeCreacion, current_timestamp(), @idUsuarioModificacion, current_timestamp()); Select last_insert_id() as 'ID';"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idProducto", MySqlDbType.Int32)).Value = oRegistroEN.oProductoEN.idProducto; Comando.Parameters.Add(new MySqlParameter("@AplicarComisiones", MySqlDbType.Int32)).Value = oRegistroEN.AplicarComisiones; Comando.Parameters.Add(new MySqlParameter("@MostrarImagenAlFacturar", MySqlDbType.Int32)).Value = oRegistroEN.MostrarImagenAlFacturar; Comando.Parameters.Add(new MySqlParameter("@MostrarContenidoDeObservacionesENFactura", MySqlDbType.Int32)).Value = oRegistroEN.MostrarContenidoDeObservacionesENFactura; Comando.Parameters.Add(new MySqlParameter("@PreguntarNumeroDeSerieAlFacturar", MySqlDbType.Int32)).Value = oRegistroEN.PreguntarNumeroDeSerieAlFacturar; Comando.Parameters.Add(new MySqlParameter("@PreguntarFechaDeVencimientoAlFacturar", MySqlDbType.Int32)).Value = oRegistroEN.PreguntarFechaDeVencimientoAlFacturar; Comando.Parameters.Add(new MySqlParameter("@PreguntarPorResetaAlFacturar", MySqlDbType.Int32)).Value = oRegistroEN.PreguntarPorResetaAlFacturar; Comando.Parameters.Add(new MySqlParameter("@NoUsarComisionesParaEsteProducto", MySqlDbType.Int32)).Value = oRegistroEN.NoUsarComisionesParaEsteProducto; Comando.Parameters.Add(new MySqlParameter("@UsarComisionesDefinidasEnElregistroDelVendedor", MySqlDbType.Int32)).Value = oRegistroEN.UsarComisionesDefinidasEnElregistroDelVendedor; Comando.Parameters.Add(new MySqlParameter("@MontoFijoPorVenta", MySqlDbType.Int32)).Value = oRegistroEN.MontoFijoPorVenta; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDeLaVenta", MySqlDbType.Int32)).Value = oRegistroEN.PorcentajeDeLaVenta; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDeLaGanacia", MySqlDbType.Int32)).Value = oRegistroEN.PorcentajeDeLaGanacia; Comando.Parameters.Add(new MySqlParameter("@Comision", MySqlDbType.Decimal)).Value = oRegistroEN.Comision; Comando.Parameters.Add(new MySqlParameter("@ComisionMaxima", MySqlDbType.Decimal)).Value = oRegistroEN.ComisionMaxima; Comando.Parameters.Add(new MySqlParameter("@idUsuarioDeCreacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioDeCreacion; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioModificacion; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.idProductoConfiguracion = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(ProductoPrecioEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @" insert into productoprecio (idProducto, Costo, PorcentajeDelPrecio1, PorcentajeDelPrecio2, PorcentajeDelPrecio3, PorcentajeDelPrecio4, PorcentajeDelPrecio5, Precio1, Precio2, Precio3, Precio4, Precio5, AplicarElIva, idUsuarioDeCreacion, FechaDeCreacion, idUsuarioModificacion, FechaDeModificacion, ValorDelIvaEnProcentaje, ValorDelIva, Estado) values (@idProducto, @Costo, @PorcentajeDelPrecio1, @PorcentajeDelPrecio2, @PorcentajeDelPrecio3, @PorcentajeDelPrecio4, @PorcentajeDelPrecio5, @Precio1, @Precio2, @Precio3, @Precio4, @Precio5, @AplicarElIva, @idUsuarioDeCreacion, current_timestamp(), @idUsuarioModificacion, current_timestamp(), @ValorDelIvaEnProcentaje, @ValorDelIva, @Estado); Select last_insert_id() as 'ID';"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Length)).Value = oRegistroEN.Estado; Comando.Parameters.Add(new MySqlParameter("@ValorDelIva", MySqlDbType.Decimal)).Value = oRegistroEN.ValorDelIva; Comando.Parameters.Add(new MySqlParameter("@ValorDelIvaEnProcentaje", MySqlDbType.Decimal)).Value = oRegistroEN.ValorDelIvaEnProcentaje; Comando.Parameters.Add(new MySqlParameter("@AplicarElIva", MySqlDbType.Int32)).Value = oRegistroEN.AplicarElIva; Comando.Parameters.Add(new MySqlParameter("@Precio5", MySqlDbType.Decimal)).Value = oRegistroEN.Precio5; Comando.Parameters.Add(new MySqlParameter("@Precio4", MySqlDbType.Decimal)).Value = oRegistroEN.Precio4; Comando.Parameters.Add(new MySqlParameter("@Precio3", MySqlDbType.Decimal)).Value = oRegistroEN.Precio3; Comando.Parameters.Add(new MySqlParameter("@Precio2", MySqlDbType.Decimal)).Value = oRegistroEN.Precio2; Comando.Parameters.Add(new MySqlParameter("@Precio1", MySqlDbType.Decimal)).Value = oRegistroEN.Precio1; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio5", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio5; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio4", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio4; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio3", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio3; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio2", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio2; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio1", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio1; Comando.Parameters.Add(new MySqlParameter("@Costo", MySqlDbType.Decimal)).Value = oRegistroEN.Costo; Comando.Parameters.Add(new MySqlParameter("@idProducto", MySqlDbType.Int32)).Value = oRegistroEN.oProductoEN.idProducto; Comando.Parameters.Add(new MySqlParameter("@idUsuarioDeCreacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioDeCreacion; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioModificacion; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.idProductoPrecio = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(TansaccionDetalleTMPBancoEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"UPDATE transacciondetalletmpbanco SET idTransaccionDetalle = @idTransaccionDetalle, ReferenciaBanco = @ReferenciaBanco, DescBanco = @DescBanco, Debe = @Debe, Haber = @Haber, IdUsuarioDeModificacion = @IdUsuarioDeModificacion, FechaDeModificacion = current_timestamp() WHERE idTansaccionDetalle_Banco = @idTansaccionDetalle_Banco;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idTansaccionDetalle_Banco", MySqlDbType.Int32)).Value = oRegistroEN.idTansaccionDetalle_Banco; Comando.Parameters.Add(new MySqlParameter("@idTransaccionDetalle", MySqlDbType.Int32)).Value = oRegistroEN.oTransaccionDetalleEN.idTransaccionDetalle; Comando.Parameters.Add(new MySqlParameter("@ReferenciaBanco", MySqlDbType.VarChar, oRegistroEN.ReferenciaBanco.Trim().Length)).Value = oRegistroEN.ReferenciaBanco.Trim(); Comando.Parameters.Add(new MySqlParameter("@DescBanco", MySqlDbType.VarChar, oRegistroEN.DescBanco.Trim().Length)).Value = oRegistroEN.DescBanco.Trim(); Comando.Parameters.Add(new MySqlParameter("@Debe", MySqlDbType.Decimal)).Value = oRegistroEN.Debe; Comando.Parameters.Add(new MySqlParameter("@Haber", MySqlDbType.Decimal)).Value = oRegistroEN.Haber; Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool ValidarRegistroDuplicado(RolEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion) { try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; switch (TipoDeOperacion.Trim().ToUpper()) { case "AGREGAR": Consultas = @"SELECT CASE WHEN EXISTS(SELECT idRol FROM Rol WHERE upper(trim(Nombre)) = upper(@Nombre)) THEN 1 ELSE 0 END AS 'RES'"; Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); break; case "ACTUALIZAR": Consultas = @"SELECT CASE WHEN EXISTS(SELECT idRol FROM Rol WHERE upper(trim(Nombre)) = upper(@Nombre) and idRol <> @idRol) THEN 1 ELSE 0 END AS 'RES'"; Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@idRol", MySqlDbType.Int32)).Value = oRegistroEN.idRol; break; default: throw new ArgumentException("La aperación solicitada no esta disponible"); } Comando.CommandText = Consultas; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); if (Convert.ToInt32(DT.Rows[0]["RES"].ToString()) > 0) { DescripcionDeOperacion = string.Format("Ya existe información del Registro dentro de nuestro sistema: {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); this.Error = DescripcionDeOperacion; return(true); } return(false); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); oTransaccionesAD.Agregar(oRegistroEN.oLoginEN.idUsuario, oRegistroEN.oLoginEN.NumeroIP, oRegistroEN.idRol, "VALIDAR", "ERROR AL VALIDAR LA INFORMACIÓN DE LA Rol", "ERROR", DescripcionDeOperacion, oRegistroEN.oLoginEN.idUsuario, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(TansaccionDetalleTMPBancoEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @" insert into transacciondetalletmpbanco (idTransaccionDetalle, ReferenciaBanco, DescBanco, Debe, Haber, IdUsuarioDeCreacion, FechaDeCreacion, IdUsuarioDeModificacion, FechaDeModificacion) values (@idTransaccionDetalle, @ReferenciaBanco, @DescBanco, @Debe, @Haber, @IdUsuarioDeCreacion, current_timestamp(), @IdUsuarioDeModificacion, current_timestamp()); Select last_insert_id() as 'ID';"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idTransaccionDetalle", MySqlDbType.Int32)).Value = oRegistroEN.oTransaccionDetalleEN.idTransaccionDetalle; Comando.Parameters.Add(new MySqlParameter("@ReferenciaBanco", MySqlDbType.VarChar, oRegistroEN.ReferenciaBanco.Trim().Length)).Value = oRegistroEN.ReferenciaBanco.Trim(); Comando.Parameters.Add(new MySqlParameter("@DescBanco", MySqlDbType.VarChar, oRegistroEN.DescBanco.Trim().Length)).Value = oRegistroEN.DescBanco.Trim(); Comando.Parameters.Add(new MySqlParameter("@Debe", MySqlDbType.Decimal)).Value = oRegistroEN.Debe; Comando.Parameters.Add(new MySqlParameter("@Haber", MySqlDbType.Decimal)).Value = oRegistroEN.Haber; Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeCreacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.idTansaccionDetalle_Banco = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(ProductoPromocionEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.StoredProcedure; Consultas = @"ActualizarPromocionDelProducto"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idProductoPromocion_", MySqlDbType.Int32)).Value = oRegistroEN.idProductoPromocion; Comando.Parameters.Add(new MySqlParameter("@idProducto_", MySqlDbType.Int32)).Value = oRegistroEN.oProductoEN.idProducto; Comando.Parameters.Add(new MySqlParameter("@PrecioDelProducto_", MySqlDbType.Decimal)).Value = oRegistroEN.PrecioDelProducto; Comando.Parameters.Add(new MySqlParameter("@FechaDeInicio_", MySqlDbType.DateTime)).Value = oRegistroEN.FechaDeInicio; Comando.Parameters.Add(new MySqlParameter("@FechaDeFinalizacion_", MySqlDbType.DateTime)).Value = oRegistroEN.FechaDeFinalizacion; Comando.Parameters.Add(new MySqlParameter("@Estado_", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value = oRegistroEN.Estado.Trim(); Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion_", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioModificacion; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool ValidarRegistroDuplicado(TansaccionDetalleTMPBancoEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; switch (TipoDeOperacion.Trim().ToUpper()) { case "AGREGAR": Consultas = @"SELECT CASE WHEN EXISTS(SELECT idTansaccionDetalle_Banco FROM transacciondetalletmpbanco AS tdb inner join transacciondetalletmp as td on td.idTransaccionDetalle = tdb.idTransaccionDetalle inner join cuenta as c on c.NoCuenta = td.NoCuenta inner join transacciontmp as t on t.idTransacciones = td.idTransacciones where c.NoCuenta = @NoCuenta and t.idTransacciones = @idTransacciones and t.idTipoDeTransaccion = @idTipoDeTransaccion) THEN 1 ELSE 0 END AS 'RES'"; Comando.Parameters.Add(new MySqlParameter("@NoCuenta", MySqlDbType.Int32)).Value = oRegistroEN.oTransaccionDetalleEN.oCuentaEN.NoCuenta; Comando.Parameters.Add(new MySqlParameter("@idTransacciones", MySqlDbType.Int32)).Value = oRegistroEN.oTransaccionDetalleEN.oTransaccionesEN.idTransacciones; Comando.Parameters.Add(new MySqlParameter("@idTipoDeTransaccion", MySqlDbType.Int32)).Value = oRegistroEN.oTransaccionDetalleEN.oTransaccionesEN.oTipoDeTransaccionEN.idTipoDeTransaccion; break; case "ACTUALIZAR": Consultas = @"SELECT CASE WHEN EXISTS(SELECT idTansaccionDetalle_Banco FROM transacciondetalletmpbanco AS tdb inner join transacciondetalletmp as td on td.idTransaccionDetalle = tdb.idTransaccionDetalle inner join cuenta as c on c.NoCuenta = td.NoCuenta inner join transacciontmp as t on t.idTransacciones = td.idTransacciones where c.NoCuenta = @NoCuenta and t.idTransacciones = @idTransacciones and t.idTipoDeTransaccion = @idTipoDeTransaccion and idTansaccionDetalle_Banco <> @idTansaccionDetalle_Banco) THEN 1 ELSE 0 END AS 'RES'"; Comando.Parameters.Add(new MySqlParameter("@NoCuenta", MySqlDbType.Int32)).Value = oRegistroEN.oTransaccionDetalleEN.oCuentaEN.NoCuenta; Comando.Parameters.Add(new MySqlParameter("@idTransacciones", MySqlDbType.Int32)).Value = oRegistroEN.oTransaccionDetalleEN.oTransaccionesEN.idTransacciones; Comando.Parameters.Add(new MySqlParameter("@idTipoDeTransaccion", MySqlDbType.Int32)).Value = oRegistroEN.oTransaccionDetalleEN.oTransaccionesEN.oTipoDeTransaccionEN.idTipoDeTransaccion; Comando.Parameters.Add(new MySqlParameter("@idTansaccionDetalle_Banco", MySqlDbType.Int32)).Value = oRegistroEN.idTansaccionDetalle_Banco; break; default: throw new ArgumentException("La aperación solicitada no esta disponible"); } Comando.CommandText = Consultas; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); if (Convert.ToInt32(DT.Rows[0]["RES"].ToString()) > 0) { DescripcionDeOperacion = string.Format("Ya existe información del Registro dentro de nuestro sistema: {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); this.Error = DescripcionDeOperacion; return(true); } return(false); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "REGISTRO DUPLICADO DENTRO DE LA BASE DE DATOS", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool VerificarSiLaEntidadEstaAsociadaAProducto(LocacionEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Comando.CommandText = string.Format(@"Select case when exists( Select idProducto from producto as p where p.TablaDeReferenciaDeAlmacenaje = 'Locacion' and p.idAlmacenEntidad = {0}) then 1 else 0 end as 'ID'", oRegistroEN.idLocacion); Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); if (Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()) == 0) { return(false); } else { this.Error = string.Format("La Operacion: '{1}', {0} no se puede completar por que el registro: {0} '{2}', ya tiene asociado un producto", Environment.NewLine, TipoDeOperacion, InformacionDelRegistro(oRegistroEN)); DescripcionDeOperacion = this.Error; //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(MonedaEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"update moneda set Nombre = @Nombre, Abreviatura = @Abreviatura where idMoneda = @idMoneda;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idMoneda", MySqlDbType.Int32)).Value = oRegistroEN.idMoneda; Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@Abreviatura", MySqlDbType.VarChar, oRegistroEN.Abreviatura.Trim().Length)).Value = oRegistroEN.Abreviatura.Trim(); Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(CuentaDeBancosEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"UPDATE cuentadebancos SET NumeroDeCuenta = @NumeroDeCuenta, Descripcion = @Descripcion, idBancos = @idBancos, idUsuarioModificacion = @idUsuarioModificacion, FechaDeModificacion = current_timestamp() WHERE idCuentaDeBancos = @idCuentaDeBancos;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idCuentaDeBancos", MySqlDbType.Int32)).Value = oRegistroEN.idCuentaDeBancos; Comando.Parameters.Add(new MySqlParameter("@NumeroDeCuenta", MySqlDbType.VarChar, oRegistroEN.NumeroDeCuenta.Trim().Length)).Value = oRegistroEN.NumeroDeCuenta.Trim(); Comando.Parameters.Add(new MySqlParameter("@Descripcion", MySqlDbType.VarChar, oRegistroEN.Descripcion.Trim().Length)).Value = oRegistroEN.Descripcion.Trim(); Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioModificacion; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(MonedaEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @" insert into moneda (Nombre, Abreviatura) values (@Nombre, @Abreviatura); Select last_insert_id() as 'ID';"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@Abreviatura", MySqlDbType.VarChar, oRegistroEN.Abreviatura.Trim().Length)).Value = oRegistroEN.Abreviatura.Trim(); Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.idMoneda = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(ModuloInterfazUsuariosEN oRegistroEN, DatosDeConexionEN oDatos) { try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"INSERT INTO modulointerfazusuario (idPrivilegio, idUsuario, Acceso, IdUsuarioDeCreacion, FechaDeCreacion, IdUsuarioDeModificacion, FechaDeModificacion) values (@idPrivilegio, @idUsuario, @Acceso, @IdUsuarioDeCreacion, current_timestamp(), @IdUsuarioDeModificacion, current_timestamp()); Select last_insert_id() as 'ID';"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idPrivilegio", MySqlDbType.Int32)).Value = oRegistroEN.oPrivilegioEN.idPrivilegio; Comando.Parameters.Add(new MySqlParameter("@idUsuario", MySqlDbType.Int32)).Value = oRegistroEN.oUsuarioEN.idUsuario; Comando.Parameters.Add(new MySqlParameter("@Acceso", MySqlDbType.Int32)).Value = oRegistroEN.Acceso; Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeCreacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.idModuloInterfazUsuario = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); oTransaccionesAD.Agregar(oRegistroEN.oLoginEN.idUsuario, oRegistroEN.oLoginEN.NumeroIP, oRegistroEN.idModuloInterfazUsuario, "AGREGAR", "INFORMACIÓN DE LA MODULO INTERFAZ USUARIO AGREGADA CORRECTAMENTE", "CORRECTA", DescripcionDeOperacion, oRegistroEN.oLoginEN.idUsuario, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); oTransaccionesAD.Agregar(oRegistroEN.oLoginEN.idUsuario, oRegistroEN.oLoginEN.NumeroIP, oRegistroEN.idModuloInterfazUsuario, "AGREGAR", "ERROR AL AGREGAR LA INFORMACIÓN DE LA ModuloInterfazUsuarios", "ERROR", DescripcionDeOperacion, oRegistroEN.oLoginEN.idUsuario, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(ConfiguracionEN oRegistroEN, DatosDeConexionEN oDatos) { try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"insert into configuracion (RutaRespaldos, RutaRespaldosDeExcel,PathMysSQLDump,PathMySQL, NombreDelSistema, TiempoDeRespaldo,@PrecioPorDefecto ) values (@RutaRespaldos, @RutaRespaldosDeExcel, @PathMysSQLDump, @PathMySQL, @NombreDelSistema, @TiempoDeRespaldo,@PrecioPorDefecto); Select last_insert_id() as 'ID';"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@RutaRespaldos", MySqlDbType.VarChar, oRegistroEN.RutaRespaldos.Trim().Length)).Value = oRegistroEN.RutaRespaldos.Trim(); Comando.Parameters.Add(new MySqlParameter("@RutaRespaldosDeExcel", MySqlDbType.VarChar, oRegistroEN.RutaRespaldosDeExcel.Trim().Length)).Value = oRegistroEN.RutaRespaldosDeExcel.Trim(); Comando.Parameters.Add(new MySqlParameter("@PathMysSQLDump", MySqlDbType.VarChar, oRegistroEN.PathMysSQLDump.Trim().Length)).Value = oRegistroEN.PathMysSQLDump.Trim(); Comando.Parameters.Add(new MySqlParameter("@PathMySQL", MySqlDbType.VarChar, oRegistroEN.PathMySQL.Trim().Length)).Value = oRegistroEN.PathMySQL.Trim(); Comando.Parameters.Add(new MySqlParameter("@NombreDelSistema", MySqlDbType.VarChar, oRegistroEN.NombreDelSistema.Trim().Length)).Value = oRegistroEN.NombreDelSistema.Trim(); Comando.Parameters.Add(new MySqlParameter("@TiempoDeRespaldo", MySqlDbType.Int32)).Value = oRegistroEN.TiempoDeRespaldo; Comando.Parameters.Add(new MySqlParameter("@PrecioPorDefecto", MySqlDbType.Decimal)).Value = oRegistroEN.PrecioPorDefecto; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.IdConfiguracion = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); oTransaccionesAD.Agregar(oRegistroEN.oLoginEN.idUsuario, oRegistroEN.oLoginEN.NumeroIP, oRegistroEN.IdConfiguracion, "AGREGAR", "INFORMACIÓN DE LA CONFIGURACIÓN AGREGADA CORRECTAMENTE", "CORRECTA", DescripcionDeOperacion, oRegistroEN.oLoginEN.idUsuario, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); oTransaccionesAD.Agregar(oRegistroEN.oLoginEN.idUsuario, oRegistroEN.oLoginEN.NumeroIP, oRegistroEN.IdConfiguracion, "AGREGAR", "ERROR AL AGREGAR LA INFORMACIÓN DE LA CONFIGURACIÓN", "ERROR", DescripcionDeOperacion, oRegistroEN.oLoginEN.idUsuario, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Agregar(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @" insert into periodo (Codigo, Desde, Hasta, Nombre, Obsevaciones, Estado, IdUsuarioDeCreacion, FechaDeCreacion, IdUsuarioDeModificacion, FechaDeModificacion) values (CrearNumeroDelPeriodo(), @Desde, @Hasta, @Nombre, @Obsevaciones, @Estado, @IdUsuarioDeCreacion, current_timestamp(), @IdUsuarioDeModificacion, current_timestamp()); select idPeriodo,Codigo from periodo where idPeriodo = last_insert_id();"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value = oRegistroEN.Desde; Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value = oRegistroEN.Hasta; Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value = oRegistroEN.Nombre.Trim(); Comando.Parameters.Add(new MySqlParameter("@Obsevaciones", MySqlDbType.VarChar, oRegistroEN.Obsevaciones.Trim().Length)).Value = oRegistroEN.Obsevaciones.Trim(); Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value = oRegistroEN.Estado.Trim(); Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeCreacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); oRegistroEN.idPeriodo = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()); oRegistroEN.Codigo = DT.Rows[0].ItemArray[1].ToString(); DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool Actualizar(ProductoPrecioEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"UPDATE productoprecio set idProducto = @idProducto, Costo = @Costo, PorcentajeDelPrecio1 = @PorcentajeDelPrecio1, PorcentajeDelPrecio2 = @PorcentajeDelPrecio2, PorcentajeDelPrecio3 = @PorcentajeDelPrecio3, PorcentajeDelPrecio4 = @PorcentajeDelPrecio4, PorcentajeDelPrecio5 = @PorcentajeDelPrecio5, Precio1 = @Precio1, Precio2 = @Precio2, Precio3 = @Precio3, Precio4 = @Precio4, Precio5 = @Precio5, AplicarElIva = @AplicarElIva, idUsuarioModificacion = @idUsuarioModificacion, FechaDeModificacion = current_timestamp(), ValorDelIvaEnProcentaje = @ValorDelIvaEnProcentaje, ValorDelIva = @ValorDelIva where idProductoPrecio = @idProductoPrecio;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idProductoPrecio", MySqlDbType.Int32)).Value = oRegistroEN.idProductoPrecio; Comando.Parameters.Add(new MySqlParameter("@ValorDelIva", MySqlDbType.Decimal)).Value = oRegistroEN.ValorDelIva; Comando.Parameters.Add(new MySqlParameter("@ValorDelIvaEnProcentaje", MySqlDbType.Decimal)).Value = oRegistroEN.ValorDelIvaEnProcentaje; Comando.Parameters.Add(new MySqlParameter("@AplicarElIva", MySqlDbType.Int32)).Value = oRegistroEN.AplicarElIva; Comando.Parameters.Add(new MySqlParameter("@Precio5", MySqlDbType.Decimal)).Value = oRegistroEN.Precio5; Comando.Parameters.Add(new MySqlParameter("@Precio4", MySqlDbType.Decimal)).Value = oRegistroEN.Precio4; Comando.Parameters.Add(new MySqlParameter("@Precio3", MySqlDbType.Decimal)).Value = oRegistroEN.Precio3; Comando.Parameters.Add(new MySqlParameter("@Precio2", MySqlDbType.Decimal)).Value = oRegistroEN.Precio2; Comando.Parameters.Add(new MySqlParameter("@Precio1", MySqlDbType.Decimal)).Value = oRegistroEN.Precio1; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio5", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio5; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio4", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio4; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio3", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio3; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio2", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio2; Comando.Parameters.Add(new MySqlParameter("@PorcentajeDelPrecio1", MySqlDbType.Decimal)).Value = oRegistroEN.PorcentajeDelPrecio1; Comando.Parameters.Add(new MySqlParameter("@Costo", MySqlDbType.Decimal)).Value = oRegistroEN.Costo; Comando.Parameters.Add(new MySqlParameter("@idProducto", MySqlDbType.Int32)).Value = oRegistroEN.oProductoEN.idProducto; Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.idUsuarioModificacion; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool RegistroDuplicadoPorFecha_contenidos(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; switch (TipoDeOperacion.Trim().ToUpper()) { case "AGREGAR": Consultas = @"SELECT CASE WHEN EXISTS(Select idPeriodo from periodo where ( Desde >= @Desde and Desde <= @Hasta ) OR (Hasta >= @Desde and Hasta <= @Hasta)) THEN 1 ELSE 0 END AS 'RES'"; Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value = oRegistroEN.Desde; Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value = oRegistroEN.Hasta; break; case "ACTUALIZAR": Consultas = @"SELECT CASE WHEN EXISTS(Select idPeriodo from periodo where ( Desde >= @Desde and Desde <= @Hasta ) OR (Hasta >= @Desde and Hasta <= @Hasta) and idPeriodo<> @idPeriodo) THEN 1 ELSE 0 END AS 'RES'"; Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value = oRegistroEN.Desde; Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value = oRegistroEN.Hasta; Comando.Parameters.Add(new MySqlParameter("@idPeriodo", MySqlDbType.Int32)).Value = oRegistroEN.idPeriodo; break; default: throw new ArgumentException("La aperación solicitada no esta disponible"); } Comando.CommandText = Consultas; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); if (Convert.ToInt32(DT.Rows[0]["RES"].ToString()) > 0) { DescripcionDeOperacion = string.Format("Ya existe información del Registro dentro de nuestro sistema: {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); this.Error = DescripcionDeOperacion; return(true); } return(false); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "REGISTRO DUPLICADO DENTRO DE LA BASE DE DATOS", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool AgregarUtilizandoLaMismaConexion(CierreDePeriodoEN oRegistroEN, DatosDeConexionEN oDatos) { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); MySqlTransaction MysqlTransaccion; MysqlTransaccion = Cnn.BeginTransaction(); try { String mensaje = ""; TasaDeCambioAD oTasaDeCambioAD = new TasaDeCambioAD(); if (oTasaDeCambioAD.Agregar(oRegistroEN.oTasaDeCambioEN, oDatos, ref Cnn, ref MysqlTransaccion) == false) { mensaje = String.Format("Error : '{0}', producido al intentar guardar la tasa de cambio", oTasaDeCambioAD.Error); throw new System.ArgumentException(mensaje); } if (Agregar(oRegistroEN, oDatos, ref Cnn, ref MysqlTransaccion) == false) { mensaje = String.Format("Error : '{0}', producido al intentar guardar el cierre del periodo", this.Error); throw new System.ArgumentException(mensaje); } PeriodoAD oPeriodoAD = new PeriodoAD(); if (oPeriodoAD.ActualizarElEstadoDelPeriodo(oRegistroEN.oPeriodoEN, oDatos, ref Cnn, ref MysqlTransaccion) == false) { mensaje = String.Format("Error : '{0}', producido al intentar actualizar el estado del periodo", oPeriodoAD.Error); throw new System.ArgumentException(mensaje); } if (AplicarSaldoAlCierre(oRegistroEN, oDatos, ref Cnn, ref MysqlTransaccion) == false) { mensaje = String.Format("Error : '{0}', producido al intentar realizar el cierre del periodo", this.Error); throw new System.ArgumentException(mensaje); } oPeriodoAD = null; MysqlTransaccion.Commit(); return(true); }catch (Exception ex) { this.Error = ex.Message; MysqlTransaccion.Rollback(); oTransaccionesAD = new TransaccionesAD(); DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al aplicar el cierre del periodo. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Cerrar Periodo", "Cerrar periodo de Movimiento de cuentas", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; MysqlTransaccion = null; } }