private void btlogin_Click(object sender, EventArgs e) { if (uname.Text == "" || upwd.Text == "") { MessageBox.Show("用户名和密码不能为空"); } else { this.Text = "正在验证..."; this.Cursor = System.Windows.Forms.Cursors.WaitCursor; string sqlStr = "select * from admin where adminID='" + uname.Text.Trim() + "'"; DataSet ds = new DataSet(); Cdatabase.conn.ConnectionString = Cdatabase.connStr; Cdatabase.conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sqlStr, Cdatabase.conn); adapter.Fill(ds); Cdatabase.conn.Close(); if (!(ds.Tables[0].Rows.Count == 0)) { string sqlad = "select * from admin where adminID='" + uname.Text.Trim() + "'"; DataSet ad = Cdatabase.GetDataFromDB(sqlad); if (ad != null) { if (ad.Tables[0].Rows[0]["adminPwd"].ToString() == upwd.Text.ToString()) { this.Hide(); mainForm adm = new mainForm(); adm.Show(); } else { MessageBox.Show("密码错误,请重新输入!", "错误"); this.Cursor = System.Windows.Forms.Cursors.Arrow; this.Text = "登录"; //uname.Text = ""; upwd.Text = ""; uname.Focus(); } } else { MessageBox.Show("用户名错误,请重新输入!", "错误"); this.Cursor = System.Windows.Forms.Cursors.Arrow; this.Text = "登录"; uname.Text = ""; upwd.Text = ""; uname.Focus(); } } else { MessageBox.Show("用户名不存在", "错误"); this.Cursor = System.Windows.Forms.Cursors.Arrow; this.Text = "登录"; uname.Text = ""; upwd.Text = ""; uname.Focus(); } } }
public editvlm(string vid) { InitializeComponent(); string sqlsch = "select * from volume where vID='" + vid + "'"; DataSet ds = new DataSet(); ds = Cdatabase.GetDataFromDB(sqlsch); txtvid.Text = vid; txtdivision.Text = ds.Tables[0].Rows[0]["division"].ToString(); txtvwriter.Text = ds.Tables[0].Rows[0]["vwriter"].ToString(); txttopic.Text = ds.Tables[0].Rows[0]["topic"].ToString(); }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { string st = dataGridView1.CurrentRow.Cells[0].Value.ToString(); string str = "select * from volume where cID='" + st + "'"; DataSet ds = new DataSet(); ds = Cdatabase.GetDataFromDB(str); if (ds != null) { dataGridView2.DataSource = ds.Tables[0]; } else { MessageBox.Show("没有符合条件的记录!", "提示"); } }
private void btsch_Click(object sender, EventArgs e) { string sqlStr = ""; if (combosch.SelectedIndex < 4 && txtsch.Text.Trim() == "") { MessageBox.Show("请输入需要查询的“" + combosch.SelectedItem.ToString().Trim() + "”!", "提示"); return; } else if (combosch.SelectedIndex == 0) { sqlStr = "select * from lend where rdID='" + txtsch.Text.Trim() + "'"; } else if (combosch.SelectedIndex == 1) { sqlStr = "select * from lend where cID='" + txtsch.Text.Trim() + "'"; } else if (combosch.SelectedIndex == 2) { sqlStr = "select * from lend where lenddate='" + txtsch.Text.Trim() + "'"; } else if (combosch.SelectedIndex == 3) { sqlStr = "select * from lend where rtndate='" + txtsch.Text.Trim() + "'"; } else if (combosch.SelectedIndex == 4) { sqlStr = "select * from lend where renew='true'"; } else if (combosch.SelectedIndex == 5) { sqlStr = "select * from lend where renew='false'"; } DataSet ds = new DataSet(); ds = Cdatabase.GetDataFromDB(sqlStr); if (ds != null) { dataGridView1.DataSource = ds.Tables[0]; } else { MessageBox.Show("没有符合条件的记录!", "提示"); } }
public editbk(string bookID) { InitializeComponent(); string sqlschcs = "select * from caseBook where caseID='" + bookID + "'"; DataSet ds = new DataSet(); ds = Cdatabase.GetDataFromDB(sqlschcs); txtcaseID.Text = bookID; txtisbn.Text = ds.Tables[0].Rows[0]["isbn"].ToString(); txtcname.Text = ds.Tables[0].Rows[0]["caseName"].ToString(); txtwriter.Text = ds.Tables[0].Rows[0]["writer"].ToString(); txtdpt.Text = ds.Tables[0].Rows[0]["department"].ToString(); txtfloor.Text = ds.Tables[0].Rows[0]["floor"].ToString(); txtpress.Text = ds.Tables[0].Rows[0]["press"].ToString(); txtpub.Text = ds.Tables[0].Rows[0]["pubdate"].ToString(); txtrow.Text = ds.Tables[0].Rows[0]["row"].ToString(); txtshelf.Text = ds.Tables[0].Rows[0]["shelf"].ToString(); txtclass.Text = ds.Tables[0].Rows[0]["classID"].ToString(); }
private void btsch_Click(object sender, EventArgs e) { string sqlStr = ""; if (txtsch.Text.Trim() == "") { MessageBox.Show("请输入需要查询的“" + combosch.SelectedItem.ToString().Trim() + "”!", "提示"); return; } else if (combosch.SelectedIndex == 0) { sqlStr = "select * from caseBook where caseID='" + txtsch.Text.Trim() + "'"; } else if (combosch.SelectedIndex == 1) { sqlStr = "select * from caseBook where caseName like '%" + txtsch.Text.Trim() + "%'"; } else if (combosch.SelectedIndex == 2) { sqlStr = "select * from caseBook where writer like '%" + txtsch.Text.Trim() + "%'"; } else if (combosch.SelectedIndex == 3) { sqlStr = "select * from caseBook where caseID in (select cID from volume where division like '%" + txtsch.Text.Trim() + "%')"; } else if (combosch.SelectedIndex == 4) { sqlStr = "select * from caseBook where caseID in (select cID from volume where vwriter like '%" + txtsch.Text.Trim() + "%')"; } DataSet ds = new DataSet(); ds = Cdatabase.GetDataFromDB(sqlStr); if (ds != null) { dataGridView1.DataSource = ds.Tables[0]; } else { MessageBox.Show("没有符合条件的记录!", "提示"); } }
private void alllend_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“bookmanageDataSet2.caseBook”中。您可以根据需要移动或删除它。 // this.caseBookTableAdapter.Fill(this.bookmanageDataSet2.caseBook); // TODO: 这行代码将数据加载到表“bookmanageDataSet.lend”中。您可以根据需要移动或删除它。 // this.lendTableAdapter.Fill(this.bookmanageDataSet.lend); string sqlStr = ""; sqlStr = "select * from caseBook"; DataSet ds = new DataSet(); ds = Cdatabase.GetDataFromDB(sqlStr); if (ds != null) { dataGridView1.DataSource = ds.Tables[0]; } else { MessageBox.Show("没有符合条件的记录!", "提示"); } }
public editrd(string rid) { InitializeComponent(); string sqlschcs = "select * from reader where rdID='" + rid + "'"; DataSet ds = new DataSet(); ds = Cdatabase.GetDataFromDB(sqlschcs); txtrdid.Text = rid; txtrdName.Text = ds.Tables[0].Rows[0]["rdname"].ToString(); txtrddpt.Text = ds.Tables[0].Rows[0]["rddpt"].ToString(); string[] rdbirth = ds.Tables[0].Rows[0]["rdbirth"].ToString().Split(' '); string[] birth = rdbirth[0].Split('/'); txtYear.Text = birth[0]; txtMonth.Text = birth[1]; txtDay.Text = birth[2]; if (ds.Tables[0].Rows[0]["rdsex"].ToString() == "男") { comboBox1.SelectedIndex = 0; } else { comboBox1.SelectedIndex = 1; } }
public void RefreshForm() { dataGridView1.DataSource = Cdatabase.GetDataFromDB("select * from caseBook").Tables[0]; dataGridView2.DataSource = Cdatabase.GetDataFromDB("select * from volume").Tables[0]; }
public void RefreshForm() { dataGridView1.DataSource = Cdatabase.GetDataFromDB("select * from reader").Tables[0]; }