Exemplo n.º 1
0
        public ActionResult DoiPass(FormCollection f)
        {
            if (Session["TaiKhoan"].ToString() == "admin")
            {
                PHANQUYEN pq = db.PHANQUYENs.First(m => m.TaiKhoan == Session["TaiKhoan"].ToString());
                if (pq.PassWord == EncryptMD5.MD5Hash(f["passold"]))
                {
                    if (f["passnew"] == f["xnpass"])
                    {
                        pq.PassWord = EncryptMD5.MD5Hash(f["passnew"]);
                        UpdateModel(pq);
                        db.SubmitChanges();
                    }
                    else
                    {
                        ViewData["Loi1"] = "Mật Khẩu không khớp vui lòng nhập lại!!!";
                        return(View());
                    }
                }
                else
                {
                    ViewData["Loi2"] = "Mật Khẩu Hiện Tại Không Đúng!!!!!";
                    return(View());
                }
                return(RedirectToAction("Index", "Admin"));
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        //[MultipleButton(Name = "action", Argument = "Edit")]

        public ActionResult Edit([Bind(Include = "username,password,question,answer,roldId,firstName,lasName,gender,country,mobile,address")] Account account)
        {
            //ProjectWebGreeting.Common.EncryptMD5.Decrypt(account.password);
            if (ModelState.IsValid)
            {
                AccountViewModels avm = new AccountViewModels()
                {
                    accountView = new Account()
                    {
                        username  = account.username,
                        password  = EncryptMD5.Encrypt(account.password),
                        question  = account.question,
                        answer    = account.answer,
                        roldId    = account.roldId,
                        firstName = account.firstName,
                        lastName  = account.lastName,
                        gender    = account.gender,
                        country   = account.country,
                        mobile    = account.mobile,
                        address   = account.address
                    }
                };
                db.Entry(avm.accountView).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.roldId = new SelectList(db.Roles, "id", "name", account.roldId);
            return(View(account));
        }
Exemplo n.º 3
0
        public ActionResult MyProfile(Account account)
        {
            AccountViewModels avm = new AccountViewModels()
            {
                accountView = new Account()
                {
                    id        = account.id,
                    username  = MySession.Username,
                    password  = EncryptMD5.Encrypt(account.password),
                    question  = account.question,
                    answer    = account.answer,
                    roldId    = account.roldId,
                    firstName = account.firstName,
                    lastName  = account.lastName,
                    gender    = account.gender,
                    country   = account.country,
                    mobile    = account.mobile,
                    address   = account.address
                }
            };

            db.Entry(avm.accountView).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "id,username,password,question,answer,roldId,firstName,lasName,gender,country,mobile,address")] Account account)
        {
            var i = db.Accounts.Count(acc => acc.username.Equals(account.username));

            if (ModelState.IsValid)
            {
                if (i < 1)
                {
                    AccountViewModels avm = new AccountViewModels();
                    avm.accountView           = new Account();
                    avm.accountView.username  = account.username;
                    avm.accountView.password  = EncryptMD5.Encrypt(account.password);
                    avm.accountView.question  = account.question;
                    avm.accountView.answer    = account.answer;
                    avm.accountView.roldId    = account.roldId;
                    avm.accountView.firstName = account.firstName;
                    avm.accountView.lastName  = account.lastName;
                    avm.accountView.gender    = account.gender;
                    avm.accountView.country   = account.country;
                    avm.accountView.mobile    = account.mobile;
                    avm.accountView.address   = account.address;


                    db.Accounts.Add(avm.accountView);
                    db.SaveChanges();
                    return(View("Index"));
                }
                ModelState.AddModelError("", "UserName Has been used");
            }

            ViewBag.roldId = new SelectList(db.Roles, "id", "name", account.roldId);
            return(View(account));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 保存之前进行密码检测
        /// </summary>
        public bool SaveRowBefore(DataRow dr, SqlCommand cmd)
        {
            if (dr.RowState == DataRowState.Added)
            {
                if (string.IsNullOrEmpty(textLoginPwd.Text))          //初始密码与用户ID相同
                {
                    EncryptMD5 en = new EncryptMD5(textLoginId.Text); //实例化EncryptMD5
                    dr["LoginPwd"] = en.str2;                         //加密后的数值
                }
                else
                {
                    EncryptMD5 en = new EncryptMD5(textLoginPwd.Text); //实例化EncryptMD5
                    dr["LoginPwd"] = en.str2;                          //加密后的数值
                }
            }
            else
            {
                if (DataTypeConvert.GetString(dr["LoginPwd", DataRowVersion.Original]) != DataTypeConvert.GetString(dr["LoginPwd", DataRowVersion.Current]))
                {
                    EncryptMD5 en = new EncryptMD5(textLoginPwd.Text); //实例化EncryptMD5
                    dr["LoginPwd"] = en.str2;                          //加密后的数值
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        private void sendnoise_Click(object sender, EventArgs e)
        {
            EncryptMD5 encrypt = new EncryptMD5();
            string     mes     = textBox1.Text;
            string     mes1    = textBox1.Text + randomtext();

            byte[] seck = difhel.DH1(key_pair, pubk);
            string key  = Convert.ToString(seck);

            string en1 = encrypt.MD5Hash(mes);
            string en2 = encrypt.MD5Hash(mes);

            if (en1 == en2)
            {
                string mes2 = "Goi tin da bi thay doi";

                byte[] send2   = aes.Encrypt(Encoding.UTF8.GetString(padding(mes2)), key, 256);
                byte[] packet2 = new byte[72 + send2.Length];
                Array.Copy(pubk, 0, packet2, 0, 72);
                Array.Copy(send2, 0, packet2, 72, send2.Length);

                //Sending the Encoded message
                sck.Send(packet2);
            }

            //Adding to the listbox
            listBox1.Items.Add("Me: " + textBox1.Text);
            keybox.Text = System.Convert.ToBase64String(pubk);
            textBox1.Clear();
        }
Exemplo n.º 7
0
        public ActionResult Login(LoginViewModel model)
        {
            var dao = new UserService();

            if (ModelState.IsValid)
            {
                var    errors            = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
                string encryptedPassword = Constants.SATL + EncryptMD5.MD5Hash(model.login_pass);
                var    rs = dao.login(model.login_id, encryptedPassword);

                if (rs == 1)
                {
                    if (!dao.CheckLock(model.login_id))
                    {
                        ModelState.AddModelError("", Constants.LOCK_MESSAGE);
                    }
                    else
                    {
                        // Reset cnt_login_error and date_login_error
                        dao.ResetCountAndDateError(model.login_id);
                        string now = DateTime.Now.ToString();
                        // Tao cookie
                        string loginkeyCrypt = EncryptMD5.MD5Hash(model.login_id) + encryptedPassword +
                                               EncryptMD5.MD5Hash(DateTime.Now.ToString("yyyy-MM-dd HH':'mm':'ss.mmm"));
                        HttpCookie userLoginCookie = new HttpCookie(Constants.USER_LOGIN_COOKIE);
                        userLoginCookie.Value   = loginkeyCrypt;
                        userLoginCookie.Expires = DateTime.Now.AddDays(dao.getSystemConfigByID(3));
                        Response.Cookies.Add(userLoginCookie);
                        // Tao session
                        Session.Add(Constants.USER_LOGIN_SESSION, model.login_id);
                        // Update loginkey
                        dao.updateLoginKeyToUser(model.login_id, loginkeyCrypt);
                        // Ve myHome
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    if (rs == 2)
                    {
                        ModelState.AddModelError("", Constants.LOGIN_FAILED);
                    }
                    else if (rs == 3)
                    {
                        dao.addCountError(model.login_id);
                        dao.updateDateLoginError(model.login_id, DateTime.Now);
                        if (dao.CheckLock(model.login_id))
                        {
                            ModelState.AddModelError("", Constants.LOGIN_FAILED);
                        }
                        else
                        {
                            ModelState.AddModelError("", Constants.LOCK_MESSAGE);
                        }
                    }
                }
            }
            return(View(model));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUserID.Text == string.Empty)
                {
                    //MessageBox.Show(string.Format("用户ID不能为空。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(string.Format(tsmiYhidbnwk.Text), tsmiYhdl.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtUserID.Focus();
                    return;
                }

                if (txtPassword.Text == string.Empty)
                {
                    //MessageBox.Show(string.Format("密码不能为空。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(string.Format(tsmiMmbnwk.Text), tsmiYhdl.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtPassword.Focus();
                    return;
                }
                EncryptMD5 en = new EncryptMD5(txtPassword.Text);                //实例化EncryptMD5, 加密后值引用en.str2
                if (FrmLoginBLL.CheckUser(txtUserID.Text, en.str2, cboLanguage)) // en.str2为加密后密码
                {
                    new SystemHandler().InitializationSystemInfo(txtPassword.Text);

                    if (SystemInfo.IsCheckServer)//启动服务端检测
                    {
                        SocketHandler socket     = new SocketHandler();
                        string        messageStr = "";
                        if (!socket.ConnectServer(ref messageStr))
                        {
                            MessageHandler.ShowMessageBox(messageStr);
                            return;
                        }
                    }

                    string iniPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase.TrimEnd('\\') + "\\Config.ini";
                    new FileHandler().IniWriteValue(iniPath, "System", "LastLanguage", cboLanguage.SelectedValue.ToString());

                    //Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    // cfa.AppSettings.Settings["last"].Value = "111";
                    //            cfa.Save();

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    txtPassword.Focus();
                }
            }
            catch (Exception ex)
            {
                //ExceptionHandler.HandleException(this.Text + "--用户登录错误。", ex);
                ExceptionHandler.HandleException(this.Text + "--" + tsmiYhdlcw.Text, ex);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Método que valida Login e Senha no sistema
        /// Para realizar o login padrão usasse:
        /// - login: admin
        /// - senha: admin
        /// </summary>
        /// <param name="Usuario">passamos um objeto Usuario</param>
        /// <returns>Verdadeiro quando existir usuário com este login e senha</returns>
        public bool LoginSistema(Usuario usuario)
        {
            var Md5Pass = EncryptMD5.MD5Hash(usuario.Senha);
            var result  = contextDb.Usuarios.FirstOrDefault(x => x.Login == usuario.Login && x.Senha == Md5Pass);

            if (result != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 10
0
        //保存更改
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(loginPwdTextBox.Text))          //初始密码与用户ID相同
            {
                EncryptMD5 en = new EncryptMD5(loginIdTextBox.Text); //实例化EncryptMD5
                loginPwdTextBox.Text = en.str2;                      //加密后的数值
            }
            else
            {
                EncryptMD5 en = new EncryptMD5(loginPwdTextBox.Text); //实例化EncryptMD5
                loginPwdTextBox.Text = en.str2;                       //加密后的数值
            }
            createDateDateTimePicker.Value = DateTime.Now;            //建立日期设定为保存时间
            founderTextBox.Text            = SystemInfo.user.EmpName; //获取当前登录用户姓名

            if (string.IsNullOrEmpty(loginIdTextBox.Text))
            {
                MessageBox.Show("【用户ID】为必填项!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                loginIdTextBox.Focus();
                return;
            }

            if (string.IsNullOrEmpty(empNameTextBox.Text))
            {
                MessageBox.Show("【用户姓名】为必填项!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                empNameTextBox.Focus();
                return;
            }

            if (string.IsNullOrEmpty(comboBox1.Text))
            {
                MessageBox.Show("【部门名称】为必填项!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                comboBox1.Focus();
                return;
            }

            try
            {
                this.Validate();
                this.bS_UserInfoBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.dsPSAP);
                ChangeEnabledState();               //保存后更新控件状态
            }
            catch (System.Data.ConstraintException) //关键字字段值重复
            {
                MessageBox.Show("此用户编码已经存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                loginIdTextBox.Focus();
            }
            bS_UserInfoDataGridView.Enabled = true;//保存后数据表控件可用
        }
Exemplo n.º 11
0
 /// <summary>
 /// 修改密码时,验证用户及密码
 /// </summary>
 /// <param name="strUserID"></param>
 /// <param name="strPassword"></param>
 /// <param name="strPasswordNew"></param>
 /// <param name="strPasswordNewV"></param>
 public static void CheckUserChangePassword(string strUserID, string strPassword, string strPasswordNew)
 {
     if (FrmLoginDAO.CheckUser(strUserID, strPassword, "") != null)
     {
         EncryptMD5 en = new EncryptMD5(strPasswordNew);//实例化EncryptMD5, 加密后值引用en.str2
         FrmLoginDAO.ChangePassword(en.str2, strUserID);
         FrmLogin.ActiveForm.Close();
     }
     else
     {
         //MessageHandler.ShowMessageBox(string.Format("用户ID或原密码错误。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
         MessageHandler.ShowMessageBox("用户ID或原密码错误。");
     }
 }
Exemplo n.º 12
0
        public ActionResult Login(string username, string password)
        {
            string passwordmd5 = EncryptMD5.Encrypt(password);
            var    user        = db.Administrators.SingleOrDefault(x => x.UserName == username && x.PassWord == passwordmd5 && x.Allowed == 1);

            if (user != null)
            {
                Session["userid"]   = user.UserID;
                Session["username"] = user.UserName;
                Session["fullname"] = user.FullName;
                Session["avatar"]   = user.Avatar;
                return(RedirectToAction("Index"));
            }
            ViewBag.Error = "Đăng nhập sai cmmr!";
            return(View());
        }
Exemplo n.º 13
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            EncryptMD5 en = new EncryptMD5(txtPassword.Text);//实例化EncryptMD5, 加密后值引用en.str2

            if (txtUserID.Text == string.Empty)
            {
                //MessageBox.Show(string.Format("用户ID不能为空。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(string.Format(tsmiYhidbnwk.Text), tsmiYhdl.Text, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                txtUserID.Focus();
                return;
            }

            if (txtPassword.Text == string.Empty)
            {
                //MessageBox.Show(string.Format("密码不能为空。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(string.Format(tsmiMm.Text), tsmiYhdl.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPassword.Focus();
                return;
            }

            if (txtPasswordNew.Text == string.Empty)
            {
                //MessageBox.Show(string.Format("新密码不能为空。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(string.Format(tsmiXmm.Text), tsmiYhdl.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPasswordNew.Focus();
                return;
            }

            if (txtPasswordNewV.Text == string.Empty)
            {
                //MessageBox.Show(string.Format("验证密码不能为空。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(string.Format(tsmiYzmm.Text), tsmiYhdl.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPasswordNewV.Focus();
                return;
            }

            if (txtPasswordNew.Text != txtPasswordNewV.Text)
            {
                //MessageBox.Show(string.Format("新密码和验证密码必须一致。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(string.Format(tsmiXmmhyz.Text), tsmiYhdl.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPasswordNew.Focus();
                return;
            }
            FrmLoginBLL.CheckUserChangePassword(txtUserID.Text, en.str2, txtPasswordNew.Text);// en.str2为加密后密码
        }
Exemplo n.º 14
0
        /// <summary>
        /// Método que atualiza os dados de um Usuario do sistema
        /// </summary>
        /// <param name="usuarioUpdate">Dados atualizados</param>
        /// <returns>Verdadeiro (atualizado) ou Falso (não atualizado)</returns>
        public bool UpdateUsuario(Usuario usuarioUpdate)
        {
            var result = contextDb.Usuarios.FirstOrDefault(b => b.Id == usuarioUpdate.Id);

            if (result != null)
            {
                result.Id    = usuarioUpdate.Id;
                result.Login = usuarioUpdate.Login;
                result.Senha = EncryptMD5.MD5Hash(usuarioUpdate.Senha);
                contextDb.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 15
0
        public ActionResult Login(Account account)
        {
            var pas    = EncryptMD5.Encrypt(account.password);
            var result = db.Accounts.Count(a => a.username.Equals(account.username) && a.password.Equals(pas));

            //var result = db.Accounts.Count(a => a.username.Equals(account.username) && a.password.Equals(pas));
            if (result > 0)
            {
                MySession.Username = account.username;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.error = "Account's Invalid";
                return(View("Login", new Account()));
            }
        }
Exemplo n.º 16
0
        public ActionResult DangKy(FormCollection f)
        {
            if (f["cmnd"].Length != 9 && f["cmnd"].Length != 12)
            {
                ViewData["L1"] = "Vui lòng nhập đúng CMND";
                return(View());
            }
            KHACHHANG         k  = new KHACHHANG();
            PHANQUYEN         p  = new PHANQUYEN();
            donghoDataContext db = new donghoDataContext();
            var query            = from kh in db.KHACHHANGs where kh.CMND == f["cmnd"].ToString() select kh;

            if (query.ToList().Count != 0)
            {
                ViewData["L1"] = "Tài Khoản đã tồn tại";
                return(View());
            }
            k.CMND = f["cmnd"];
            if (string.Compare(f["gioitinh"], "nam") == 0)
            {
                k.GioiTinh = false;
            }
            else
            {
                k.GioiTinh = true;
            }

            k.TenKH     = f["hoten"];
            k.Ngaysinh  = DateTime.Parse(f["ngaysinh"]);
            k.Email     = f["email"];
            k.TrangThai = true;
            if (string.Compare(f["pass"], f["xnpass"]) != 0)
            {
                ViewData["L3"] = "Mật khẩu không trùng khớp";
                return(View());
            }
            p.TrangThai = true;
            p.TaiKhoan  = f["cmnd"];
            p.PassWord  = EncryptMD5.MD5Hash(f["pass"]);
            p.MaCN      = 2;
            db.PHANQUYENs.InsertOnSubmit(p);
            db.KHACHHANGs.InsertOnSubmit(k);
            db.SubmitChanges();
            return(RedirectToAction("Login", "Home"));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Método que cadastra usuário no sistema
        /// </summary>
        private static void CadastraUsuario()
        {
            Usuario usuario = new Usuario();

            Console.Write("Informe o Login: "******"Informe a Senha: ");
            usuario.Senha = Console.ReadLine();

            new Usuario()
            {
                Login = usuario.Login,
                Senha = EncryptMD5.MD5Hash(usuario.Senha),
                Ativo = true
            };

            //Console.WriteLine($"Usuário {ListaDeUsuarios[ListaDeUsuarios.Count - 1].Login} adicionado com sucesso. ID: {ListaDeUsuarios[ListaDeUsuarios.Count - 1].Id} ");
            usuariosController.AddUsuario(usuario);
            Console.WriteLine("Usuário cadastrado com sucesso! (Press any key...)");
        }
Exemplo n.º 18
0
        public ActionResult Login(FormCollection f)
        {
            PHANQUYEN pq = DB.PHANQUYENs.SingleOrDefault(a => a.TaiKhoan == f["TaiKhoan"] &&
                                                         a.PassWord == EncryptMD5.MD5Hash(f["pass"]));

            if (pq != null && pq.TaiKhoan == "admin")
            {
                Session["TaiKhoan"] = pq.TaiKhoan;
                return(RedirectToAction("Index", "Admin"));
            }
            else if (pq != null && pq.TaiKhoan != "admin")
            {
                ViewBag.ThongBao    = "Chúc mừng đăng nhập thành công";
                Session["TaiKhoan"] = pq.TaiKhoan;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewData["Loi1"] = "Tên đăng nhập hoặc mật khẩu không đúng";
            }
            return(View());
        }
Exemplo n.º 19
0
        public ActionResult QuenPass(FormCollection f)
        {
            var       query = from kh in DB.KHACHHANGs where kh.CMND == f["CMND"] && kh.Email == f["email"] select kh;
            KHACHHANG k     = query.SingleOrDefault();

            if (k != null)
            {
                // phan email
                StringBuilder Body = new StringBuilder();
                Body.Append("<p>Cảm ơn quý khách đã sử dụng dịch của chúng tôi. Dưới đây là mật khẩu mới của bạn:</p>");
                Body.Append("<p>Mật khẩu mới là: <b>1</b></p>");
                MailMessage mail = new MailMessage();
                mail.To.Add(k.Email);
                mail.From       = new MailAddress("*****@*****.**");
                mail.Subject    = "Thay Đổi Mật Khẩu";
                mail.Body       = Body.ToString();// phần thân của mail ở trên
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "trungsangquan@123");// tài khoản Gmail của bạn
                smtp.EnableSsl             = true;
                smtp.Send(mail);
                PHANQUYEN pq = DB.PHANQUYENs.SingleOrDefault(m => m.TaiKhoan == k.CMND);
                pq.PassWord = EncryptMD5.MD5Hash("1");
                UpdateModel(pq);
                DB.SubmitChanges();
                return(RedirectToAction("Login"));
            }
            else
            {
                ViewData["Loi1"] = "Vui lòng Nhập đúng email đã đăng ký";
                return(View());
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUserID.Text == string.Empty)
                {
                    //MessageHandler.ShowMessageBox(string.Format("用户ID不能为空。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageHandler.ShowMessageBox("用户ID不能为空。");
                    txtUserID.Focus();
                    return;
                }

                if (txtPassword.Text == string.Empty)
                {
                    //MessageHandler.ShowMessageBox(string.Format("密码不能为空。"), "用户登录", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageHandler.ShowMessageBox("密码不能为空。");
                    txtPassword.Focus();
                    return;
                }

                FileHandler fileHandler = new FileHandler();
                string      iniPath     = System.Windows.Forms.Application.StartupPath + "\\Config.ini";

                try
                {
                    //Data Source=192.168.0.3;Initial Catalog=PSAP;Persist Security Info=True;User ID=sa;Password=1qaz2wsx

                    string dataSourceStr = fileHandler.IniReadValue(iniPath, "System", "DataSource");
                    string userIDStr     = fileHandler.IniReadValue(iniPath, "System", "UserID");
                    string passwordStr   = fileHandler.IniReadValue(iniPath, "System", "Password");

                    BaseSQL.connectionString = BaseSQL.GetConnectionString(dataSourceStr, "PSAP", userIDStr, passwordStr);

                    string tempStr      = BaseSQL.connectionString.Replace("Data Source=", "");
                    string ipAddressStr = tempStr.Substring(0, tempStr.IndexOf(";"));

                    if (!new SystemHandler().TestIPAddress(ipAddressStr, 1000))
                    {
                        MessageHandler.ShowMessageBox(string.Format("IP地址【{0}】连接不通,请确认客户端和服务端的网络是否正常。", ipAddressStr));
                        btnSet.Visible = true;
                        return;
                    }
                    if (!BaseSQL.TestSqlConnection())
                    {
                        MessageHandler.ShowMessageBox("服务端的数据库不能正常访问,请确认数据库是否正常");
                        btnSet.Visible = true;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageHandler.ShowMessageBox(ex.Message);
                    return;
                }

                EncryptMD5 en = new EncryptMD5(txtPassword.Text);                //实例化EncryptMD5, 加密后值引用en.str2
                if (FrmLoginBLL.CheckUser(txtUserID.Text, en.str2, cboLanguage)) // en.str2为加密后密码
                {
                    if (SystemInfo.user.IsDisable == 1)
                    {
                        MessageHandler.ShowMessageBox("当前用户已经停用,不可以登陆系统。");
                        txtUserID.Focus();
                        return;
                    }

                    new SystemHandler().InitializationSystemInfo(txtPassword.Text);

                    if (SystemInfo.IsCheckServer)//启动服务端检测
                    {
                        SocketHandler socket     = new SocketHandler();
                        string        messageStr = "";
                        if (!socket.ConnectServer(ref messageStr))
                        {
                            MessageHandler.ShowMessageBox(messageStr);
                            return;
                        }
                    }

                    fileHandler.IniWriteValue(iniPath, "System", "LastLanguage", cboLanguage.SelectedValue.ToString());

                    //Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    // cfa.AppSettings.Settings["last"].Value = "111";
                    //            cfa.Save();


                    Thread formThread = new Thread(ThreadInitializeForm);
                    formThread.Start();

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    txtPassword.Focus();
                }
            }
            catch (Exception ex)
            {
                //ExceptionHandler.HandleException(this.Text + "--用户登录错误。", ex);
                ExceptionHandler.HandleException(this.Text + "--" + tsmiYhdlcw.Text, ex);
            }
        }