Esempio n. 1
0
 private void Signup()
 {
     using (moyEntities db = new moyEntities())
     {
         var signup = db.USERs.Where(a => a.Email.Equals(email.Text)).FirstOrDefault();
         if (signup == null)
         {
             USER save = new USER();
             save.Email    = email.Text.Trim();
             save.Name     = name.Text.Trim();
             save.Surname  = surname.Text.Trim();
             save.Password = pwd.Text.Trim();
             db.USERs.Add(save);
             db.SaveChanges();
             Session.Add("Id", save.Id);
             Session.Add("name", save.Name);
             Session.Add("surname", save.Surname);
             Session.Add("email", save.Email);
             Session.Add("password", save.Password);
             email.Text   = string.Empty;
             name.Text    = string.Empty;
             surname.Text = string.Empty;
             Response.Redirect("Dashboard.aspx");
         }
         else
         {
             emailerror.Visible = true;
         }
     }
 }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (moyEntities db = new moyEntities())
     {
         int usrname = Session["Id"].GetHashCode();
         var user    = db.USERs.Where(a => a.Id == usrname).FirstOrDefault();
         username.Text = user.Name;
     }
 }
Esempio n. 3
0
 public void Done_List()
 {
     using (moyEntities db = new moyEntities())
     {
         int         userid = Convert.ToInt32(Session["Id"]);
         List <Done> done   = db.Dones.Where(a => a.UserId == userid).OrderBy(a => a.DONE1).ToList();
         DoneList.DataSource     = done;
         DoneList.DataTextField  = "Done1";
         DoneList.DataValueField = "Id";
         DoneList.DataBind();
     }
 }
Esempio n. 4
0
 public void Willdo_List()
 {
     using (moyEntities db = new moyEntities())
     {
         int           userid = Convert.ToInt32(Session["Id"]);
         List <Willdo> willdo = db.Willdoes.Where(a => a.UserId == userid).OrderBy(a => a.Willdo1).ToList();
         WilldoList.DataSource     = willdo;
         WilldoList.DataTextField  = "Willdo1";
         WilldoList.DataValueField = "Id";
         WilldoList.DataBind();
     }
 }
Esempio n. 5
0
 protected void DeleteDoingList(object sender, EventArgs e)
 {
     using (moyEntities db = new moyEntities())
     {
         int userid = Convert.ToInt32(Session["Id"]);
         var remove = db.Doings.Where(a => a.UserId == userid && a.Doing1 == DoingList.SelectedItem.Text).FirstOrDefault();
         db.Doings.Remove(remove);
         db.SaveChanges();
     }
     Doing_List();
     Response.Redirect("list.aspx");
 }
Esempio n. 6
0
 protected void Add_OnClick(object sender, EventArgs e)
 {
     using (moyEntities db = new moyEntities())
     {
         Willdo willdo = new Willdo();
         willdo.UserId  = Session["Id"].GetHashCode();
         willdo.Willdo1 = txtwilldo.Text;
         db.Willdoes.Add(willdo);
         db.SaveChanges();
     }
     txtwilldo.Text = "";
     Willdo_List();
     Response.Redirect("list.aspx");
 }
Esempio n. 7
0
 protected void AddDoneList(object sender, EventArgs e)
 {
     using (moyEntities db = new moyEntities())
     {
         Done done = new Done();
         done.UserId = Session["Id"].GetHashCode();
         done.DONE1  = txtdone.Text;
         db.Dones.Add(done);
         db.SaveChanges();
     }
     txtdone.Text = "";
     Doing_List();
     Response.Redirect("list.aspx");
 }
Esempio n. 8
0
 protected void AddDoing_OnClick(object sender, EventArgs e)
 {
     using (moyEntities db = new moyEntities())
     {
         Doing doing = new Doing();
         doing.UserId = Session["Id"].GetHashCode();
         doing.Doing1 = txtdoing.Text;
         db.Doings.Add(doing);
         db.SaveChanges();
     }
     txtdoing.Text = "";
     Doing_List();
     Response.Redirect("list.aspx");
 }
