Exemplo n.º 1
0
        public void getData()
        {
            try
            {
                string                    CEID  = new Students().GetCoureEnrollID(Semester, course, Years);
                string                    Query = "select t.SCORE_DISTRIBUTION_ID as ID, t2.CODE_VALUE as AID,t.SCORE_VALUE as SV,t.COURSE_ENR_ID as CID from APP_SCORE_DISTRIBUTION t inner join App_CODE t2 on t.ASSESSMENT_ID = t2.CODE_ID inner join APP_COURSE_ENROLMENT t3 on t.COURSE_ENR_ID = t3.COURSE_ENROL_ID inner join App_Instructor t4 on t3.UNIVERSITY_ID = t4.UNI_ID  where COURSE_ENR_ID = " + CEID + " and t4.instructor_id = " + Session["LoginID"].ToString() + "";
                SqlDataReader             sdb   = new MyUtilities.DBUtils().readOperation(Query);
                List <Score_Distribution> List  = new List <Score_Distribution>();

                while (sdb.Read())
                {
                    List.Add(new Score_Distribution()
                    {
                        Assessment_ID = sdb["AID"].ToString(), ID = sdb["ID"].ToString(), Score_Value = sdb["SV"].ToString()
                    });
                }


                MainGrid.DataSource = List;
                MainGrid.DataBind();
            }
            catch (Exception ex)
            {
                MyUtilities.LogUtils.myLog.Error("Error", ex);
            }
        }
Exemplo n.º 2
0
        public void GetAllCourseTopicEnrollment()
        {
            try
            {
                string        query = "select TOPIC_ID as ID, TOPIC_STATEMENT as TS, t2.course_name as 'CN', t3.clo_statement as 'C' from APP_COURSE_TOPIC t1 inner join App_Course t2 on t1.COURSE_ID = t2.course_id inner join I_CLO t3 on t1.CLO_ID = t3.clo_id  where t2.course_name = '" + course.SelectedValue + "'";
                SqlDataReader sdb   = new MyUtilities.DBUtils().readOperation(query);

                List <APP_CourseTopic> list = new List <APP_CourseTopic>();

                while (sdb.Read())
                {
                    list.Add(new APP_CourseTopic()
                    {
                        TOPIC_ID = sdb["ID"].ToString(), Course_ID = sdb["CN"].ToString(), TOPIC_STATEMENT = sdb["TS"].ToString(), CLO = sdb["C"].ToString()
                    });
                }

                MainGrid.DataSource = list;
                MainGrid.DataBind();
            }
            catch (Exception ex)
            {
                MyUtilities.LogUtils.myLog.Error("Error Occur While Get Course Topic Enrollment", ex);
            }
        }
Exemplo n.º 3
0
        public void GetAllCourseTopicEnrollment()
        {
            try
            {
                string        query = "select t1.COURSE_TOPIC_ENR_ID as ID,t2.course_name as CN,t3.TOPIC_STATEMENT as St,t1.TOPIC_SEQ_NUM as SQ from APP_COURSE_TOPIC_ENROL t1 inner join App_Course t2 on t1.COURSE_ENR_ID = t2.course_id inner join APP_COURSE_TOPIC t3 on t1.COURSE_TOPIC_ID = t3.TOPIC_ID inner join APP_COURSE_ENROLMENT t4 on t4.COURSE_ENROL_ID = t1.COURSE_ENR_ID where t4.ACDEMIC_YEAR = " + Acadmicyear.SelectedValue + " and t4.SEMESTER = (select CODE_ID from App_CODE where CODE_VALUE = '" + semester.SelectedValue + "')";
                SqlDataReader sdb   = new MyUtilities.DBUtils().readOperation(query);

                List <App_Course_Topic_Enroll> list = new List <App_Course_Topic_Enroll>();

                while (sdb.Read())
                {
                    list.Add(new App_Course_Topic_Enroll()
                    {
                        CourseTopicEnrID = sdb["ID"].ToString(), CourseEnrolID = sdb["CN"].ToString(), CourseTopicID = sdb["St"].ToString(), TopicSeqNo = sdb["SQ"].ToString()
                    });
                }

                MainGrid.DataSource = list;
                MainGrid.DataBind();
            }
            catch (Exception ex)
            {
                MyUtilities.LogUtils.myLog.Error("Error Occur While Get Course Topic Enrollment", ex);
            }
        }
Exemplo n.º 4
0
        public override void DataBind()
        {
            ((BoundColumn)MainGrid.Columns[0]).DataField = DataValueField;

            string[] savedValue = Value;
            MainGrid.DataBind();
            Value = savedValue;
        }
