Esempio n. 1
0
 private void button8_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows[0].Cells["学号"].Value == null)
     {
         MessageBox.Show("请选择用户!");
     }
     else
     {
         string Unum = dataGridView1.SelectedRows[0].Cells["学号"].Value.ToString();
         mem    f    = new mem();
         f.str0 = Unum;
         f.ShowDialog();
         用户管理ToolStripMenuItem_Click(null, null);
     }
 }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            string userid = textBox1.Text.Trim();
            string userpw = textBox2.Text.Trim();

            if (radioButton2.Checked == true)
            {
                try
                {
                    Sql1           sqlHelper = new Sql1();
                    SqlConnection  con       = sqlHelper.GetConnection();
                    SqlCommand     com       = new SqlCommand("select Aid,Apwd from Administrators where Aid='" + userid + "' and Apwd='" + userpw + "'", con);
                    SqlDataAdapter da        = new SqlDataAdapter(com);
                    DataSet        ds        = new DataSet();
                    int            n         = da.Fill(ds, "register");


                    if (n != 0)
                    {
                        memad f = new memad();
                        f.str0 = userid;
                        f.ShowDialog();
                        textBox1.Text = null;
                        textBox2.Text = null;
                    }
                    else
                    {
                        MessageBox.Show("请输入正确的账号和密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        textBox2.Text = null;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    Sql1           sqlHelper = new Sql1();
                    SqlConnection  con       = sqlHelper.GetConnection();
                    SqlCommand     com       = new SqlCommand("select Sid,Spwd from Students where Sid='" + userid + "' and Spwd='" + userpw + "'", con);
                    SqlDataAdapter da        = new SqlDataAdapter(com);
                    DataSet        ds        = new DataSet();
                    int            n         = da.Fill(ds, "register");


                    if (n != 0)
                    {
                        mem f = new mem();
                        f.str0 = userid;
                        f.ShowDialog();
                        textBox1.Text = null;
                        textBox2.Text = null;
                    }
                    else
                    {
                        MessageBox.Show("请输入正确的账号和密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        textBox2.Text = null;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }