コード例 #1
0
ファイル: LoginForm.cs プロジェクト: KIBICHAN/LibraryManager
        private void btnLogin_Click(object sender, EventArgs e)
        {
            String   username = txtUsername.Text;
            String   password = txtPassword.Text;
            Employee emp      = dao.checkLogin(username, password);

            if (emp != null)
            {
                if (emp.Role.Equals("Admin"))
                {
                    FormEmployeeManagement frm = new FormEmployeeManagement(emp);

                    this.Visible = false;
                    frm.ShowDialog();
                    this.Visible = true;
                }
                else
                {
                    LibraryForm frm = new LibraryForm(emp);
                    this.Visible = false;
                    frm.ShowDialog();
                    this.Visible = true;
                }
            }
            else
            {
                MessageBox.Show("Your Username or Password is not correct!!");
            }
        }
コード例 #2
0
        private void btnUpdateProfile_Click(object sender, EventArgs e)
        {
            if (txtEmployeeName.Text.Length == 0 || txtDateOfBirth.Text.Length == 0 || txtPhone.Text.Length == 0)
            {
                MessageBox.Show("All input must not blank!!");
                return;
            }
            DateTime dt;
            bool     check = DateTime.TryParseExact(txtDateOfBirth.Text, "yyyy/MM/dd", null,
                                                    System.Globalization.DateTimeStyles.AllowLeadingWhite,
                                                    out dt);

            if (!check)
            {
                MessageBox.Show("Pls input follow format year/Month/day");
                return;
            }
            try
            {
                int test = int.Parse(txtPhone.Text);
            }catch (Exception ex)
            {
                MessageBox.Show("The phone must be a number");
                return;
            }
            string name  = txtEmployeeName.Text;
            string phone = txtPhone.Text;

            string      DOB = txtDateOfBirth.Text;
            EmployeeDAO dao = new EmployeeDAO();

            dao.updateEmployee(employee.EmployeeID, name, DOB, phone);
            MessageBox.Show("Edit Success!!");
            employee.EmployeeName = name;
            employee.Phone        = phone;
            employee.DateOfBirth  = DateTime.Parse(DOB);
            LibraryForm frm = new LibraryForm(employee);

            this.Visible = false;
            frm.ShowDialog();
        }