示例#1
0
        protected void grdUser_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridViewRow      row         = (GridViewRow)grdUser.Rows[e.RowIndex];
            Label            lbldeleteid = (Label)row.FindControl("lblUserID");
            DatabaseEntities db          = new DatabaseEntities();
            int id = Convert.ToInt32(lbldeleteid.Text);

            USERS u = (from x in db.USERS where x.userID == id && x.approvalSituation == true && x.isActive == true select x).SingleOrDefault();

            u.isActive = false;
            db.SaveChanges();

            USERS[] u1 = (from x in db.USERS where x.approvalSituation == true && x.isActive == true select x).ToArray();
            grdUser.DataSource = u1;
            grdUser.DataBind();
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            USERS loginUser = (USERS)Session["User"];

            lblHeaderName.Text = loginUser.name + " " + loginUser.surname;
            imgUser.ImageUrl   = loginUser.photoURL;
            DateTime todayDate = DateTime.Today;

            DatabaseEntities db = new DatabaseEntities();

            ANNOUNCEMENTS[] listOfPastAnnouncements = (from x in db.ANNOUNCEMENTS where x.date < todayDate && x.isActive == true select x).ToArray();

            for (int i = 0; i < listOfPastAnnouncements.Length; i++)
            {
                listOfPastAnnouncements[i].isActive = false;
            }

            db.SaveChanges();
        }
示例#3
0
        protected void btnMyAnnouncements_Click(object sender, EventArgs e)
        {
            DatabaseEntities db = new DatabaseEntities();

            USERS loginUser = (USERS)Session["User"];

            var query = (from a in db.ANNOUNCEMENTS
                         join u in db.USERS on a.userID equals u.userID
                         join p in db.PETS on a.petID equals p.petID
                         where u.userID == loginUser.userID && a.approvalSituation == true && a.isActive == true
                         select new DataBindingProjection
            {
                ID = a.announcementID,
                date = a.date,
                photo = p.photoURL,
                name = p.name,
                type = p.type,
                petClass = p.petClass,
                age = p.age,
                gender = p.gender,
                situation = a.situation,
                fee = a.fee,
                text = a.text,
                userName = u.name,
                userSurname = u.surname,
                userAddress = u.address,
                userMail = u.emailAddress,
                userPhone = u.phoneNumber
            }).ToList();

            grdAnnouncements.DataSource = query;
            grdAnnouncements.DataBind();

            grdAnnouncements.Visible       = true;
            grdPets.Visible                = false;
            lblAnnouncementsHeader.Visible = true;
            lblPetsHeader.Visible          = false;
        }
示例#4
0
        protected void grdUser_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Label    id           = (Label)grdUser.Rows[e.RowIndex].FindControl("lblUserID");
            TextBox  name         = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtUserName");
            TextBox  surname      = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtUserSurname");
            TextBox  eMailAddress = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtEmail");
            TextBox  password     = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtPassword");
            TextBox  phoneNumber  = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtPhone");
            TextBox  age          = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtAge");
            TextBox  gender       = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtGender");
            TextBox  photo        = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtPhoto");
            TextBox  address      = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtAddress");
            TextBox  city         = (TextBox)grdUser.Rows[e.RowIndex].FindControl("txtCity");
            CheckBox approval     = (CheckBox)grdUser.Rows[e.RowIndex].FindControl("checkApproval");

            DatabaseEntities db = new DatabaseEntities();
            int id1             = Convert.ToInt32(id.Text);

            USERS u = (from x in db.USERS where x.approvalSituation == true && x.userID == id1 && x.isActive == true select x).SingleOrDefault();

            u.name              = name.Text;
            u.surname           = surname.Text;
            u.emailAddress      = eMailAddress.Text;
            u.password          = password.Text;
            u.phoneNumber       = phoneNumber.Text;
            u.age               = Convert.ToInt32(age.Text);
            u.gender            = gender.Text;
            u.photoURL          = photo.Text;
            u.address           = address.Text;
            u.city              = city.Text;
            u.approvalSituation = approval.Checked;
            db.SaveChanges();

            USERS[] u1 = (from x in db.USERS where x.approvalSituation == true && x.isActive == true select x).ToArray();
            grdUser.DataSource = u1;
            grdUser.DataBind();
        }
