文件名称:C#编写的图书管理系统源代码
文件大小:7.26MB
文件格式:RAR
更新时间:2014-09-26 05:18:49
管理
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace 图书管理系统 { public partial class 登录窗口 : Form { //public static string ConnectionString = "Server=(local);database=图书管理库;uid=sa;pwd=1234"; //sql server 混合模式 // public static string ConnectionString = "Server=(local);Integrated Security=SSPI;database=图书管理库"; //windows模式 public string strSQL; public SqlConnection myConnection; public SqlCommandBuilder sqlCmdBld; public DataSet ds = new DataSet(); public SqlDataAdapter da; public int num=0; private DataTable myTable; private DataRow myRow; public static string strUser; public static string strPassword; // public static string strDepartment; public static bool login_flag = false; public 登录窗口() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { Close(); } private void 登录窗口_Load(object sender, EventArgs e) { linkdatabase link = new linkdatabase(); //实例化 myConnection = new SqlConnection(link.connectionstring()); //实例化连接 strSQL = "select * from 用户表 "; da = new SqlDataAdapter(strSQL, myConnection); ds.Clear(); da.Fill(ds, "用户表"); //////动作 myTable = ds.Tables["用户表"]; for (int i = 0; i < myTable.Rows.Count; i++) { comboBox1.Items.Add(myTable.Rows[i]["用户名"].ToString().Trim()); } } private void button1_Click(object sender, EventArgs e) { linkdatabase link = new linkdatabase(); //实例化 myConnection = new SqlConnection(link.connectionstring()); //实例化连接 strSQL = "select * from 用户表 where 用户名='"+ comboBox1.Text.Trim()+"'"; da = new SqlDataAdapter(strSQL, myConnection); ds.Clear(); da.Fill(ds, "用户表"); myTable = ds.Tables["用户表"]; crypt cry = new crypt(); if (cry.SetEncrypt(textBox1.Text.Trim()) == myTable.Rows[0]["密码"].ToString().Trim()) { // MessageBox.Show("合法用户!welcome!"); strUser = comboBox1.Text.Trim(); strPassword = textBox1.Text.Trim(); 系统菜单 frm = new 系统菜单(); frm.ShowDialog(); } else { MessageBox.Show("非法法用户!logout!"); num++; } if (num >= 3) { MessageBox.Show("登录次数超限,退出系统!OUT!"); // Close(); Application.Exit(); } } private void 登录窗口_DoubleClick(object sender, EventArgs e) { MessageBox.Show("你双击了窗体!"); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //MessageBox.Show(comboBox1.Text ); } } }