protected void Button2_Click(object sender, EventArgs e)
        {
            HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
            int StudentID = Convert.ToInt32(GridView1.Rows[0].Cells[0].Text);

            var NewStu = (from nstu in db.StudentRequests
                          where nstu.StudentID == StudentID
                          select nstu).First();

            string NewHouseName = NewStu.NewHouseName;

            var house = (from h in db.Houses
                         where h.HouseName == NewHouseName
                         select h).First();
            var stu = (from s in db.Students
                       where s.StudentID == StudentID
                       select s).First();

            stu.FirstName = NewStu.NewFirstName;
            stu.LastName = NewStu.NewLastName;
            stu.Nationality = NewStu.NewNationality;
            stu.MmailAddress = NewStu.NewMMailAddress;
            stu.HouseID = house.HouseID;
            db.SubmitChanges();
            deleteStudentRequest();
            //give notification to the student in charge
            Staff staff = Classes.HogwartsDataAccess.GetStaff(Context.User.Identity.Name);
            Classes.TableDataContract.AddNotice(staff.StaffID, StudentID, "accepted", 0, true, false);
            Response.Redirect("ProcessStudentRequests.aspx");
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (DropDownList1.Items.Count == 0) return;
            HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
            int StudentID = Convert.ToInt32(DropDownList1.SelectedValue);
            var NeededStu = (from stu in db.Students
                             join house in db.Houses on stu.HouseID equals house.HouseID
                             where stu.StudentID == StudentID && stu.HouseID == house.HouseID
                             select new
                             {
                                 StudentID = stu.StudentID,
                                 CurrentFirstname = stu.FirstName,
                                 CurrentLastname = stu.LastName,
                                 CurrentNationality = stu.Nationality,
                                 CurrentMMailAddress = stu.MmailAddress,
                                 CurrentHouseName = house.HouseName
                             });

            GridView1.DataSource = NeededStu;
            GridView1.DataBind();
            var NewStu = (from stu in db.StudentRequests
                          where stu.StudentID == StudentID
                          select stu);

            GridView2.DataSource = NewStu;
            GridView2.DataBind();
            Button2.Visible = true;
            Button3.Visible = true;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Classes.HogwartsDataAccess.GetRole(Context.User.Identity.Name) == 0)
         Response.Redirect("~/StudentWorks/StudentHome/StudentProfile.aspx");
     string username = Context.User.Identity.Name;
     HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
     var staff = (from s in db.Staffs
                  where s.UserName == username
                  select s).First();
     ViewState["title"] = staff.FirstName + " " + staff.LastName;
     try
     {
         if (!IsPostBack)
         {
             this.EnsureContainerExists();
         }
         this.RefreshGallery();
     }
     catch (System.Net.WebException we)
     {
         status.Text = "Network error: " + we.Message;
         if (we.Status == System.Net.WebExceptionStatus.ConnectFailure)
         {
             status.Text += "<br />Please check if the blob storage service is running at " +
                            ConfigurationManager.AppSettings["storageEndpoint"];
         }
     }
     catch (StorageException se)
     {
         Console.WriteLine("Storage service error: " + se.Message);
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Classes.HogwartsDataAccess.GetRole(Context.User.Identity.Name) == 1)
         Response.Redirect("~/StaffWorks/StaffHome/StaffProfile.aspx");
     if (!Page.IsPostBack)
     {
         HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
         var halls = (from hall in db.Houses
                      select hall.HouseName);
         DropDownList1.DataSource = halls;
         DropDownList1.DataBind();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Classes.HogwartsDataAccess.GetRole(Context.User.Identity.Name) == 1)
         Response.Redirect("~/StaffWorks/StaffHome/StaffProfile.aspx");
     if (!Page.IsPostBack)
     {
         HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
         string username = Context.User.Identity.Name;
         var rec = (from c in db.Students
                    where username == c.UserName
                    select c).First();
         Session["StudentID"] = rec.StudentID;
         Session["StudentName"] = rec.FirstName + " " + rec.LastName;
         Label2.Text = Classes.HogwartsDataAccess.GetStudentName(rec.StudentID);
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Classes.HogwartsDataAccess.GetRole(Context.User.Identity.Name) == 1)
             Response.Redirect("~/StaffWorks/StaffHome/StaffProfile.aspx");
         HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
         int StudentID = (int)Session["studentID"];
         var EachStudent = (from st in db.Students
                            where st.StudentID == StudentID
                            select st).First();
         var rec = (from sr in db.StudentRequests
                    where StudentID == sr.StudentID
                    select sr).FirstOrDefault();
         if (rec != null) LinkButton1.Enabled = false;
         else LinkButton1.Enabled = true;
         Label2.Text = EachStudent.FirstName + " " + EachStudent.LastName;
         Label3.Text = EachStudent.Nationality;
         Label4.Text = EachStudent.MmailAddress;
         Label5.Text = EachStudent.House.HouseName;
         Label6.Text = Context.User.Identity.Name;
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
            Student student = HogwartsDataAccess.GetStudent(UsernameTextBox.Text, PasswordTextBox.Text);

            if (student == null)
            {
                Staff staff = HogwartsDataAccess.GetStaff(UsernameTextBox.Text, PasswordTextBox.Text);
                if (staff == null)
                {
                    UsernameTextBox.Text = "";
                    PasswordTextBox.Text = "";
                    error.Visible = true;
                    return;
                }
                FormsAuthentication.RedirectFromLoginPage(UsernameTextBox.Text,false);
                Response.Redirect("~/StaffWorks/StaffHome/StaffProfile.aspx");
                return;
            }
            FormsAuthentication.RedirectFromLoginPage(UsernameTextBox.Text, false);
            Response.Redirect("~/StudentWorks/StudentHome/StudentProfile.aspx");
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = Label2.Text = Label3.Text = Label4.Text = "";
            if (TextBox1.Text == "")
                Label1.Text = "Field can't be nill";
            if (TextBox2.Text == "")
                Label2.Text = "Field can't be nill";
            if (TextBox3.Text == "")
                Label3.Text = "Field can't be nill";
            if (TextBox4.Text == "")
                Label4.Text = "Field can't be nill";
            if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "")
                return;

            //update username + password
            string OldUserName = Context.User.Identity.Name;
            HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
            var NeededStu = (from st in db.Students
                             where st.UserName == OldUserName
                             select st).First();
            StudentRequest sr = new StudentRequest();
            sr.StudentID = NeededStu.StudentID;
            sr.NewFirstName = TextBox1.Text;
            sr.NewLastName = TextBox2.Text;
            sr.NewNationality = TextBox3.Text;
            sr.NewMMailAddress = TextBox4.Text;
            sr.NewHouseName = DropDownList1.SelectedValue;
            db.StudentRequests.InsertOnSubmit(sr);
            db.SubmitChanges();

            //NOTICE TO ALL ONLINE STAFF
            List<Staff> lst = db.Staffs.ToList();
            for(int i=0;i<lst.Count;i++)
                Classes.TableDataContract.AddStudentRequest(Classes.HogwartsDataAccess.GetStudentID(Context.User.Identity.Name), lst[i].StaffID, false);
            Response.Redirect("./StudentInfo.aspx");
        }
 protected void deleteStudentRequest()
 {
     HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
     int StudentID = Convert.ToInt32(GridView1.Rows[0].Cells[0].Text);
     var Stu = (from stu in db.StudentRequests
                where stu.StudentID == StudentID
                select stu).First();
     db.StudentRequests.DeleteOnSubmit(Stu);
     db.SubmitChanges();
     GridView1.DataSource = null;
     GridView1.DataBind();
     GridView2.DataSource = null;
     GridView2.DataBind();
     DropDownList1.Items.Remove(Convert.ToString(StudentID));
     Button2.Visible = false;
     Button3.Visible = false;
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Classes.HogwartsDataAccess.GetRole(Context.User.Identity.Name) == 0)
         Response.Redirect("~/StudentWorks/StudentHome/StudentProfile.aspx");
     if (!IsPostBack)
     {
         Button2.Visible = false;
         Button3.Visible = false;
         HogwartsDatabaseModelDataContext db = new HogwartsDatabaseModelDataContext();
         List<StudentRequest> rec = (from stu in db.StudentRequests
                                     select stu).ToList<StudentRequest>();
         for (int i = 0; i < rec.Count; i++)
             DropDownList1.Items.Add(Convert.ToString(rec[i].StudentID));
     }
 }