Beispiel #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (IsValidate())
     {
         AdminsModel newAdmin = new AdminsModel()
         {
             Name     = txtAdminName.Text,
             Password = txtAdminPassWord.Text
         };
         List <AdminsModel> admins = PrepAndPaintDB.GetAdmins();
         foreach (var name in admins)
         {
             if (name.Name == newAdmin.Name)
             {
                 MessageBox.Show($"Name: {newAdmin.Name} already exist", "Exist Already!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtAdminName.Focus();
                 return;
             }
         }
         PrepAndPaintDB.AddAdmin(newAdmin);
         txtAdminName.Clear();
         txtAdminPassWord.Clear();
         PopulateDataGrid();
     }
 }
Beispiel #2
0
        private void PassWord_Load(object sender, EventArgs e)
        {
            List <AdminsModel> adminList = PrepAndPaintDB.GetAdmins();

            if (adminList.Count == 0)
            {
                MessageBox.Show("Currently there are no admins. Please create an admin account to protect your data", "No Admins!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                AdminPage adminPage = new AdminPage();
                adminPage.ShowDialog();
            }
        }
Beispiel #3
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            List <AdminsModel> adminList = PrepAndPaintDB.GetAdmins();

            if (adminList.Count == 0)
            {
                MessageBox.Show("Currently there are no admins. Please create an admin account to protect your data", "No Admins!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                Close();
            }
        }
Beispiel #4
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            string             login     = txtLogin.Text;
            string             password  = txtPassWord.Text;
            List <AdminsModel> adminList = PrepAndPaintDB.GetAdmins();

            foreach (var name in adminList)
            {
                if (login == name.Name && password == name.Password)
                {
                    adminLogin        = true;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Sorry login or password wrong! Please try again", "Incorrect PassWord!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPassWord.Clear();
                    txtPassWord.Focus();
                    return;
                }
            }
        }
Beispiel #5
0
 private void PopulateDataGrid()
 {
     adminDataGridView.DataSource          = PrepAndPaintDB.GetAdmins();
     adminDataGridView.Columns[0].Visible  = false;
     adminDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
 }