private void saveActor()
        {
            var db = new eRegisterContext();

            Actor newActor = new Actor();

            newActor.FirstName   = Name.Text;
            newActor.MiddleName  = Midname.Text;
            newActor.LastName    = Lastname.Text;
            newActor.Gender      = Convert.ToBoolean(dropDownListGender.SelectedIndex);
            newActor.Address     = Address.Text;
            newActor.EGN         = PersonalID.Text;
            newActor.email       = Email.Text;
            newActor.PhoneNumber = Number.Text;
            newActor.UserID      = newUser.UserID;

            newActor.ClassDivisionID = dropDownListDivisionDetails.SelectedIndex;
            newActor.SchoolID        = dropDownListSchool.SelectedIndex;
            newActor.CityVillageID   = dropDownListTown.SelectedIndex;

            if (dropDownListType.SelectedIndex == 1)
            {
                newActor.ParentlID = parrentActor.ActorID;
            }

            db.Actors.Add(newActor);
            db.SaveChanges();
        }
Exemple #2
0
        protected void searchButton_Click(object sender, EventArgs e)
        {
            ddlCity.SelectedIndex   = 0;
            ddlClass.SelectedIndex  = 0;
            ddlSchool.SelectedIndex = 0;
            var db       = new eRegisterContext();
            var userList = from us in db.Users
                           join ac in db.Actors
                           on us.UserID equals ac.UserID
                           join type in db.UserTypes
                           on us.UserTypeID equals type.UserTypeID
                           orderby us.UserID ascending
                           select new
            {
                UserID   = us.UserID,
                FullName = ac.FirstName + " " + ac.MiddleName + " " + ac.LastName,
                Type     = type.Type
            };

            userList.Where(x => x.FullName.ToLower().Contains(txtSearch.Text.ToLower()) == true).ToList();
            if (userList.Any(x => x.FullName.ToLower().Contains(txtSearch.Text.ToLower()) == true))
            {
                gridViewUsers.DataSource = userList.Where(x => x.FullName.ToLower().Contains(txtSearch.Text.ToLower()) == true).ToList();
                gridViewUsers.DataBind();
            }
            else
            {
                loadStartPage();
            }
            txtSearch.Text = "";
        }
Exemple #3
0
        private void loadScores()
        {
            var db = new eRegisterContext();

            int currUserID = UserMasterPage.getCurrUser().UserID;
            var listScore  = from reg in db.Registers
                             join ac in db.Actors
                             on reg.StudentID equals ac.ActorID
                             join sc in db.ScoreTypes
                             on reg.ScoreTypeID equals sc.ScoreTypeID
                             where ac.UserID == currUserID
                             where reg.SubjectID == dropDownListSubjects.SelectedIndex
                             where reg.StudyYearID == dropDownListStudyYear.SelectedIndex
                             where reg.TermID == dropDownListTerm.SelectedIndex
                             orderby reg.Date
                             select new
            {
                date      = reg.Date,
                scoreType = sc.ScoreType1,
                score     = reg.ScoreNum
            };

            if (listScore.Any())
            {
                gridViewScore.DataSource = listScore.ToList();
                gridViewScore.DataBind();
                gridViewScore.Visible   = true;
                lblWarningScore.Visible = false;
            }
            else
            {
                gridViewScore.Visible   = false;
                lblWarningScore.Visible = true;
            }
        }
