public ActionResult Home_Actualitation(EstadodeCuentaWebModel model)
        {
            if ((sesion = SessionDB.start(Request, Response, false, db, SESSION_BEHAVIOR.AJAX)) == null)
            {
                return(Content("-1"));
            }

            sesion.vdata["Sede"]     = Request.Params["filter_Sede"];
            sesion.vdata["HmeAclzn"] = "Sí";
            this.setDatosProfesor(sesion, model);
            //model.Sede = sesion.vdata["Sede"];
            //model.ID_PERSONA = sesion.vdata["ID_PERSONA"];

            sesion.vdata["Sede"]       = model.Sede;
            sesion.vdata["ID_PERSONA"] = model.ID_PERSONA;
            ViewBag.IDSIU = model.IDSIU;
            sesion.saveSession();

            //cuenta
            string casilla_valida     = "";
            string boton_validacuenta = "";

            if (!string.IsNullOrWhiteSpace(model.NoCuenta))
            {
                if (model.VerificarCuenta())
                {
                    casilla_valida     = "<input type=\"checkbox\" id=\"valida_check\" checked disabled/>";
                    boton_validacuenta = "<button type = 'button' id = \"btn_valida\" class='btn btn-sm btn-success' onclick=\"validaCuenta();\" disabled>Verificado</button>";
                }
                else
                {
                    casilla_valida     = "<input type=\"checkbox\" id=\"valida_check\"/>";
                    boton_validacuenta = "<button type = 'button' id = \"btn_valida\" class='btn btn-sm btn-success' onclick=\"validaCuenta();\">Verificar</button>";
                }
            }
            else
            {
                casilla_valida     = "<input type=\"checkbox\" id=\"valida_check\" disabled/>";
                boton_validacuenta = "<button type = 'button' id = \"btn_valida\" class='btn btn-sm btn-success' onclick=\"validaCuenta();\" disabled>Verificar</button>";
                // limpiar validacuenta** y poner en 0
                model.validaCuenta_2();
            }

            return(Json(new
            {
                PagosPendientes = model.GetPagosDashboardPendientes(),
                PagosDepositados = model.GetPagosDashboardDepositados(),
                Contratos = model.GetDashboardContratos(),
                PagosxDepositar = model.GetPagosxDepositar(),
                Bloqueos = model.GetBloqueosDashboard(),
                Comunicados = model.GetComunicados(),
                jcasilla_valida = casilla_valida,
                jboton_validacuenta = boton_validacuenta
            }));
        }
        //#EXPORT EXCEL
        public void ExportExcel()
		{
			SessionDB sesion = SessionDB.start(Request, Response, false, db);

            try
            {
                string sede = Request.Params["sedes"];
                string sql = string.Empty;
                /**
                 * Inicio - Primera pestaña
                 * */
                System.Data.DataTable tbl = new System.Data.DataTable();
                tbl.Columns.Add("ID_PERSONA", typeof(string));
                tbl.Columns.Add("ORIGEN", typeof(string));
                tbl.Columns.Add("IDSIU", typeof(string));
                tbl.Columns.Add("NOMBRES", typeof(string));
                tbl.Columns.Add("APELLIDOS", typeof(string));
                tbl.Columns.Add("CORREO", typeof(string));
                tbl.Columns.Add("TIPODEPAGO", typeof(string));
                tbl.Columns.Add("RFC", typeof(string));
                tbl.Columns.Add("CURP", typeof(string));
                tbl.Columns.Add("CVE_BANCO", typeof(string));
                tbl.Columns.Add("CUENTACLABE", typeof(string));
                tbl.Columns.Add("RAZONSOCIAL", typeof(string));
                tbl.Columns.Add("DIRECCION_PAIS", typeof(string));
                tbl.Columns.Add("DIRECCION_ESTADO", typeof(string));
                tbl.Columns.Add("DIRECCION_CIUDAD", typeof(string));
                tbl.Columns.Add("DIRECCION_ENTIDAD", typeof(string));
                tbl.Columns.Add("DIRECCION_COLONIA", typeof(string));
                tbl.Columns.Add("DIRECCION_CALLE", typeof(string));
                tbl.Columns.Add("DIRECCION_NUMERO", typeof(string));
                tbl.Columns.Add("DIRECCION_CP", typeof(string));

                sql = "SELECT * FROM QPersonas WHERE CVE_SEDE = '" + sede + "'";

                ResultSet res = db.getTable(sql);

                while (res.Next()) // Here we add five DataRows.
                    tbl.Rows.Add(
                        res.Get("ID_PERSONA"),
                        res.Get("ORIGEN"),
                        res.Get("IDSIU"),
                        res.Get("NOMBRES"),
                        res.Get("APELLIDOS"),
                        res.Get("CORREO"),
                        res.Get("TIPODEPAGO"),
                        res.Get("RFC"),
                        res.Get("CURP"),
                        res.Get("CVE_BANCO"),
                        res.Get("CUENTACLABE"),
                        res.Get("RAZONSOCIAL"),
                        res.Get("DIRECCION_PAIS"),
                        res.Get("DIRECCION_ESTADO"),
                        res.Get("DIRECCION_CIUDAD"),
                        res.Get("DIRECCION_ENTIDAD"),
                        res.Get("DIRECCION_COLONIA"),
                        res.Get("DIRECCION_CALLE"),
                        res.Get("DIRECCION_NUMERO"),
                        res.Get("DIRECCION_CP")
                    );
                /**
                 * Fin - Primera pestaña
                 * */

                /**
                 * Inicio - Segunda pestaña
                 * */
                System.Data.DataTable tblR = new System.Data.DataTable();
                tblR.Columns.Add("ID_PERSONA", typeof(string));
                tblR.Columns.Add("SEDE", typeof(string));
                tblR.Columns.Add("IDSIU", typeof(string));
                tblR.Columns.Add("NOMBRES", typeof(string));
                tblR.Columns.Add("APELLIDOS", typeof(string));
                tblR.Columns.Add("FECHANACIMIENTO", typeof(string));
                tblR.Columns.Add("NACIONALIDAD", typeof(string));
                tblR.Columns.Add("CORREO365", typeof(string));
                tblR.Columns.Add("TELEFONO", typeof(string));
                tblR.Columns.Add("TIPODEPAGO", typeof(string));
                tblR.Columns.Add("RFC", typeof(string));
                tblR.Columns.Add("CURP", typeof(string));
                tblR.Columns.Add("PAIS", typeof(string));
                tblR.Columns.Add("ESTADO", typeof(string));
                tblR.Columns.Add("CIUDAD", typeof(string));
                tblR.Columns.Add("ENTIDAD", typeof(string));
                tblR.Columns.Add("COLONIA", typeof(string));
                tblR.Columns.Add("CALLE", typeof(string));
                tblR.Columns.Add("NUMERO", typeof(string));
                tblR.Columns.Add("CP", typeof(string));
                tblR.Columns.Add("BANCO", typeof(string));
                tblR.Columns.Add("CUENTACLABE", typeof(string));
                tblR.Columns.Add("NOCUENTA", typeof(string));
                tblR.Columns.Add("VERIFICADO", typeof(string));//
                tblR.Columns.Add("TITULOPROFESIONAL", typeof(string));
                tblR.Columns.Add("PROFESION", typeof(string));
                tblR.Columns.Add("CEDULAPROFESIONAL", typeof(string));
                tblR.Columns.Add("FECHACEDULA", typeof(string));
                tblR.Columns.Add("SEGUROSOCIAL", typeof(string));

                sql = "SELECT * FROM QPersonasReporte WHERE SEDE = '" + sede + "'";

                ResultSet resR = db.getTable(sql);



                EstadodeCuentaWebModel model = new EstadodeCuentaWebModel();

                while (resR.Next()) { // Here we add five DataRows.

                    model.IDSIU = resR.Get("IDSIU");
                    model.ID_PERSONA = resR.Get("ID_PERSONA");
                    model.NoCuenta = resR.Get("NOCUENTA");

                    if (!string.IsNullOrWhiteSpace(model.NoCuenta))                    
                        model.VerificarCuenta();                   
                    else
                        model.validaCuenta_2(); // limpiar validacuenta** y poner en 0


                    string validado = "NO";
                    if (resR.GetBool("NOCUENTA_VALIDADO")) { validado = "SI"; }



                    tblR.Rows.Add(
                        resR.Get("ID_PERSONA"),
                        resR.Get("SEDE"),
                        resR.Get("IDSIU"),
                        resR.Get("NOMBRES"),
                        resR.Get("APELLIDOS"),
                        resR.Get("FECHANACIMIENTO"),
                        resR.Get("NACIONALIDAD"),
                        resR.Get("CORREO365"),
                        resR.Get("TELEFONO"),
                        resR.Get("TIPODEPAGO"),
                        resR.Get("RFC"),
                        resR.Get("CURP"),
                        resR.Get("PAIS"),
                        resR.Get("ESTADO"),
                        resR.Get("CIUDAD"),
                        resR.Get("ENTIDAD"),
                        resR.Get("COLONIA"),
                        resR.Get("CALLE"),
                        resR.Get("NUMERO"),
                        resR.Get("CP"),
                        resR.Get("BANCO"),
                        resR.Get("CUENTACLABE"),
                        resR.Get("NOCUENTA"),
                        validado,
                        resR.Get("TITULOPROFESIONAL"),
                        resR.Get("PROFESION"),
                        resR.Get("CEDULAPROFESIONAL"),
                        resR.Get("FECHACEDULA"),
                        resR.Get("SEGUROSOCIAL")
                        );


            }
                /**
                 * Fin - Segunda pestaña
                 * */

                using (ExcelPackage pck = new ExcelPackage())
				{
					//Create the worksheet
					ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Personas");
                    ExcelWorksheet wsR = pck.Workbook.Worksheets.Add("Reporte de Personas");

                    //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
                    ws.Cells["A1"].LoadFromDataTable(tbl, true);
					ws.Cells["A1:C1"].AutoFitColumns();

                    wsR.Cells["A1"].LoadFromDataTable(tblR, true);
                    wsR.Cells["A1:AB1"].AutoFitColumns();

                    //Format the header for column 1-3
                    using (ExcelRange rng = ws.Cells["A1:U1"])
					{
						rng.Style.Font.Bold = true;
						rng.Style.Fill.PatternType = ExcelFillStyle.Solid;                      //Set Pattern for the background to Solid
						rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79, 129, 189));  //Set color to dark blue
						rng.Style.Font.Color.SetColor(Color.White);
                    }

                    using (ExcelRange rngR = wsR.Cells["A1:AB1"])
                    {
                        rngR.Style.Font.Bold = true;
                        rngR.Style.Fill.PatternType = ExcelFillStyle.Solid;                      //Set Pattern for the background to Solid
                        rngR.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79, 129, 189));  //Set color to dark blue
                        rngR.Style.Font.Color.SetColor(Color.White);
                    }

                    int rowexcel = 2;
                    //FORMAT RFC EXCEL
                    res.ReStart();

                    while (res.Next())
                    {
                        if (!rfcValido(res.Get("RFC")))
                        {
                            ws.Cells["H" + rowexcel].Style.Font.Bold = true;
                            ws.Cells["H" + rowexcel].Style.Fill.PatternType = ExcelFillStyle.Solid;
                            ws.Cells["H" + rowexcel].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(153, 0, 0));
                            ws.Cells["H" + rowexcel].Style.Font.Color.SetColor(Color.White);
                        }

                        rowexcel++;
                    }

                    int rowexcelR = 2;
                    //FORMAT RFC EXCEL
                    resR.ReStart();

                    while (resR.Next())
                    {
                        if (!rfcValido(resR.Get("RFC")))
                        {
                            wsR.Cells["K" + rowexcelR].Style.Font.Bold = true;
                            wsR.Cells["K" + rowexcelR].Style.Fill.PatternType = ExcelFillStyle.Solid;
                            wsR.Cells["K" + rowexcelR].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(153, 0, 0));
                            wsR.Cells["K" + rowexcelR].Style.Font.Color.SetColor(Color.White);
                        }

                        rowexcelR++;
                    }

                    //Example how to Format Column 1 as numeric 
                    using (ExcelRange col = ws.Cells[2, 1, 2 + tbl.Rows.Count, 1])
					{
						col.Style.Numberformat.Format = "#,##0.00";
						col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
					}

                    using (ExcelRange colR = wsR.Cells[2, 1, 2 + tblR.Rows.Count, 1])
                    {
                        colR.Style.Numberformat.Format = "#,##0.00";
                        colR.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                    }
                    //Write it back to the client
                    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
					Response.AddHeader("content-disposition", "attachment;  filename=Personas.xlsx");
					Response.BinaryWrite(pck.GetAsByteArray());
				}
				Log.write(this, "Start", LOG.CONSULTA, "Exporta Excel Catalogo DatosPersonas", sesion);
			}
			catch (Exception e)
			{
				ViewBag.Notification = Notification.Error(e.Message);
				Log.write(this, "Start", LOG.ERROR, "Exporta Excel  DatosPersonas" + e.Message, sesion);
			}
		}
        public ActionResult Home()
        {
            if ((sesion = SessionDB.start(Request, Response, false, db)) == null)
            {
                return(Content("-1"));
            }
            try
            {
                Main view = new Main();
                EstadodeCuentaWebModel model = new EstadodeCuentaWebModel();

                Scripts.SCRIPTS = new string[]
                {
                    "js/Pagos/EstadodeCuentaWeb/ECW_Contratos.js"
                };

                ViewBag.Scripts = Scripts.addScript() + Scripts.setPrivileges(Privileges, sesion);

                sesion.vdata["HmeAclzn"] = "No";
                this.setDatosProfesor(sesion, model);

                // Datos persona
                model.GetDatos();
                sesion.vdata["ID_PERSONA"] = model.ID_PERSONA;
                ViewBag.Profesor           = model.Profesor;
                ViewBag.IDSIU       = model.IDSIU;
                ViewBag.NoCuenta    = model.NoCuenta;
                ViewBag.CuentaClabe = model.CuentaClabe;
                ViewBag.Banco       = model.Banco;
                ViewBag.RFC         = model.RFC;

                // Datos fiscales
                model.GetDatosFiscales();
                ViewBag.Fis_Sede      = model.Sede;
                ViewBag.Fis_RecibiDe  = model.Fis_Recibide;
                ViewBag.Fis_RFC       = model.Fis_RFC;
                ViewBag.Fis_Domicilio = model.Fis_Domicilio;
                ViewBag.Fis_Concepto  = model.Fis_Concepto;

                ViewBag.Email_Sociedad = model.Email_Sociedad;

                ViewBag.SEDES = view.createSelectSedesWeb("Sedes", sesion, model.ID_PERSONA);

                sesion.vdata["CVE_TIPOFACTURA"] = model.CveTipoFactura;
                sesion.saveSession();

                //Intercom
                ViewBag.User     = sesion.nickName.ToString();
                ViewBag.Email    = sesion.nickName.ToString();
                ViewBag.FechaReg = DateTime.Today;

                //cuenta
                if (!string.IsNullOrWhiteSpace(model.NoCuenta))
                {
                    if (model.VerificarCuenta())
                    {
                        ViewBag.casilla_valida     = "<input type=\"checkbox\" id=\"valida_check\" checked disabled/>";
                        ViewBag.boton_validacuenta = "<button type = 'button' id = \"btn_valida\" class='btn btn-sm btn-success' onclick=\"validaCuenta();\" disabled>Verificado</button>";
                    }
                    else
                    {
                        ViewBag.casilla_valida     = "<input type=\"checkbox\" id=\"valida_check\"/>";
                        ViewBag.boton_validacuenta = "<button type = 'button' id = \"btn_valida\" class='btn btn-sm btn-success' onclick=\"validaCuenta();\">Verificar</button>";
                    }
                }
                else
                {
                    ViewBag.casilla_valida     = "<input type=\"checkbox\" id=\"valida_check\" disabled/>";
                    ViewBag.boton_validacuenta = "<button type = 'button' id = \"btn_valida\" class='btn btn-sm btn-success' onclick=\"validaCuenta();\" disabled>Verificar</button>";

                    // limpiar validacuenta** y poner en 0
                    model.validaCuenta_2();
                }

                this.getPagosDashboardPagos(model);

                Log.write(this, "Start", LOG.CONSULTA, "Ingresa Pantalla Estado de cuenta Web", sesion);
            }
            catch (Exception e)
            {
                ViewBag.Notification = Notification.Error(e.Message);
                Log.write(this, "Start", LOG.ERROR, "Ingresa Pantalla Estado de cuenta Web" + e.Message, sesion);  //MODIFICAR LA REFERENCIA DE LA PAGINA A INGRESAR
            }
            return(View(Factory.View.Access + "Pagos/EstadodeCuentaWeb/Home.cshtml"));
        }