示例#1
0
 private void FindButton_Click(object sender, RoutedEventArgs e) //Finds the competitor in the SkiRun class.
 {
     NameTextBox.Clear();                                        //Clears the name text box.
     AddressTextBox.Clear();                                     //Clears the address text box.
     ScoreTextBox.Clear();                                       //Clears the score text box.
     TagTextBox.Clear();                                         //Clears the tag text box.
     FindCompetitor();                                           //Calls the FindCompetitor method above.
 }
示例#2
0
 private void ClearScoresButton_Click(object sender, EventArgs e)
 {
     score        = 0;
     scoreTotal   = 0;
     scoreCount   = 0;
     scoreAverage = 0;
     ScoreTextBox.Clear();
     ScoreTotalTextBox.Clear();
     ScoreCountTextBox.Clear();
     AverageTextBox.Clear();
     ScoreTextBox.Focus();
 }
示例#3
0
 private void ClearData_Click(object sender, RoutedEventArgs e)
 {
     activeSkiRun.ClearCompData();             //Calls a method in the SkiRun class which empties the dictionary and the lists.
     IncomeTextBox.Clear();                    //Clears the income textbox.
     TotalScoresTextBox.Clear();               //Clears the total scores text box.
     EntriesTextBox.Clear();                   //Clears the ammount of entries the competiton had.
     TopThreeScoresTextBox.Clear();            //Clears the high scores text box so data doesn't overlap.
     AgeMinTextBox.Clear();                    //Clears the minimum age textbox.
     AgeMaxTextBox.Clear();                    //Clears the maximum age textbox.
     AgeAveTextBox.Clear();                    //Clears the average age textbox.
     AgeModeTextBox.Clear();                   //Clears the mode age textbox.
     activeSkiRun.CompetitorAges.Clear();      //Clears the ages list.
     CompetitorNumberTextBox.Text = "000000";  //Resets the competitor number text box.
     NumberTextBox.Clear();                    //Clears the number text box.
     NameTextBox.Clear();                      //Clears the name text box.
     AddressTextBox.Clear();                   //Clears the address text box.
     DetailsTextBox.Clear();                   //Clears the details text box.
     ScoreTextBox.Clear();                     //Clears the scores text box.
     SearchTextBox.Clear();                    //Clears the seach by name text box.
     TagTextBox.Clear();                       //Clears the tag text box.
     SearchByName.Items.Clear();               //Clears the search by name combo box.
 }
