protected void Confirm_OnClick(object sender, EventArgs e)
        {
            //验证码检验
            if (!txtCaptcha.Text.Equals(Session["code"]))
            {
                Response.Write("<script>alert('验证码错误!')</script>");
                return;
            }

            // 用LoginController进行登录检验
            try
            {
                //订阅登录结果分支事件
                LoginController.LoginSuccess += LoginSuccess;
                LoginController.LoginFailure += LoginFailure;
                var login = new LoginController(UserID.Text, UserPassword.Text);
            }
            catch (LoginErrorException et)
            {
                if (et.Message == "密码错误!")
                {
                    Response.Write($"<script>alert('密码错误!这是第{Session["Time"]}次错误!')</script>");
                    Session["Time"] = Int32.Parse(Session["Time"].ToString()) + 1;
                    UserPassword.Focus();
                }
            }
        }
Exemple #2
0
 private void UserName_OnKeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.Enter)
     {
         UserPassword.Focus(FocusState.Keyboard);
         e.Handled = true;
     }
 }
Exemple #3
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            User   user;
            string userName = this.UserName.Text;
            string password = this.UserPassword.Password;

            try
            {
                user = myIBL.GetUser(userName);
                if (password == user.Password)
                {
                    if (user.Type == UserType.Guest)
                    {
                        Window guestMainWindow = new GuestMainWindow(myIBL.GetGuestByUserName(user.UserName));
                        guestMainWindow.Show();
                        this.Close();
                    }
                    else if (user.Type == UserType.Host)
                    {
                        Window hostMainWindow = new HostMainWindow(myIBL.GetHostByUserName(user.UserName));
                        hostMainWindow.Show();
                        this.Close();
                        //}
                    }
                    else if (user.Type == UserType.Admin)
                    {
                        Window adminMainWindow = new AdminMainWindow();
                        adminMainWindow.Show();
                        this.Close();
                    }
                }
                else
                {
                    throw new NotExsitingUserException();
                }
            }
            catch (NotExsitingUserException)
            {
                UserPassword.Focus();
                MessageBox.Show("The Password you entered are incorrect.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (NotExistingKeyException)
            {
                UserName.Focus();
                MessageBox.Show("The UserName you entered doesn't exist", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #4
0
 protected void UserMailID_TextChanged(object sender, EventArgs e)
 {
     if (Page.IsPostBack == true && UserMailID.Text != String.Empty.ToString())
     {
         SqlConnection tempcon = new SqlConnection(constr);
         tempcon.Open();
         SqlCommand    tempcmd = new SqlCommand("Select * From Employee where EmployeeMailID='" + UserMailID.Text + "' AND isactive = '1'", tempcon);
         SqlDataReader tempdr  = tempcmd.ExecuteReader();
         tempdr.Read();
         if (tempdr.HasRows && tempdr["SecondaryPosition"].ToString() != "Approver" && tempdr["Position"].ToString() == "Employee")
         {
             Apprvckeck.Visible = false;
             UserPassword.Focus();
         }
         else if (tempdr.HasRows && tempdr["SecondaryPosition"].ToString() == "Approver" && tempdr["Position"].ToString() == "Employee")
         {
             Apprvckeck.Visible = true;
             UserPassword.Focus();
         }
         else if (tempdr.HasRows && tempdr["SecondaryPosition"].ToString() != "Approver" && tempdr["Position"].ToString() == "Admin")
         {
             Apprvckeck.Visible = false;
             UserPassword.Focus();
         }
         else
         {
             Apprvckeck.Visible = false;
             Response.Write("<script>alert('Invalid Mail ID');</script>");
             UserMailID.Focus();
         }
         //UserPassword.Focus();
     }
     else
     {
         UserMailID.Focus();
     }
 }
Exemple #5
0
 private void UserName_OnUnfocused(object sender, FocusEventArgs e)
 {
     UserPassword.Focus();
 }
Exemple #6
0
        /// <summary>
        /// Save user information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveBT_Click(object sender, RoutedEventArgs e)
        {
            NewUserBT.Focus();

            if (UserNameTX.Text.Length == 0 || UserNameTX.Text.Length < 5)
            {
                MessageBox.Show("El nombre de usuario no puede estar en blanco o ser inferior a 5 caracteres");
                UserNameTX.Focus();
                return;
            }
            else if (UserPassword.Password.Length == 0 || UserPassword.Password.Length < 5)
            {
                MessageBox.Show("la contraseña no puede estar en blanco o ser inferior a 5 caracteres");
                UserPassword.Focus();
                return;
            }

            //Get/Set user parameters
            var Data = new NovaAPI.APIUsers.UsersClass();

            Data.id       = SelectedIndex;
            Data.name     = UserNameTX.Text;
            Data.realname = UserRealTX.Text;

            Data.rolid    = ((NovaAPI.APIRoles.Rols)UserRolCB.SelectedItem).rolid;
            Data.branchid = ((NovaAPI.APIBranch.BranchClass)UserBranchCB.SelectedItem).id;
            Data.status   = UserStatusCB.IsChecked == true ? "1" : "0";

            //Password logic
            if (CheckPassword.Visibility == Visibility.Visible)
            {
                Data.hash = GeneralFunctions.GenerateMD5(UserPassword.Password);
            }

            //rol json data
            string requestData = JsonConvert.SerializeObject(Data);

            bool response;

            //Modify / Create request
            if (Data.id.Length > 0)
            {
                response = await NovaAPI.APIUsers.GetValues("2", DataConfig.LocalAPI, requestData);
            }
            else
            {
                response = await NovaAPI.APIUsers.GetValues("1", DataConfig.LocalAPI, requestData);
            }

            //Request response
            if (response)
            {
                if (Data.id.Length > 0)
                {
                    //On user modified
                    var UserData = NovaAPI.APIUsers.users.Find(x => x.id == Data.id);
                    UserData.name       = Data.name;
                    UserData.realname   = Data.realname;
                    UserData.branchid   = Data.branchid;
                    UserData.branchname = NovaAPI.APIBranch.branch.Find(x => x.id == Data.branchid).name;
                    UserData.rolid      = Data.rolid;
                    UserData.rolname    = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Data.rolid).rolname;
                    UserData.status     = Data.status;

                    UsersGrid.Items.Refresh();
                    FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    ResetForm();
                }
                else
                {
                    //On new user created response
                    var UserData = new NovaAPI.APIUsers.UsersClass();
                    UserData.name       = Data.name;
                    UserData.realname   = Data.realname;
                    UserData.branchid   = Data.branchid;
                    UserData.branchname = NovaAPI.APIBranch.branch.Find(x => x.id == Data.branchid).name;
                    UserData.rolid      = Data.rolid;
                    UserData.rolname    = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Data.rolid).rolname;
                    UserData.status     = Data.status;

                    UserData.id = NovaAPI.APIUsers.LastID;

                    FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    ResetForm();

                    NovaAPI.APIUsers.users.Add(UserData);

                    //Reload rol data
                    LoadData();
                }
            }
            else
            {
                MessageBox.Show($"Error al crear el usuario, INFO: {Environment.NewLine}{NovaAPI.APIUsers.Message}");
            }
        }