Esempio n. 1
0
        private async void ClassesViewDeleteClassButton_Click(object sender, RoutedEventArgs e)
        {
            if (selectedClassName.Tag != null)
            {
                //Delete selected Class
                //MessageBoxResult result = MessageBox.Show("Do you want to delete " + selectedClassName.Text + " ?", "Delete", MessageBoxButton.OKCancel);
                //if (result == MessageBoxResult.OK)
                //{
                //    ResultYN resultYN = await Controllers.Controller.Instance.DeleteClass(Convert.ToInt32(selectedClassName.Tag.ToString()));

                //    PanelClassview_Loaded();
                //    selectedClassName.Tag = null;
                //    selectedClassName.Text = "";
                //}
                mUC.iNotifierBoxOKCancel iNotifierBoxOKCancel = new mUC.iNotifierBoxOKCancel();
                iNotifierBoxOKCancel.Text = "Do you want to delete " + selectedClassName.Text + " ?";
                iNotifierBoxOKCancel.ShowDialog();
                if (iNotifierBoxOKCancel.result == mUC.iNotifierBoxOKCancel.Result.OK)
                {
                    ResultYN resultYN = await Controllers.Controller.Instance.DeleteClass(Convert.ToInt32(selectedClassName.Tag.ToString()));

                    PanelClassview_Loaded();
                    selectedClassName.Tag  = null;
                    selectedClassName.Text = "";
                }
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string username = usernameTb.Text;
            string password = passwordBox.Password.ToString();
            string email    = emailTb.Text;
            string name     = nameTb.Text;

            if (!IsValidEmail(email))
            {
                MessageBox.Show("Email không hợp lệ");
                return;
            }

            if (!IsValidUsername(username))
            {
                MessageBox.Show("Username không hợp lệ");
                return;
            }


            /*Regex regex1 = new Regex("^[a-zA-Z]+[a-zA-Z0-9]+[[a-zA-Z0-9-_.!#$%'*+/=?^]{1,20}@[a-zA-Z0-9]{1,20}.[a-zA-Z]{2,3}$")*/;

            ResultYN result = await Controller.Instance.SignUp(username, password, email, name);

            if (result.Result)
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("Đăng kí không thành công!", "Thông báo");
            }
        }
Esempio n. 3
0
        private async void StudentsListviewDeleteStudentButton_Click(object sender, RoutedEventArgs e)
        {
            if (studentsLv.SelectedValue != null)
            {
                //Delete selected Student
                mUC.iNotifierBoxOKCancel iNotifierBoxOKCancel = new mUC.iNotifierBoxOKCancel();
                iNotifierBoxOKCancel.Text = "Do you want to delete " + selectedStudentTbName.Text + " ?";
                iNotifierBoxOKCancel.ShowDialog();
                if (iNotifierBoxOKCancel.result == mUC.iNotifierBoxOKCancel.Result.OK)
                {
                    for (int i = 0; i < studentInfos.Count; i++)
                    {
                        if (studentInfos.ElementAt(i).MaHS.ToString() == studentsLv.SelectedValue.ToString())
                        {
                            ResultYN resultYN = await Controllers.Controller.Instance.DeleteStudent(Convert.ToInt32(studentsLv.SelectedValue.ToString()));

                            studentsLv_Loaded();
                            CollectionViewSource.GetDefaultView(studentsLv.ItemsSource).Refresh();
                            break;
                        }
                    }
                }
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (studentNameTb.Text != "" &&
                sexTb.Text != "" &&
                dobTb.Text != "" &&
                countryTb.Text != "" &&
                parentNameTb.Text != "" &&
                phoneNumberTb.Text != "" &&
                currentClassTb.Text != "")
            {
                if (!InputTester.IsAName(studentNameTb.Text))
                {
                    iNotifierBox.Text = "Tên học sinh không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                if (!InputTester.IsADate(dobTb.Text))
                {
                    iNotifierBox.Text = "Ngày không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                if (!InputTester.IsAName(countryTb.Text))
                {
                    iNotifierBox.Text = "Tên quê không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                if (!InputTester.IsAName(parentNameTb.Text))
                {
                    iNotifierBox.Text = "Tên phụ huynh không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                if (!InputTester.IsANumber(phoneNumberTb.Text, 10))
                {
                    iNotifierBox.Text = "Số điện thoại không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                if (!InputTester.IsAClassName(currentClassTb.Text))
                {
                    iNotifierBox.Text = "Tên lớp không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                Student student = new Student()
                {
                    Hoten       = studentNameTb.Text,
                    GioiTinh    = sexTb.Text,
                    NgaySinh    = dobTb.Text,
                    NoiSinh     = countryTb.Text,
                    TenNgGianHo = parentNameTb.Text,
                    SDT         = phoneNumberTb.Text,
                    MaLop       = currentClassTb.Text
                };

                ResultYN resultYN = await Controllers.Controller.Instance.InsertNewStudent(student);

                if (resultYN.Result)
                {
                    this.Hide();
                    isCorrected         = true;
                    studentNameTb.Text  = "";
                    sexTb.Text          = "";
                    dobTb.Text          = "";
                    countryTb.Text      = "";
                    parentNameTb.Text   = "";
                    phoneNumberTb.Text  = "";
                    currentClassTb.Text = "";
                    iNotifierBox.Text   = "Thêm thành công !";
                    iNotifierBox.ShowDialog();
                }
                else
                {
                    iNotifierBox.Text = "Lỗi";
                    iNotifierBox.ShowDialog();
                }
            }
            else
            {
                iNotifierBox.Text = "Vui lòng điền đầy đủ thông tin";
                iNotifierBox.ShowDialog();
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (classNameTb.Text != "" &&
                gradeTb.Text != "" &&
                teacherNameTb.Text != "" &&
                countTb.Text != "" &&
                yearTb.Text != "")
            {
                if (!InputTester.IsAClassName(classNameTb.Text))
                {
                    iNotifierBox.Text = "Tên lớp không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                if (!InputTester.IsAName(teacherNameTb.Text))
                {
                    iNotifierBox.Text = "Tên giáo viên không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                if (!InputTester.IsANumber(countTb.Text, 2))
                {
                    iNotifierBox.Text = "Sĩ số không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                if (!InputTester.IsANumber(yearTb.Text, 4))
                {
                    iNotifierBox.Text = "Năm không hợp lệ";
                    iNotifierBox.ShowDialog();
                    return;
                }

                ClassInfo classInfo = new ClassInfo()
                {
                    tenLop   = classNameTb.Text,
                    khoi     = gradeTb.Text,
                    tenGVCN  = teacherNameTb.Text,
                    siSo     = Convert.ToInt32(countTb.Text),
                    nienKhoa = yearTb.Text
                };

                ResultYN resultYN = await Controllers.Controller.Instance.DeleteClass(classInfo.maLop);

                if (resultYN.Result)
                {
                    this.Hide();
                    isCorrected        = true;
                    classNameTb.Text   = "";
                    gradeTb.Text       = "";
                    teacherNameTb.Text = "";
                    countTb.Text       = "";
                    yearTb.Text        = "";
                    iNotifierBox.Text  = "Xoá thành công !";
                    iNotifierBox.ShowDialog();
                }
            }
            else
            {
                iNotifierBox.Text = "Vui lòng điền đầy đủ thông tin";
                iNotifierBox.ShowDialog();
            }
        }