Esempio n. 1
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            rowIndex = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName == "DeleteUser")
            {
                RoleEditPnl.Visible    = false;
                changePassword.Visible = false;

                //delete user from membership

                Membership.DeleteUser(GridView1.DataKeys[rowIndex].Values[1].ToString());

                //delete user data from database

                var db    = new CloudAppDbEntities();
                var _User = db.User.Find(GridView1.DataKeys[rowIndex].Values[1].ToString());
                db.User.Remove(_User);
                db.SaveChanges();
                //update gridview1
                GridView1.DataSource = GetAllUsers();
                GridView1.DataBind();
            }
            if (e.CommandName == "EditRole")
            {
                RoleEditPnl.Visible    = true;
                changePassword.Visible = false;
            }
            if (e.CommandName == "EditPassword")
            {
                RoleEditPnl.Visible    = false;
                changePassword.Visible = true;
            }
        }
Esempio n. 2
0
        // changing password!!!
        public DataTable GetFacultyUsers(int facultyID)
        {
            var db        = new CloudAppDbEntities();
            var UsersList = db.User.Where(u => u.Class.Department.FacultyID == facultyID || u.FacultyID == facultyID).ToList();
            //var DepList = db.Department.Where(d => d.FacultyID == facultyID);
            var dtAllItems = new DataTable();

            dtAllItems.Columns.Add("Name");
            dtAllItems.Columns.Add("UserID");
            //foreach (var d in DepList)
            //foreach (var u in studentlist)
            //{
            //var classlist = db.Class.Where(c => c.DepartmentID == d.DepartmentID).ToList();
            //foreach (var c in classlist)
            //{
            //var UsersList = db.User.Where(u => u.ClassID == c.ClassID).ToList();
            foreach (var u in UsersList)
            {
                string _type2 = null;
                switch (u.UserType)
                {
                case 2:
                    _type2 = "FacultyAdmin";
                    break;

                case 4:
                    _type2 = "Student";
                    break;
                }
                dtAllItems.Rows.Add(u.UserName, u.UserID, _type2);
            }
            return(dtAllItems);
        }
Esempio n. 3
0
        private DataTable GetClassFiles()
        {
            var db = new CloudAppDbEntities();

            classID = db.User.Find(currentUserID).ClassID ?? 0;
            //var i = Guid.NewGuid();// random genaration for i, and can be used in file.fname which must be userd by server
            var filesList = db.UserFile.Where(f => f.ClassID == classID);

            // function
            var dtAllItems = new DataTable();

            dtAllItems.Columns.Add("Name");
            dtAllItems.Columns.Add("Size");
            dtAllItems.Columns.Add("UploadTime");
            dtAllItems.Columns.Add("Type");
            dtAllItems.Columns.Add("Uploader");
            dtAllItems.Columns.Add("FName");

            foreach (var f in filesList)
            {
                var fuploader = db.User.Find(f.UploaderID).UserName;
                dtAllItems.Rows.Add(f.FileName, f.FileSize, f.UploadTime, f.FileType, fuploader, string.Format("{0}{1}", f.FName, f.FileType));
            }
            //  function
            return(dtAllItems);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];

            var db          = new CloudAppDbEntities();
            var Facultylist = db.Faculty.ToList();
            var deplist     = db.Department.ToList();
            var classlist   = db.Class.ToList();

            // DropDownList2.Items.Clear();
            if (DropDownList2.Items.Count < 4)
            {
                foreach (var x in Facultylist)
                {
                    DropDownList2.Items.Add(x.FacultyName);
                }
            }
            if (DropDownList3.Items.Count < 4)
            {
                foreach (var x in deplist)
                {
                    DropDownList3.Items.Add(x.DepartmentName);
                }
            }
            if (DropDownList1.Items.Count < 4)
            {
                foreach (var x in classlist)
                {
                    DropDownList1.Items.Add(x.ClassName);
                }
            }
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GridView1.AutoGenerateColumns = false;
            GridView1.DataSource          = GetData();
            GridView1.DataBind();
            var db = new CloudAppDbEntities();

            _classID = db.User.Find(User.Identity.Name).ClassID ?? 0;
        }
Esempio n. 6
0
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var db         = new CloudAppDbEntities();
            var _facultyID = db.Faculty.First(f => f.FacultyName == DropDownList1.SelectedValue).FacultyID;

            //update gridview2

            GridView2.DataSource = GetDepartments(_facultyID);
            GridView2.DataBind();
        }
Esempio n. 7
0
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            //class div..
            //department dropdownlist selected ..
            var db            = new CloudAppDbEntities();
            int _departmentID = db.Department.First(d => d.DepartmentName == DropDownList2.SelectedValue).DepartmentID;

            GridView3.DataSource = GetClasses(_departmentID);
            GridView3.DataBind();
        }
