Exemple #1
0
        protected void lnkAddFav_Click(object sender, EventArgs e)
        {
            try
            {
                var user = (Users)Session["UserLogged"];

                DataAccess.Menu oMenu = new Admin().GetMenuByUrl(Request.Url.AbsolutePath);

                var oFav = new Favoritos {MenuId = oMenu.MenuId, PersonaId = user.PersonaId};
                new Admin().AddFavorito(oFav);

                Session["MenuFavoritos"] = new Admin().GetListFavorito(user.PersonaId);

                var listaFav = (List<Favoritos>)Session["MenuFavoritos"];

                this.rptMenuFav.DataSource = listaFav;
                this.rptMenuFav.DataBind();

                if (listaFav.Where(p => p.Menu.Url == Request.Url.AbsolutePath).ToList().Count > 0)
                    this.lnkAddFav.Visible = false;
            }
            catch (Exception ex)
            {
            }
        }
Exemple #2
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     Users userPreLogin = new Admin().PreLogin(Convert.ToInt32(this.txtUserName.Text));
     if (userPreLogin != null)
     {
         if (userPreLogin.Activo == true)
         {
             userPreLogin =
                 new Admin().Login(Convert.ToInt32(this.txtUserName.Text),
                                                                  Security.GetSHA512WithSalt(
                                                                      this.txtPassword.Text, userPreLogin.Salt));
             if (userPreLogin != null)
             {
                 Session["UserLogged"] = userPreLogin;
                 Session["MenuFavoritos"] = new Admin().GetListFavorito(userPreLogin.PersonaId);
                 Session["Menu"] = new Admin().Menus(userPreLogin.RolId);
                 Response.Redirect("Default.aspx");
             }
             else
             {
                 this.lblError.Text = "Contraseña o usuario incorrecto.";
             }
         }
         else
         {
             this.lblError.Text = "Usuario desactivado.";
         }
     }
     else
     {
         this.lblError.Text = "Usuario inexistente.";
     }
 }
Exemple #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["adminid"] != null)
     {
         if (!IsPostBack)
         {
             SliderRepository repSlider = new SliderRepository();
             gvSlider.DataSource = repSlider.LoadSliders();
             gvSlider.DataBind();
             ContactUsRepository repContact = new ContactUsRepository();
             ContactWay          cnw        = repContact.Findcwy(1);
             tbxAbout.Text     = cnw.AboutUs;
             tbxAdress.Text    = cnw.Adrees;
             tbxMail.Text      = cnw.Email;
             tbxPhone.Text     = cnw.PhoneNumber;
             tbxAboutPage.Text = cnw.AboutPage;
             tbxInsta.Text     = cnw.Instagram;
             tbxtele.Text      = cnw.Telegram;
             AdminsRepository ad    = new AdminsRepository();
             DataAccess.Admin admin = ad.getAdmin(Session["adminid"].ToString().ToInt());
             tbxPass.Text = admin.Password;
         }
     }
     else
     {
         Response.Redirect("/AdminLogin");
     }
 }
Exemple #4
0
        public void sendEmail(SMTPEmail email)
        {
            try
            {
                Admin aux = new Admin();
                MailMessage Email;

                Email = new MailMessage(email.From, email.To, email.subject, email.Message);

                SmtpClient smtpMail = new SmtpClient(email.SMTPClient);
                Email.IsBodyHtml = true;

                smtpMail.UseDefaultCredentials = false;
                smtpMail.Host = email.SMTPClient;
                smtpMail.Port = email.SMTPPort;
                smtpMail.EnableSsl = false;
                smtpMail.Credentials = new NetworkCredential(aux.GetGeneralParameterValue("EmailSMTP Sitio"), aux.GetGeneralParameterValue("PasswordSMTP Sitio"));//[email protected] // Aep123456

                smtpMail.Send(Email);
            }
            catch (Exception ex)
            {
                this.lblMessage.InnerText = ex.Message;
            }
        }
Exemple #5
0
        protected void btnEnviar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateData())
                {
                    Admin aux = new Admin();
                    var email = new SMTPEmail();

                    email.From = aux.GetGeneralParameterValue("EmailSMTP Sitio");
                    email.To = aux.GetGeneralParameterValue("EmailSMTP Sitio");
                    email.subject = "Contacto - Web Site";
                    email.SMTPClient = aux.GetGeneralParameterValue("SMTP Client");
                    email.SMTPPort = Convert.ToInt32(aux.GetGeneralParameterValue("SMTP Port"));

                    email.Message = String.Concat(GetHtmlTemplate(txtNombre.Text,txtEmail.Text,txtTelefono.Text,txtDetalle.Value));

                    this.sendEmail(email);

                    this.divContenido.Visible = false;
                    this.divContentMessage.Visible = true;
                }
            }
            catch (Exception ex)
            {
                this.divContenido.Visible = false;
                this.lblError.InnerText = ex.Message;
            }
        }
Exemple #6
0
        protected void btnAddRol_Click(object sender, EventArgs e)
        {
            try
            {
                Roles oRol;

                if (!string.IsNullOrEmpty(this.lblRolId.Text))
                {
                    oRol = new Admin().GetRol(int.Parse(this.lblRolId.Text));
                    oRol.Descripcion = this.txtRolDesc.Text;
                    oRol.Activo = this.ddlActivo.SelectedValue == "1" ? true : false;

                    new Admin().UpdateRol(oRol);
                }
                else
                {
                    oRol = new Roles
                        {
                            Descripcion = this.txtRolDesc.Text,
                            Activo = this.ddlActivo.SelectedValue == "1" ? true : false
                        };

                    new Admin().AddRol(oRol);
                }

                this.FillGridRol();
            }
            catch (Exception ex)
            {
                this.lblErrorRol.Text = ex.Message;
            }
        }
Exemple #7
0
        public void CheckIfMustBeRedirected()
        {
            //check wheter the user is authorized or not to view this page
            bool redirect = false;
            MenusRoles item = null;
            var user = (Users)Session["UserLogged"];
            if (user == null)
                redirect = true;
            else
                item = new Admin().MenuAccess(Request.Url.AbsolutePath, user.RolId);// ((SiteMaster)this.Master).Menu.Where(p => p.IdMenu == (short)selectedPage).SingleOrDefault();

            if (item == null)
                redirect = true;

            if (redirect)
            {
                Response.Redirect("~/Login.aspx");
            }
        }
Exemple #8
0
        protected void btnAddRolesMenus_Click(object sender, EventArgs e)
        {
            try
            {
                var user = (Users)Session["UserLogged"];

                new Admin().DeleteMenuRoles(int.Parse(this.ddlRol.SelectedValue));

                foreach (GridViewRow item in this.gvRolesMenus.Rows)
                {
                    Int32 menuId;
                    Int32.TryParse(item.Cells[(int)ColumnasRolesMenus.MenuId].Text, out menuId);
                    var chk = (CheckBox)item.FindControl("chk");

                    if (menuId != 0 && chk != null)
                    {
                        if (chk.Checked)
                        {
                            var oMR = new MenusRoles();
                            oMR.RolId = int.Parse(this.ddlRol.SelectedValue);
                            oMR.MenuId = int.Parse(item.Cells[(int)ColumnasRolesMenus.MenuId].Text);

                            new Admin().AddMenuRoles(oMR);
                        }
                    }
                }

                Session["Menu"] = new Admin().Menus(user.RolId);

                (this.Master as SiteMaster).GenerarMenuPadre();

                this.FillGridRolesMenus();
            }
            catch (Exception ex)
            {
                this.lblErrorRolesMenus.Text = ex.Message;
            }
        }
Exemple #9
0
        protected void btnAddMenu_Click(object sender, EventArgs e)
        {
            try
            {
                DataAccess.Menu oMenu;
                int? menuPadre = null;

                if (!string.IsNullOrEmpty(this.lblMenuId.Text))
                {
                    oMenu = new Admin().GetMenu(int.Parse(this.lblMenuId.Text));
                    oMenu.Descripcion = this.txtDesc.Text;
                    oMenu.HijoDe = ddlMenuPadre.SelectedValue != "0" ? Convert.ToInt32(ddlMenuPadre.SelectedValue) : menuPadre;
                    oMenu.Orden = Convert.ToInt32(this.txtOrden.Text);
                    oMenu.Url = this.txtUrl.Text;
                    oMenu.Activo = this.ddlActivo.SelectedValue == "1" ? true : false;

                    new Admin().UpdateMenu(oMenu);
                }
                else
                {
                    oMenu = new DataAccess.Menu();

                    oMenu.Descripcion = this.txtDesc.Text;
                    oMenu.HijoDe = ddlMenuPadre.SelectedValue != "0" ? Convert.ToInt32(ddlMenuPadre.SelectedValue) : menuPadre;
                    oMenu.Orden = Convert.ToInt32(this.txtOrden.Text);
                    oMenu.Url = this.txtUrl.Text;
                    oMenu.Activo = this.ddlActivo.SelectedValue == "1" ? true : false;

                    new Admin().AddMenu(oMenu);
                }

                this.FillGridMenu();
            }
            catch (Exception ex)
            {
                this.lblErrorMenu.Text = ex.Message;
            }
        }
Exemple #10
0
 protected void gvRol_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandArgument != null)
     {
         switch (e.CommandName.ToLower())
         {
             case "delete":
                 new Admin().DeleteRol(int.Parse(e.CommandArgument.ToString()));
                 this.FillGridRol();
                 ClientScript.RegisterStartupScript(this.GetType(), "myScript", "alert('Registro borrado exitosamente.');", true);
                 break;
             case "edit":
                 Roles oRol = new Admin().GetRol(int.Parse(e.CommandArgument.ToString()));
                 this.lblRolId.Text = oRol.RolId.ToString();
                 this.txtRolDesc.Text = oRol.Descripcion;
                 this.ddlActivo.SelectedValue = oRol.Activo == true ? "1" : "0";
                 this.btnAddRol.Text = "Actualizar";
                 this.btnCancelarRol.Visible = true;
                 break;
             default:
                 break;
         }
     }
 }
Exemple #11
0
        private void FillGridRolesMenus()
        {
            var listaRolesMenus = new Admin().GetListMenu();

            //Carga los datos en la grilla.
            this.gvRolesMenus.DataSource = listaRolesMenus;

            //Enlaza los datos.
            this.gvRolesMenus.DataBind();

            this.lblMessageRolesMenus.Visible = listaRolesMenus.Count == 0;
        }
Exemple #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<Roles> listaMenus = new Admin().GetListRol();
                this.ddlRol.DataSource = listaMenus;
                this.ddlRol.DataValueField = "RolId";
                this.ddlRol.DataTextField = "Descripcion";
                this.ddlRol.DataBind();

                this.ddlRol.Items.Insert(0, new ListItem("Seleccione un rol...", "0"));
            }
        }
Exemple #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var listaMenus = new Admin().GetListMenu();
                this.ddlMenuPadre.DataSource = listaMenus;
                this.ddlMenuPadre.DataValueField = "MenuId";
                this.ddlMenuPadre.DataTextField = "Descripcion";
                this.ddlMenuPadre.DataBind();

                this.ddlMenuPadre.Items.Insert(0, new ListItem("Seleccione un menu...", "0"));

                this.FillGridMenu();
            }
        }
Exemple #14
0
        protected void rptMenuFav_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "delete")
                {
                    var user = (Users)Session["UserLogged"];

                    new Admin().DeleteFavorito(int.Parse(e.CommandArgument.ToString()));
                    Session["MenuFavoritos"] = new Admin().GetListFavorito(user.PersonaId);
                    var listaFav = (List<Favoritos>)Session["MenuFavoritos"];

                    this.rptMenuFav.DataSource = listaFav;
                    this.rptMenuFav.DataBind();

                    if (listaFav.Where(p => p.Menu.Url == Request.Url.AbsolutePath).ToList().Count > 0)
                        this.lnkAddFav.Visible = false;
                    else
                    {
                        this.lnkAddFav.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {  }
        }
Exemple #15
0
        private void FillProvincia()
        {
            //limpia el dropdown de localidades
            this.ddlLocalidadResi.Items.Clear();
            this.ddlLocalidadResi.Enabled = false;

            List<Provincia> listaProvincias = new Admin().GetListProvincia(Convert.ToInt32(ddlPais.SelectedValue));

            //llena el dropdown de provincias
            ddlProvincia.Enabled = true;
            ddlProvincia.DataTextField = "Descripcion";
            ddlProvincia.DataValueField = "ProvinciaId";
            ddlProvincia.DataSource = listaProvincias;
            ddlProvincia.DataBind();

            ddlProvincia.Items.Insert(0, new ListItem("- Seleccione -", "0"));
        }
Exemple #16
0
        private void FillLocalidad()
        {
            //activa y llena el dropdown de localidades
            this.ddlLocalidadResi.Enabled = true;

            List<Localidad> listaProvincias = new Admin().GetLocalidades(Convert.ToInt32(ddlProvincia.SelectedValue));

            ddlLocalidadResi.Items.Clear();

            ddlLocalidadResi.DataSource = listaProvincias;
            ddlLocalidadResi.DataValueField = "LocalidadId";
            ddlLocalidadResi.DataTextField = "Descripcion";
            ddlLocalidadResi.DataBind();

            ddlLocalidadResi.Items.Insert(0, new ListItem("- Seleccione -", "0"));
        }
Exemple #17
0
        protected void FillCombos()
        {
            List<Pais> listaPaises = new Admin().GetListPais();

            ddlNacionalidad.DataValueField = "PaisId";
            ddlNacionalidad.DataTextField = "Descripcion";
            ddlNacionalidad.DataSource = listaPaises.ToList();
            ddlNacionalidad.DataBind();
            ddlNacionalidad.Items.Insert(0, new ListItem("- Seleccione -", "0"));

            ddlPais.DataValueField = "PaisId";
            ddlPais.DataTextField = "Descripcion";
            ddlPais.DataSource = listaPaises;
            ddlPais.DataBind();
            ddlPais.Items.Insert(0, new ListItem("- Seleccione -", "0"));

            List<Roles> listaRol = new DataAccess.Admin().GetListRol();

            this.ddlRol.DataValueField = "RolId";
            this.ddlRol.DataTextField = "Descripcion";
            this.ddlRol.DataSource = listaRol.ToList();
            this.ddlRol.DataBind();
            this.ddlRol.Items.Insert(0, new ListItem("- Seleccione -", "0"));
        }
Exemple #18
0
        private void sendEmail(TechLogInformation tech)
        {
            try
            {
                var aux = new Admin();
                SMTPEmail email = new SMTPEmail();

                email.From = aux.GetGeneralParameterValue("EmailSMTP Error");
                email.To = aux.GetGeneralParameterValue("ToEmail Error");
                email.subject = aux.GetGeneralParameterValue("Subject Error");
                email.SMTPClient = aux.GetGeneralParameterValue("SMTP Client");
                email.SMTPPort = Convert.ToInt32(aux.GetGeneralParameterValue("SMTP Port"));

                email.Message = "<label style=\"display:block;\">Página: " + tech.ClassName + "</label></br></br><label style=\"display:block;\">Método: " + tech.MethodName + "</label></br></br><label style=\"display:block;\">Excepción: " + tech.ExceptionDetail + "</label></br></br>";

                MailMessage Email = new MailMessage(email.From, email.To, email.subject, email.Message);

                var smtpMail = new SmtpClient(email.SMTPClient);
                Email.IsBodyHtml = true;

                smtpMail.UseDefaultCredentials = false;
                smtpMail.Host = email.SMTPClient;
                smtpMail.Port = email.SMTPPort;
                smtpMail.EnableSsl = false;
                smtpMail.Credentials = new NetworkCredential(aux.GetGeneralParameterValue("EmailSMTP Error"), aux.GetGeneralParameterValue("PasswordSMTP Error"));//[email protected] // Aep123456

                smtpMail.Send(Email);
            }
            catch (Exception ex)
            {
                //log the error
                SaveTechLog(System.Reflection.MethodBase.GetCurrentMethod().Name, LevelError.ERROR, ex);
                throw ex;
            }
        }
Exemple #19
0
        private void FillGridMenu()
        {
            var listaMenu = new Admin().GetListMenu();

            //Paginamos la grilla.
            if (this.gvMenu.PageSize < listaMenu.Count)
            {
                this.gvMenu.AllowPaging = true;
                //--- Me fijo que pagina tengo que mostrar
                if (listaMenu.Count <= this.gvMenu.PageIndex * this.gvMenu.PageSize)
                    this.gvMenu.PageIndex = 0;
            }
            else
                this.gvMenu.AllowPaging = false;

            //Carga los datos en la grilla.
            this.gvMenu.DataSource = listaMenu;

            //Enlaza los datos.
            this.gvMenu.DataBind();

            this.lblMessageMenu.Visible = listaMenu.Count == 0;
        }
Exemple #20
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ContactUsRepository repContact = new ContactUsRepository();
            AdminsRepository    ad         = new AdminsRepository();

            DataAccess.Admin addsd = ad.getAdmin(Session["adminid"].ToString().ToInt());
            if (tbxPass.Text != "")
            {
                addsd.Password = tbxPass.Text;
                ad.SaveAdmin(addsd);
            }
            ContactWay cnw = repContact.Findcwy(1);

            if (tbxAbout.Text != "")
            {
                cnw.AboutUs = tbxAbout.Text;
            }
            if (tbxAdress.Text != "")
            {
                cnw.Adrees = tbxAdress.Text;
            }
            if (tbxMail.Text != "")
            {
                cnw.Email = tbxMail.Text;
            }
            if (tbxPhone.Text != "")
            {
                cnw.PhoneNumber = tbxPhone.Text;
            }
            if (tbxAboutPage.Text != "")
            {
                cnw.AboutPage = tbxAboutPage.Text;
            }
            if (tbxtele.Text != "")
            {
                cnw.Telegram = tbxtele.Text;
            }
            if (tbxInsta.Text != "")
            {
                cnw.Instagram = tbxInsta.Text;
            }
            if (FileUpload1.HasFile)
            {
                string filename = Path.GetFileName(FileUpload1.FileName);
                string rand     = DBManager.CurrentTimeWithoutColons() + DBManager.CurrentPersianDateWithoutSlash();
                filename = rand + filename;
                string ps = Server.MapPath(@"~\img\") + filename;
                FileUpload1.SaveAs(ps);
                FileStream fStream  = File.OpenRead(ps);
                byte[]     contents = new byte[fStream.Length];
                fStream.Read(contents, 0, (int)fStream.Length);
                fStream.Close();
                //FileInfo fi = new FileInfo(Server.MapPath(@"~\img\") + cnw.logo.Substring(5));
                //fi.Delete();
                //FileInfo fil = new FileInfo(Server.MapPath(@"~\img\") + cnw.logo.Substring(5));
                //fil.Delete();
                cnw.logo = "/img/" + filename;
            }

            if (repContact.Savecwy(cnw))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(' ثبت با موفقیت انجام شد  ');", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(' ثبت با خطا مواجه شد ! ');", true);
            }
        }
Exemple #21
0
 protected void gvMenu_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandArgument != null)
     {
         switch (e.CommandName.ToLower())
         {
             case "delete":
                 new Admin().DeleteMenu(int.Parse(e.CommandArgument.ToString()));
                 this.FillGridMenu();
                 ClientScript.RegisterStartupScript(this.GetType(), "myScript", "alert('Registro borrado exitosamente.');", true);
                 break;
             case "edit":
                 DataAccess.Menu oMenu = new Admin().GetMenu(int.Parse(e.CommandArgument.ToString()));
                 this.lblMenuId.Text = oMenu.MenuId.ToString();
                 this.txtDesc.Text = oMenu.Descripcion;
                 this.txtOrden.Text = oMenu.Orden.ToString();
                 this.txtUrl.Text = oMenu.Url;
                 this.ddlActivo.SelectedValue = oMenu.Activo == true ? "1" : "0";
                 this.ddlMenuPadre.SelectedValue = oMenu.HijoDe != null ? oMenu.HijoDe.ToString() : "0";
                 this.btnAddMenu.Text = "Actualizar";
                 this.btnCancelarMenu.Visible = true;
                 break;
             default:
                 break;
         }
     }
 }
Exemple #22
0
        private void FillGridRol()
        {
            List<Roles> listaRol = new Admin().GetListRol();

            //Paginamos la grilla.
            if (this.gvRol.PageSize < listaRol.Count)
            {
                this.gvRol.AllowPaging = true;
                //--- Me fijo que pagina tengo que mostrar
                if (listaRol.Count <= this.gvRol.PageIndex * this.gvRol.PageSize)
                    this.gvRol.PageIndex = 0;
            }
            else
                this.gvRol.AllowPaging = false;

            //Carga los datos en la grilla.
            this.gvRol.DataSource = listaRol;

            //Enlaza los datos.
            this.gvRol.DataBind();

            this.lblMessageRol.Visible = listaRol.Count == 0;
        }