コード例 #1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            int    id       = Convert.ToInt32(userNameTextBox.Text);
            string password = passwordTextBox.Text;

            if (customerRadioButton.Checked)
            {
                //查询客户表是否有用户名存在
                Customer customer = SqlManage.searchCustomer(id, password);
                if (customer != null)
                {
                    CustomerForm customerForm = new CustomerForm(customer);
                    customerForm.Visible = true;
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!");
                }
            }
            else if (salesmanRadioButton.Checked)
            {
                //查询销售员表
                Salesman salesman = SqlManage.searchSalesman(id, password);
                if (salesman != null)
                {
                    SalesmanForm salesmanForm = new SalesmanForm(salesman);
                    salesmanForm.Visible = true;
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!");
                }
            }
            else
            {
                MessageBox.Show("你未选择身份!");
            }
        }