Example #1
0
        public ActionResult Delete(ContratosWebModel model)
        {
            if (sesion == null)
            {
                sesion = SessionDB.start(Request, Response, false, db);
            }
            model.sesion = sesion;

            if (!sesion.permisos.havePermission(Privileges[0].Permiso))
            {
                return(Json(new { msg = Notification.notAccess() }));
            }

            try
            {
                if (model.Delete())
                {
                    Log.write(this, "Delete", LOG.BORRADO, "SQL:" + model.sql, sesion);
                    return(Json(new { msg = Notification.Succes("Contrato ELIMINADO con exito: " + model.Contrato) }));
                }
                else
                {
                    Log.write(this, "Delete", LOG.ERROR, "SQL:" + model.sql, sesion);
                    return(Json(new { msg = Notification.Error(" Error al Eliminar: " + model.Contrato) }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { msg = Notification.Error(e.Message) }));
            }
        }
Example #2
0
        public ActionResult Add(ContratosWebModel model)
        {
            if (sesion == null)
            {
                sesion = SessionDB.start(Request, Response, false, db);
            }
            model.sesion = sesion;

            if (!sesion.permisos.havePermission(Privileges[0].Permiso))
            {
                return(Json(new { msg = Notification.notAccess() }));
            }

            try
            {
                if (model.Add())
                {
                    Log.write(this, "Add", LOG.REGISTRO, "SQL:" + model.sql, sesion);
                    return(Json(new { msg = Notification.Succes("Contrato agregado con exito: " + model.Contrato) }));
                }
                else
                {
                    Log.write(this, "Add", LOG.ERROR, "SQL:" + model.sql, sesion);
                    return(Json(new { msg = Notification.Error(" Error al agregar: " + model.Contrato) }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { msg = Factory.Notification.Error(e.Message) }));
            }
        }
Example #3
0
 public ActionResult Edit(ContratosWebModel model)
 {
     if (model.Edit())
     {
         return(Json(new JavaScriptSerializer().Serialize(model)));
     }
     return(View());
 }
Example #4
0
        public void ConvertPDF()
        {
            if ((sesion = SessionDB.start(Request, Response, false, db, SESSION_BEHAVIOR.AJAX)) == null)
            {
                return;
            }

            // convert HTML to PDF
            byte[] pdfBuffer = null;

            // convert HTML code
            ContratosWebModel conModel = new ContratosWebModel();

            conModel.Clave = sesion.vdata["CVE_CONTRATO"];
            conModel.Edit();
            string htmlCode = HttpUtility.UrlDecode(conModel.Formato, System.Text.Encoding.Default);

            ContratosWebPDFModel model = new ContratosWebPDFModel();

            model.Sede       = sesion.vdata["Sede"]; // from combobox Sedes
            model.IDSIU      = sesion.vdata["IDSIU"];
            model.PERIDO     = sesion.vdata["PERIODO"];
            model.CVE_SEDE   = sesion.vdata["CVE_SEDE"]; // from QEntregaContratos01
            model.ID_ESQUEMA = sesion.vdata["ID_ESQUEMA"];

            model.getDatos();
            htmlCode = model.fill(htmlCode);

            string htmlString = htmlCode;
            string baseUrl    = "";// collection["TxtBaseUrl"];

            //string thisPageUrl = this.ControllerContext.HttpContext.Request.Url.AbsoluteUri;
            //string baseUrl = thisPageUrl.Substring(0, thisPageUrl.Length - "ConstanciaRetencion".Length);

            string      pdf_page_size = "A4";
            PdfPageSize pageSize      = (PdfPageSize)Enum.Parse(typeof(PdfPageSize),
                                                                pdf_page_size, true);

            string             pdf_orientation = "Portrait";
            PdfPageOrientation pdfOrientation  =
                (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation),
                                               pdf_orientation, true);

            // instantiate a html to pdf converter object
            HtmlToPdf converter = new HtmlToPdf();

            // license key
            GlobalProperties.LicenseKey = "KgEbChgfGwoZGx0fChsSBBoKGRsEGxgEExMTEw==";

            // set converter options
            converter.Options.PdfPageSize        = pageSize;
            converter.Options.PdfPageOrientation = pdfOrientation;
            converter.Options.WebPageWidth       = Convert.ToInt32(1024);
            converter.Options.WebPageHeight      = Convert.ToInt32(0);
            converter.Options.MarginTop          = 35;
            converter.Options.MarginBottom       = 35;

            PdfDocument doc = converter.ConvertHtmlString(htmlString, baseUrl);

            pdfBuffer = doc.Save();

            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "inline; filename=ConstanciaRetencion.pdf");
            Response.BinaryWrite(pdfBuffer);
            doc.Close();
        }