Пример #1
0
        private void btn1_Click(object sender, EventArgs e)
        {
            string username = txt_1.Text;
            string password = Encryption.ComputeSha256Hash(txt_2.Text);
            bool   remember = false;
            bool   usertype = false;

            for (int i = 0; i < userlist.Count; i++)
            {
                User user = userlist[i];

                if (user.IsValid(username, password))
                {
                    MessageBox.Show("User is already exist");
                    txt_1.Clear();
                    txt_2.Clear();
                    txt_3.Clear();
                }
                else
                {
                    User user1 = new User(username, password, remember, usertype);
                    userlist.Add(user1);
                    File_Operation.set_csv(userlist, Userpath);
                    log_lbl.Visible   = true;
                    log_lbl.Text      = "Loading Successfull";
                    log_lbl.ForeColor = Color.Green;
                    t_register.Start();
                    return;
                }
            }
        }
Пример #2
0
        private void update_btn_Click(object sender, EventArgs e)
        {
            confirm_lb.Visible = false;
            string username = txt_1.Text;
            string password = User_login.getIntance().User.Password;
            bool   remmber  = false;
            string cb       = usertype_cb.Text;
            bool   usertype = cb == "Admin" ? true : false;

            listView_user.SelectedItems[0].SubItems[0].Text = username;
            listView_user.SelectedItems[0].SubItems[1].Text = cb;

            User user = new User(username, password, remmber, usertype);

            userlist.Add(user);
            File_Operation.set_csv(userlist, Userpath);
            show_userlist();
        }
Пример #3
0
        private void login_Click(object sender, EventArgs e)
        {
            string username   = txt_1.Text;
            string password   = Encryption.ComputeSha256Hash(txt_2.Text);
            bool   rememberMe = checkB_1.Checked;

            for (int i = 0; i < userlist.Count; i++)
            {
                User user = userlist[i];

                if (user.IsValid(username, password))
                {
                    user.RememberMe = rememberMe;
                    User_login.getIntance().User = user;
                    File_Operation.set_csv(userlist, Userpath);

                    lb_1.Visible   = true;
                    lb_1.Text      = "Succesfull";
                    lb_1.ForeColor = Color.Green;


                    if (user.Usertype == true)
                    {
                        progressBar1.Visible = true;
                        t_2.Enabled          = true;
                        return;
                    }
                    else
                    {
                        progressBar1.Visible = true;
                        t_1.Enabled          = true;
                        return;
                    }
                }
                else
                {
                    lb_1.Visible = true;
                }
                lb_1.Text      = "Failed";
                lb_1.ForeColor = Color.Red;
            }
        }
Пример #4
0
        private void add__Click(object sender, EventArgs e)
        {
            confirm_lb.Visible = false;
            listView_user.Items.Clear();

            string username = txt_1.Text;
            string password = Encryption.ComputeSha256Hash(txt_2.Text);
            bool   remember = false;
            string cb       = usertype_cb.Text;
            bool   usertype = cb == "Admin" ? true : false;

            foreach (User user in userlist)
            {
                if (user.IsValid(username, password))
                {
                    confirm_lb.Visible = true;
                    confirm_lb.Text    = "User is already exist";
                    txt_1.Clear();
                    txt_2.Clear();
                    show_userlist();
                    return;
                }
            }
            if (username == "" || password == "")
            {
                confirm_lb.Visible = true;
                confirm_lb.Text    = "unfilled area";
                show_userlist();
                return;
            }
            User user1 = new User(username, password, remember, usertype);

            userlist.Add(user1);
            File_Operation.set_csv(userlist, Userpath);
            txt_1.Clear();
            txt_2.Clear();
            show_userlist();
            confirm_lb.Text    = "Loading Successfull";
            confirm_lb.Visible = true;
            return;
        }