Exemplo n.º 5
0
        private void BindGrid()
        {
            MainGrid.Columns[1].HeaderText = LocRM.GetString("Title");
            MainGrid.Columns[2].HeaderText = "%";
            MainGrid.Columns[3].HeaderText = LocRM.GetString("EndDate");

            ArrayList objectTypes = new ArrayList();

            objectTypes.Add(ObjectTypes.Task);
            objectTypes.Add(ObjectTypes.ToDo);
            objectTypes.Add(ObjectTypes.Issue);
            objectTypes.Add(ObjectTypes.Document);
//			objectTypes.Add(ObjectTypes.CalendarEntry);

            DateTime  userNow = Security.CurrentUser.CurrentTimeZone.ToLocalTime(DateTime.UtcNow);
            DataTable dt      = Mediachase.IBN.Business.Calendar.GetResourceUtilization(
                Security.CurrentUser.UserID,
                userNow,
                userNow,
                userNow.AddDays(14),
                objectTypes,
                null,
                false,
                false,
                true,
                false);

            DataView dv = dt.DefaultView;

            dv.Sort = "Start";

            if (pageSize >= dv.Count)
            {
                MainGrid.PagerStyle.Visible = false;
            }
            else
            {
                MainGrid.PagerStyle.Visible = true;
            }
            MainGrid.PageSize = pageSize;

            int curPage = (int)ViewState[keyPage];
            int maxPage = (dv.Count - 1) / MainGrid.PageSize + 1;

            if (curPage <= maxPage)
            {
                MainGrid.CurrentPageIndex = curPage;
            }
            else
            {
                MainGrid.CurrentPageIndex = 0;
            }

            MainGrid.DataSource = dv;
            MainGrid.DataBind();
        }
        public void GetAllEnrollmentData()
        {
            try
            {
                List <APP_CourseTopic> MainList = new List <APP_CourseTopic>();
                List <string>          li       = Connections.LIST;

                string        query = "select TOPIC_ID as ID, TOPIC_STATEMENT as TS,t2.course_name as 'CN' from APP_COURSE_TOPIC t1 inner join App_Course t2 on t1.COURSE_ID = t2.course_id where t2.course_name = '" + course.SelectedValue + "'";
                SqlDataReader sdb   = new MyUtilities.DBUtils().readOperation(query);

                List <APP_CourseTopic> list = new List <APP_CourseTopic>();

                while (sdb.Read())
                {
                    list.Add(new APP_CourseTopic()
                    {
                        TOPIC_ID = sdb["ID"].ToString(), Course_ID = sdb["CN"].ToString(), TOPIC_STATEMENT = sdb["TS"].ToString()
                    });
                }

                for (int i = 0; i < li.Count; i++)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (li[i] == list[j].TOPIC_STATEMENT)
                        {
                            MainList.Add(list[j]);
                        }
                    }
                }

                MainGrid.DataSource = MainList;
                MainGrid.DataBind();

                foreach (GridViewRow item in MainGrid.Rows)
                {
                    DropDownList dropdown = (DropDownList)item.FindControl("drop");

                    if (dropdown.SelectedIndex == 0 || true)
                    {
                        for (int i = 0; i < MainList.Count; i++)
                        {
                            dropdown.Items.Add(new ListItem()
                            {
                                Text = i + 1 + "", Value = i + 1 + ""
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MyUtilities.LogUtils.myLog.Error("Error", ex);
            }
        }
Exemplo n.º 7
0
        private void BindGrid()
        {
            EnsureSelectInstance();

            if (BlockInstanceList.Items.Count > 0 && UserList.Items.Count > 0)
            {
                MainGrid.Visible = true;

                int      instanceId = int.Parse(BlockInstanceList.SelectedValue, CultureInfo.InvariantCulture);
                int      userId     = int.Parse(UserList.SelectedValue, CultureInfo.InvariantCulture);
                DateTime startDate  = DTCWeek.SelectedDate;
                //if (startDate == DateTime.MinValue)
                //    startDate = CHelper.GetWeekStartByDate(DTCWeek.Value);

                if (instanceId > 0)
                {
                    TimeTrackingBlock block = TimeTrackingManager.GetTimeTrackingBlock(instanceId, startDate, userId);
                    if (block == null || Mediachase.Ibn.Data.Services.Security.CanWrite(block))
                    {
                        MainGrid.DataSource = Mediachase.IBN.Business.TimeTracking.GetListTimeTrackingItemsForAdd_DataTable(instanceId, startDate, userId);
                        MainGrid.DataBind();
                    }
                    else
                    {
                        MainGrid.Visible = false;
                    }
                }
                else                    // All Projects
                {
                    BindAllProjectsGrid(startDate, userId);
                }
            }
            else
            {
                MainGrid.Visible = false;
            }

            foreach (DataGridItem dgi in MainGrid.Items)
            {
                if (dgi.Cells[1].Text == ProjectObjectType.ToString(CultureInfo.InvariantCulture))
                {
                    dgi.BackColor = Color.FromArgb(240, 240, 240);
                    dgi.Font.Bold = true;

                    // Add the OnClick handler
                    CheckBox cb = (CheckBox)dgi.FindControl("chkElement");
                    if (cb != null)
                    {
                        cb.Attributes.Add("onclick", String.Format(CultureInfo.InvariantCulture, "CheckChildren(this, {0})", dgi.Cells[2].Text));
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void BindGrid()
        {
            DateTime fromDate;
            DateTime toDate;

            if (PeriodType.Value == "1")                // LastWeek
            {
                fromDate = UserDateTime.Today.AddDays(-7);
                toDate   = UserDateTime.Today.AddDays(1);
            }
            else if (PeriodType.Value == "2")                   // LastMonth
            {
                fromDate = UserDateTime.Today.AddMonths(-1);
                toDate   = UserDateTime.Today.AddDays(1);
            }
            else
            {
                fromDate = PeriodFrom.SelectedDate;
                toDate   = PeriodTo.SelectedDate.AddDays(1);
            }

            DataTable dt = new DataTable();

            dt.Load(Mediachase.IBN.Business.Task.GetTaskDates(int.Parse(ProjectList.SelectedValue), fromDate, toDate));

            // remove duplicated project names
            int oldProject = -1;
            int oldTask    = -1;

            foreach (DataRow dr in dt.Rows)
            {
                int curProject = (int)dr["ProjectId"];
                int curTask    = (int)dr["TaskId"];
                if (curProject == oldProject)
                {
                    dr["ProjectName"] = "";
                }
                if (curTask == oldTask)
                {
                    dr["TaskName"] = "";
                }
                oldProject = curProject;
                oldTask    = curTask;
            }

            MainGrid.DataSource = dt.DefaultView;
            MainGrid.DataBind();
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PrepareContext();

            if (!IsPostBack)
            {
                MainGrid.DoPadding      = true;
                MainGrid.ShowCheckBoxes = true;
                MainGrid.ClassName      = "WorkflowInstance";
                MainGrid.PlaceName      = PlaceName;
                MainGrid.ViewName       = "WorkflowInstancesByObject";
                MainGrid.ProfileName    = "WorkflowInstancesByDocument";

                MainGrid.DataBind();
            }
        }
Exemplo n.º 10
0
        private void FillItems(bool checkUser)
        {
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Checked", typeof(bool));

            foreach (MetaEnumItem item in MetaEnum.GetItems(DataContext.Current.MetaModel.RegisteredTypes[principalType]))
            {
                // Ibn 4.7 fix: use only Users and Groups
                if (item.Handle != (int)PrincipalTypes.User && item.Handle != (int)PrincipalTypes.Department)
                {
                    continue;
                }

                DataRow row = dt.NewRow();
                row["Id"] = item.Handle;

                // Ibn 4.7 fix
                if (item.Handle == (int)PrincipalTypes.Department)
                {
                    row["Name"] = GetGlobalResourceObject("IbnFramework.Global", "Group").ToString();
                }
                else
                {
                    row["Name"] = CHelper.GetResFileString(item.Name);
                }

                if (checkUser && item.Handle == (int)PrincipalTypes.User)
                {
                    row["Checked"] = true;
                }
                else
                {
                    row["Checked"] = false;
                }
                dt.Rows.Add(row);
            }

            MainGrid.DataSource = dt.DefaultView;
            MainGrid.DataBind();
        }
Exemplo n.º 11
0
        private void BindGrid()
        {
            MetaClass mc = MetaDataWrapper.GetMetaClassByName(ClassName);
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("Id", typeof(string));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Type", typeof(string));

            HistoryMetaClassInfo historyInfo    = HistoryManager.GetInfo(mc);
            Collection <string>  selectedFields = historyInfo.SelectedFields;

            foreach (string fieldName in selectedFields)
            {
                MetaField mf = mc.Fields[fieldName];
                if (mf == null)
                {
                    continue;
                }

                DataRow row = dt.NewRow();
                row["Id"]   = fieldName;
                row["Name"] = CHelper.GetMetaFieldName(mf);
                row["Type"] = CHelper.GetMcDataTypeName(mf.GetOriginalMetaType().McDataType);

                dt.Rows.Add(row);
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();

            foreach (GridViewRow row in MainGrid.Rows)
            {
                ImageButton ib = (ImageButton)row.FindControl("DeleteButton");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')");
                }
            }
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SqlDataReader  sdb  = new MyUtilities.DBUtils().readOperation("Select Program_id as ID, Program_Name as PN from App_Program");
                List <Program> list = new List <Program>();
                while (sdb.Read())
                {
                    list.Add(new Program()
                    {
                        ID = sdb["ID"].ToString(), Program_Name = sdb["PN"].ToString()
                    });
                }

                MainGrid.DataSource = list;
                MainGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SqlDataReader       sdb  = new MyUtilities.DBUtils().readOperation("select UNI_ID as ID, UNI_NAME as Name, UNI_ADDRESS as 'A', UNI_VERIFIED as V from APP_UNIVERSITY;");
                List <Universities> list = new List <Universities>();
                while (sdb.Read())
                {
                    list.Add(new Universities()
                    {
                        ID = sdb["ID"].ToString(), UA = sdb["A"].ToString(), UN = sdb["Name"].ToString(), V = sdb["V"].ToString()
                    });
                }

                MainGrid.DataSource = list;
                MainGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                List <Courses> list = new List <Courses>();
                SqlDataReader  sdb  = new MyUtilities.DBUtils().readOperation("select course_id as ID, t2.program_name as PN, course_name as CN, COURSE_NUMBER as CNU, t3.CODE_VALUE as CT, THEORY_CREDIT_HOURS as TCRH, LAB_CREDIT_HOURS as LCRH, THEORY_CONTACT_HOURS as TCH, LAB_CONTACT_HOURS as LCH from App_Course t1 inner join App_Program t2 on t1.App_Program_program_id = t2.program_id inner join App_CODE t3 on t1.COURSE_TYPE = t3.CODE_ID ");
                while (sdb.Read())
                {
                    list.Add(new Courses()
                    {
                        ID = sdb["ID"].ToString(), PN = sdb["PN"].ToString(), CN = sdb["CN"].ToString(), CNU = sdb["CNU"].ToString(), CT = sdb["CT"].ToString(), LCHOURS = sdb["LCH"].ToString(), LCRHOURS = sdb["LCRH"].ToString(), TCHOURS = sdb["TCH"].ToString(), TCRHOURS = sdb["TCRH"].ToString()
                    });
                }

                MainGrid.DataSource = list;
                MainGrid.DataBind();
            }
            catch (Exception ex)
            {
                MyUtilities.LogUtils.myLog.Error("Error While Gatting Data", ex);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                List <App_Course_Topic_Enroll> list = new List <App_Course_Topic_Enroll>();

                try
                {
                    SqlDataReader sdb = new MyUtilities.DBUtils().readOperation("select t1.ACDEMIC_YEAR as 'Y', t3.CODE_VALUE as 'SM', t2.course_name as 'CN', t4.program_name as 'PN' from APP_COURSE_ENROLMENT t1 inner join App_Course t2 on t1.APP_COURSE_ID = t2.course_id inner join App_CODE t3 on t1.SEMESTER = t3.CODE_ID inner join App_Program t4 on t2.App_Program_program_id = t4.program_id where COURSE_ENROL_ID = '" + Request.QueryString["EID"].ToString() + "'");

                    while (sdb.Read())
                    {
                        Program.Text  = sdb["PN"].ToString();
                        Course.Text   = sdb["CN"].ToString();
                        Year.Text     = sdb["Y"].ToString();
                        Semester.Text = sdb["SM"].ToString();
                    }


                    sdb = new MyUtilities.DBUtils().readOperation("select t1.COURSE_TOPIC_ENR_ID as ID, t2.TOPIC_STATEMENT as ST,TOPIC_SEQ_NUM as SEQ from APP_COURSE_TOPIC_ENROL t1 inner join APP_COURSE_TOPIC t2 on t1.COURSE_TOPIC_ID = t2.TOPIC_ID where COURSE_ENR_ID = " + Request.QueryString["EID"].ToString() + "");

                    while (sdb.Read())
                    {
                        list.Add(new App_Course_Topic_Enroll()
                        {
                            CourseTopicEnrID = sdb["ID"].ToString(), CourseTopicID = sdb["ST"].ToString(), TopicSeqNo = sdb["seq"].ToString()
                        });
                    }

                    MainGrid.DataSource = list;
                    MainGrid.DataBind();
                }
                catch (Exception ex)
                {
                    MyUtilities.LogUtils.myLog.Error("Error Occure While Run Page Load Of Course Topic Enroll View.", ex);
                }
            }
        }
Exemplo n.º 16
0
        private void GetData()
        {
            try
            {
                List <ScoreDesignDataView> List = new List <ScoreDesignDataView>();
                string        Query             = "select t1.APP_SCORE_DESIGN_ID as ID, t3.CODE_VALUE as 'AT', t1.ASSESSMENT_NAME as AN, t4.clo_statement as 'CLOS', t1.RAW_SCORE as 'RS',t1.SCORE_VALUE as 'SV', t2.SCORE_VALUE as 'TS'  from APP_SCORE_DESIGN t1 inner join APP_SCORE_DISTRIBUTION t2 on t1.SCORE_DISTRIBUTION_ID = t2.SCORE_DISTRIBUTION_ID inner join App_CODE t3 on t2.ASSESSMENT_ID = t3.CODE_ID inner join I_CLO t4 on t1.CLO_ID = t4.clo_id where t3.CODE_VALUE = '" + Assessments.SelectedValue + "' and t2.COURSE_ENR_ID = " + new Students().GetCoureEnrollID(Semester, course, Years) + "";
                SqlDataReader sdb = new MyUtilities.DBUtils().readOperation(Query);

                while (sdb.Read())
                {
                    List.Add(new ScoreDesignDataView()
                    {
                        Assessment = sdb["AN"].ToString(), Assessment_type = sdb["AT"].ToString(), CLO_Statement = sdb["CLOS"].ToString(), ID = sdb["ID"].ToString(), Raw_Score = sdb["RS"].ToString(), Score_Value = sdb["SV"].ToString(), Total_Score = sdb["TS"].ToString()
                    });
                }

                MainGrid.DataSource = List;
                MainGrid.DataBind();
            }
            catch (Exception ex)
            {
                MyUtilities.LogUtils.myLog.Error("Error", ex);
            }
        }
Exemplo n.º 17
0
        public void GetData()
        {
            try
            {
                string Query = "select t1.APP_SCORE_INPUT_ID as ID, t3.STUDENT_NAME as N, t2.ASSESSMENT_NAME as AN, MARKS_OBTAINED as M from APP_SCORE_INPUT t1 inner join APP_SCORE_DESIGN t2 on t1.APP_SCORE_DESIGN_ID = t2.APP_SCORE_DESIGN_ID inner join APP_STUDENT t3 on t1.STUDENT_ID = t3.STUDENT_ID";

                SqlDataReader     sdb  = new MyUtilities.DBUtils().readOperation(Query);
                List <Scoreinput> list = new List <Scoreinput>();
                while (sdb.Read())
                {
                    list.Add(new Scoreinput()
                    {
                        Assessment_Name = sdb["AN"].ToString(), ID = sdb["ID"].ToString(), Marks = sdb["M"].ToString(), Student_Name = sdb["N"].ToString()
                    });
                }

                MainGrid.DataSource = list;
                MainGrid.DataBind();
            }
            catch (Exception ex)
            {
                MyUtilities.LogUtils.myLog.Error("Error", ex);
            }
        }
Exemplo n.º 18
0
        private void BindData()
        {
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("DisplayName", typeof(string));
            dt.Columns.Add("PrimaryName", typeof(string));
            dt.Columns.Add("RelatedName", typeof(string));
            dt.Columns.Add("FieldTypeImageUrl", typeof(string));
            dt.Columns.Add("EditLink", typeof(string));
            dt.Columns.Add("IsSystem", typeof(bool));

            foreach (MetaField field in mc.FindReferencesTo(true))
            {
                // don't process references from bridges
                if (field.Owner.IsBridge)
                {
                    continue;
                }

                DataRow row = dt.NewRow();
                row["Name"] = String.Format(CultureInfo.InvariantCulture,
                                            "{0},{1}",
                                            field.Owner.Name,
                                            field.Name);

                // DisplayName - get from attribute or use PluralName
                if (!String.IsNullOrEmpty(field.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayBlock, string.Empty)) &&
                    field.Attributes.ContainsKey(McDataTypeAttribute.ReferenceDisplayText))
                {
                    row["DisplayName"] = CHelper.GetResFileString(field.Attributes[McDataTypeAttribute.ReferenceDisplayText].ToString());
                }
                else
                {
                    row["DisplayName"] = CHelper.GetResFileString(field.Owner.PluralName);
                }

                // PrimaryName - current class
                row["PrimaryName"] = CHelper.GetResFileString(mc.FriendlyName);

                // RelatedName - link
                row["RelatedName"] = CHelper.GetMetaClassAdminPageLink(field.Owner, this.Page);

                // FieldTypeImageUrl
                string postfix = string.Empty;
                if (field.Attributes.ContainsKey(MetaClassAttribute.IsSystem))
                {
                    postfix = "_sys";
                }

                row["FieldTypeImageUrl"] = String.Format(CultureInfo.InvariantCulture,
                                                         "~/images/IbnFramework/metainfo/backreference{0}.gif",
                                                         postfix);

                // Edit - we use related class and related field as params
                row["EditLink"] = String.Format(CultureInfo.InvariantCulture,
                                                "{0}?class={1}&refclass={2}&reffield={3}&mode=1N",
                                                EditFieldLink,
                                                mc.Name,
                                                field.Owner.Name,
                                                field.Name);

                // IsSystem
                row["IsSystem"] = field.Attributes.ContainsKey(MetaClassAttribute.IsSystem) || field.Owner.TitleFieldName == field.Name;

                dt.Rows.Add(row);
            }

            DataView dv = dt.DefaultView;

            if (_pc[sortKey] == null)
            {
                _pc[sortKey] = "DisplayName";
            }

            dv.Sort = _pc[sortKey];

            MainGrid.DataSource = dv;
            MainGrid.DataBind();

            foreach (GridViewRow row in MainGrid.Rows)
            {
                ImageButton ib = (ImageButton)row.FindControl("DeleteButton");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')");
                }
            }
        }
Exemplo n.º 19
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("EntryId", typeof(int)));
            dt.Columns.Add(new DataColumn("ObjectId", typeof(int)));
            dt.Columns.Add(new DataColumn("ObjectTypeId", typeof(int)));
            dt.Columns.Add(new DataColumn("ObjectName", typeof(string)));
            dt.Columns.Add(new DataColumn("BlockTypeInstanceId", typeof(int)));
            DataRow dr;

            DateTime localDate     = IBN45Business.User.GetLocalDate(DateTime.UtcNow);
            DateTime srcStartDate  = IBN45Business.TimeTracking.GetWeekStart(localDate.AddDays(-7));
            DateTime destStartDate = IBN45Business.TimeTracking.GetWeekStart(localDate);

            TimeTrackingEntry[] srcEntries = TimeTrackingManager.GetEntriesForClone(Mediachase.Ibn.Data.Services.Security.CurrentUserId, srcStartDate, destStartDate);

            int blockTypeInstanceId = -1;

            foreach (TimeTrackingEntry srcEntry in srcEntries)
            {
                if (blockTypeInstanceId != srcEntry.BlockTypeInstanceId)
                {
                    blockTypeInstanceId = srcEntry.BlockTypeInstanceId;
                    dr                        = dt.NewRow();
                    dr["EntryId"]             = -1;
                    dr["ObjectId"]            = blockTypeInstanceId;
                    dr["ObjectTypeId"]        = ProjectObjectType;
                    dr["ObjectName"]          = srcEntry.ParentBlock;
                    dr["BlockTypeInstanceId"] = blockTypeInstanceId;
                    dt.Rows.Add(dr);
                }

                dr            = dt.NewRow();
                dr["EntryId"] = srcEntry.PrimaryKeyId;
                if (srcEntry.Properties["ObjectId"].Value != null && srcEntry.Properties["ObjectTypeId"].Value != null)
                {
                    dr["ObjectId"]     = srcEntry.Properties["ObjectId"].Value;
                    dr["ObjectTypeId"] = srcEntry.Properties["ObjectTypeId"].Value;
                }
                else
                {
                    dr["ObjectId"]     = -1;
                    dr["ObjectTypeId"] = -1;
                }
                dr["ObjectName"]          = srcEntry.Title;
                dr["BlockTypeInstanceId"] = blockTypeInstanceId;
                dt.Rows.Add(dr);
            }

            MainGrid.DataSource = dt.DefaultView;
            MainGrid.DataBind();

            foreach (DataGridItem dgi in MainGrid.Items)
            {
                CheckBox cb;
                if (dgi.Cells[1].Text == ProjectObjectType.ToString(CultureInfo.InvariantCulture))
                {
                    dgi.BackColor = Color.FromArgb(240, 240, 240);
                    dgi.Font.Bold = true;

                    // Add the OnClick handler
                    cb = (CheckBox)dgi.FindControl("chkElement");
                    if (cb != null)
                    {
                        cb.Attributes.Add("onclick", String.Format(CultureInfo.InvariantCulture, "CheckChildren(this, {0})", dgi.Cells[2].Text));
                    }
                }
            }
        }
Exemplo n.º 20
0
        private void BindGrid()
        {
            // DataTable structure
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add(idColumn, typeof(string));
            dt.Columns.Add(principalColumn, typeof(string));
            foreach (SecurityRight right in Mediachase.Ibn.Data.Services.Security.GetMetaClassRights(mc.Name))
            {
                dt.Columns.Add(right.RightName, typeof(string));
            }
            dt.Columns.Add(editColumn, typeof(string));
            dt.Columns.Add(deleteColumn, typeof(string));

            // Fill data
            DataRow dr;

            foreach (MetaObject mo in Mediachase.Ibn.Data.Services.Security.GetGlobalAcl(mc.Name))
            {
                int principalId = (PrimaryKeyId)mo.Properties["PrincipalId"].Value;

                dr                  = dt.NewRow();
                dr[idColumn]        = mo.PrimaryKeyId;
                dr[principalColumn] = CHelper.GetUserName(principalId);

                for (int i = 1; i < MainGrid.Columns.Count - 2; i++)
                {
                    BoundField rightsField = MainGrid.Columns[i] as BoundField;
                    if (rightsField != null)
                    {
                        string fieldName = rightsField.DataField;
                        dr[fieldName] = CHelper.GetPermissionImage((int)mo.Properties[fieldName].Value);
                    }
                }

                string url = String.Format(CultureInfo.InvariantCulture,
                                           "javascript:ShowWizard(&quot;{5}?ClassName={0}&btn={1}&PrincipalId={2}&quot;, {3}, {4});",
                                           mc.Name, Page.ClientScript.GetPostBackEventReference(RefreshButton, ""),
                                           principalId, dialogWidth, dialogHeight,
                                           ResolveUrl("~/Apps/Security/Pages/Admin/GlobalRoleAclEdit.aspx"));
                dr[editColumn] = String.Format(CultureInfo.InvariantCulture,
                                               "<a href=\"{0}\"><img src=\"{1}\" title=\"{2}\" width=\"16\" height=\"16\" border=\"0\" /></a>", url, ResolveUrl("~/Images/IbnFramework/edit.gif"), GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Edit").ToString());

                dt.Rows.Add(dr);
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();

            foreach (GridViewRow row in MainGrid.Rows)
            {
                if (row.Cells[row.Cells.Count - 1].Controls.Count > 0)
                {
                    WebControl ctrl = (WebControl)row.Cells[row.Cells.Count - 1].Controls[0];
                    if (ctrl != null)
                    {
                        ctrl.Attributes.Add("onclick", "if (!confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')) return false;");
                    }
                }
            }
        }
Exemplo n.º 21
0
        void BindGrid()
        {
            MetaObject[] list = this.CurrentView.List(CurrentPreferences);

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Day1", typeof(float)));
            dt.Columns.Add(new DataColumn("Day2", typeof(float)));
            dt.Columns.Add(new DataColumn("Day3", typeof(float)));
            dt.Columns.Add(new DataColumn("Day4", typeof(float)));
            dt.Columns.Add(new DataColumn("Day5", typeof(float)));
            dt.Columns.Add(new DataColumn("Day6", typeof(float)));
            dt.Columns.Add(new DataColumn("Day7", typeof(float)));
            dt.Columns.Add(new DataColumn("DayT", typeof(float)));
            dt.Columns.Add(new DataColumn("StateFriendlyName", typeof(string)));

            foreach (MetaObject mo in list)
            {
                DataRow row             = dt.NewRow();
                string  additionalTitle = string.Empty;

                if (cbShowWeekNumber.Checked && mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() != MetaViewGroupByType.Total.ToString())
                {
                    DateTime dtNew = DateTime.MinValue;

                    try
                    {
                        dtNew = (DateTime)mo.Properties["Title"].Value;
                    }
                    catch
                    {
                    }

                    if (dtNew != DateTime.MinValue)
                    {
                        additionalTitle = string.Format("(#{0})", Iso8601WeekNumber.GetWeekNumber((DateTime)mo.Properties["Title"].Value));
                    }
                }

                if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Primary.ToString())
                {
                    if (Convert.ToInt32(ddPrimary.SelectedValue, CultureInfo.InvariantCulture) != 0)
                    {
                        row["Title"] = String.Format("<b>{0} {1}</b>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("<b>{0} - {1} {2}</b>", ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), additionalTitle);
                    }
                }
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Secondary.ToString())
                {
                    if (Convert.ToInt32(ddSecondary.SelectedValue, CultureInfo.InvariantCulture) != 0)
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0} {1}</div>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0} - {1} {2}</div>", ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), additionalTitle);
                    }
                }
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Total.ToString())
                {
                    row["Title"] = String.Format("<div style='padding-left: 25px;'>{0} {1}</div>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                }
                else
                {
                    //TO DO: switch
                    switch (this.ThirdGroupById)
                    {
                    case 0:
                    {
                        row["Title"] = String.Format("<div style='padding-left: 45px;'>{0}-{1} {2}</div>", ((DateTime)mo.Properties["StartDate"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["StartDate"].Value).AddDays(6).ToString("d MMM yyyy"), additionalTitle);
                        break;
                    }

                    case 1:
                    {
                        row["Title"] = String.Format("<div style='padding-left: 45px;'>{0} {1}</div>", mo.Properties["Owner"].Value.ToString(), additionalTitle);
                        break;
                    }

                    case 2:
                    {
                        string sTitle = (mo.Properties["Project"].Value != null) ? mo.Properties["Project"].Value.ToString() : mo.Properties["Title"].Value.ToString();
                        row["Title"] = String.Format("<div style='padding-left: 45px;'>{0} {1}</div>", sTitle, additionalTitle);
                        break;
                    }
                    }
                }

                row["Day1"] = Convert.ToDouble(mo.Properties["Day1"].Value);
                row["Day2"] = Convert.ToDouble(mo.Properties["Day2"].Value);
                row["Day3"] = Convert.ToDouble(mo.Properties["Day3"].Value);
                row["Day4"] = Convert.ToDouble(mo.Properties["Day4"].Value);
                row["Day5"] = Convert.ToDouble(mo.Properties["Day5"].Value);
                row["Day6"] = Convert.ToDouble(mo.Properties["Day6"].Value);
                row["Day7"] = Convert.ToDouble(mo.Properties["Day7"].Value);
                row["DayT"] = Convert.ToDouble(mo.Properties["DayT"].Value);

                if (mo.Properties["StateFriendlyName"].Value != null)
                {
                    row["StateFriendlyName"] = CHelper.GetResFileString(mo.Properties["StateFriendlyName"].Value.ToString());
                }
                else
                {
                    row["StateFriendlyName"] = "";
                }

                dt.Rows.Add(row);
            }

            // Header Text
            for (int i = 0; i < MainGrid.Columns.Count; i++)
            {
                MetaField field     = CurrentPreferences.GetVisibleMetaField()[i];
                string    fieldName = field.Name;

                // First day of week can be different, so we should specify it.
                if (fieldName == "Day1" || fieldName == "Day2" || fieldName == "Day3" || fieldName == "Day4" || fieldName == "Day5" || fieldName == "Day6" || fieldName == "Day7")
                {
                    DateTime curDate = CHelper.GetRealWeekStartByDate(DateTime.UtcNow);
                    if (fieldName == "Day2")
                    {
                        curDate = curDate.AddDays(1);
                    }
                    else if (fieldName == "Day3")
                    {
                        curDate = curDate.AddDays(2);
                    }
                    else if (fieldName == "Day4")
                    {
                        curDate = curDate.AddDays(3);
                    }
                    else if (fieldName == "Day5")
                    {
                        curDate = curDate.AddDays(4);
                    }
                    else if (fieldName == "Day6")
                    {
                        curDate = curDate.AddDays(5);
                    }
                    else if (fieldName == "Day7")
                    {
                        curDate = curDate.AddDays(6);
                    }

                    MainGrid.Columns[i].HeaderText = GetGlobalResourceObject("IbnFramework.TimeTracking", curDate.DayOfWeek.ToString()).ToString();
                }
                else
                {
                    MainGrid.Columns[i].HeaderText = CHelper.GetResFileString(field.FriendlyName);
                }
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();
        }
Exemplo n.º 22
0
        private void BindAllProjectsGrid(DateTime startDate, int userId)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("ObjectId", typeof(int)));
            dt.Columns.Add(new DataColumn("ObjectTypeId", typeof(int)));
            dt.Columns.Add(new DataColumn("ObjectName", typeof(string)));
            dt.Columns.Add(new DataColumn("BlockTypeInstanceId", typeof(int)));
            DataRow dr;

            #region 1. Make the list of all BlockTypeInstances
            Dictionary <int, string> allList = new Dictionary <int, string>();
            bool isProject = false;
            foreach (ListItem li in BlockInstanceList.Items)
            {
                if (!isProject)
                {
                    // Check that we have reached the [ All Projects ]
                    if (li.Value == "0")
                    {
                        isProject = true;
                    }
                    continue;
                }
                allList.Add(int.Parse(li.Value, CultureInfo.InvariantCulture), li.Text);
            }
            #endregion

            #region 2. Get the list of the existing blocks by StartDate and OwnerId
            List <int> idList = new List <int>();
            Dictionary <int, TimeTrackingBlock> existingBlocks = new Dictionary <int, TimeTrackingBlock>();
            foreach (TimeTrackingBlock block in TimeTrackingBlock.List(FilterElement.EqualElement("StartDate", startDate), FilterElement.EqualElement("OwnerId", userId), FilterElement.IsNotNullElement("ProjectId")))
            {
                idList.Add(block.PrimaryKeyId.Value);
                existingBlocks.Add(block.PrimaryKeyId.Value, block);
            }
            #endregion

            #region 3. Get the security info by existing blocks and remove the forbidden items from allList
            SerializableDictionary <int, Collection <string> > objectRights = Mediachase.Ibn.Data.Services.Security.GetAllowedRights(TimeTrackingBlock.GetAssignedMetaClass(), idList.ToArray());
            foreach (KeyValuePair <int, Collection <string> > item in objectRights)
            {
                int id = item.Key;
                Collection <string> allowedRights = item.Value;

                TimeTrackingBlock block = existingBlocks[id];
                if (!allowedRights.Contains(Mediachase.Ibn.Data.Services.Security.RightWrite))
                {
                    allList.Remove(block.BlockTypeInstanceId);
                }
            }
            #endregion

            #region 4. Fill in the DataTable
            foreach (KeyValuePair <int, string> item in allList)
            {
                bool   isHeaderAdded = false;
                int    instanceId    = item.Key;
                string instanceName  = item.Value;
                using (IDataReader reader = Mediachase.IBN.Business.TimeTracking.GetListTimeTrackingItemsForAdd(instanceId, startDate, userId))
                {
                    while (reader.Read())
                    {
                        if (!isHeaderAdded)
                        {
                            dr                        = dt.NewRow();
                            dr["ObjectId"]            = instanceId;
                            dr["ObjectTypeId"]        = ProjectObjectType;
                            dr["ObjectName"]          = instanceName;
                            dr["BlockTypeInstanceId"] = instanceId;
                            dt.Rows.Add(dr);

                            isHeaderAdded = true;
                        }

                        dr                        = dt.NewRow();
                        dr["ObjectId"]            = reader["ObjectId"];
                        dr["ObjectTypeId"]        = reader["ObjectTypeId"];
                        dr["ObjectName"]          = reader["ObjectName"];
                        dr["BlockTypeInstanceId"] = reader["BlockTypeInstanceId"];
                        dt.Rows.Add(dr);
                    }
                }
            }
            #endregion

            MainGrid.DataSource = dt.DefaultView;
            MainGrid.DataBind();
        }
Exemplo n.º 23
0
        private void BindGrid()
        {
            // DataTable structure
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add(idColumn, typeof(string));
            dt.Columns.Add(principalColumn, typeof(string));
            dt.Columns.Add(isInheritedColumn, typeof(bool));
            foreach (SecurityRight right in Mediachase.Ibn.Data.Services.Security.GetMetaClassRights(mc.Name))
            {
                dt.Columns.Add(right.RightName, typeof(string));
            }
            dt.Columns.Add(editColumn, typeof(string));
            dt.Columns.Add(resetColumn, typeof(string));

            // Fill data
            DataRow dr;

            foreach (MetaObject mo in Mediachase.Ibn.Data.Services.Security.GetGlobalAcl(mc.Name))
            {
                int principalId = (PrimaryKeyId)mo.Properties["PrincipalId"].Value;

                dr                  = dt.NewRow();
                dr[idColumn]        = mo.PrimaryKeyId.Value;
                dr[principalColumn] = CHelper.GetUserName(principalId);

                bool       isInhereted = false;
                MetaObject obj         = StateMachineUtil.GetGlobalAclStateItem(mc.Name, mo.PrimaryKeyId.Value, int.Parse(StateMachineList.SelectedValue), int.Parse(StateList.SelectedValue));
                if (obj == null)
                {
                    obj         = mo;
                    isInhereted = true;
                }

                dr[isInheritedColumn] = isInhereted;

                for (int i = 1; i < MainGrid.Columns.Count - 2; i++)
                {
                    BoundField rightsField = MainGrid.Columns[i] as BoundField;
                    if (rightsField != null)
                    {
                        string fieldName = rightsField.DataField;
                        dr[fieldName] = CHelper.GetPermissionImage((int)obj.Properties[fieldName].Value, isInhereted);
                    }
                }

                string url = String.Format(CultureInfo.InvariantCulture,
                                           "javascript:ShowWizard(&quot;{7}?ClassName={0}&btn={1}&PrincipalId={2}&SmId={3}&StateId={4}&quot;, {5}, {6});",
                                           mc.Name, Page.ClientScript.GetPostBackEventReference(RefreshButton, ""),
                                           principalId, StateMachineList.SelectedValue, StateList.SelectedValue,
                                           dialogWidth, dialogHeight,
                                           ResolveClientUrl("~/Apps/Security/Pages/Admin/GlobalRoleAclStateEdit.aspx"));
                dr[editColumn] = String.Format(CultureInfo.InvariantCulture,
                                               "<a href=\"{0}\"><img src=\"{1}\" title=\"{2}\" width=\"16\" height=\"16\" border=\"0\" /></a>", url, ResolveUrl("~/Images/IbnFramework/edit.gif"), GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Edit").ToString());

                dt.Rows.Add(dr);
            }


            MainGrid.DataSource = dt;
            MainGrid.DataBind();
        }
Exemplo n.º 24
0
        private void BindData()
        {
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("DisplayName", typeof(string));
            dt.Columns.Add("CurrentName", typeof(string));
            dt.Columns.Add("RelatedName", typeof(string));
            dt.Columns.Add("FieldTypeImageUrl", typeof(string));
            dt.Columns.Add("EditLink", typeof(string));
            dt.Columns.Add("IsSystem", typeof(bool));

            foreach (MetaClass bridgeClass in DataContext.Current.MetaModel.GetBridgesReferencedToClass(mc))
            {
                if (!bridgeClass.Attributes.ContainsKey(MetaClassAttribute.BridgeRef1Name) ||
                    !bridgeClass.Attributes.ContainsKey(MetaClassAttribute.BridgeRef2Name))
                {
                    continue;
                }

                string field1Name = bridgeClass.Attributes[MetaClassAttribute.BridgeRef1Name].ToString();
                string field2Name = bridgeClass.Attributes[MetaClassAttribute.BridgeRef2Name].ToString();

                MetaField bridgeField1;                 // reference to current class
                MetaField bridgeField2;                 // reference to another class
                if (bridgeClass.Fields[field1Name].Attributes.GetValue <string>(McDataTypeAttribute.ReferenceMetaClassName, string.Empty) == mc.Name)
                {
                    bridgeField1 = bridgeClass.Fields[field1Name];
                    bridgeField2 = bridgeClass.Fields[field2Name];
                }
                else
                {
                    bridgeField1 = bridgeClass.Fields[field2Name];
                    bridgeField2 = bridgeClass.Fields[field1Name];
                }

                if (bridgeField2 == null)
                {
                    continue;
                }

                string relatedClassName = bridgeField2.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceMetaClassName, string.Empty);
                if (String.IsNullOrEmpty(relatedClassName))
                {
                    continue;
                }

                MetaClass relatedClass = MetaDataWrapper.GetMetaClassByName(relatedClassName);

                DataRow row = dt.NewRow();
                row["Name"] = bridgeClass.Name;

                // DisplayName - get from attribute or use PluralName of related class
                if (!String.IsNullOrEmpty(bridgeField1.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayBlock, string.Empty)) &&
                    bridgeField1.Attributes.ContainsKey(McDataTypeAttribute.ReferenceDisplayText))
                {
                    row["DisplayName"] = CHelper.GetResFileString(bridgeField1.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayText, string.Empty));
                }
                else
                {
                    row["DisplayName"] = CHelper.GetResFileString(relatedClass.PluralName);
                }

                // CurrentName - current class
                row["CurrentName"] = CHelper.GetResFileString(mc.FriendlyName);

                // RelatedName - related class
                if (relatedClass.Name == mc.Name)                       // if reletion with the same class
                {
                    row["RelatedName"] = CHelper.GetResFileString(mc.FriendlyName);
                }
                else
                {
                    row["RelatedName"] = CHelper.GetMetaClassAdminPageLink(relatedClass, this.Page);
                }


                // FieldTypeImageUrl
                string postfix = string.Empty;
                if (bridgeClass.Attributes.ContainsKey(MetaClassAttribute.IsSystem))
                {
                    postfix = "_sys";
                }

                row["FieldTypeImageUrl"] = String.Format(CultureInfo.InvariantCulture,
                                                         "~/images/IbnFramework/metainfo/bridge{0}.gif",
                                                         postfix);

                // Edit - we use current class, bridge class and field as params
                row["EditLink"] = String.Format("{0}?class={1}&bridge={2}&field={3}", EditFieldLink, mc.Name, bridgeClass.Name, bridgeField1.Name);

                // IsSystem
                row["IsSystem"] = bridgeClass.Attributes.ContainsKey(MetaClassAttribute.IsSystem);

                dt.Rows.Add(row);

                // we can have two references to current class from one bridge
                if (bridgeField2.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceMetaClassName, string.Empty) == mc.Name)
                {
                    row         = dt.NewRow();
                    row["Name"] = bridgeClass.Name;

                    // DisplayName - get from attribute or use PluralName
                    if (!String.IsNullOrEmpty(bridgeField2.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayBlock, string.Empty)) &&
                        bridgeField2.Attributes.ContainsKey(McDataTypeAttribute.ReferenceDisplayText))
                    {
                        row["DisplayName"] = CHelper.GetResFileString(bridgeField2.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayText, string.Empty));
                    }
                    else
                    {
                        row["DisplayName"] = CHelper.GetResFileString(mc.PluralName);
                    }

                    // CurrentName - current class
                    row["CurrentName"] = CHelper.GetResFileString(mc.FriendlyName);

                    // RelatedName - related class
                    row["RelatedName"] = CHelper.GetResFileString(mc.FriendlyName);

                    // FieldTypeImageUrl
                    postfix = string.Empty;
                    if (bridgeClass.Attributes.ContainsKey(MetaClassAttribute.IsSystem))
                    {
                        postfix = "_sys";
                    }

                    row["FieldTypeImageUrl"] = String.Format(CultureInfo.InvariantCulture,
                                                             "~/images/IbnFramework/metainfo/bridge{0}.gif",
                                                             postfix);

                    // Edit - we use current class, bridge class and field as params
                    row["EditLink"] = String.Format("{0}?class={1}&bridge={2}&field={3}", EditFieldLink, mc.Name, bridgeClass.Name, bridgeField2.Name);

                    // IsSystem
                    row["IsSystem"] = bridgeClass.Attributes.ContainsKey(MetaClassAttribute.IsSystem);

                    dt.Rows.Add(row);
                }
            }

            DataView dv = dt.DefaultView;

            if (_pc[sortKey] == null)
            {
                _pc[sortKey] = "DisplayName";
            }

            dv.Sort = _pc[sortKey];

            MainGrid.DataSource = dv;
            MainGrid.DataBind();

            foreach (GridViewRow row in MainGrid.Rows)
            {
                ImageButton ib = (ImageButton)row.FindControl("DeleteButton");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')");
                }
            }

            if (!ShowSystemInfo)
            {
                MainGrid.Columns[1].Visible = false;
            }
        }
