Example #1
0
        public int agregar_reporte(Reporte reporte, List <Detalle_Reporte> detalles_reporte, List <Detalle_Reporte> detalles_reporte_extra, string horas_disponibles, string correos, string user)
        {
            int result = 0;

            string[] vector_correo = correos.Split(',');

            Fecha  fecha         = new Fecha();
            string fecha_asignar = fecha.fecha();

            reporte.FECHA_CREACION   = fecha_asignar;
            reporte.USUARIO_CREACION = user;

            int id = dao_reporte.AgregarReporte(reporte);

            string nombre_cliente = dao_reporte.ObtenerNombreCliente2(id);

            if (detalles_reporte != null)
            {
                for (int i = 0; i < detalles_reporte.Count; i++)
                {
                    detalles_reporte[i].USUARIO_CREACION = user;
                    detalles_reporte[i].FECHA_CREACION   = fecha_asignar;
                    detalles_reporte[i].FK_ID_REPORTE    = id;
                }

                result = dao_reporte.AgregarDetallesReporte(detalles_reporte);
            }

            if (detalles_reporte_extra != null)
            {
                for (int i = 0; i < detalles_reporte_extra.Count; i++)
                {
                    detalles_reporte_extra[i].USUARIO_CREACION = user;
                    detalles_reporte_extra[i].FECHA_CREACION   = fecha_asignar;
                    detalles_reporte_extra[i].FK_ID_REPORTE    = id;
                }

                result = dao_reporte.AgregarDetallesReporteExtra(detalles_reporte_extra);
            }

            if (horas_disponibles != "f" && reporte.TIPO_DOCUMENTO != "Reporte Contrato Garantía")
            {
                double hor = Double.Parse(horas_disponibles);
                dao_contrato.RebajarHorasContrato(reporte.ID_CONTRATO, hor, user, fecha_asignar);

                if (hor == 0)
                {
                    dao_reporte.CambiarEstadoReporteContrato(reporte.ID_CONTRATO, user, fecha_asignar);
                }
            }
            else
            {
                dao_reporte.CambiarEstadoReporteContrato(reporte.ID_CONTRATO, user, fecha_asignar);
            }

            mail.Enviar_Resporte_Correo(encryption.Encrypt(id.ToString()), reporte, detalles_reporte, nombre_cliente, vector_correo);

            return(result);
        }