Пример #1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get all right for a Role and ProtectObj
        ///    </Description>
        ///    <Inputs>
        ///       int pRoleID
        ///       int pProtectObjID
        ///    </Inputs>
        ///    <Outputs>
        ///    </Outputs>
        ///    <Returns>
        ///       DataSet
        ///    </Returns>
        ///    <Authors>
        ///       TuanMD
        ///    </Authors>
        ///    <History>
        ///       Thursday, 13 - January , 2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************

        public object GetObjectVO(int pRoleID, int pProtectObjID)
        {
            const string METHOD_NAME = THIS + ".GetObjectVO()";

            OleDbDataReader odrPCS  = null;
            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                string strSql = String.Empty;

                strSql = "SELECT "
                         + Sys_RightTable.RIGHTID_FLD + ","
                         + Sys_RightTable.PERMISSION_FLD + ","
                         + Sys_RightTable.ROLEID_FLD + ","
                         + Sys_RightTable.MENU_ENTRYID_FLD
                         + " FROM " + Sys_RightTable.TABLE_NAME
                         + " WHERE " + Sys_RightTable.ROLEID_FLD + " = " + pRoleID + " and " + Sys_RightTable.MENU_ENTRYID_FLD + " = " + pProtectObjID;

                Utils utils = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSql, oconPCS);

                ocmdPCS.Connection.Open();
                odrPCS = ocmdPCS.ExecuteReader();

                Sys_RightVO objObject = new Sys_RightVO();

                while (odrPCS.Read())
                {
                    objObject.RightID      = int.Parse(odrPCS[Sys_RightTable.RIGHTID_FLD].ToString().Trim());
                    objObject.Permission   = int.Parse(odrPCS[Sys_RightTable.PERMISSION_FLD].ToString());
                    objObject.RoleID       = int.Parse(odrPCS[Sys_RightTable.ROLEID_FLD].ToString().Trim());
                    objObject.Menu_EntryID = int.Parse(odrPCS[Sys_RightTable.MENU_ENTRYID_FLD].ToString().Trim());
                }
                return(objObject);
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (Exception ex)
            {
                throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
            }

            finally
            {
                if (oconPCS != null)
                {
                    if (oconPCS.State != ConnectionState.Closed)
                    {
                        oconPCS.Close();
                    }
                }
            }
        }
Пример #2
0
        public void Add(object pobjObjectVO)
        {
            const string METHOD_NAME = THIS + ".Add()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                Sys_RightVO      objObject = (Sys_RightVO)pobjObjectVO;
                string           strSql    = String.Empty;
                DataAccess.Utils utils     = new DataAccess.Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand("", oconPCS);

                strSql = "INSERT INTO Sys_Right("
                         + Sys_RightTable.PERMISSION_FLD + ","
                         + Sys_RightTable.ROLEID_FLD + ","
                         + Sys_RightTable.MENU_ENTRYID_FLD + ")"
                         + "VALUES(?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_RightTable.PERMISSION_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_RightTable.PERMISSION_FLD].Value = objObject.Permission;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_RightTable.ROLEID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_RightTable.ROLEID_FLD].Value = objObject.RoleID;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_RightTable.MENU_ENTRYID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_RightTable.MENU_ENTRYID_FLD].Value = objObject.Menu_EntryID;

                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);
            }
            catch (Exception ex)
            {
                throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
            }

            finally
            {
                if (oconPCS != null)
                {
                    if (oconPCS.State != ConnectionState.Closed)
                    {
                        oconPCS.Close();
                    }
                }
            }
        }