⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 用Csharp编写的一个图书馆里系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string username = this.USER.Text;
            string password = this.PASS.Text;
            SqlConnection conn = new SqlConnection(@"Data Source=.;Initial Catalog=tushu;
                                                 Integrated Security=True");
            string sql = "select * from usertable where userna=@uname and password=@pwd";
            try
            {
                conn.Open();
                SqlCommand cmmd = new SqlCommand(sql, conn);
                SqlParameter pUname = new SqlParameter("@uname", SqlDbType.NVarChar);
                SqlParameter pPwd = new SqlParameter("@pwd", SqlDbType.NVarChar);
                pUname.Value = username;
                pPwd.Value = password;
                cmmd.Parameters.Add(pUname);
                cmmd.Parameters.Add(pPwd);
                object o = cmmd.ExecuteScalar();
                if (o == null)
                {
                    MessageBox.Show("帐号或密码错误");
                }
                else
                {
                    if (username == "sunyi")
                    {
                        guanli f1 = new guanli();
                        f1.ShowDialog();
                    }
                    else if (username == "zhangsan")
                    {
                        guanli f1 = new guanli();
                        f1.ShowDialog();
                    }
                    else if (username == "qianwu")
                    {
                        guanli f1 = new guanli();
                        f1.ShowDialog();
                    }
                    else
                    {
                        putong f3 = new putong();
                        f3.ShowDialog();
 
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
            finally
            {
                conn.Close();
            }
            
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -