示例#1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            int k = msg.WParam.ToInt32();

            if (k == 27)//Esc
            {
                if (IsLock)
                {
                    if (MessageBox.Show("必须重新登录,否则将退出系统,是否退出?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        isExist = true;
                        CApplication.ClearCSession();
                        Application.Exit();
                    }
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                }
                return(true);
            }
            else
            {
                return(base.ProcessCmdKey(ref msg, keyData));
            }
        }
示例#2
0
 private void frmLogin_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (IsLock && this.DialogResult != DialogResult.OK && !isExist)
     {
         if (MessageBox.Show("必须重新登录,否则将退出系统,是否退出?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             isExist = true;
             CApplication.ClearCSession();
             Application.Exit();
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
示例#3
0
        private void picOk_Click(object sender, EventArgs e)
        {
            if (this.txtUserId.Text.Trim() == string.Empty)
            {
                MessageBox.Show("用户名不能为空.");
                txtUserId.Focus();
                return;
            }
            if (this.txtUserPwd.Text.Trim() == string.Empty)
            {
                MessageBox.Show("密码不能为空.");
                txtUserPwd.Focus();
                return;
            }

            string[]      strKey = "Number,PassWord".Split(",".ToCharArray());
            string[]      strVal = new string[] { this.txtUserId.Text, txtUserPwd.Text };
            MethodRequest req    = new MethodRequest();

            req.ParamKeys = strKey;
            req.ParamVals = strVal;
            req.ProceName = "Get_Bse_User";
            req.ProceDb   = this.BtProduceCS;
            DataTable dt = ServerRequestProcess.DbRequest.DataRequest_By_DataTable(req);

            dt.AcceptChanges();
            if (dt.Rows.Count <= 0)
            {
                MessageBox.Show("密码或用户名不正确.");
                return;
            }
            else
            {
                DataRow dr = dt.Rows[0];

                strKey        = "User_Id".Split(",".ToCharArray());
                strVal        = new string[] { dr["User_id"].ToString() };
                req.ParamKeys = strKey;
                req.ParamVals = strVal;
                req.ProceName = "Get_Account_Menus_By_User";
                req.ProceDb   = this.BtProduceCS;
                DataTable dtAccount = ServerRequestProcess.DbRequest.DataRequest_By_DataTable(req);
                dtAccount.AcceptChanges();
                DataTable dtAllow = dtAccount.Clone();
                foreach (DataRow drA in dtAccount.Rows)
                {
                    DataRow[] drs = dtAllow.Select("Menu_Id = '" + drA["Menu_Id"].ToString() + "'");
                    if (drs.Length == 0)
                    {
                        DataRow drNew = dtAllow.NewRow();
                        foreach (DataColumn dc in dtAccount.Columns)
                        {
                            drNew[dc.ColumnName] = drA[dc.ColumnName];
                        }
                        dtAllow.Rows.Add(drNew);
                    }
                    else
                    {
                        string strOps = drs[0]["Allowed_Operator"].ToString();
                        drs[0]["Allowed_Operator"] = strOps + ";" + drA["Allowed_Operator"].ToString();
                    }
                }

                if (dtAllow.Select("Menus_Class='frmMainBase'").Length == 0)
                {
                    MessageBox.Show("你没有登录该系统的权限,请与系统管理员联系.");
                    Application.Exit();
                    return;
                }

                CApplication.ClearCSession();
                CApplication.App.DtAllowMenus           = dtAllow;
                CApplication.App.CurrentSession.UserId  = Int64.Parse(dr["User_id"].ToString());
                CApplication.App.CurrentSession.UserNme = dr["Name"].ToString();
                CApplication.App.CurrentSession.Number  = dr["Number"].ToString();
                CApplication.App.CurrentSession.DeptNme = dr["Dept_Txt"].ToString();
                Int64 iCompany_Id = -1;
                if (dt.Columns.Contains("Company_Id"))
                {
                    if (Int64.TryParse(dr["Company_Id"].ToString(), out iCompany_Id))
                    {
                        CApplication.App.CurrentSession.Company_Id = iCompany_Id;
                    }
                }
                Int64 iDeptId = -1;
                if (Int64.TryParse(dr["Dept_Id"].ToString(), out iDeptId))
                {
                    CApplication.App.CurrentSession.DeptId = iDeptId;
                }
                if (Int64.TryParse(dr["Fy_Id"].ToString(), out iDeptId))
                {
                    CApplication.App.CurrentSession.FyId = iDeptId;
                }
                CApplication.App.CurrentSession.UserType = dr["User_Type"].ToString();
                CApplication.App.CurrentSession.CardNub  = dr["CardNub"].ToString();



                strKey = "Form,EUser_Id,EDept_Id,EFy_Id".Split(",".ToCharArray());
                strVal = new string[] { "frmLogin"
                                        , CApplication.App.CurrentSession.UserId.ToString()
                                        , CApplication.App.CurrentSession.DeptId.ToString()
                                        , CApplication.App.CurrentSession.FyId.ToString() };
                req.ParamKeys = strKey;
                req.ParamVals = strVal;
                req.ProceName = "Get_Form_Load_Table";
                req.ProceDb   = this.BtProduceCS;
                CApplication.App.DtUserBasicSet = ServerRequestProcess.DbRequest.DataRequest_By_DataTable(req);
                CApplication.App.DtUserBasicSet.AcceptChanges();
                //保存用户登录信息到UserInfo.xml
                if (dt.Columns.Contains("UserInfo") && dr["UserInfo"].ToString() == "1")
                {
                    string AppPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
                    dt.WriteXml(AppPath + "\\UserInfo");
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }