Exemplo n.º 1
0
        private Decimal actualizarDescargoConArchivo(Decimal REGISTRO, Decimal ID_EMPLEADO, DateTime FECHA_R, String OBS_REG, DateTime FECHA_SOLICITUD, DateTime FECHA_ACTA, DateTime FECHA_CIERRE, String MOTIVO, Byte[] ARCHIVO_ACTA, Int32 ARCHIVO_TAMANO, String ARCHIVO_EXTENSION, String ARCHIVO_TYPE)
        {
            Int32 actualizados = 0;
            String sql = null;
            String informacion = null;
            Boolean ejecutar = true;
            Boolean ejecutadoCorrectamente = true;

            tools _tools = new tools();

            sql = "usp_reg_acta_desc_actualizar_con_archivo ";

            #region validaciones
            sql += REGISTRO + ", ";
            informacion += "REGISTRO = '" + REGISTRO + "', ";

            sql += ID_EMPLEADO + ", ";
            informacion += "ID_EMPLEADO = '" + ID_EMPLEADO + "', ";

            sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_R) + "', ";
            informacion += "FECHA_R = '" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_R) + "', ";

            if (String.IsNullOrEmpty(OBS_REG) == false)
            {
                sql += "'" + OBS_REG + "', ";
                informacion += "OBS_REG = '" + OBS_REG + "', ";
            }
            else
            {
                sql += "NULL, ";
                informacion += "OBS_REG = 'NULL', ";
            }

            sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_SOLICITUD) + "', ";
            informacion += "FECHA_SOLICITUD = '" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_SOLICITUD) + "', ";

            sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_ACTA) + "', ";
            informacion += "FECHA_ACTA = '" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_ACTA) + "', ";

            if (FECHA_CIERRE == new DateTime())
            {
                sql += "'NULL', ";
                informacion += "FECHA_CIERRE = 'NULL', ";
            }
            else
            {
                sql += "'" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_CIERRE) + "', ";
                informacion += "FECHA_CIERRE = '" + _tools.obtenerStringConFormatoFechaSQLServer(FECHA_CIERRE) + "', ";
            }

            sql += "'" + MOTIVO + "', ";
            informacion += "MOTIVO = '" + MOTIVO + "', ";

            sql += "'" + Usuario.ToString() + "'";
            informacion += "USU_CRE = '" + Usuario.ToString() + "'";
            #endregion validaciones

            if (ejecutar)
            {
                Conexion conexion = new Conexion(Empresa);
                conexion.IniciarTransaccion();
                try
                {
                    #region actualizar descargo
                    actualizados = conexion.ExecuteNonQueryParaActualizarDescargoConArchivo(REGISTRO, ID_EMPLEADO, FECHA_R, OBS_REG, FECHA_SOLICITUD, FECHA_ACTA, FECHA_CIERRE, MOTIVO, ARCHIVO_ACTA, ARCHIVO_TAMANO, ARCHIVO_EXTENSION, ARCHIVO_TYPE, Usuario);
                    #endregion adicionar descargo

                    #region auditoria
                    if (actualizados > 0)
                    {
                        auditoria _auditoria = new auditoria(Empresa);
                        if (!(_auditoria.Adicionar(Usuario, tabla.REG_ACTA_DESC, tabla.ACCION_ACTUALIZAR, sql, informacion, conexion)))
                        {
                            conexion.DeshacerTransaccion();
                            MensajeError = "ERROR: Al intentar ingresar la auditoría.";
                            ejecutadoCorrectamente = false;
                        }
                        else
                        {
                            conexion.AceptarTransaccion();
                        }
                    }
                    else
                    {
                        conexion.DeshacerTransaccion();
                        MensajeError = "ERROR: intenatar actualizar en la bd el descargo.";
                        ejecutadoCorrectamente = false;
                    }
                    #endregion auditoria
                }
                catch (Exception e)
                {
                    conexion.DeshacerTransaccion();
                    MensajeError = e.Message;
                    ejecutadoCorrectamente = false;
                }
                finally
                {
                    conexion.Desconectar();
                }
            }

            if (ejecutadoCorrectamente)
            {
                return actualizados;
            }
            else
            {
                return 0;
            }
        }