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.OleDb;
namespace login
{
public partial class deleteuser : Form
{
private Int32 current =10001;
string str = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=qyjc.mdb";
public deleteuser()
{
InitializeComponent();
current =10001;
ShowCurrentUser();
}
private void ShowCurrentUser()
{
string command = String.Format("select * from 监察员信息 where zfzh='{0}'",current);
using (OleDbConnection con = new OleDbConnection(str))
{
con.Open();
OleDbCommand cmd = new OleDbCommand(command, con);
OleDbDataReader r = cmd.ExecuteReader();//显示问题:标准表达式中数据类型不匹配
if (r.Read())
{
textBox1.Text = r.GetString(0);
textBox2.Text = r.GetString(1).ToString();
textBox3.Text = r.GetString(2);
textBox4.Text = r.GetString(3);
string xgqx = r.GetString(4);
if (xgqx == "管理员")
checkBox1.Checked = true;
else checkBox2.Checked = true;
}
else
{
MessageBox.Show("前面或后面已无数据", "没有数据", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
r.Close();
con.Close();
}
}
private void deleteuser_Load(object sender, EventArgs e)
{
//current = 10001;
//ShowCurrentUser();
}
private void button1_Click(object sender, EventArgs e)
{
current--;
ShowCurrentUser();
}
private void button2_Click(object sender, EventArgs e)
{
current++;
ShowCurrentUser();
}
private void button3_Click(object sender, EventArgs e)
{
string ad_xm = textBox1.Text;
string ad_zfzh = textBox2.Text;
string ad_zh = textBox3.Text;
string ad_pwd = textBox4.Text;
string ad_qx = "";
if (checkBox1.Checked) ad_qx += checkBox1.Text;
if (checkBox2.Checked) ad_qx += checkBox2.Text;
string command = String.Format("update 监察员信息 set xm='{0}',zh='{1}',pwd='{2}',type='{3}' where zfzh='{4}'", ad_xm, ad_zh, ad_pwd, ad_qx,current );
string str = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=qyjc.mdb";
using (OleDbConnection con = new OleDbConnection(str))
{
con.Open();
OleDbCommand cmd = new OleDbCommand(command, con);
int n = cmd.ExecuteNonQuery();
if (n <= 0)
{
MessageBox.Show("用户信息更新操作失败!", "操作数据库出错", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
con.Close();
}
}
}
}