Ejemplo n.º 1
0
        private void btn_Register_Click(object sender, EventArgs e)
        {
            if (ValidateEmpty())
            {
                int code = SqlRequestFunction.CreateAccount(txt_LoginName.Text
                                                            , cmb_Employees.SelectedValue.ToString()
                                                            , txt_Password.Text
                                                            , cmb_Role.SelectedValue.ToString());

                if (code == 1)
                {
                    MessageBox.Show("Đăng nhập thành công.", "", MessageBoxButtons.OK);
                }


                switch (code)
                {
                case 15014:     //Role does not exists
                    ErrorHandler.ShowError(lbl_Err_Summary, new string[] { "Ox6001" });
                    break;

                case 15025:     //login name exists
                    ErrorHandler.ShowError(lbl_Err_LoginName, new string[] { "Ox6002" });
                    break;

                case 15023:     //user name exists
                    ErrorHandler.ShowError(lbl_Err_Employee, new string[] { "Ox6003" });
                    break;

                case 1:
                    MessageBox.Show(
                        "Đã tạo tài khoản thành công cho giáo viên: "
                        + cmb_Employees.Text
                        + "Với tài khảo đăng nhập: "
                        + txt_LoginName.Text
                        , "Success"
                        , MessageBoxButtons.OK
                        , MessageBoxIcon.Information);
                    break;
                }
            }
        }