Beispiel #1
0
        /// <summary>
        /// Returns a new RepeaterItemEventHandler which sets hidden lookup code ids
        /// as well as bind child checkboxes and check items in relationship
        /// </summary>
        /// <param name="lkpFieldName"></param>
        /// <returns></returns>
        private RepeaterItemEventHandler GetRelationRptrBoundHandler(string lkpFieldName)
        {
            RepeaterItemEventHandler itemBoundHandler = new RepeaterItemEventHandler(delegate(object sender, RepeaterItemEventArgs e)
            {
                string lkpId = DataBinder.Eval(e.Item.DataItem, LookupCode.LookupCodeId).ToString();
                int parLkpId = int.Parse(lkpId);

                HiddenField parLkpIdField = e.Item.FindControl("ParentLookupCodeId") as HiddenField;
                parLkpIdField.Value       = lkpId;

                Repeater curItems   = e.Item.FindControl("CurrentItemsRptr") as Repeater;
                DataTable rptrCodes = da.GetLookupsByFieldName(lkpFieldName).Tables[0];
                curItems.DataSource = rptrCodes;
                curItems.DataBind();

                DataTable childCodes = da.GetChildCodesByLookupIdAndChildLookupName(parLkpId, lkpFieldName);
                foreach (RepeaterItem item in curItems.Items)
                {
                    CheckBox childCheckBox      = item.FindControl("CurrentItemCheckBox") as CheckBox;
                    HiddenField childLkpIdField = item.FindControl("LookupCodeId") as HiddenField;
                    if (!string.IsNullOrEmpty(childLkpIdField.Value))
                    {
                        // See if this item (child lookupcodeid) is in childCode list
                        // and determine if item should be checked
                        string sqlFindChildCode = "ParentCodeId = " + lkpId + " AND ChildCodeId = " + childLkpIdField.Value;
                        if (childCodes.Select(sqlFindChildCode).Length > 0)
                        {
                            childCheckBox.Checked = true;
                        }
                    }
                }
            });

            return(itemBoundHandler);
        }
Beispiel #2
0
        protected virtual void OnNoneItemsDataBound(RepeaterItemEventArgs e)
        {
            RepeaterItemEventHandler handler = (RepeaterItemEventHandler)base.Events[EventNoneItemsDataBound];

            if (handler != null)
            {
                handler(this, e);
            }
        }
Beispiel #3
0
        protected virtual void OnItemDataBound(RepeaterItemEventArgs e)
        {
            RepeaterItemEventHandler h = (RepeaterItemEventHandler)Events [ItemDataBoundEvent];

            if (h != null)
            {
                h(this, e);
            }
        }
Beispiel #4
0
        /// <devdoc>
        /// <para>A protected method. Raises the <see langword='ItemDataBound'/>
        /// event.</para>
        /// </devdoc>
        protected virtual void OnItemDataBound(RepeaterItemEventArgs e)
        {
            RepeaterItemEventHandler onItemDataBoundHandler = (RepeaterItemEventHandler)Events[EventItemDataBound];

            if (onItemDataBoundHandler != null)
            {
                onItemDataBoundHandler(this, e);
            }
        }
        protected virtual void OnItemCreated(RepeaterItemEventArgs e)
        {
            RepeaterItemEventHandler handler = (RepeaterItemEventHandler)base.Events[EventItemCreated];

            if (handler != null)
            {
                handler(this, e);
            }
        }
        protected virtual void OnItemDataBound(RepeaterItemEventArgs rie)
        {
            RepeaterItemEventHandler repeaterItemEventDelegate =
                (RepeaterItemEventHandler)Events[ItemDataBoundKey];

            if (repeaterItemEventDelegate != null)
            {
                repeaterItemEventDelegate(this, rie);
            }
        }