Esempio n. 8
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            var db = new CloudAppDbEntities();

            var _EditedUser = db.User.Find(GridView1.DataKeys[rowIndex].Values[1].ToString());

            int _type2 = 0;

            switch (RadioButtonList1.SelectedValue)
            {
            case "Admin":
                _type2 = 1;
                Roles.AddUserToRole(GridView1.DataKeys[rowIndex].Values[1].ToString(), "Admin");
                break;

            case "Faculty Admin":
                _type2 = 2;
                Roles.AddUserToRole(GridView1.DataKeys[rowIndex].Values[1].ToString(), "Faculty Admin");
                break;

            case "Teacher":
                _type2 = 3;
                Roles.AddUserToRole(GridView1.DataKeys[rowIndex].Values[1].ToString(), "Teacher");
                break;

            case "Student":
                _type2 = 4;
                Roles.AddUserToRole(GridView1.DataKeys[rowIndex].Values[1].ToString(), "Student");
                break;
            }

            //editing data in database

            _EditedUser.UserType = _type2;

            if (_type2 == 2)
            {
                int _facultyID = db.Faculty.First(f => f.FacultyName == DropDownList5.SelectedValue).FacultyID;
                _EditedUser.FacultyID = _facultyID;
            }

            else if (_type2 == 4)
            {
                int _classID = db.Class.First(c => c.ClassName == DropDownList4.SelectedValue).ClassID;
                _EditedUser.ClassID = _classID;
            }

            db.Entry(_EditedUser).State = EntityState.Modified;
            db.SaveChanges();

            //..
            // update GridView1
            GridView1.DataSource = GetAllUsers();
            GridView1.DataBind();
        }
Esempio n. 9
0
        protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
        {
            //course div..
            //class dropdownlist selected..
            var db = new CloudAppDbEntities();

            int _ClassID = db.Class.First(c => c.ClassName == DropDownList3.SelectedValue).ClassID;

            GridView4.DataSource = GetCourses(_ClassID);
            GridView4.DataBind();
        }
Esempio n. 10
0
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            RegisterUser.LoginCreatedUser = false;
            if (DropDownList1.SelectedValue == "Admin")
            {
                _type = 1;
                Roles.AddUserToRole(RegisterUser.UserName, "Admin");
            }
            if (DropDownList1.SelectedValue == "Faculty Admin")
            {
                _type = 2;
                Roles.AddUserToRole(RegisterUser.UserName, "FacultyAdmin");
            }
            if (DropDownList1.SelectedValue == "Teacher")
            {
                _type = 3;
                Roles.AddUserToRole(RegisterUser.UserName, "Teacher");
            }
            if (DropDownList1.SelectedValue == "Student")
            {
                _type = 4;
                Roles.AddUserToRole(RegisterUser.UserName, "Student");
            }

            // saving user data in database
            var db = new CloudAppDbEntities();

            _UserEmail = RegisterUser.Email;
            _UserID    = User.Identity.Name;
            _UserName  = FirstName.Text + " " + MiddleName.Text + " " + LastName.Text;

            var _User = new User();

            _User.UserID    = _UserID;
            _User.UserName  = _UserName;
            _User.UserType  = _type;
            _User.UserEmail = _UserEmail;
            if (_type == 4)
            {
                _ClassID      = db.Class.First(c => c.ClassName == DropDownList4.SelectedValue).ClassID;
                _User.ClassID = _ClassID;
            }
            else if (_type == 2)
            {
                _facultyID      = db.Faculty.First(f => f.FacultyName == DropDownList5.SelectedValue).FacultyID;
                _User.FacultyID = _facultyID;
            }

            db.User.Add(_User);
            db.SaveChanges();

            GridView1.DataSource = GetAllUsers();
            GridView1.DataBind();
        }
Esempio n. 11
0
        protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList4.Items.Clear();
            var db          = new CloudAppDbEntities();
            int _DepID      = db.Department.First(d => d.DepartmentName == DropDownList3.SelectedValue).DepartmentID;
            var ClassesList = db.Class.Where(d => d.DepartmentID == _DepID);

            foreach (var c in ClassesList)
            {
                DropDownList4.Items.Add(c.ClassName);
            }
        }
Esempio n. 12
0
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList3.Items.Clear();
            var db         = new CloudAppDbEntities();
            int _FacultyID = db.Faculty.First(f => f.FacultyName == DropDownList2.SelectedValue).FacultyID;
            var DepList    = db.Department.Where(d => d.FacultyID == _FacultyID);

            foreach (var d in DepList)
            {
                DropDownList3.Items.Add(d.DepartmentName);
            }
        }
Esempio n. 13
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument);
            var db       = new CloudAppDbEntities();
            var faculty  = new Faculty();

            faculty = db.Faculty.Find(GridView1.DataKeys[rowIndex].Values[1].ToString());
            db.Faculty.Remove(faculty);
            db.SaveChanges();
            GridView1.DataSource = GetFaculties();
            GridView1.DataBind();
        }
Esempio n. 14
0
        protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex   = Convert.ToInt32(e.CommandArgument);
            var db         = new CloudAppDbEntities();
            var department = new Department();

            department = db.Department.Find(GridView2.DataKeys[rowIndex].Values[1].ToString());
            db.Department.Remove(department);
            db.SaveChanges();

            GridView2.DataSource = GetDepartments();
            GridView2.DataBind();
        }
Esempio n. 15
0
        public DataTable GetDepartments()
        {
            var db         = new CloudAppDbEntities();
            var DepList    = db.Department.Where(d => d.FacultyID == _facultyID).ToList();
            var dtAllItems = new DataTable();

            dtAllItems.Columns.Add("Name");
            dtAllItems.Columns.Add("ID");
            foreach (var d in DepList) // faculty list
            {
                dtAllItems.Rows.Add(d.DepartmentName, d.DepartmentID);
            }
            return(dtAllItems);
        }
Esempio n. 16
0
        protected void GridView4_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument);
            var db       = new CloudAppDbEntities();
            var course   = new Course();

            course = db.Course.Find(GridView3.DataKeys[rowIndex].Values[1].ToString());
            db.Course.Remove(course);
            db.SaveChanges();
            int _ClassID = db.Class.First(c => c.ClassName == DropDownList3.SelectedValue).ClassID;

            GridView4.DataSource = GetCourses(_ClassID);
            GridView4.DataBind();
        }
Esempio n. 17
0
        protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex   = Convert.ToInt32(e.CommandArgument);
            var db         = new CloudAppDbEntities();
            var department = new Department();

            department = db.Department.Find(GridView2.DataKeys[rowIndex].Values[1].ToString());
            db.Department.Remove(department);
            db.SaveChanges();
            var _facultyID = db.Faculty.First(f => f.FacultyName == DropDownList1.SelectedValue).FacultyID;

            GridView2.DataSource = GetDepartments(_facultyID);
            GridView2.DataBind();
        }
Esempio n. 18
0
        protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument);
            var db       = new CloudAppDbEntities();
            var _class   = new Class();

            _class = db.Class.Find(GridView3.DataKeys[rowIndex].Values[1].ToString());
            db.Class.Remove(_class);
            db.SaveChanges();
            int _departmentID = db.Department.First(d => d.DepartmentName == DropDownList2.SelectedValue).DepartmentID;

            GridView3.DataSource = GetClasses(_departmentID);
            GridView3.DataBind();
        }
Esempio n. 19
0
        private DataTable GetData()
        {
            var dt = new DataTable();

            dt.Columns.Add("Course");
            dt.Columns.Add("CourseID");
            var db         = new CloudAppDbEntities();
            var courseList = db.TeacherCourse.Where(t => t.TeacherID == User.Identity.Name);

            foreach (var tc in courseList)
            {
                dt.Rows.Add(tc.Course.CourseName, tc.CourseID);
            }
            return(dt);
        }
Esempio n. 20
0
        public DataTable GetClasses(int _departmentID)
        {
            var db         = new CloudAppDbEntities();
            var ClassList  = db.Class.Where(d => d.DepartmentID == _departmentID).ToList();
            var dtAllItems = new DataTable();

            dtAllItems.Columns.Add("Name");
            dtAllItems.Columns.Add("ID");
            foreach (var c in ClassList)
            {
                dtAllItems.Rows.Add(c.ClassName, c.ClassID);
            }

            return(dtAllItems);
        }
Esempio n. 21
0
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            PnlDep.Visible    = false;
            PnlClass.Visible  = true;
            PnlCourse.Visible = false;
            // fullfill dropdownlists from db
            DropDownList2.Items.Clear();
            var db      = new CloudAppDbEntities();
            var DepList = db.Department.Where(d => d.FacultyID == _facultyID).ToList();

            foreach (var x in DepList)
            {
                DropDownList2.Items.Add(x.DepartmentName);
            }
        }
Esempio n. 22
0
        public DataTable GetCourses(int _classID)
        {
            var db         = new CloudAppDbEntities();
            var CourseList = db.Course.Where(c => c.ClassID == _classID).ToList();
            var dtAllItems = new DataTable();

            dtAllItems.Columns.Add("Name");
            dtAllItems.Columns.Add("ID");
            foreach (var c in CourseList)
            {
                dtAllItems.Rows.Add(c.CourseName, c.CourseID);
            }

            return(dtAllItems);
        }
Esempio n. 23
0
        protected void DropDownList6_SelectedIndexChanged(object sender, EventArgs e)
        {
            //course div..
            //department dropdownlist selected ..
            var db            = new CloudAppDbEntities();
            int _departmentID = db.Department.First(d => d.DepartmentName == DropDownList6.SelectedValue).DepartmentID;

            //update class dropdownlist
            DropDownList3.Items.Clear();
            var Classlist = db.Class.Where(c => c.DepartmentID == _departmentID).ToList();

            foreach (var x in Classlist)
            {
                DropDownList3.Items.Add(x.ClassName);
            }
        }
Esempio n. 24
0
        protected void DropDownList5_SelectedIndexChanged(object sender, EventArgs e)
        {
            //course div..
            //faculty dropdownlist selected..
            var db         = new CloudAppDbEntities();
            var _facultyID = db.Faculty.First(f => f.FacultyName == DropDownList5.SelectedValue).FacultyID;

            //update departments dropdownlist
            DropDownList6.Items.Clear();
            var DepList = db.Department.Where(d => d.FacultyID == _facultyID).ToList();

            foreach (var x in DepList)
            {
                DropDownList6.Items.Add(x.DepartmentName);
            }
        }
Esempio n. 25
0
        private DataTable GetData()
        {
            var dt = new DataTable();

            dt.Columns.Add("Courses");
            dt.Columns.Add("ID");
            var db         = new CloudAppDbEntities();
            var courseList = db.CourseClass.Where(c => c.ClassID == _classID);

            foreach (var cc in courseList)
            {
                var _coursename = db.Course.Find(cc.CourseID).CourseName;
                dt.Rows.Add(_coursename, cc.CourseID);
            }
            return(dt);
        }
Esempio n. 26
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            PnlFaculty.Visible = false;
            PnlDep.Visible     = true;
            PnlClass.Visible   = false;
            PnlCourse.Visible  = false;

            // fullfill dropdownlist from db
            DropDownList1.Items.Clear();
            var db          = new CloudAppDbEntities();
            var Facultylist = db.Faculty.ToList();

            foreach (var x in Facultylist)
            {
                DropDownList1.Items.Add(x.FacultyName);
            }
        }
Esempio n. 27
0
        public DataTable GetFaculties()
        {
            var db = new CloudAppDbEntities();

            var facultylist = db.Faculty.ToList();
            // function

            var dtAllItems = new DataTable();

            dtAllItems.Columns.Add("Name");
            dtAllItems.Columns.Add("ID");
            foreach (var f in facultylist) // faculty list
            {
                dtAllItems.Rows.Add(f.FacultyName, f.FacultyID);
            }
            return(dtAllItems);
        }
Esempio n. 28
0
        public static int rowIndex; // used in edit users gridview

        protected void Page_Load(object sender, EventArgs e)
        {
            var db = new CloudAppDbEntities();

            _facultyID = db.User.Find(User.Identity.Name).FacultyID ?? 0;
            var DepList = db.Department.Where(d => d.FacultyID == _facultyID);

            // fullfill dropdownlist of departmwnts
            DropDownList3.Items.Clear();
            foreach (var d in DepList)
            {
                DropDownList3.Items.Add(d.DepartmentName);
            }
            //...
            GridView1.DataSource = GetFacultyUsers(_facultyID);
            GridView1.DataBind();
        }
Esempio n. 29
0
        public DataTable GetDepartments(int _facultyID)
        {
            var db = new CloudAppDbEntities();
            //var _facultyID = db.Faculty.First(f => f.FacultyName == DropDownList1.SelectedValue).FacultyID;

            var DepList = db.Department.Where(d => d.FacultyID == _facultyID).ToList();
            // function

            var dtAllItems = new DataTable();

            dtAllItems.Columns.Add("Name");
            dtAllItems.Columns.Add("ID");
            foreach (var d in DepList) // faculty list
            {
                dtAllItems.Rows.Add(d.DepartmentName, d.DepartmentID);
            }
            return(dtAllItems);
        }
        private DataTable GetCourseStudents()
        {
            var db          = new CloudAppDbEntities();
            int _classID    = db.CourseClass.First(c => c.CourseID == _courseID).ClassID;
            var StudentList = db.User.Where(u => u.ClassID == _classID);

            // function
            var dtAllItems = new DataTable();

            dtAllItems.Columns.Add("StudentName");
            dtAllItems.Columns.Add("UserID");
            foreach (var f in StudentList)
            {
                dtAllItems.Rows.Add(f.UserName, f.UserID);
            }
            //  function
            return(dtAllItems);
        }