Esempio n. 9
0
        protected bool IsEmailValid(string email)
        {
            USER userToEdit = new USER();

            using (moyEntities db = new moyEntities())
            {
                userToEdit = db.USERs.Where(a => a.Email == email).FirstOrDefault();
            }
            if (userToEdit == null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 10
0
 protected void PassDoingList(object sender, EventArgs e)
 {
     using (moyEntities db = new moyEntities()) {
         int   userid = Convert.ToInt32(Session["Id"]);
         Doing doing  = new Doing();
         doing.Doing1 = WilldoList.SelectedItem.Text;
         doing.UserId = Session["Id"].GetHashCode();
         db.Doings.Add(doing);
         db.SaveChanges();
         Willdo willdo = new Willdo();
         var    remove = db.Willdoes.Where(a => a.UserId == userid && a.Willdo1 == WilldoList.SelectedItem.Text).FirstOrDefault();
         db.Willdoes.Remove(remove);
         db.SaveChanges();
     }
     Willdo_List();
     Doing_List();
     Response.Redirect("list.aspx");
 }
Esempio n. 11
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (moyEntities db = new moyEntities())
            {
                CONTACT save = new CONTACT();
                save.Email   = email.Text.Trim();
                save.Message = message.Text.Trim();
                if (Session["Id"] != null)
                {
                    save.UserId = Session["Id"].GetHashCode();
                }
                db.CONTACTs.Add(save);
                db.SaveChanges();
                sucmessage.Visible = true;
            }

            email.Text   = string.Empty;
            message.Text = string.Empty;
        }
Esempio n. 12
0
        public void btnsave1_click(object sender, EventArgs e)
        {
            int    length       = 8;
            string oldpassword  = txtold1.Text.Trim();
            string newpassword1 = txtnew1.Text.Trim();
            string newpassword2 = txtnew2.Text.Trim();
            string UserID       = Session["Id"].ToString();
            string DBPassword   = string.Empty;

            if (newpassword1.Length >= length && newpassword1 == newpassword2)

            {
                using (moyEntities db = new moyEntities())

                {
                    int  userid     = Convert.ToInt32(Session["Id"].GetHashCode());
                    USER loggedUser = db.USERs.Where(a => a.Id == userid).FirstOrDefault();

                    if (loggedUser != null)
                    {
                        DBPassword = loggedUser.Password;
                    }
                }
                if (oldpassword != newpassword1 && newpassword1 == newpassword2)

                {
                    using (moyEntities db = new moyEntities())
                    {
                        int  userid     = Convert.ToInt32(Session["Id"].GetHashCode());
                        USER loggedUser = db.USERs.Where(a => a.Id == userid).FirstOrDefault();
                        loggedUser.Password = newpassword1;
                        db.SaveChanges();
                    }


                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showSuccess():", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showError();", true);
            }
        }
Esempio n. 13
0
 protected void login_button_Click(object sender, EventArgs e)
 {
     using (moyEntities db = new moyEntities()) // connect to database.
     {
         var login = db.USERs.Where(a => a.Email == email.Text && a.Surname == surname.Text && a.Name == name.Text && a.Password == pwd.Text).FirstOrDefault();
         if (login != null)
         {
             Session.Add("Id", login.Id);
             Session.Add("name", login.Name);
             Session.Add("surname", login.Surname);
             Session.Add("email", login.Email);
             Session.Add("password", login.Password);
             Response.Redirect("Dashboard.aspx");
         }
         else
         {
             Label1.Visible = true;
         }
     }
 }
Esempio n. 14
0
        protected void btnsave2_click(object sender, EventArgs e)
        {
            bool validEmail = IsEmailValid(txtemail.Text);

            using (moyEntities db = new moyEntities())

            {
                int userid = Convert.ToInt32(Session["Id"].GetHashCode());


                USER editedUser = db.USERs.Where(a => a.Id == userid).FirstOrDefault();
                if (validEmail == true)
                {
                    editedUser.Email = txtemail.Text;
                }
                db.SaveChanges();
            }
            txtemail.Text    = null;
            txtusername.Text = null;
        }