示例#4
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                int.Parse(ScoreTextBox.Text);
            }
            catch (FormatException ex)
            {
                //MessageBox.Show("Điểm chỉ bao gồm số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điểm chỉ bao gồm số", "Thông báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                ScoreTextBox.Focus();
                return;
            }

            DateTime dob;

            if (string.IsNullOrEmpty(DobTextBox.Text))
            {
                NotificationForm notificationForm = new NotificationForm("Điền ngày tháng năm sinh của học sinh", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }
            else
            {
                bool chValidity = DateTime.TryParseExact(
                    DobTextBox.Text,
                    "dd/MM/yyyy",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out dob);
                if (!chValidity)
                {
                    NotificationForm notificationForm = new NotificationForm("Điền ngày tháng theo dạng dd/MM/yyyy ví dụ 12/07/2020", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }
            }

            try
            {
                int.Parse(GraduatingYearTextBox.Text);
            }
            catch (FormatException ex)
            {
                //MessageBox.Show("Năm tốt nghiệp chỉ bao gồm số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Năm tốt nghiệp chỉ bao gồm số", "Thông báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                GraduatingYearTextBox.Focus();
                return;
            }

            if (LearningModeComboBox.SelectedValue == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn hình thức đào tạo", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (MajorComboBox.SelectedValue == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn Chuyên ngành", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (RankingComboBox.SelectedValue == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn xếp loại", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (GenderComboBox.SelectedItem == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn giới tính", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (EthnicComboBox.SelectedValue == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn dân tộc", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }
        }
示例#5
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    float.Parse(ScoreTextBox.Text);
                }
                catch (FormatException ex)
                {
                    //MessageBox.Show("Điểm chỉ bao gồm số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điểm chỉ bao gồm số", "Thông báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    ScoreTextBox.Focus();
                    return;
                }

                try
                {
                    int graduatingYear = int.Parse(GraduatingYearTextBox.Text);
                    int currentYear    = DateTime.Now.Year;
                    if (graduatingYear < 1000 || graduatingYear > currentYear)
                    {
                        NotificationForm notificationForm = new NotificationForm("Năm tốt nghiệp nằm ngoài phạm vi cho phep", "Cảnh báo", MessageBoxIcon.Warning);
                        notificationForm.ShowDialog();
                        GraduatingYearTextBox.Focus();
                        return;
                    }
                }
                catch (FormatException ex)
                {
                    //MessageBox.Show("Năm tốt nghiệp chỉ bao gồm số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Năm tốt nghiệp chỉ bao gồm số", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    GraduatingYearTextBox.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(FullnameTextBox.Text))
                {
                    //MessageBox.Show("Nhập tên học sinh / sinh viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập tên học sinh / sinh viên", "Thông báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(AddressTextBox.Text))
                {
                    //MessageBox.Show("Nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập địa chỉ", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(BornedAddressTextBox.Text))
                {
                    //MessageBox.Show("Nhập nơi sinh", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập nơi sinh", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }


                if (string.IsNullOrEmpty(HouseHoldTextBox.Text))
                {
                    //MessageBox.Show("Nhập hộ khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập hộ khẩu", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(IdentityTextBox.Text))
                {
                    //MessageBox.Show("Nhập chứng minh thư", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập chứng minh thư", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(imageLocation))
                {
                    //MessageBox.Show("Thêm ảnh học sinh / sinh viên", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Thêm ảnh học sinh", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                DateTime dob;
                if (string.IsNullOrEmpty(DobTextBox.Text))
                {
                    NotificationForm notificationForm = new NotificationForm("Điền ngày tháng năm sinh của học sinh", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }
                else
                {
                    bool chValidity = DateTime.TryParseExact(
                        DobTextBox.Text,
                        "dd/MM/yyyy",
                        CultureInfo.InvariantCulture,
                        DateTimeStyles.None, out dob);
                    if (!chValidity)
                    {
                        NotificationForm notificationForm = new NotificationForm("Điền ngày tháng theo dạng dd/MM/yyyy ví dụ 12/07/2020", "Cảnh báo", MessageBoxIcon.Warning);
                        notificationForm.ShowDialog();
                        return;
                    }
                }

                if (SchoolComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn trường học", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (LearningModeComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn hình thức đào tạo", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (MajorComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn Chuyên ngành", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (RankingComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn xếp loại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (GenderComboBox.SelectedItem == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn giới tính", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (EthnicComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn dân tộc", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }


                saveFileName = FullnameTextBox.Text + "_" + IdentityTextBox.Text;

                StudentModel studentModel = new StudentModel();
                studentModel.FullName        = FullnameTextBox.Text;
                studentModel.Address         = AddressTextBox.Text;
                studentModel.HouseHold       = HouseHoldTextBox.Text;
                studentModel.IdentityNumber  = IdentityTextBox.Text;
                studentModel.Note            = NoteRichTextBox.Text;
                studentModel.Gender          = GenderComboBox.SelectedItem.ToString();
                studentModel.SchoolId        = int.Parse(SchoolComboBox.SelectedValue.ToString());
                studentModel.EthnicId        = int.Parse(EthnicComboBox.SelectedValue.ToString());
                studentModel.GraduatingYear  = int.Parse(GraduatingYearTextBox.Text);
                studentModel.LearningModeId  = int.Parse(LearningModeComboBox.SelectedValue.ToString());
                studentModel.MajorId         = int.Parse(MajorComboBox.SelectedValue.ToString());
                studentModel.RankingId       = int.Parse(RankingComboBox.SelectedValue.ToString());
                studentModel.Dob             = dob;
                studentModel.Score           = float.Parse(ScoreTextBox.Text);
                studentModel.BornedAddress   = BornedAddressTextBox.Text;
                studentModel.BlankCertTypeId = managingSchoolService.GetSingleSchoolById(int.Parse(SchoolComboBox.SelectedValue.ToString())).BlankCertTypeId;
                studentModel.Image           = saveFileName + extension;

                // add avatar image to StudentImages folder
                string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;

                int result = managingStudentService.AddStudent(studentModel);
                if (result > 0)
                {
                    File.Copy(imageLocation, Path.Combine(@"C:\JbCert_Resource\StudentImages", saveFileName + extension));
                    //MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Thêm thành công", "Cảnh báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    OnStudentAdded();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Thêm không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#6
0
        private void FindCompetitor()                                                                  //Set up to find the competitors by their number.
        {
            DetailsTextBox.Clear();                                                                    //Clears the details textbox.
            Competitor editSkier;                                                                      //Makes aninstance of the Competitor class.

            if (SearchTextBox.Text.Trim() != "" && NumberTextBox.Text.Trim() != "")                    //You can only use on search method so if there is text in both it will be rejected.
            {
                MessageBox.Show("Please use only one search method!");                                 //The error message.
            }
            else if (SearchByName.Text.Trim() == "" && NumberTextBox.Text.Trim() == "")                //If there is no text in either search methods then the search will fail.
            {
                editSkier = null;                                                                      //There's no competitor.
                MessageBox.Show("There is no competitor with that number or name! Please try again."); //The error message.
                NameTextBox.Clear();                                                                   //Clears the name text box.
                AddressTextBox.Clear();                                                                //Clears the address text box.
                ScoreTextBox.Clear();                                                                  //Clears the score text box.
                NumberTextBox.Clear();                                                                 //Clears number text box.
                TagTextBox.Clear();                                                                    //Clears the tag text box.
            }

            //***NOTE*** - This is a very inefficient way to seach. I have the same code twice for each search method because I didn't know how to differentiate between the two.

            else if (SearchByName.Text.Trim() != "")                          //If search by name has some text in it then it will make a competitor.
            {
                editSkier = SkiRun.FindSkierByName(SearchByName.Text.Trim()); //Calls the find competitor by name in the SkiRun class.
                try
                {
                    NameTextBox.Text    = editSkier.GetName().Trim();                                                                                                                                                                                                                                    //Sets the competitor name.
                    AddressTextBox.Text = editSkier.GetAddress().Trim();                                                                                                                                                                                                                                 //Sets the competitor address.
                    ScoreTextBox.Text   = editSkier.GetScore().Trim();                                                                                                                                                                                                                                   //Sets the competitor score.

                    if (editSkier.GetSponsor() == null && editSkier.GetBlood() == null && editSkier.GetNoK() == null)                                                                                                                                                                                    //If there's no sponsor, no blood type and no next of kin then it must be an amateur.
                    {
                        DetailsTextBox.Text = "Class: Amatuer" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £100";                                                                                                                                   //Information show in details text box.
                        TagTextBox.Text     = "Amateur";                                                                                                                                                                                                                                                 //Displays the tag in the tag text box.
                    }
                    else if (editSkier.GetSponsor() != null)                                                                                                                                                                                                                                             //If the sponsor does no equal null then it must be a professional.
                    {
                        DetailsTextBox.Text = "Class: Professional" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £200" + Environment.NewLine + "Sponsor: " + editSkier.GetSponsor();                                                                 //Information show in details text box.
                        TagTextBox.Text     = "Professional";                                                                                                                                                                                                                                            //Displays the tag in the tag text box.
                    }
                    else if (editSkier.GetBlood() != null)                                                                                                                                                                                                                                               //If blood type does not equal null then is must be a celebrity.
                    {
                        DetailsTextBox.Text = "Class: Celebrity" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You do not have to pay." + Environment.NewLine + "Blood Type: " + editSkier.GetBlood() + Environment.NewLine + "Next of Kin: " + editSkier.GetNoK(); //Information show in details text box.
                        TagTextBox.Text     = "Celebrity";                                                                                                                                                                                                                                               //Displays the tag in the tag text box.
                    }
                }
                catch
                {
                    MessageBox.Show("Could not find competitor!");  //If the user types a name it cannot find then it will display this.
                }
            }
            else if (NumberTextBox.Text.Trim() != "")                    //If the number text box has something in it then it will use this method.
            {
                editSkier = SkiRun.FindSkier(NumberTextBox.Text.Trim()); //Calls the find competitor in the SkiRun class.
                try
                {
                    NameTextBox.Text    = editSkier.GetName();                                                                                                                                                                                                                                           //Sets the competitor name.
                    AddressTextBox.Text = editSkier.GetAddress();                                                                                                                                                                                                                                        //Sets the competitor address.
                    ScoreTextBox.Text   = editSkier.GetScore();                                                                                                                                                                                                                                          //Sets the competitor score.

                    if (editSkier.GetSponsor() == null && editSkier.GetBlood() == null && editSkier.GetNoK() == null)                                                                                                                                                                                    //If there's no sponsor, no blood type and no next of kin then it must be an amateur.
                    {
                        DetailsTextBox.Text = "Class: Amatuer" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £100";                                                                                                                                   //Information show in details text box.
                        TagTextBox.Text     = "Amateur";                                                                                                                                                                                                                                                 //Displays the tag in the tag text box.
                    }
                    else if (editSkier.GetSponsor() != null)                                                                                                                                                                                                                                             //If the sponsor does no equal null then it must be a professional.
                    {
                        DetailsTextBox.Text = "Class: Professional" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £200" + Environment.NewLine + "Sponsor: " + editSkier.GetSponsor();                                                                 //Information show in details text box.
                        TagTextBox.Text     = "Professional";                                                                                                                                                                                                                                            //Displays the tag in the tag text box.
                    }
                    else if (editSkier.GetBlood() != null)                                                                                                                                                                                                                                               //If blood type does not equal null then is must be a celebrity.
                    {
                        DetailsTextBox.Text = "Class: Celebrity" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You do not have to pay." + Environment.NewLine + "Blood Type: " + editSkier.GetBlood() + Environment.NewLine + "Next of Kin: " + editSkier.GetNoK(); //Information show in details text box.
                        TagTextBox.Text     = "Celebrity";                                                                                                                                                                                                                                               //Displays the tag in the tag text box.
                    }
                }
                catch
                {
                    MessageBox.Show("Could not find competitor!");  //If the user types a name it cannot find then it will display this.
                }
            }
            //NumberTextBox.Clear();
            //SearchByName.Items.Clear();
            //SearchTextBox.Clear();
        }