using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DBFactory;
namespace ControlSystem
{
    /// <summary>
    /// Creator:Richard.liu
    /// 审核用户密码
    /// </summary>
    public partial class FrmConfirmPassword : Form
    {
        private static FrmConfirmPassword _formInstance;
        public static FrmConfirmPassword FormInstance
        {
            get
            {
                if (_formInstance == null)
                {
                    _formInstance = new FrmConfirmPassword();
                }
                return _formInstance;
            }
            set { _formInstance = value; }
        }
        DBOperator dbo =CStaticClass.dbo;
        public FrmConfirmPassword()
        {
            InitializeComponent();
            _formInstance=this;
        }

       

        private void FrmPassword_Load(object sender, EventArgs e)
        {
            DataView dv = dbo.ExceSQL("select * from t_base_users where f_userid ='"+CStaticClass.UserID+"'").Tables[0].DefaultView;
            if (dv.Count > 0)
            {
                this.lblUserID.Text = dv[0]["f_userid"].ToString();
                this.lblUserName.Text = dv[0]["f_username"].ToString();

            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("您确认要保存您的登录密码吗？", "操作提示：", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
            {
                return;
            }
            
            if (this.tbPassword2.Text.Trim() == "")
            {
                MessageBox.Show("确认密码不允许是空值！", "误操作提示：", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.tbPassword2.Focus();
                return;
            }

            DataView dv = dbo.ExceSQL("select * from t_base_users where f_userid ='" + CStaticClass.UserID + "' and f_password ='" + this.tbPassword2.Text.Trim() + "'").Tables[0].DefaultView;
            if (dv.Count > 0)
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("确认密码不正确！", "误操作提示：", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.tbPassword2.Focus();
                return;
            }
            //CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "UserID：" + CStaticClass.UserID + "的操作日志", "点击【确认】按钮", "修改当前用户密码", "");
        }

       
    }
}