예제 #1
0
파일: TianShu.cs 프로젝트: Crookec/YLibrary
        private void button2_Click(object sender, EventArgs e)
        {
            YGuanliy yguanliy = new YGuanliy();

            yguanliy.Show();
            yguanliy.uname = uname;
            guanbi         = false;
            this.Close();
        }
예제 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (shibie == 0)
     {
         YUser yuser = new YUser();
         yuser.label2.Text = uname;
         yuser.Show();
         guanbi = false;
         this.Close();
     }
     else
     {
         YGuanliy yguanli = new YGuanliy();
         yguanli.uname = uname;
         yguanli.Show();
         guanbi = false;
         this.Close();
     }
 }
예제 #3
0
파일: DengLu.cs 프로젝트: Crookec/YLibrary
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "")
            {
                try
                {
                    string        constr = "server=YTT-PC\\SQLEXPRESS;database=YLibrary;Integrated Security=SSPI";
                    SqlConnection conn   = new SqlConnection(constr);
                    int           shibie = 0;
                    if (radioButton2.Checked)
                    {
                        shibie = 1;
                    }
                    conn.Open();
                    string         sqlStr = "select Password from YUser where Uid= '" + textBox1.Text + "'and Ushibie='" + shibie + "'";
                    SqlDataAdapter da     = new SqlDataAdapter(sqlStr, conn);
                    DataSet        ds     = new DataSet();
                    da.Fill(ds);
                    DataTable dt = ds.Tables[0];
                    if (dt.Rows.Count == 0)
                    {
                        if (shibie == 0)
                        {
                            MessageBox.Show("该用户未注册!");
                        }
                        else
                        {
                            MessageBox.Show("该管理员未注册!");
                        }
                    }
                    else
                    {
                        string mima = dt.Rows[0]["Password"].ToString();

                        mima = mima.Trim();

                        if (mima.Equals(textBox2.Text.Trim()))
                        {
                            MessageBox.Show("登录成功!");
                            conn.Close();
                            if (shibie == 0)
                            {
                                YUser yuser = new YUser();
                                yuser.Show();
                                yuser.label2.Text = textBox1.Text;
                                guanbi            = false;
                                this.Close();
                            }
                            else
                            {
                                YGuanliy yguanliy = new YGuanliy();
                                yguanliy.Show();
                                yguanliy.uname = textBox1.Text;
                                guanbi         = false;
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show("密码错误!");
                            textBox1.Text = "";
                            textBox2.Text = "";
                        }
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show("连接失败");
                }
            }
            else
            {
                MessageBox.Show("登录失败");
                textBox1.Text = "";
                textBox2.Text = "";
            }
        }