Exemplo n.º 1
0
        protected void AddOnClickEventsToRBs(RepeaterItem item, CICCombined c)
        {
            CheckBox cb = (CheckBox)item.FindControl("CheckBoxCollect");

            if (cb != null)
            {
                cb.Attributes.Add("onClick", GetOnClickJavascript(c, cb.ClientID));
            }
        }
Exemplo n.º 2
0
        private string GetOnClickJavascript(CICCombined c, string cbId)
        {
            Control _c       = c.CICParent as Control;
            Control _c_child = c.CICChild as Control;

            if (_c is CaisisCheckBox)
            {
                return(string.Format("toggleUserEntered_CheckBox('{0}', '{1}')", _c.ClientID, cbId));
            }
            else
            {
                string childId = _c_child != null ? _c_child.ClientID : "";
                return(string.Format("toggleUserEntered('{0}', '{1}', '{2}')", _c.ClientID, childId, cbId));
            }
        }
Exemplo n.º 3
0
        // Add dynamic Caisis controls
        protected void PopulateItemValues(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item ||
                e.Item.ItemType == ListItemType.AlternatingItem)
            {
                PlaceHolder presetPanel =
                    (PlaceHolder)e.Item.FindControl("DynamicControlHolder");
                if (presetPanel != null)
                {
                    if (e.Item.DataItem is CICCombined)
                    {
                        CICCombined _c = e.Item.DataItem as CICCombined;
                        if (_c.CICParent is ICaisisInputControl)
                        {
                            ICaisisInputControl cisControl = _c.CICParent as ICaisisInputControl;
                            cisControl.ShowLabel = false;

                            Label attrName =
                                (Label)e.Item.FindControl("ItemAttrName");
                            if (cisControl.Required)
                            {
                                attrName.CssClass = "requiredField";
                            }

                            CheckBox checkBoxCollect = (CheckBox)e.Item.FindControl("CheckBoxCollect");

                            if (attrName != null)
                            {
                                attrName.Text = cisControl.FieldLabel;
                            }

                            string controlValue = GetFieldValue(cisControl.Field);

                            if (String.IsNullOrEmpty(controlValue) ||
                                controlValue.Equals("[enter]"))
                            {
                                cisControl.CssClass = "UnEditable";
                            }

                            presetPanel.Controls.Add((Control)_c.CICParent);

                            // Populate radio buttons and controls
                            if (!IsPostBack)
                            {
                                RestoreRadioButtonsState(controlValue, e.Item);
                                cisControl.Value = controlValue == "[enter]" ? "" : controlValue;
                            }

                            if (_c.CICChild != null &&
                                _c.CICChild is CaisisHidden)
                            {
                                _c.CICChild.Value = GetFieldValue(_c.CICChild.Field);
                                presetPanel.Controls.Add((Control)_c.CICChild);
                            }

                            // add events so the entry item changes its state
                            AddOnClickEventsToRBs(e.Item, _c);

                            AddOnClickEventsToControls(e.Item, _c.CICParent);

                            HandleNonNullFields(e.Item, _c.CICParent);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
            // copy and paste; ugh, but you c/n override static methods
            public static List <CICCombined> GetCaisisInputControlsByTableName(string tableName)
            {
                List <CICCombined> cicList = new List <CICCombined>();
                // get metadata
                var fieldMetadata = ProtocolMgmtController.GetTableFieldsMetadata(tableName);

                foreach (var field in fieldMetadata)
                {
                    string fieldName = field.Key;
                    Dictionary <string, string> metadata = new Dictionary <string, string>(field.Value);
                    bool   required    = BOL.BusinessObject.IsRequired(tableName, fieldName, null);
                    string controlType = metadata.ContainsKey(CONTROLTYPE) ? metadata[CONTROLTYPE] : "";
                    if (controlType.Equals(""))
                    {
                        controlType = typeof(CaisisTextBox).Name;
                    }

                    // eliminate LookupDistinct that references PatientId, UserName
                    if (metadata.ContainsKey("LookupDistinct"))
                    {
                        string lkpDistint = metadata["LookupDistinct"];
                        if (!string.IsNullOrEmpty(lkpDistint) && lkpDistint.Contains("@"))
                        {
                            metadata.Remove("LookupDistinct");
                        }
                    }

                    ICaisisInputControl cic = InvokeInputControl(controlType);
                    cic.Field = fieldName;
                    cic.Table = tableName;

                    // set its metadata based attributes
                    SetCICAttributes(cic, metadata);

                    // set required from db if not set via metadata
                    if (!cic.Required && BOL.BusinessObjectFactory.CanBuildBusinessObject(tableName))
                    {
                        cic.Required = required;
                    }

                    CICCombined cicCombined = new CICCombined();
                    cicCombined.CICParent = cic;

                    // if it's a fuzzy date, add to the previous control
                    if (cicList.Count() > 0 && cic is CaisisHidden)
                    {
                        CICCombined cicTop = cicList[cicList.Count - 1];
                        if (cicTop.CICParent is CaisisTextBox &&
                            ((CaisisTextBox)cicTop.CICParent).CalcDate)
                        {
                            cicTop.CICChild = cic;
                        }
                        else
                        {
                            // Add control to Control list
                            cicList.Add(cicCombined);
                        }
                    }
                    else
                    {
                        // Add control to Control list
                        cicList.Add(cicCombined);
                    }
                }

                return(cicList);
            }