Beispiel #7
0
        public static void RepeaterBind <T>(System.Web.UI.WebControls.Repeater repeater, IList <T> dataSource, int paginaAtual, int qtdRegistrosPagina, int totalRegistros, int[] opcoesRegistroPagina, PopularDropDownListOrdernacao popularDropDownListOrdernacao, RepeaterItemEventHandler onItemDataBound)
        {
            int nroPaginas = (int)Math.Ceiling((decimal)totalRegistros / qtdRegistrosPagina);

            if (nroPaginas <= paginaAtual)
            {
                paginaAtual = nroPaginas - 1;
            }
            if (paginaAtual < 0)
            {
                paginaAtual = 0;
            }

            if (opcoesRegistroPagina == null)
            {
                opcoesRegistroPagina = new int[] { 20, 40, 60, 80, 100, 160, 200 }
            }
            ;

            DadosDatabound = new CarregaDadosDatabound()
            {
                PaginaAtual = paginaAtual, TotalPaginas = nroPaginas, QtdRegistrosPagina = qtdRegistrosPagina, TotalRegistros = totalRegistros, OpcoesRegistroPagina = opcoesRegistroPagina, PopularDropDownListOrdernacao = popularDropDownListOrdernacao, OnItemDataBound = onItemDataBound
            };

            repeater.ItemDataBound += new RepeaterItemEventHandler(repeater_ItemDataBound);
            repeater.DataSource     = dataSource;
            repeater.DataBind();

            DadosDatabound = null;
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BindStudyItems(object sender, RepeaterItemEventArgs schemaItemArg)
        {
            RepeaterItem schemaItemRow = schemaItemArg.Item;

            if (schemaItemRow.ItemType == ListItemType.Header || schemaItemRow.ItemType == ListItemType.Item || schemaItemRow.ItemType == ListItemType.AlternatingItem)
            {
                // Locate child PreStudy and OnStudy Repeaters
                Repeater     preStudyItems     = schemaItemRow.FindControl(PRE_STUDY_RPTR_ID) as Repeater;
                Repeater     onStudyItems      = schemaItemRow.FindControl(ON_STUDY_RPTR_ID) as Repeater;
                CaisisHidden schemaItemIdField = schemaItemRow.FindControl("SchemaItemIdField") as CaisisHidden;

                // Set Schema-Item Field
                if (schemaItemIdField != null)
                {
                    schemaItemIdField.Value = DataBinder.Eval(schemaItemRow.DataItem, SchemaItem.SchemaItemId).ToString();
                }

                // When SchemaItem is binding, bind child PreStudy and OnStudy Repeaters
                // These columns will be the assciation between a SchemaItem (row) and Timeline (col)
                schemaItemRow.DataBinding += new EventHandler(delegate(object schemaItemRptr, EventArgs schemaItemArgs)
                {
                    preStudyItems.DataSource = PreStudyTimeline;
                    preStudyItems.DataBind();

                    onStudyItems.DataSource = OnStudyTimeline;
                    onStudyItems.DataBind();
                });

                // CLOSURES

                // A method which returns and RepeaterItemEventHandler used for handling the creation
                // of each column/checkbox, containing logic for updating/populating the ItemTimeline table
                ProtocolRptrCreator GetCreator = new ProtocolRptrCreator(delegate(Repeater mirrorRptr)
                {
                    // Create a new instance of the OnItemCreate Handler
                    RepeaterItemEventHandler creationHandler = new RepeaterItemEventHandler(delegate(object o, RepeaterItemEventArgs timelineItemEventArg)
                    {
                        if (timelineItemEventArg.Item.ItemType == ListItemType.Item || timelineItemEventArg.Item.ItemType == ListItemType.AlternatingItem)
                        {
                            // Repeater item repsents a ItemTimline columns in current SchemaItem row
                            RepeaterItem itemTimelineCol = timelineItemEventArg.Item;
                            // This Timeline data entry layer will contain the foreign TimelineId record
                            // During inserts and update of ItemTime records, foreign key will come from this
                            RepeaterItem timelineDataEntryCol = mirrorRptr.Items[itemTimelineCol.ItemIndex];

                            // Current Timeline Index
                            int colIndex = timelineDataEntryCol.ItemIndex;
                            // Current SchemaItem
                            int rowIndex = schemaItemRow.ItemIndex;

                            bool isRowColumnDirty = false;

                            PlaceHolder colCheckBoxHolder = itemTimelineCol.FindControl("CheckBoxHolder") as PlaceHolder;

                            // Create anonmous EventHandler to determine checkbox state when binding to data
                            itemTimelineCol.DataBinding += new EventHandler(delegate(object oo, EventArgs ee)
                            {
                                string timelineId   = DataBinder.Eval(itemTimelineCol.DataItem, Timeline.TimelineId).ToString();
                                string schemaItemId = schemaItemIdField.Value;

                                if (!string.IsNullOrEmpty(schemaItemId) && !string.IsNullOrEmpty(timelineId))
                                {
                                    // If ItemTimeline records are found based, check check-box
                                    DataRow[] foundRecords = FindItemTimelineRecords(schemaItemId, timelineId);
                                    if (foundRecords.Length > 0)
                                    {
                                        // checkbox chcked
                                        Image img    = new Image();
                                        img.ID       = "ColCheckBox";
                                        img.ImageUrl = "Images/Review_Check.PNG";

                                        colCheckBoxHolder.Controls.Add(img);
                                    }
                                    else
                                    {
                                        //colCheckBox.Checked = false;
                                    }
                                }
                                else
                                {
                                    //colCheckBox.Checked = false;
                                }
                            });
                        }
                    });
                    return(creationHandler);
                });

                // During ItemCreation of TimelineItems
                if (schemaItemRow.ItemType == ListItemType.Item || schemaItemRow.ItemType == ListItemType.AlternatingItem)
                {
                    // Attach Handlers
                    preStudyItems.ItemCreated += GetCreator(PreStudyItemsLayerRptr);
                    onStudyItems.ItemCreated  += GetCreator(OnStudyItemsLayerRptr);
                }
            }
        }