Exemplo n.º 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();
        }
Exemplo n.º 2
0
        protected void grdAppVet_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = grdAppVet.SelectedRow;
            int         id  = Convert.ToInt32(row.Cells[0].Text);

            DatabaseEntities db = new DatabaseEntities();

            VETS[] chosenVet = (from v in db.VETS where v.vetID == id && v.isActive == true select v).ToArray();

            chosenVet[0].approvalSituation = true;
            db.SaveChanges();

            VETS[] listOfVets = (from v in db.VETS where v.approvalSituation == false && v.isActive == true select v).ToArray();

            grdAppVet.DataSource = listOfVets;
            grdAppVet.DataBind();
        }
Exemplo n.º 3
0
        protected void grdAppUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = grdAppUser.SelectedRow;
            int         id  = Convert.ToInt32(row.Cells[0].Text);

            DatabaseEntities db = new DatabaseEntities();

            USERS[] chosenUser = (from u in db.USERS where u.userID == id && u.isActive == true select u).ToArray();

            chosenUser[0].approvalSituation = true;
            db.SaveChanges();

            USERS[] listOfUsers = (from u in db.USERS where u.approvalSituation == false && u.isActive == true select u).ToArray();

            grdAppUser.DataSource = listOfUsers;
            grdAppUser.DataBind();
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            VETS loginVet = (VETS)Session["Vet"];

            lblHeaderName.Text = loginVet.name + " " + loginVet.surname;
            imgVet.ImageUrl    = loginVet.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();
        }
Exemplo n.º 5
0
        protected void grdVet_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Label    id           = (Label)grdVet.Rows[e.RowIndex].FindControl("lblVetID");
            TextBox  name         = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtVetName");
            TextBox  surname      = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtVetSurname");
            TextBox  eMailAddress = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtEmail");
            TextBox  password     = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtPassword");
            TextBox  phoneNumber  = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtPhone");
            TextBox  age          = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtAge");
            TextBox  gender       = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtGender");
            TextBox  photo        = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtPhoto");
            TextBox  address      = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtAddress");
            TextBox  city         = (TextBox)grdVet.Rows[e.RowIndex].FindControl("txtCity");
            CheckBox approval     = (CheckBox)grdVet.Rows[e.RowIndex].FindControl("checkApproval");

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

            VETS v = (from x in db.VETS where x.approvalSituation == true && x.vetID == id1 && x.isActive == true select x).SingleOrDefault();

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

            VETS[] v1 = (from x in db.VETS where x.approvalSituation == true && x.isActive == true select x).ToArray();
            grdVet.DataSource = v1;
            grdVet.DataBind();
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            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();



            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
                         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,
                userCity = u.city,
                userMail = u.emailAddress,
                userPhone = u.phoneNumber
            }).ToList();

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

            var query2 = (from a in db.ANNOUNCEMENTS
                          join v in db.VETS on a.vetID equals v.vetID
                          join p in db.PETS on a.petID equals p.petID
                          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,
                vetName = v.name,
                vetSurname = v.surname,
                vetAddress = v.address,
                vetCity = v.city,
                vetMail = v.emailAddress,
                vetPhone = v.phoneNumber
            }).ToList();

            grdAnnouncementsVet.DataSource = query2;
            grdAnnouncementsVet.DataBind();
        }
Exemplo n.º 7
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 !";
            }
        }