示例#5
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string email    = txtEmail.Text;
            string password = txtPassword.Text;

            DatabaseEntities db = new DatabaseEntities();

            USERS u = (from x in db.USERS
                       where x.emailAddress == email && x.password == password && x.approvalSituation == true && x.isActive == true
                       select x).SingleOrDefault();

            if (u == null)
            {
                ADMINISTRATORS a = (from x in db.ADMINISTRATORS
                                    where x.companyEmail == email && x.password == password && x.isActive == true
                                    select x).SingleOrDefault();

                if (a == null)
                {
                    VETS v = (from x in db.VETS
                              where x.emailAddress == email && x.password == password && x.isActive == true
                              select x).SingleOrDefault();

                    if (v == null)
                    {
                        lblMessage.Visible = true;
                        lblMessage.Text    = "Please check your information !";
                    }

                    else
                    {
                        if (cbRememberMe.Checked)
                        {
                            Response.Cookies["Email"].Value   = txtEmail.Text;
                            Response.Cookies["Email"].Expires = DateTime.Now.AddHours(8);

                            Response.Cookies["Password"].Value   = txtPassword.Text;
                            Response.Cookies["Password"].Expires = DateTime.Now.AddHours(8);
                        }

                        else
                        {
                            if (Request.Cookies["Email"] != null && Request.Cookies["Password"] != null)
                            {
                                Response.Cookies["Email"].Expires    = DateTime.Now.AddHours(-1);
                                Response.Cookies["Password"].Expires = DateTime.Now.AddHours(-1);
                            }
                        }

                        Session["Vet"] = v;

                        Application.Lock();
                        Application["Counter"] = Convert.ToInt32(Application["Counter"]) + 1;
                        Application.UnLock();

                        Response.Redirect("VetHomePage.aspx");
                    }
                }

                else
                {
                    if (cbRememberMe.Checked)
                    {
                        Response.Cookies["Email"].Value   = txtEmail.Text;
                        Response.Cookies["Email"].Expires = DateTime.Now.AddHours(8);

                        Response.Cookies["Password"].Value   = txtPassword.Text;
                        Response.Cookies["Password"].Expires = DateTime.Now.AddHours(8);
                    }

                    else
                    {
                        if (Request.Cookies["Email"] != null && Request.Cookies["Password"] != null)
                        {
                            Response.Cookies["Email"].Expires    = DateTime.Now.AddHours(-1);
                            Response.Cookies["Password"].Expires = DateTime.Now.AddHours(-1);
                        }
                    }

                    Session["Admin"] = a;

                    Application.Lock();
                    Application["Counter"] = Convert.ToInt32(Application["Counter"]) + 1;
                    Application.UnLock();

                    Response.Redirect("AdminHomePage.aspx");
                }
            }

            else
            {
                if (cbRememberMe.Checked)
                {
                    Response.Cookies["Email"].Value   = txtEmail.Text;
                    Response.Cookies["Email"].Expires = DateTime.Now.AddHours(8);

                    Response.Cookies["Password"].Value   = txtPassword.Text;
                    Response.Cookies["Password"].Expires = DateTime.Now.AddHours(8);
                }

                else
                {
                    if (Request.Cookies["Email"] != null && Request.Cookies["Password"] != null)
                    {
                        Response.Cookies["Email"].Expires    = DateTime.Now.AddHours(-1);
                        Response.Cookies["Password"].Expires = DateTime.Now.AddHours(-1);
                    }
                }

                Session["User"] = u;

                Application.Lock();
                Application["Counter"] = Convert.ToInt32(Application["Counter"]) + 1;
                Application.UnLock();

                Response.Redirect("UserHomePage.aspx");
            }
        }
示例#6
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            DatabaseEntities db = new DatabaseEntities();

            USERS u = (from x in db.USERS
                       where x.emailAddress == txtEmail.Text
                       select x).SingleOrDefault();

            if (u == null)
            {
                VETS v = (from x in db.VETS
                          where x.emailAddress == txtEmail.Text
                          select x).SingleOrDefault();

                if (v == null)
                {
                    if (ddlUserTypes.SelectedValue == "User")
                    {
                        USERS newUser = new USERS();
                        newUser.name         = txtName.Text;
                        newUser.surname      = txtSurname.Text;
                        newUser.emailAddress = txtEmail.Text;
                        newUser.password     = txtPassword.Text;
                        newUser.phoneNumber  = txtPhoneNumber.Text;
                        newUser.age          = Convert.ToInt32(txtAge.Text);
                        newUser.gender       = ddlGender.SelectedValue;
                        newUser.address      = txtAddress.Text;
                        newUser.city         = txtCity.Text;
                        fuImage.SaveAs(Server.MapPath("~/Photos/" + fuImage.FileName));
                        newUser.photoURL          = "~/Photos/" + fuImage.FileName;
                        newUser.isActive          = true;
                        newUser.approvalSituation = false;
                        db.USERS.Add(newUser);
                        db.SaveChanges();
                    }

                    else if (ddlUserTypes.SelectedValue == "Veterinary")
                    {
                        VETS newVet = new VETS();
                        newVet.name         = txtName.Text;
                        newVet.surname      = txtSurname.Text;
                        newVet.emailAddress = txtEmail.Text;
                        newVet.password     = txtPassword.Text;
                        newVet.phoneNumber  = txtPhoneNumber.Text;
                        newVet.age          = Convert.ToInt32(txtAge.Text);
                        newVet.gender       = ddlGender.SelectedValue;
                        newVet.address      = txtAddress.Text;
                        newVet.city         = txtCity.Text;
                        fuImage.SaveAs(Server.MapPath("~/Photos/" + fuImage.FileName));
                        newVet.photoURL          = "~/Photos/" + fuImage.FileName;
                        newVet.isActive          = true;
                        newVet.approvalSituation = false;
                        db.VETS.Add(newVet);
                        db.SaveChanges();
                    }

                    lblMessage.Visible = true;
                    lblMessage.Text    = "Your information has been successfully saved.";

                    clear();
                }

                else
                {
                    lblMessage.Visible = true;
                    lblMessage.Text    = "Your e-mail registered already !";
                }
            }

            else
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "Your e-mail registered already !";
            }
        }