Esempio n. 1
0
        void showAccess()
        {
            try
            {
                bool PWDOKFlag = false;

                bool blnReadable   = false;
                bool blnWritable   = false;
                bool blnAddable    = false;
                bool blnDeletable  = false;
                bool blnDuplicable = false;
                bool blnExportable = false;
                bool blnImportable = false;

                string pUserID = "";
                if (this.chkSQLlib.CheckState == CheckState.Checked)
                {
                    #region User SQL Server
                    mySQL = new SqlManager(Login.ServerName, Login.DBName, Login.DBUser, Login.DBPassword);   //140918_0 //140722_2   //140912_0
                    getLoginStutes();
                    //Username -->LoginName
                    myInfo = mySQL.GetDataTable("select * from UserInfo where LoginName='" + this.txtUserID.Text.ToString() + "'", "UserInfo");

                    DataRow[] myInfoRows = myInfo.Select("LoginName='" + this.txtUserID.Text.ToString() + "'");
                    if (myInfoRows.Length == 1)
                    {
                        //140612_2 Password-->UserPassword
                        if (myInfoRows[0]["LoginPassword"].ToString().ToUpper().Trim() == this.txtPWD.Text.ToString().ToUpper().Trim())
                        {
                            PWDOKFlag = true;
                            pUserID   = myInfoRows[0]["ID"].ToString();
                        }
                        else
                        {
                            PWDOKFlag = false;
                        }
                    }

                    if (!PWDOKFlag)
                    {
                        MessageBox.Show("用户或密码不正确!", "用户名或密码错误", MessageBoxButtons.OK);
                        return;
                    }
                    else
                    {
                        //140626 获取权限--> 正常来讲一个账号角色分配为1个...
                        string queryCMD = "select sum(FunctionCode) from functiontable where id in "
                                          + "(select RoleFunctionTable.FunctionID from RoleFunctionTable where RoleFunctionTable.RoleID  in "
                                          + "(select roleID from UserRoleTable where UserRoleTable.UserID = " + pUserID + "))";
                        //+ pUserID + "))";--> ToString+ "(select id from UserInfo	where UserInfo.LoginName='" + this.txtUserID.Text.ToString() + "')))";
                        DataTable myFunctions = mySQL.GetDataTable(queryCMD, "UserRoleFuncTable");

                        //140630_0 修改为读取sum(FunctionCode) 来体现,原为判断Title>>>>>>>>>>>>>>>>>
                        long myAccessCode = -1;
                        if (myFunctions.Rows.Count > 0)
                        {
                            myAccessCode = Convert.ToInt64(myFunctions.Rows[0][0].ToString());
                        }
                        else
                        {
                            myAccessCode = -1;
                        }
                        blnReadable   = ((myAccessCode & 0x01) == 0x01 ? true:false);
                        blnWritable   = ((myAccessCode & 0x02) == 0x02 ? true : false);
                        blnAddable    = ((myAccessCode & 0x04) == 0x04 ? true : false);
                        blnDeletable  = ((myAccessCode & 0x08) == 0x08 ? true : false);
                        blnDuplicable = ((myAccessCode & 0x10) == 0x10 ? true : false);
                        blnExportable = ((myAccessCode & 0x20) == 0x20 ? true : false);
                        blnImportable = ((myAccessCode & 0x40) == 0x40 ? true : false);
                        //TBD = ((myAccessCode & 0x80) == 0x80 ? true : false);

                        #region 原为判断Title>
                        //for (int i = 0; i < myFunctions.Rows.Count; i++)
                        //{
                        //    if (myFunctions.Rows[i]["Title"].ToString().ToUpper() == "Readable".ToUpper())
                        //    {
                        //        blnReadable = true;
                        //    }
                        //    else if (myFunctions.Rows[i]["Title"].ToString().ToUpper() == "Writable".ToUpper())
                        //    {
                        //        blnWritable = true;
                        //    }
                        //    else if (myFunctions.Rows[i]["Title"].ToString().ToUpper() == "Addable".ToUpper())
                        //    {
                        //        blnAddable = true;
                        //    }
                        //    else if (myFunctions.Rows[i]["Title"].ToString().ToUpper() == "Deletable".ToUpper())
                        //    {
                        //        blnDeletable = true;
                        //    }
                        //    else if (myFunctions.Rows[i]["Title"].ToString().ToUpper() == "Duplicable".ToUpper())
                        //    {
                        //        blnDuplicable = true;
                        //    }
                        //    else if (myFunctions.Rows[i]["Title"].ToString().ToUpper() == "Exportable".ToUpper())
                        //    {
                        //        blnExportable = true;
                        //    }
                        //    else if (myFunctions.Rows[i]["Title"].ToString().ToUpper() == "Importable".ToUpper())
                        //    {
                        //        blnImportable = true;
                        //    }
                        //}
                        #endregion

                        //140630_0 修改为读取sum(FunctionCode) 来体现,原为判断Title<<<<<<<<<<<<<<<<<<<
                        updateStutes(true, myInfo);
                    }

                    mySQL.OpenDatabase(false);
                }
                #endregion

                UserName         = this.txtUserID.Text;
                this.txtPWD.Text = "";
                this.Hide();

                PNInfo myPNInfo = new PNInfo();
                PNInfo.blnReadable   = blnReadable;
                PNInfo.blnWritable   = blnWritable;
                PNInfo.blnAddable    = blnAddable;
                PNInfo.blnDeletable  = blnDeletable;
                PNInfo.blnDuplicable = blnDuplicable;
                PNInfo.blnExportable = blnExportable;
                PNInfo.blnImportable = blnImportable;
                myPNInfo.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }