public async Task <HttpResponseMessage> GetStudent(int UserID) //32168
        {
            try
            {
                ParentDAL      dal  = new ParentDAL();
                List <Profile> data = await dal.GetStudent(UserID);

                if (data != null)
                {
                    return(Request.CreateResponse <List <Profile> >(HttpStatusCode.OK, data));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Constants.ErrorNotFound));
                }
            }
            catch (DbEntityValidationException ex)
            {
                var    controllerName = ControllerContext.RouteData.Values["controller"].ToString();
                var    actionName     = ControllerContext.RouteData.Values["action"].ToString();
                Logger log            = new Logger();
                log.ErrorLog(ex, controllerName, actionName);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Constants.ErrorSysError));
            }
        }
Beispiel #2
0
        private void ParentStudentsWindow_Load(object sender, EventArgs e)
        {
            students = ParentDAL.GetParentStudents(this.ParentID);

            //bind binging navigator to data grid
            var bs = new BindingSource();

            bs.DataSource = students.DefaultView;
            bindingNavigator1.BindingSource      = bs;
            this.studentsDataGridView.DataSource = bs;

            this.toolStripParentID.Text = "Parent ID: " + this.ParentID;
        }
        private void AddNewParentWindow_Load(object sender, EventArgs e)
        {
            this.lblStudentID.Text  = this.lblStudentID.Text.Replace("#", StudentID.ToString());
            this.lblStudentID1.Text = this.lblStudentID.Text;

            List <string> parentNames = ParentDAL.GetParentNames();

            foreach (string name in parentNames)
            {
                this.comboParents.Items.Add(name);
            }
            if (comboParents.Items.Count > 0)
            {
                this.comboParents.SelectedItem = comboParents.Items[0];
            }
        }
        private void btnAddNewParent_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtLastName.Text.Length == 0 || txtFirstName.Text.Length == 0 || txtPatronymic.Text.Length == 0)
                {
                    throw new ArgumentException("FIO fields can't be null!");
                }
                if (txtEmail.Text.Length == 0)
                {
                    throw new ArgumentException("Email is required!");
                }
                if (txtPassword.Text.Length == 0)
                {
                    throw new ArgumentException("Password is required!");
                }
                if (!Util.IsValidEmail(txtEmail.Text))
                {
                    throw new ArgumentException("Email is not valid!");
                }
                User basicUserInfo = new User
                {
                    LastName    = txtLastName.Text,
                    FirstName   = txtFirstName.Text,
                    Patronymic  = txtPatronymic.Text,
                    DateOfBirth = dateTimePickerBirth.Value.Year == 9998 ? null : new DateTime?(dateTimePickerBirth.Value),
                    Email       = txtEmail.Text,
                    Password    = txtPassword.Text,
                    Phone       = txtPhone.Text
                };

                Parent p = new Parent
                {
                    user = basicUserInfo,
                    Job  = txtJob.Text
                };

                ParentDAL.AddNewParent(p);
                StudentDAL.AddParent(this.StudentID, p.ParentID);
                MessageBox.Show("Parent successfully added!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        private void ChildOverallProgress_Load(object sender, EventArgs e)
        {
            students = ParentDAL.GetParentStudents(this.ParentID);

            //populate combo box STUDENTS
            foreach (DataRow dr in students.Rows)
            {
                string studID     = dr[0].ToString();
                string lastName   = dr[1].ToString();
                string firstName  = dr[2].ToString();
                string patronymic = dr[3].ToString();
                comboChild.Items.Add(
                    string.Format("{0} {1} {2} {3}", studID, lastName, firstName, patronymic));
            }
            if (comboChild.Items.Count > 0)
            {
                comboChild.SelectedItem = comboChild.Items[0];
            }
            else
            {
                comboChild.Enabled = false;
            }
        }
        private void ChildProgressWindow_Load(object sender, EventArgs e)
        {
            students = ParentDAL.GetParentStudents(this.ParentID);

            //populate combo box STUDENTS
            foreach (DataRow dr in students.Rows)
            {
                string studID     = dr[0].ToString();
                string lastName   = dr[1].ToString();
                string firstName  = dr[2].ToString();
                string patronymic = dr[3].ToString();
                comboChild.Items.Add(
                    string.Format("{0} {1} {2} {3}", studID, lastName, firstName, patronymic));
            }
            if (comboChild.Items.Count > 0)
            {
                comboChild.SelectedItem = comboChild.Items[0];
            }
            else
            {
                comboChild.Enabled = false;
            }


            //populate combo box SUBJECTS
            UpdateSubjectsComboBox();


            // Set palette.
            this.chartProgress.Palette = ChartColorPalette.SeaGreen;

            // Set title.
            this.chartProgress.Titles.Add("Student progress");

            IsLoaded = true;
        }
Beispiel #7
0
        private void btnMyProfile_Click(object sender, EventArgs e)
        {
            ParentInfo info = null;

            try
            {
                info = ParentDAL.GetParentInfo(this.ParentID);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ProfileWindow wnd = new ProfileWindow(info, "Job", info.Job);

            wnd.FormClosed += ((o, s) =>
            {
                this.Show();
            });
            wnd.Owner = this;
            wnd.Show();
            this.Hide();
        }