changeuserpasswordform.cs

来自「宾馆酒店管理系统 Visual Studio 2005 + SQL Serve」· CS 代码 · 共 52 行

CS
52
字号
//文件名:ChangeUserPasswordForm.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 MyHotel
{
    public partial class ChangeUserPasswordForm : Form
    {
        public ChangeUserPasswordForm()
        {
            InitializeComponent();
        }

        private void 返回系统Button_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void 修改密码Button_Click(object sender, EventArgs e)
        {
            if (!(this.新密码TextBox.Text == this.再输一次新密码TextBox.Text) || (this.新密码TextBox.Text.Length==0))
            {
                MessageBox.Show("两次密码的输入不一致!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            String MySQLConnectionString = global::MyHotel.Properties.Settings.Default.MyHotelConnectionString;
            string MySQL = "Update  操作用户 Set 用户密码='" + this.新密码TextBox.Text + "' Where 用户名称='"+this.用户名称TextBox.Text+"' AND 用户密码='"+this.旧密码TextBox.Text +"'";            
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
            MyCommand.Connection.Open();
            int MyCount = MyCommand.ExecuteNonQuery();
            if (MyCount == 1)
            {
                MessageBox.Show("在数据库中修改用户密码操作成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("在数据库中修改用户密码操作失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
        }
    }
}

⌨️ 快捷键说明

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