Example #1
0
    public int UpdatePrivilegeObjects(InitializeModule.EnumCampus Campus, int iMode, int ObjectID, string ObjectNameAr, string ObjectNameEn, string DisplayObjectName, int ShowOrder, int SystemID, int ParentID, string sURL, int iLevel)
    {
        int iEffected = 0;
        Connection_StringCLS MyConnection_string = new Connection_StringCLS(Campus);
        SqlConnection        Conn = new SqlConnection(MyConnection_string.Conn_string.ToString());

        try
        {
            Conn.Open();
            string           sql = "";
            PrivilegeObjects thePrivilegeObjects = new PrivilegeObjects();
//'Updates the  table
            switch (iMode)
            {
            case  (int)InitializeModule.enumModes.EditMode:
                sql = GetUpdateCommand();
                break;

            case (int)InitializeModule.enumModes.NewMode:
                sql = GetInsertCommand();
                break;
            }
            SqlCommand Cmd = new SqlCommand(sql, Conn);
            Cmd.Parameters.Add(new SqlParameter("@ObjectID", ObjectID));
            Cmd.Parameters.Add(new SqlParameter("@ObjectNameAr", ObjectNameAr));
            Cmd.Parameters.Add(new SqlParameter("@ObjectNameEn", ObjectNameEn));
            Cmd.Parameters.Add(new SqlParameter("@DisplayObjectName", DisplayObjectName));
            Cmd.Parameters.Add(new SqlParameter("@ShowOrder", ShowOrder));
            Cmd.Parameters.Add(new SqlParameter("@SystemID", SystemID));
            Cmd.Parameters.Add(new SqlParameter("@ParentID", ParentID));
            Cmd.Parameters.Add(new SqlParameter("@sURL", sURL));
            Cmd.Parameters.Add(new SqlParameter("@iLevel", iLevel));
            iEffected = Cmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            LibraryMOD.ShowErrorMessage(ex);
        }
        finally
        {
            Conn.Close();
            Conn.Dispose();
        }
        return(iEffected);
    }
Example #2
0
    public List <PrivilegeObjects> GetPrivilegeObjects(InitializeModule.EnumCampus Campus, string sCondition, string sOrder, bool isDeafaultIncluded)
    {
//' returns a list of Classes instances based on the
//' data in the PrivilegeObjects
        Connection_StringCLS MyConnection_string = new Connection_StringCLS(Campus);
        string sSQL = GetSQL();

        if (!string.IsNullOrEmpty(sCondition))
        {
            sSQL += sCondition;
            sSQL += sOrder;
        }
        SqlConnection Conn = new SqlConnection(MyConnection_string.Conn_string.ToString());
        SqlCommand    Cmd  = new SqlCommand(sSQL, Conn);

        Conn.Open();
        SqlDataReader           reader  = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
        List <PrivilegeObjects> results = new List <PrivilegeObjects>();

        try
        {
//Default Value
            PrivilegeObjects myPrivilegeObjects = new PrivilegeObjects();
            if (isDeafaultIncluded)
            {
//Change the code here
                myPrivilegeObjects.ObjectID     = 0;
                myPrivilegeObjects.ObjectNameEn = "Select Object ...";
                results.Add(myPrivilegeObjects);
            }
            while (reader.Read())
            {
                myPrivilegeObjects = new PrivilegeObjects();
                if (reader[LibraryMOD.GetFieldName(ObjectIDFN)].Equals(DBNull.Value))
                {
                    myPrivilegeObjects.ObjectID = 0;
                }
                else
                {
                    myPrivilegeObjects.ObjectID = int.Parse(reader[LibraryMOD.GetFieldName(ObjectIDFN)].ToString());
                }
                myPrivilegeObjects.ObjectNameAr      = reader[LibraryMOD.GetFieldName(ObjectNameArFN)].ToString();
                myPrivilegeObjects.ObjectNameEn      = reader[LibraryMOD.GetFieldName(ObjectNameEnFN)].ToString();
                myPrivilegeObjects.DisplayObjectName = reader[LibraryMOD.GetFieldName(DisplayObjectNameFN)].ToString();
                if (reader[LibraryMOD.GetFieldName(ShowOrderFN)].Equals(DBNull.Value))
                {
                    myPrivilegeObjects.ShowOrder = 0;
                }
                else
                {
                    myPrivilegeObjects.ShowOrder = int.Parse(reader[LibraryMOD.GetFieldName(ShowOrderFN)].ToString());
                }
                if (reader[LibraryMOD.GetFieldName(SystemIDFN)].Equals(DBNull.Value))
                {
                    myPrivilegeObjects.SystemID = 0;
                }
                else
                {
                    myPrivilegeObjects.SystemID = int.Parse(reader[LibraryMOD.GetFieldName(SystemIDFN)].ToString());
                }
                if (reader[LibraryMOD.GetFieldName(ParentIDFN)].Equals(DBNull.Value))
                {
                    myPrivilegeObjects.ParentID = 0;
                }
                else
                {
                    myPrivilegeObjects.ParentID = int.Parse(reader[LibraryMOD.GetFieldName(ParentIDFN)].ToString());
                }
                myPrivilegeObjects.sURL = reader[LibraryMOD.GetFieldName(sURLFN)].ToString();
                if (reader[LibraryMOD.GetFieldName(iLevelFN)].Equals(DBNull.Value))
                {
                    myPrivilegeObjects.iLevel = 0;
                }
                else
                {
                    myPrivilegeObjects.iLevel = int.Parse(reader[LibraryMOD.GetFieldName(iLevelFN)].ToString());
                }
                results.Add(myPrivilegeObjects);
            }
        }
        catch (Exception ex)
        {
            LibraryMOD.ShowErrorMessage(ex);
        }
        finally
        {
            reader.Close();
            reader.Dispose();
            Conn.Close();
            Conn.Dispose();
        }
        return(results);
    }