Exemplo n.º 1
0
        // Register Button
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            // Give Focus to Username Textbox to prevent the weird fous border on buttons
            UsernameTextbox.Focus();

            // Check if UsernameTextbox contains something
            if (UsernameTextbox.Text.Length == 0)
            {
                MessageBox.Show("Username Textbox is empty.");
                return;
            }

            // Check if PasswordTextbox contains something
            if (PasswordTextbox.Text.Length == 0)
            {
                MessageBox.Show("Password Textbox is empty.");
                return;
            }

            // Set Username & Password in Globals
            Globals.Username = UsernameTextbox.Text;
            Globals.Password = PasswordTextbox.Text;

            // Start Register Function
            RegisterUser();
        }
Exemplo n.º 2
0
        // Login Button
        private void LoginButton_Click(object sender, EventArgs e)
        {
            // Give Focus to Username Textbox to prevent the weird fous border on buttons
            UsernameTextbox.Focus();

            // Check if UsernameTextbox contains something
            if (UsernameTextbox.Text.Length == 0)
            {
                MessageBox.Show("Username Textbox is empty.");
                return;
            }

            // Check if PasswordTextbox contains something
            if (PasswordTextbox.Text.Length == 0)
            {
                MessageBox.Show("Password Textbox is empty.");
                return;
            }

            // Set Username, Password & Token in Globals
            Globals.Username = UsernameTextbox.Text;
            Globals.Password = PasswordTextbox.Text;
            Globals.Token    = Functions.CreateString(65);

            // Start Check Function
            CheckUser();
        }
Exemplo n.º 3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!this.ValidateChildren())
            {
                if (passwordNotMatch)
                {
                    ClientHelper.ShowErrorMessage("Passwords do not match.");
                }
                else
                {
                    ClientHelper.ShowRequiredMessage("Username, First Name, Password");
                }
            }
            else if (hasDuplicate)
            {
                ClientHelper.ShowDuplicateMessage("Username");
            }
            else
            {
                InventoryUserColumnModel model = new InventoryUserColumnModel()
                {
                    Id         = UserId,
                    Username   = UsernameTextbox.Text.Trim(),
                    Firstname  = FirstnameTextbox.Text.Trim(),
                    Lastname   = LastnameTextbox.Text.Trim(),
                    Password   = TY.SPIMS.Utilities.Helper.EncryptString(PasswordTextbox.Text.Trim()),
                    IsAdmin    = IsAdminCheckbox.Checked,
                    IsApprover = IsApproverCheckbox.Checked,
                    IsVisitor  = IsVisitorCheckbox.Checked,
                    IsDeleted  = false,
                    Theme      = false
                };

                if (UserId == 0)
                {
                    this.inventoryUserController.InsertInventoryUser(model);
                    ClientHelper.ShowSuccessMessage("User successfully added.");
                }
                else
                {
                    this.inventoryUserController.UpdateInventoryUser(model);
                    ClientHelper.ShowSuccessMessage("User details successfully updated.");
                }

                ClearForm();
                UsernameTextbox.Focus();

                if (UserEdit)
                {
                    UserInfo.UserFullName = string.Format("{0} {1}", FirstnameTextbox.Text.Trim(), LastnameTextbox.Text.Trim());
                }

                if (UserUpdated != null)
                {
                    UserUpdated(sender, e);
                }
            }
        }
        private void ResetLoginFormState()
        {
            UsernameTextbox.Focus();
            UsernameTextbox.ResetText();
            PasswordTextbox.ResetText();

            LoginErrorMessage.Visible  = false;
            LoginErrorMessage.Location = new Point(141, 134);
        }
        private void LoginButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(UsernameTextbox.Text) ||
                string.IsNullOrEmpty(PasswordTextbox.Text))
            {
                MessageBox.Show("Tên đăng nhập hoặc mật khẩu bị để trống. Xin hãy kiểm tra lại.");
                return;
            }

            // Kiểm tra trong mục nhân viên
            string pass = FindPassword(0, UsernameTextbox.Text);

            if (string.IsNullOrEmpty(pass))
            {
                // Kiểm tra tiếp trong mục người dùng
                pass = FindPassword(-1, UsernameTextbox.Text);
                if (!string.IsNullOrEmpty(pass))
                {
                    // MessageBox.Show("Success login NguoiDung");
                    this.Hide();

                    mainForm = new Forms.MainFormLibrary(DataUser);
                    mainForm.Show();
                }
                else
                {
                    MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu.");

                    // Trỏ đến username textbox
                    UsernameTextbox.Focus();

                    UsernameTextbox_Click(sender, e);

                    return;
                }
            }
            else if (pass == PasswordTextbox.Text)
            {
                // MessageBox.Show("Success login NhanVien");
                this.Hide();

                mainForm = new Forms.MainFormLibrary(DataUser);
                mainForm.Show();
            }
        }
Exemplo n.º 6
0
 public AddUserWindow()
 {
     InitializeComponent();
     UsernameTextbox.Focus();
 }