예제 #1
0
        private void Login_btn_Click(object sender, EventArgs e)
        {
            if (DBConnect())
            {
                if (UserName_txt.Text[0].ToString() == "U")
                //Customer login
                {
                    DBConnect();
                    strsql = string.Format("select count(*) from VotingUsers where UserId ='{0}' and Password='******' ", UserName_txt.Text, Password_txt.Text);
                    // link customer of datebase
                    command = new SqlCommand(strsql, mycon);


                    try
                    {
                        if (User_button.Checked == true)
                        {
                            Topic topic = new Topic();
                            this.Hide();
                            topic.ShowDialog(this);
                            // to jump form "Service"
                        }
                        else
                        {
                            MessageBox.Show("Login faill!!!!!!");
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Sql statement error!!?");
                    }
                }

                if (UserName_txt.Text[0].ToString() == "S")
                {
                    strsql = string.Format("select count(*) from VotingStaff where StaffId ='{0}' and Password='******'", UserName_txt.Text, Password_txt.Text);
                    // link customer of datebase
                    command = new SqlCommand(strsql, mycon);
                    s       = Staff_button.Text;
                    try
                    {
                        if (Staff_button.Checked == true)
                        {
                            StaffManagement staffManagement = new StaffManagement();
                            this.Hide();
                            staffManagement.ShowDialog(this);
                            // to jump form "Work"
                        }
                        else
                        {
                            MessageBox.Show("Login faill!");
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Sql statement error!");
                    }
                }

                if (UserName_txt.Text[0].ToString() == "C")
                {
                    strsql = string.Format("select count(*) from VotingComptoller where ComptollerId ='{0}' and Password='******'", UserName_txt.Text, Password_txt.Text);
                    // link customer of datebase
                    command = new SqlCommand(strsql, mycon);
                    s       = Staff_button.Text;
                    try
                    {
                        if (Comptoller_button.Checked == true)
                        {
                            DataForm dataForm = new DataForm();
                            this.Hide();
                            dataForm.ShowDialog(this);
                            // to jump form "Work"
                        }
                        else
                        {
                            MessageBox.Show("Login faill!");
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Sql statement error!");
                    }
                }
            }

            else
            {
                MessageBox.Show("User is empty or password is empty");
            }
        }