Пример #1
0
        public bool KhoiTaoKetNoi()
        {
            VietBaIT.Encrypt sv_oEncrypt = new VietBaIT.Encrypt("Rijndael");
            string           fv_sUID     = null;
            string           fv_sPWD     = null;

            try {
                if (bGetConfigInfor(ref fv_sUID, ref fv_sPWD))
                {
                    if (fv_sUID == null | fv_sPWD == null)
                    {
                        return(false);
                    }
                    string sv_sConnectionString = "workstation id=" + gv_sComName + ";packet size=4096;data source=" + gv_sComName + ";persist security info=False;initial catalog=" + gv_sDBName + ";uid=" + sv_oEncrypt.GiaiMa(fv_sUID) + ";pwd=" + sv_oEncrypt.GiaiMa(fv_sPWD);
                    gv_sConnString = sv_sConnectionString;
                    if ((gv_oSqlCnn == null))
                    {
                        gv_oSqlCnn = new SqlConnection(sv_sConnectionString);
                        gv_oSqlCnn.Open();
                        //GetBranchInfor(gv_sBranchID)
                    }
                    else if (gv_oSqlCnn.State == ConnectionState.Closed)
                    {
                        gv_oSqlCnn.Open();
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            } catch (Exception ex) {
                MessageBox.Show("Không kết nối được vào CSDL. Liên hệ với quản trị hệ thống ", gv_sAnnouncement, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
        }
Пример #2
0
        private void cmdLogin_Click(object sender, EventArgs e)
        {
            string sv_sUID = string.Empty;
            string sv_sPWD = string.Empty;
            VietBaIT.Encrypt sv_oEncrypt = new VietBaIT.Encrypt(picCom.Tag.ToString());

            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (Login_blnIsValidData())
                {
                    if (bLoginSuccess())
                    {
                        globalVariables.UserName = txtUID.Text.Trim();
                        //globalVariables.pư = sv_oEncrypt.Mahoa(txtPWD.Text.Trim);
                        RegConfiguration.SaveSettings("DVC_COMPANY", "VBIT_DRTech_DVC", "APP_UID", txtUID.Text.Trim());
                        RegConfiguration.SaveSettings("DVC_COMPANY", "VBIT_DRTech_DVC", "APP_PWD", txtPWD.Text.Trim());
                        globalVariables.gv_ConnectSuccess = true;
                        SaveValue2File(Application.StartupPath + @"\Account.Info", txtUID.Text.Trim());
                        this.Cursor = Cursors.Default;

                        mv_bLoginSuccess = true;
                        StartDROC();
                        return;
                    }

                }
                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                AppLogger.LogAction.LogActions("==>Login().Exception occurred at " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "." + ex.ToString());
                MessageBox.Show(ex.Message);
                this.Cursor = Cursors.Default;
            }

        }
Пример #3
0
        private bool bLoginSuccess()
        {
            clsUser sv_oUser = new clsUser();
            VietBaIT.Encrypt sv_oEncrypt = new VietBaIT.Encrypt(picCom.Tag.ToString());

            if (!globalVariables.gv_ConnectSuccess)
            {
                return false;
            }
            if (!sv_oUser.bIsExisted(txtUID.Text.Trim()))
            {
                Utility.ShowMsg("Không tồn tại người dùng có tên đăng nhập là " + txtUID.Text.Trim() + ". Đề nghị nhập lại", "Thông báo");
                txtUID.Focus();
                return false;
            }
            if (!sv_oUser.bLoginSuccess(txtUID.Text.Trim(), sv_oEncrypt.Mahoa(txtPWD.Text.Trim())))
            {
                MessageBox.Show("Sai mật khẩu đăng nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPWD.Focus();
                return false;
            }
            return true;
        }
Пример #4
0
        private void cmdLogin_Click(object sender, System.EventArgs e)
        {
            string sv_sUID = string.Empty;
            string sv_sPWD = string.Empty;
            VietBaIT.Encrypt sv_oEncrypt = new VietBaIT.Encrypt("Rijndael");

            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (mf_bCheckData())
                {
                    if (bLoginSuccess())
                    {
                        globalVariables.UserName = txtUID.Text.Trim();
                        //globalVariables.pư = sv_oEncrypt.Mahoa(txtPWD.Text.Trim);
                        hrk.RegConfiguration.SaveSettings("DVC_COMPANY", "VBIT_DRTech_DVC", "APP_UID", txtUID.Text.Trim());
                        hrk.RegConfiguration.SaveSettings("DVC_COMPANY", "VBIT_DRTech_DVC", "APP_PWD", txtPWD.Text.Trim());
                        globalVariables.gv_ConnectSuccess = true;
                  
                        this.Cursor = Cursors.Default;
                        //this.Close();
                        mv_bLoginSuccess = true;
                        mdlStatic.mainform.ShowDialog();

                        return;
                    }

                }
                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Cursor = Cursors.Default;
            }
        }
Пример #5
0
 //------------------------------------------------------------------------------------------------------------
 //Mục đích        : Thay đổi mật khẩu quản trị
 //Đầu vào          :Mã người dùng, mật khẩu mới
 //Đầu ra            :Thành công=True. Ngược lại=False
 //Người tạo       :CuongDV
 //Ngày tạo         :09/03/2005
 //Nhật kí sửa đổi:
 //------------------------------------------------------------------------------------------------------------
 public bool bChangePasswordForAdmin(string pv_sUID, string pv_sNewPWD)
 {
     OleDbCommand sv_oCmd = null;
     VietBaIT.Encrypt sv_oEncrypt = new VietBaIT.Encrypt("Rijndael");
     mv_sSql = "UPDATE Sys_ADMINISTRATOR SET sPWD='" + pv_sNewPWD + "' WHERE PK_sAdminID='" + pv_sUID + "'" + " AND FP_sBranchID='" +globalVariables.Branch_ID + "'";
     try
     {
         sv_oCmd = new OleDbCommand(mv_sSql,globalVariables.OleDbConnection);
         sv_oCmd.ExecuteNonQuery();
         return true;
     }
     catch (Exception ex)
     {
         return false;
     }
 }
Пример #6
0
        private void cmdLogin_Click(object sender, EventArgs e)
        {
            string sv_sPWD = string.Empty;
            VietBaIT.Encrypt sv_oEncrypt = new VietBaIT.Encrypt("Rijndael");
            clsUser sv_oUser = new clsUser();
            try
            {

                sv_sPWD = sv_oEncrypt.Mahoa(txtOldPwd.Text.Trim());
                if (!txtNewPwd.Text.Trim().Equals(txtConfirm.Text.Trim()))
                {
                    MessageBox.Show("Mật khẩu xác nhận phải giống mật khẩu mới!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtConfirm.Focus();
                    return;
                }
                //Kiểm tra xem đã nhập mật khẩu cũ đúng hay chưa?
                if (globalVariables.IsAdminLogin)
                {
                    if (!sv_oUser.bLoginSuccessAdmin(globalVariables.UserName, sv_sPWD))
                    {
                        MessageBox.Show("Sai mật khẩu đăng nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtOldPwd.Focus();
                        return;
                    }
                }
                else
                {
                    if (!sv_oUser.bLoginSuccess(globalVariables.UserName, sv_sPWD))
                    {
                        MessageBox.Show("Sai mật khẩu đăng nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtOldPwd.Focus();
                        return;
                    }
                }

                //Kiểm tra xem mật khẩu cũ và mật khẩu mới có giống nhau không
                if (txtNewPwd.Text.Trim().Equals(txtOldPwd.Text.Trim()))
                {
                    MessageBox.Show("Đã thay đổi mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                    return;
                }
                if (globalVariables.IsAdminLogin)
                {
                    if (sv_oUser.bChangePasswordForAdmin(globalVariables.UserName, sv_oEncrypt.Mahoa(txtNewPwd.Text.Trim())))
                    {
                        MessageBox.Show("Đã thay đổi mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                        return;
                    }
                }
                else
                {
                    if (sv_oUser.bChangePassword(globalVariables.UserName, sv_oEncrypt.Mahoa(txtNewPwd.Text.Trim())))
                    {
                        MessageBox.Show("Đã thay đổi mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                        return;
                    }
                }
            }

            catch (Exception ex)
            {

            }
        }