Exemple #4
0
        private void loadAbsences()
        {
            var db         = new eRegisterContext();
            int currUserID = UserMasterPage.getCurrUser().UserID;
            int actorId    = db.Actors.FirstOrDefault(x => x.UserID == currUserID).ActorID;

            var absencesList = from ab in db.Absences
                               join sub in db.Subjects
                               on ab.SubjectID equals sub.SubjectID
                               join abType in db.AbsenceTypes
                               on ab.AbsenceTypeID equals abType.AbsenceTypeID
                               where ab.StudentID == actorId
                               orderby ab.Date
                               select new
            {
                subject = sub.Name,
                type    = abType.Absence,
                date    = ab.Date
            };

            if (absencesList.Any())
            {
                gridViewAbsences.DataSource = absencesList.ToList();
                gridViewAbsences.DataBind();
                lblAbsences.Visible = false;
            }
            else
            {
                lblAbsences.Visible = true;
            }
        }
        private void LoadPage()
        {
            var   db           = new eRegisterContext();
            Actor currentActor = new Actor();
            int   userId       = Convert.ToInt32(Session["userid"]);

            if (db.Actors.Any(x => x.UserID == userId))
            {
                currentActor = db.Actors.First(x => x.UserID == userId);
            }
            else
            {
                Session.Abandon();
                Response.Redirect("~/UserWebForms/LogInForm.aspx");
            }
            firstNameLbl.InnerText  = currentActor.FirstName;
            middleNameLbl.InnerText = currentActor.MiddleName;
            lastNameLbl.InnerText   = currentActor.LastName;
            genderLbl.InnerText     = getGender(currentActor.Gender);
            phoneLbl.InnerText      = currentActor.PhoneNumber;
            mailLbl.InnerText       = currentActor.email;
            addressLbl.InnerText    = currentActor.Address;


            egnLbl.InnerText      = currentActor.EGN;
            schoolLbl.InnerText   = currentActor.School.SchooName;
            devisionLbl.InnerText = "";
            classLbl.InnerText    = "";
            statusLbl.InnerText   = "";
            if (currentActor.ClassDivisionID != null && UserMasterPage.getCurrUser().UserTypeID == 1)
            {
                int divClassId = (int)currentActor.ClassDivisionID;
                int divId      = db.ClassDevisionDetails.FirstOrDefault(x => x.ClassDevisionDetailsID == divClassId).DivID;
                devisionLbl.InnerText = db.Divisions.FirstOrDefault(x => x.DivisionID == divId).Division1;
                int classId = db.ClassDevisionDetails.FirstOrDefault(x => x.ClassDevisionDetailsID == divClassId).ClassID;
                classLbl.InnerText  = db.Classes.FirstOrDefault(x => x.ClassID == classId).Class1.ToString();
                statusLbl.InnerText = getStudentStatus(currentActor.Status ?? false);
            }

            schoolAdressLbl.InnerText = currentActor.School.Address;

            if (UserMasterPage.getCurrUser().UserTypeID == 1 && currentActor.ParentlID != null)
            {
                int   parId   = (int)currentActor.ParentlID;
                Actor parrent = db.Actors.FirstOrDefault(x => x.ActorID == parId);
                lblParName.InnerText   = parrent.FirstName + " " + parrent.MiddleName + " " + parrent.LastName;
                lblParNumber.InnerText = parrent.PhoneNumber;
                h3Parrent.Visible      = true;
                lblParName.Visible     = true;
                lblParNumber.Visible   = true;
                lblPName.Visible       = true;
                lblPNumber.Visible     = true;
            }
        }
        private void saveUser()
        {
            var db = new eRegisterContext();


            newUser.UserName   = inputUsername.Text;
            newUser.Password   = inputPassword.Text;
            newUser.UserTypeID = dropDownListType.SelectedIndex;
            db.Users.Add(newUser);
            db.SaveChanges();
            //ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert(\" Потребителят е добавен успешно. \");", true);
        }
        bool CheckForUser()
        {
            var db = new eRegisterContext();

            if (db.Users.Any(x => x.UserName == inputUser.Text && x.Password == inputPass.Text))
            {
                currentUser = db.Users.First(x => x.UserName == inputUser.Text && x.Password == inputPass.Text);
                return(true);
            }

            return(false);
        }
Exemple #8
0
        private void loadStartPage()
        {
            var db = new eRegisterContext();

            /**  Load cities in dropdownlist */
            var listOfCities = db.CityVillages.ToList();

            ddlCity.DataSource     = listOfCities;
            ddlCity.DataValueField = "CityVillageID";
            ddlCity.DataTextField  = "Name";
            ddlCity.DataBind();
            ddlCity.Items.Insert(0, "Град");

            /**  Load schools in dropdownlist */
            var listOfSchools = db.Schools.ToList();

            ddlSchool.DataSource     = listOfSchools;
            ddlSchool.DataValueField = "SchoolID";
            ddlSchool.DataTextField  = "SchooName";
            ddlSchool.DataBind();
            ddlSchool.Items.Insert(0, "Училище");

            /**  Load classes in dropdownlist */
            var listOfClasses = db.Classes.ToList();

            ddlClass.DataSource     = listOfClasses;
            ddlClass.DataValueField = "ClassID";
            ddlClass.DataTextField  = "Class1";
            ddlClass.DataBind();
            ddlClass.Items.Insert(0, "Клас");

            /**  Load gridview with users  */
            var userList = from us in db.Users
                           join ac in db.Actors
                           on us.UserID equals ac.UserID
                           join type in db.UserTypes
                           on us.UserTypeID equals type.UserTypeID
                           orderby us.UserID ascending
                           select new
            {
                UserID   = us.UserID,
                FullName = ac.FirstName + " " + ac.MiddleName + " " + ac.LastName,
                Type     = type.Type
            };


            gridViewUsers.DataSource = userList.ToList();
            gridViewUsers.DataBind();
        }
        private void onInitData()
        {
            var db        = new eRegisterContext();
            var userTypes = db.UserTypes.ToList();

            dropDownListType.DataSource     = userTypes;
            dropDownListType.DataValueField = "UserTypeID";
            dropDownListType.DataTextField  = "Type";
            dropDownListType.DataBind();
            dropDownListType.Items.Insert(0, "Избери");

            var schools = db.Schools.ToList();

            dropDownListSchool.DataSource     = schools;
            dropDownListSchool.DataValueField = "SchoolID";
            dropDownListSchool.DataTextField  = "SchooName";
            dropDownListSchool.DataBind();
            dropDownListSchool.Items.Insert(0, "Избери");

            var divisionDetails = from divDet in db.ClassDevisionDetails
                                  join cl in db.Classes
                                  on divDet.ClassID equals cl.ClassID
                                  join div in db.Divisions
                                  on divDet.DivID equals div.DivisionID
                                  orderby divDet.ClassDevisionDetailsID ascending
                                  select new
            {
                classDivDetailsID   = divDet.ClassDevisionDetailsID,
                classDivDetailsText = cl.Class1.ToString() + " " + div.Division1
            };

            dropDownListDivisionDetails.DataSource     = divisionDetails.ToList();
            dropDownListDivisionDetails.DataValueField = "classDivDetailsID";
            dropDownListDivisionDetails.DataTextField  = "classDivDetailsText";
            dropDownListDivisionDetails.DataBind();
            dropDownListDivisionDetails.Items.Insert(0, "Избери");

            dropDownListGender.Items.Insert(0, "Жена");
            dropDownListGender.Items.Insert(1, "Мъж");

            var cities = db.CityVillages.ToList();

            dropDownListTown.DataSource     = cities;
            dropDownListTown.DataValueField = "CityVillageID";
            dropDownListTown.DataTextField  = "Name";
            dropDownListTown.DataBind();
            dropDownListTown.Items.Insert(0, "Избери");
        }
        private void saveParrentActor()
        {
            var db = new eRegisterContext();

            parrentActor.FirstName  = parrentName.Text;
            parrentActor.MiddleName = parrentMName.Text;
            parrentActor.LastName   = parrentLName.Text;

            parrentActor.Gender      = Convert.ToBoolean(dropDownListGender.SelectedIndex);
            parrentActor.Address     = Address.Text;
            parrentActor.EGN         = PersonalID.Text;
            parrentActor.email       = Email.Text;
            parrentActor.PhoneNumber = parrentPhone.Text;
            db.Actors.Add(parrentActor);
            db.SaveChanges();
        }
Exemple #11
0
        private void showTeacherLabel()
        {
            var db = new eRegisterContext();

            if (dropDownListStudyYear.SelectedIndex != 0 && dropDownListSubjects.SelectedIndex
                != 0 && dropDownListTerm.SelectedIndex != 0)
            {
                if (db.TeacherSubjects.Any(x => x.SubjectID == dropDownListSubjects.SelectedIndex))
                {
                    showTeacherLbl.Visible = true;
                    teacherLbl.InnerText   = db.TeacherSubjects.FirstOrDefault(x => x.SubjectID == dropDownListSubjects.SelectedIndex).Actor.FirstName.ToString() + " " +
                                             db.TeacherSubjects.FirstOrDefault(x => x.SubjectID == dropDownListSubjects.SelectedIndex).Actor.LastName.ToString();
                }
                else
                {
                    teacherLbl.InnerText   = "";
                    showTeacherLbl.Visible = false;
                }
                loadScores();
            }
        }
        protected void Button_Click(object sender, EventArgs e)
        {
            var db = new eRegisterContext();

            if (CheckForUser())
            {
                if (currentUser.UserTypeID == 2)
                {
                    Response.Redirect("~/UserWebForms/AdminPage.aspx");
                }
                else
                {
                    Session["userid"] = currentUser.UserID;
                    Response.Redirect(string.Format("~/UserWebForms/ProfileWebForm.aspx?id={0}", db.Actors.First(x => x.UserID == currentUser.UserID).ActorID));
                }
            }
            else
            {
                inputUser.Text = "Wrong pass or user name!!!!";
            }
        }
Exemple #13
0
        private void loadDropDownLists()
        {
            var db        = new eRegisterContext();
            var subjects  = db.Subjects.ToList();
            var studyYear = db.StudyYears.ToList();

            dropDownListSubjects.DataSource     = subjects;
            dropDownListSubjects.DataValueField = "SubjectID";
            dropDownListSubjects.DataTextField  = "Name";
            dropDownListSubjects.DataBind();
            dropDownListSubjects.Items.Insert(0, "Избери");

            dropDownListStudyYear.DataSource     = studyYear;
            dropDownListStudyYear.DataValueField = "StudyYearID";
            dropDownListStudyYear.DataTextField  = "StudyYear1";
            dropDownListStudyYear.DataBind();
            dropDownListStudyYear.Items.Insert(0, "Избери");

            dropDownListTerm.Items.Insert(0, "Избери");
            dropDownListTerm.Items.Add(new ListItem("Първи", "1"));
            dropDownListTerm.Items.Add(new ListItem("Втори", "2"));
        }
Exemple #14
0
        protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
        {
            var db     = new eRegisterContext();
            int cityId = ddlCity.SelectedIndex;

            /**  Load gridview with users  */
            var userList = from us in db.Users
                           join ac in db.Actors
                           on us.UserID equals ac.UserID
                           join type in db.UserTypes
                           on us.UserTypeID equals type.UserTypeID
                           where ac.CityVillageID == cityId
                           orderby us.UserID ascending
                           select new
            {
                UserID   = us.UserID,
                FullName = ac.FirstName + " " + ac.MiddleName + " " + ac.LastName,
                Type     = type.Type
            };

            if (ddlSchool.SelectedIndex != 0 && ddlClass.SelectedIndex != 0)
            {
                /**  Load gridview with users  */
                userList = from us in db.Users
                           join ac in db.Actors
                           on us.UserID equals ac.UserID
                           join type in db.UserTypes
                           on us.UserTypeID equals type.UserTypeID
                           join cd in db.ClassDevisionDetails
                           on ac.ClassDivisionID equals cd.ClassDevisionDetailsID
                           where ac.CityVillageID == cityId
                           where cd.ClassID == ddlClass.SelectedIndex
                           where ac.SchoolID == ddlSchool.SelectedIndex
                           orderby us.UserID ascending
                           select new
                {
                    UserID   = us.UserID,
                    FullName = ac.FirstName + " " + ac.MiddleName + " " + ac.LastName,
                    Type     = type.Type
                };
            }
            else if (ddlClass.SelectedIndex != 0)
            {
                /**  Load gridview with users  */
                userList = from us in db.Users
                           join ac in db.Actors
                           on us.UserID equals ac.UserID
                           join type in db.UserTypes
                           on us.UserTypeID equals type.UserTypeID
                           join cd in db.ClassDevisionDetails
                           on ac.ClassDivisionID equals cd.ClassDevisionDetailsID
                           where ac.CityVillageID == cityId
                           where cd.ClassID == ddlClass.SelectedIndex
                           orderby us.UserID ascending
                           select new
                {
                    UserID   = us.UserID,
                    FullName = ac.FirstName + " " + ac.MiddleName + " " + ac.LastName,
                    Type     = type.Type
                };
            }
            else if (ddlSchool.SelectedIndex != 0)
            {
                /**  Load gridview with users  */
                userList = from us in db.Users
                           join ac in db.Actors
                           on us.UserID equals ac.UserID
                           join type in db.UserTypes
                           on us.UserTypeID equals type.UserTypeID
                           where ac.CityVillageID == cityId
                           where ac.SchoolID == ddlSchool.SelectedIndex
                           orderby us.UserID ascending
                           select new
                {
                    UserID   = us.UserID,
                    FullName = ac.FirstName + " " + ac.MiddleName + " " + ac.LastName,
                    Type     = type.Type
                };
            }

            if (userList.Any())
            {
                gridViewUsers.DataSource = userList.ToList();
                gridViewUsers.DataBind();
            }
            else
            {
                loadStartPage();
            }
        }