Newer
Older
GHFX_REFACTOR / FrmChangePassword.cs
wxn on 9 Nov 2016 1 KB 冗余代码整理
using System;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace Cyberpipe
{
    public partial class FrmChangePassword : Office2007Form
    {
        public static bool IS_OPEN;

        public FrmChangePassword()
        {
            InitializeComponent();
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(txt_pwd_new.Text.Trim()))
                {
                    MessageBox.Show("新密码不能为空!");
                    return;
                }
                if (!txt_pwd_new.Text.Trim().Equals(txt_pwd_cfm.Text.Trim()))
                {
                    MessageBox.Show("请确认要修改的密码!");
                    return;
                }
                string sql = "select count(*) from casic_userinfotest where SYSNAME='GHFX' and USERNAME='" + Utility.userName + "' and PASSWORD='" + Utility.MD5Encrypt2(txt_pwd_old.Text.Trim()) + "'";
                int count = int.Parse(OracleUtils.ExecuteScalar(OracleUtils.ConnectionString, CommandType.Text, sql).ToString());
                if (count <= 0)
                {
                    MessageBox.Show("密码错误!");
                    return;
                }
                sql = "update casic_userinfotest set password='" + Utility.MD5Encrypt2(txt_pwd_new.Text.Trim()) + "' where sysname='GHFX' and username='" + Utility.userName + "'";
                OracleUtils.ExecuteNonQuery(OracleUtils.ConnectionString, CommandType.Text, sql);
                MessageBox.Show("修改成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("修改失败:" + ex);
            }

        }

        private void FrmChangePassword_Load(object sender, EventArgs e)
        {
            IS_OPEN = true;
        }

        private void FrmChangePassword_FormClosing(object sender, FormClosingEventArgs e)
        {
            IS_OPEN = false;
        }
    }
}