当前位置:首页 > C#酒店管理系统课程设计设计论文
string deluser = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
DialogResult dr1 = MessageBox.Show(\是否删除此用户!\ + deluser, \警告\, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
if (dr1 == DialogResult.Yes) {
String delstr = \from userinfo where userid='\ + deluser + \;
cmd = new OleDbCommand(); cmd.CommandText = delstr;
cmd.Connection = accesshelp.conn; accesshelp.conn.Open();
int count = cmd.ExecuteNonQuery(); if (count > 0) {
MessageBox.Show(\删除成功!\); ds.Clear(); string constr = %userid,username,usertype from userinfo \; adp = new OleDbDataAdapter(constr, accesshelp.conn);
adp.Fill(ds, \); dataGridView1.DataSource = ds.Tables[\].DefaultView; } } }
catch (Exception ex) {
MessageBox.Show(\请选中一条记录!\); }
finally { accesshelp.conn.Close (); }
}
17
4下面就是修改密码按钮实现功能所使用的代码
1、点击修改密码按钮之后就会弹出一个修改密码模块。
2、
首先输入用户名必须是存在的,不存在则会弹出信息框“用户名不正确”。以及原始密码必须正确,不正确则会弹出信息框“密码不正确”,新密码和确认密码必须一致,不一致则会弹出信息框“输入新密码不一致,请重新输入” textbox的内容必须填满和正确!否则会弹出信息框“请正确输入”,如果是正确填写则会弹出信息框“密码修改成功”那么修改成功!
3、下面就是修改密码实现功能所使用的代码
private void button1_Click(object sender, EventArgs e) {
if (textBox1.Text == \ || textBox2.Text == \ || textBox3.Text == \ || textBox4.Text == \) {
MessageBox.Show(\请输入正确信息!\); } else
18
{
string str = %userpsw from userinfo where userid='\+textBox1 .Text +\;
cmd = new OleDbCommand(); cmd.CommandText = str;
cmd.Connection = accesshelp.conn; accesshelp.conn.Open(); dr = cmd.ExecuteReader(); if (dr.HasRows == false) {
MessageBox.Show(\用户ID不正确,请重新输入!\); textBox1.Text = \; textBox1.Focus();
// accesshelp.conn.Close();
} else {
dr.Read ();
if (!textBox2.Text.Equals(dr.GetString(0))) {
MessageBox.Show(\输入的密码不正确,请重新输入!\);
textBox2.Text = \; textBox2.Focus(); }
else if (textBox3.Text != textBox4.Text) {
MessageBox.Show(\两次输入的密码不一致,请重新输入!\);
textBox3.Text = \; textBox4.Text = \; textBox3.Focus(); } else {
accesshelp.conn.Close(); try {
if (MessageBox.Show(\确定要修改吗?\, \警告\, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation)==DialogResult .Yes )
19
{
string modistr = %userpsw='\ + textBox3.Text + \ + textBox1.Text + \; cmd = new OleDbCommand(); cmd.CommandText = modistr;
cmd.Connection = accesshelp.conn; accesshelp.conn.Open(); cmd.ExecuteNonQuery();
MessageBox.Show(\密码修改成功!\); this.Close(); } }
catch (Exception ex) {
MessageBox.Show(ex.Message); }
finally { accesshelp.conn.Close(); } } }
accesshelp.conn.Close(); }
}
(2)单击客房收入统计弹出如下界面
20
共分享92篇相关文档