コード例 #1
0
ファイル: AuthWin.cs プロジェクト: YuryYarmoshuk/WichesBowler
        private void button1_Click(object sender, EventArgs e)
        {
            string login    = textBox1.Text;
            string password = textBox2.Text;

            correctInput = new CorrectInputCheck();

            bd = new BD();

            if (correctInput.CheckLogPas(login, password))
            {
                if (correctInput.CorrectInputLogin(login))
                {
                    if (bd.AuthCheck(login, password))
                    {
                        switch (bd.AccessCheck(login))
                        {
                        case "Admin":
                        {
                            adm = new AdmWin(this);
                            adm.Show();
                            clearFields();
                            Hide();
                            break;
                        }

                        case "Consultant":
                        {
                            consult = new ConsultForm(this);
                            consult.Show();
                            clearFields();
                            Hide();
                            break;
                        }

                        case "Guest":
                        {
                            guest = new GuestForm(this, login, password);
                            guest.Show();
                            clearFields();
                            Hide();
                            break;
                        }

                        default:
                            errorList.ErrorMessage("Unknow access!!!");
                            break;
                        }
                    }
                    else
                    {
                        errorList.ErrorMessage(13);
                    }
                }
            }
        }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            int    ind = listBox1.SelectedIndex;
            int    id;
            string title;

            if (inputCheck.SelectedItemCheck(ind))
            {
                id    = subString.IndReturn(listBox1.Text, "Title");
                title = subString.TitleReturn(listBox1.Text, "Title", "Category");

                if (button2.Text == "Delete")
                {
                    if (inputCheck.AccessMessage(String.Format("Do you really want to delete the record? ({0} {1})", id, title)))
                    {
                        string req = String.Format("DELETE FROM Products WHERE Id = {0}", id);

                        bd.WorkWithBD(req);

                        bd.ViewAll(listBox1, true);
                    }
                }
                else
                {
                    EditForm editForm = new EditForm(id, bd.WorkWithBD(id), listBox1);

                    editForm.Show();
                }
            }
            else
            {
                errorList.ErrorMessage(10);
            }
        }
コード例 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            int    ind = listBox1.SelectedIndex;
            int    id;
            string login;

            if (inputCheck.SelectedItemCheck(ind))
            {
                id    = subString.IndReturn(listBox1.Text, "Login");
                login = subString.TitleReturn(listBox1.Text, "Login", "Password");

                login.Replace(" ", "");
                if (inputCheck.AccessMessage(String.Format("Do you really want to delete the record? ({0} {1})", id, login)))
                {
                    string req = String.Format("DELETE FROM Accounts WHERE Id = {0}", id);

                    bd.WorkWithBD(req);

                    bd.ViewAllAcc(listBox1);
                }
            }
            else
            {
                errorList.ErrorMessage(10);
            }
        }
コード例 #4
0
        public bool BucketIsEmpty(int id)
        {
            BD        bd        = new BD();
            ErrorList errorList = new ErrorList();
            bool      ans       = true;

            if (!bd.EmptyBucketCheck(id))
            {
                ans = false;
                errorList.ErrorMessage(12);
            }

            return(ans);
        }
コード例 #5
0
        public bool CheckLogPas(string log, string pass)
        {
            if (log == "" || pass == "")
            {
                errorList.ErrorMessage(1);
                return(false);
            }
            else if (log.Length < 3 || log.Length > 20)
            {
                errorList.ErrorMessage(2);
                return(false);
            }
            else if (pass.Length < 3 || pass.Length > 20)
            {
                errorList.ErrorMessage(3);
                return(false);
            }

            return(true);
        }