Exemplo n.º 25
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Total", typeof(string)));
            dt.Columns.Add(new DataColumn("TotalApproved", typeof(string)));
            dt.Columns.Add(new DataColumn("Rate", typeof(string)));
            dt.Columns.Add(new DataColumn("Cost", typeof(string)));

            MetaView currentView = GetMetaView();

            currentView.Filters = GetFilters();

            McMetaViewPreference currentPreferences = CreateDefaultReportPreferenceTimeTracking(currentView);

            MetaObject[] list = currentView.List(currentPreferences);

            foreach (MetaObject mo in list)
            {
                DataRow row             = dt.NewRow();
                string  additionalTitle = string.Empty;

                string prefix  = "";
                string postfix = "";

                if (cbShowWeekNumber.Checked && mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() != MetaViewGroupByType.Total.ToString())
                {
                    DateTime dtNew = DateTime.MinValue;

                    try
                    {
                        dtNew = (DateTime)mo.Properties["Title"].Value;
                    }
                    catch
                    {
                    }

                    if (dtNew != DateTime.MinValue)
                    {
                        additionalTitle = string.Format("(#{0})", Iso8601WeekNumber.GetWeekNumber((DateTime)mo.Properties["Title"].Value));
                    }
                }

                // Primary Grouping
                if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Primary.ToString())
                {
                    prefix  = "<b>";
                    postfix = "</b>";
                    if (GroupingList.SelectedValue == GroupingWeekUser)
                    {
                        row["Title"] = String.Format("{0}{1} - {2}{3} {4}", prefix, ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), prefix, additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("{0}{1}{2} {3}", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                    }
                }
                // Secondary Grouping
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Secondary.ToString())
                {
                    prefix  = "<b>";
                    postfix = "</b>";
                    if (GroupingList.SelectedValue == GroupingUserWeek)
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0}{1} - {2}{3} {4}</div>", prefix, ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), prefix, additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0}{1}{2} {3}</div>", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                    }
                }
                // Total
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Total.ToString())
                {
                    prefix       = "<b>";
                    postfix      = "</b>";
                    row["Title"] = String.Format("{0}{1}{2} {3}", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                }
                // Other
                else
                {
                    row["Title"] = String.Format("<div style='padding-left: 50px;'>{0} {1}</div>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                    row["Rate"]  = String.Format("{0}{1:F2}{2}", prefix, Convert.ToDecimal(mo.Properties["Rate"].Value), postfix);
                }

                row["Total"]         = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["DayT"].Value) / 60, Convert.ToInt32(mo.Properties["DayT"].Value) % 60, postfix);
                row["TotalApproved"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["TotalApproved"].Value) / 60, Convert.ToInt32(mo.Properties["TotalApproved"].Value) % 60, postfix);
                row["Cost"]          = String.Format("{0}{1:F2}{2}", prefix, Convert.ToDecimal(mo.Properties["Cost"].Value), postfix);

                dt.Rows.Add(row);
            }

            // Header Text
            for (int i = 0; i < MainGrid.Columns.Count; i++)
            {
                MetaField field = currentPreferences.GetVisibleMetaField()[i];

                MainGrid.Columns[i].HeaderText = CHelper.GetResFileString(field.FriendlyName);
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();
        }
Exemplo n.º 26
0
        /// <summary>
        /// Internals the bind.
        /// </summary>
        private void internalBind()
        {
            MainGrid.Columns.Clear();

            McMetaViewPreference mvPref = GetMetaViewPreference();

            MainGrid.AllowPaging = true;

            if (mvPref.Attributes["PageSize"] != null)
            {
                int pageSize = Convert.ToInt32(mvPref.Attributes.GetValue("PageSize").ToString());
                if (pageSize != -1)
                {
                    MainGrid.PageSize = pageSize;
                }
                else
                {
                    MainGrid.PageSize = 10000;
                    //MainGrid.AllowPaging = false;
                }

                //CHelper.SafeSelect(ddPaging, mvPref.Attributes.Get("PageSize").ToString());
            }
            else
            {
                MainGrid.PageSize = 10;
                mvPref.Attributes.Set("PageSize", 10);
                Mediachase.Ibn.Core.UserMetaViewPreference.Save((int)DataContext.Current.CurrentUserId, mvPref);
            }

            int width = 0;

            if (this.ShowCheckboxes)
            {
                width += 22 + 7;
            }

            #region Check Additional columns from xml

            foreach (MetaGridCustomColumnInfo customColumn in this.CustomColumns)
            {
                MainGrid.Columns.Add(customColumn.Column);
                width += customColumn.Width + 7;
            }

            #endregion


            int counter = 0;
            foreach (MetaField field in this.VisibleMetaFields)
            {
                int cellWidth = 0;

                if (PlaceName == String.Empty)
                {
                    MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field));
                }
                else
                {
                    MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field, PlaceName));
                }


                cellWidth = mvPref.GetMetaFieldWidth(counter, 100);
                if (cellWidth == 0)
                {
                    cellWidth = 100;
                }
                width += cellWidth;

                counter++;
            }

            width += this.VisibleMetaFields.Length * 7;


            MainGrid.Width = width;

            #region Adding PrimaryKeyColumn
            MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetCssColumn(this.Page, CurrentView.MetaClass.Name));
            #endregion

            internalBindHeader();

            FilterElement fe = null;

            if (this.SearchKeyword != string.Empty)
            {
                fe = ListManager.CreateFilterByKeyword(mvPref.MetaView.MetaClass, this.SearchKeyword);
                mvPref.Filters.Add(fe);
            }

            MetaObject[] list = CurrentView.List(mvPref);

            if (fe != null)
            {
                mvPref.Filters.Remove(fe);
            }

            if (CurrentView.PrimaryGroupBy == null && CurrentView.SecondaryGroupBy == null)
            {
                MainGridExt.IsEmpty = (list.Length == 0);

                if (list.Length == 0)
                {
                    list = new MetaObject[] { new MetaObject(CurrentView.MetaClass) };
                }

                MainGrid.DataSource = list;
            }
            else
            {
                if (CurrentView.SecondaryGroupBy != null)
                {
                    list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Secondary, CurrentView.SecondaryGroupBy, CurrentView.PrimaryGroupBy, mvPref, list);
                }

                list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Primary, CurrentView.PrimaryGroupBy, null, mvPref, list);

                MainGridExt.IsEmpty = (list.Length == 0);

                if (list.Length == 0)
                {
                    list = new MetaObject[] { new MetaObject(CurrentView.MetaClass) };
                }

                MainGrid.DataSource = list;
            }

            this.Count = list.Length;
            if (MainGridExt.IsEmpty)
            {
                this.Count = 0;
            }
            MainGrid.DataBind();

            internalBindPaging();

            if (list.Length == 0)
            {
                MainGrid.CssClass = "serverGridBodyEmpty";
            }
        }
Exemplo n.º 27
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Day1", typeof(string)));
            dt.Columns.Add(new DataColumn("Day2", typeof(string)));
            dt.Columns.Add(new DataColumn("Day3", typeof(string)));
            dt.Columns.Add(new DataColumn("Day4", typeof(string)));
            dt.Columns.Add(new DataColumn("Day5", typeof(string)));
            dt.Columns.Add(new DataColumn("Day6", typeof(string)));
            dt.Columns.Add(new DataColumn("Day7", typeof(string)));
            dt.Columns.Add(new DataColumn("DayT", typeof(string)));
            dt.Columns.Add(new DataColumn("StateFriendlyName", typeof(string)));

            MetaView currentView = GetMetaView();

            currentView.Filters = GetFilters();

            McMetaViewPreference currentPreferences = Mediachase.UI.Web.Util.CommonHelper.CreateDefaultReportPreferenceTimeTracking(currentView);

            MetaObject[] list = null;
            if (String.Compare(Mediachase.IBN.Business.Configuration.Domain, "ibn47.mediachase.net", true) == 0)
            {
                list = currentView.List(currentPreferences, McRoundValues);

                // For Excel
                for (int i = 1; i <= 8; i++)
                {
                    MainGrid.Columns[i].ItemStyle.CssClass = "TdTextClass";
                }
            }
            else
            {
                list = currentView.List(currentPreferences);
            }

            foreach (MetaObject mo in list)
            {
                DataRow row = dt.NewRow();

                string additionalTitle = string.Empty;
                string prefix          = "";
                string postfix         = "";

                if (cbShowWeekNumber.Checked && mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() != MetaViewGroupByType.Total.ToString())
                {
                    DateTime dtNew = DateTime.MinValue;

                    try
                    {
                        dtNew = (DateTime)mo.Properties["Title"].Value;
                    }
                    catch
                    {
                    }

                    if (dtNew != DateTime.MinValue)
                    {
                        additionalTitle = string.Format("(#{0})", Iso8601WeekNumber.GetWeekNumber((DateTime)mo.Properties["Title"].Value));
                    }
                }

                if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Primary.ToString())
                {
                    prefix  = "<b>";
                    postfix = "</b>";
                    if (GroupingList.SelectedValue == GroupingWeekUser)
                    {
                        row["Title"] = String.Format("{0}{1} - {2}{3} {4}", prefix, ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), prefix, additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("{0}{1}{2} {3}", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                    }
                }
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Secondary.ToString())
                {
                    prefix  = "<b>";
                    postfix = "</b>";
                    if (GroupingList.SelectedValue == GroupingUserWeek)
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0}{1} - {2}{3} {4}</div>", prefix, ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), prefix, additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0}{1}{2} {3}</div>", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                    }
                }
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Total.ToString())
                {
                    prefix       = "<b>";
                    postfix      = "</b>";
                    row["Title"] = String.Format("{0}{1}{2} {3}", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                }
                else
                {
                    row["Title"] = String.Format("<div style='padding-left: 50px;'>{0} {1}</div>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                }

                if (String.Compare(Mediachase.IBN.Business.Configuration.Domain, "ibn47.mediachase.net", true) == 0)
                {
                    if (mo.Properties["MetaViewGroupByType"] == null || (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Total.ToString()) || (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Secondary.ToString()))
                    {
                        row["Day1"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day1"].Value) / 60.0, postfix);
                        row["Day2"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day2"].Value) / 60.0, postfix);
                        row["Day3"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day3"].Value) / 60.0, postfix);
                        row["Day4"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day4"].Value) / 60.0, postfix);
                        row["Day5"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day5"].Value) / 60.0, postfix);
                        row["Day6"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day6"].Value) / 60.0, postfix);
                        row["Day7"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day7"].Value) / 60.0, postfix);
                        row["DayT"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["DayT"].Value) / 60.0, postfix);
                    }
                }
                else
                {
                    row["Day1"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day1"].Value) / 60, Convert.ToInt32(mo.Properties["Day1"].Value) % 60, postfix);
                    row["Day2"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day2"].Value) / 60, Convert.ToInt32(mo.Properties["Day2"].Value) % 60, postfix);
                    row["Day3"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day3"].Value) / 60, Convert.ToInt32(mo.Properties["Day3"].Value) % 60, postfix);
                    row["Day4"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day4"].Value) / 60, Convert.ToInt32(mo.Properties["Day4"].Value) % 60, postfix);
                    row["Day5"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day5"].Value) / 60, Convert.ToInt32(mo.Properties["Day5"].Value) % 60, postfix);
                    row["Day6"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day6"].Value) / 60, Convert.ToInt32(mo.Properties["Day6"].Value) % 60, postfix);
                    row["Day7"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day7"].Value) / 60, Convert.ToInt32(mo.Properties["Day7"].Value) % 60, postfix);
                    row["DayT"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["DayT"].Value) / 60, Convert.ToInt32(mo.Properties["DayT"].Value) % 60, postfix);
                }

                if (mo.Properties["StateFriendlyName"].Value != null)
                {
                    row["StateFriendlyName"] = CHelper.GetResFileString(mo.Properties["StateFriendlyName"].Value.ToString());
                }
                else
                {
                    row["StateFriendlyName"] = "";
                }

                dt.Rows.Add(row);
            }

            // Header Text
            for (int i = 0; i < MainGrid.Columns.Count; i++)
            {
                MetaField field     = currentPreferences.GetVisibleMetaField()[i];
                string    fieldName = field.Name;

                // First day of week can be different, so we should specify it.
                if (fieldName == "Day1" || fieldName == "Day2" || fieldName == "Day3" || fieldName == "Day4" || fieldName == "Day5" || fieldName == "Day6" || fieldName == "Day7")
                {
                    DateTime curDate = CHelper.GetRealWeekStartByDate(DateTime.UtcNow);
                    if (fieldName == "Day2")
                    {
                        curDate = curDate.AddDays(1);
                    }
                    else if (fieldName == "Day3")
                    {
                        curDate = curDate.AddDays(2);
                    }
                    else if (fieldName == "Day4")
                    {
                        curDate = curDate.AddDays(3);
                    }
                    else if (fieldName == "Day5")
                    {
                        curDate = curDate.AddDays(4);
                    }
                    else if (fieldName == "Day6")
                    {
                        curDate = curDate.AddDays(5);
                    }
                    else if (fieldName == "Day7")
                    {
                        curDate = curDate.AddDays(6);
                    }

                    MainGrid.Columns[i].HeaderText = GetGlobalResourceObject("IbnFramework.TimeTracking", curDate.DayOfWeek.ToString()).ToString();
                }
                else
                {
                    MainGrid.Columns[i].HeaderText = CHelper.GetResFileString(field.FriendlyName);
                }
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();
        }
Exemplo n.º 28
0
        private void BindData()
        {
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("DisplayName", typeof(string));
            dt.Columns.Add("PrimaryName", typeof(string));
            dt.Columns.Add("RelatedName", typeof(string));
            dt.Columns.Add("FieldTypeImageUrl", typeof(string));
            dt.Columns.Add("EditLink", typeof(string));
            dt.Columns.Add("IsSystem", typeof(bool));

            foreach (MetaField field in mc.GetReferences())
            {
                DataRow row = dt.NewRow();
                row["Name"] = field.Name;

                // DisplayName
                row["DisplayName"] = CHelper.GetResFileString(field.FriendlyName);

                // PrimaryName - referenced class.Link or text
                string refClassName = field.Attributes[McDataTypeAttribute.ReferenceMetaClassName].ToString();
                row["PrimaryName"] = CHelper.GetMetaClassAdminPageLink(refClassName, this.Page);

                // RelatedName - current class
                row["RelatedName"] = CHelper.GetResFileString(mc.FriendlyName);

                // FieldTypeImageUrl
                string postfix = string.Empty;
                if (field.Attributes.ContainsKey(MetaClassAttribute.IsSystem))
                {
                    postfix = "_sys";
                }

                row["FieldTypeImageUrl"] = String.Format(CultureInfo.InvariantCulture,
                                                         "~/images/IbnFramework/metainfo/reference{0}.gif",
                                                         postfix);

                // Edit - we use current class and field as params
                row["EditLink"] = String.Format(CultureInfo.InvariantCulture,
                                                "{0}?class={1}&field={2}&mode=N1",
                                                EditFieldLink,
                                                mc.Name,
                                                field.Name);

                // IsSystem
                row["IsSystem"] = field.Attributes.ContainsKey(MetaClassAttribute.IsSystem) || mc.TitleFieldName == field.Name;

                dt.Rows.Add(row);
            }

            DataView dv = dt.DefaultView;

            if (_pc[sortKey] == null)
            {
                _pc[sortKey] = "DisplayName";
            }

            dv.Sort = _pc[sortKey];

            MainGrid.DataSource = dv;
            MainGrid.DataBind();

            foreach (GridViewRow row in MainGrid.Rows)
            {
                ImageButton ib = (ImageButton)row.FindControl("DeleteButton");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')");
                }
            }

            if (!ShowSystemInfo)
            {
                MainGrid.Columns[1].Visible = false;
            }
        }
Exemplo n.º 29
0
        private void BindGrid()
        {
            if (!this.Visible)
            {
                return;
            }

            // DataTable structure
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add(idColumn, typeof(string));
            dt.Columns.Add(roleColumn, typeof(string));
            dt.Columns.Add(classColumn, typeof(string));

            CustomTableRow[] classRights = CustomTableRow.List(SqlContext.Current.Database.Tables[Mediachase.Ibn.Data.Services.Security.BaseRightsTableName],
                                                               FilterElement.EqualElement("ClassOnly", 1));

            foreach (SecurityRight right in Mediachase.Ibn.Data.Services.Security.GetMetaClassRights(mc.Name))
            {
                // Check for Class Right (ex. Create)
                bool   isClassRight = false;
                string rightUid     = right.BaseRightUid.ToString();
                foreach (CustomTableRow r in classRights)
                {
                    if (r["BaseRightUid"].ToString() == rightUid)
                    {
                        isClassRight = true;
                        break;
                    }
                }
                if (isClassRight)
                {
                    continue;
                }

                dt.Columns.Add(right.RightName, typeof(string));
            }
            dt.Columns.Add(editColumn, typeof(string));

            // Fill data
            DataRow dr;

            foreach (MetaObject mo in Mediachase.Ibn.Data.Services.RoleManager.GetObjectRoleItems(mc.Name))
            {
                string roleName = mo.Properties["RoleName"].Value.ToString();

                dr             = dt.NewRow();
                dr[idColumn]   = mo.PrimaryKeyId;
                dr[roleColumn] = CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString());
                if (mo.Properties["ClassName"].Value != null)
                {
                    string className = (string)mo.Properties["ClassName"].Value;
                    if (className.Contains("::"))
                    {
                        string[] s = new string[] { "::" };
                        className = className.Split(s, StringSplitOptions.None)[0];
                    }
                    dr[classColumn] = className;
                    dr[roleColumn] += String.Format(CultureInfo.InvariantCulture,
                                                    " ({0})",
                                                    CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(className).PluralName));
                }

                for (int i = 1; i < MainGrid.Columns.Count - 1; i++)
                {
                    BoundField rightsField = MainGrid.Columns[i] as BoundField;
                    if (rightsField != null)
                    {
                        string fieldName = rightsField.DataField;
                        dr[fieldName] = CHelper.GetPermissionImage((int)mo.Properties[fieldName].Value);
                    }
                }

                string url = String.Format(CultureInfo.InvariantCulture,
                                           "javascript:ShowWizard(&quot;{5}?ClassName={0}&btn={1}&Role={2}&quot;, {3}, {4});",
                                           mc.Name,
                                           Page.ClientScript.GetPostBackEventReference(RefreshButton, ""),
                                           roleName,
                                           dialogWidth, dialogHeight,
                                           ResolveUrl("~/Apps/Security/Pages/Admin/ObjectRoleEdit.aspx"));
                dr[editColumn] = String.Format(CultureInfo.InvariantCulture,
                                               "<a href=\"{0}\"><img src=\"{1}\" title=\"{2}\" width=\"16\" height=\"16\" border=\"0\" /></a>",
                                               url,
                                               ResolveUrl("~/Images/IbnFramework/edit.gif"),
                                               GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Edit").ToString());

                dt.Rows.Add(dr);
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();
        }