Esempio n. 1
0
        private string GetCustomAttributeVale(IExtendable extendable, PVIMS.Core.Entities.CustomAttributeConfiguration customAttribute)
        {
            var attributeValue = extendable.GetAttributeValue(customAttribute.AttributeKey);

            if (attributeValue == null)
            {
                return(string.Empty);
            }

            if (customAttribute.CustomAttributeType == CustomAttributeType.DateTime)
            {
                DateTime datetimeValue = DateTime.MinValue;

                if (DateTime.TryParse(attributeValue.ToString(), out datetimeValue))
                {
                    return(datetimeValue.ToString("yyyy-MM-dd"));
                }
                else
                {
                    return(string.Empty);
                }
            }
            else
            {
                return(attributeValue.ToString());
            }
        }
Esempio n. 2
0
        private string GetCustomAttributeValue(CustomAttributeConfiguration config, IExtendable extended)
        {
            if (extended.GetAttributeValue(config.AttributeKey) == null)
            {
                return("");
            }
            ;

            var val = extended.GetAttributeValue(config.AttributeKey).ToString();

            if (config.CustomAttributeType == CustomAttributeType.Selection)
            {
                var selection = unitOfWork.Repository <SelectionDataItem>().Queryable().SingleOrDefault(s => s.AttributeKey == config.AttributeKey && s.SelectionKey == val);
                return(selection.Value);
            }
            else
            {
                return(val);
            }
        }
Esempio n. 3
0
        private void RenderCustomValue(CustomAttributeConfiguration con)
        {
            if (con == null)
            {
                return;
            }
            ;

            DropDownList      ddl;
            TextBox           txt;
            Label             lbl;
            SelectionDataItem tempSDI;

            lbl    = new Label();
            lbl.ID = string.Format("lbl{0}", con.Id);
            lbl.Attributes.Add("class", "input");

            // Add mode so initialise value
            switch (con.CustomAttributeType)
            {
            case CustomAttributeType.String:
                txt    = new TextBox();
                txt.ID = "txt" + con.Id;
                txt.Attributes.Add("type", "text");
                txt.Text = "";
                if (con.StringMaxLength.HasValue)
                {
                    txt.Attributes.Add("maxlength", con.StringMaxLength.Value.ToString());
                }
                lbl.Controls.Add(txt);
                break;

            case CustomAttributeType.DateTime:
                txt          = new TextBox();
                txt.TextMode = TextBoxMode.Date;
                if (con.FutureDateOnly)
                {
                    txt.Attributes.Add("min", DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));
                }
                if (con.PastDateOnly)
                {
                    txt.Attributes.Add("max", DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"));
                }
                txt.ID   = "txt" + con.Id;
                txt.Text = "";
                lbl.Controls.Add(txt);
                break;

            case CustomAttributeType.Numeric:
                txt          = new TextBox();
                txt.TextMode = TextBoxMode.Number;
                if (con.NumericMinValue.HasValue)
                {
                    txt.Attributes.Add("min", con.NumericMinValue.Value.ToString());
                }
                if (con.NumericMaxValue.HasValue)
                {
                    txt.Attributes.Add("max", con.NumericMaxValue.Value.ToString());
                }
                txt.ID   = "txt" + con.Id;
                txt.Text = "";
                lbl.Controls.Add(txt);
                break;

            case CustomAttributeType.Selection:
                ddl          = new DropDownList();
                ddl.ID       = "ddl" + con.Id;
                ddl.CssClass = "form-control";
                // Populate drop down list
                ddl.Items.Add(new ListItem("", ""));
                foreach (var sdi in UnitOfWork.Repository <SelectionDataItem>().Queryable().Where(h => h.AttributeKey == con.AttributeKey).ToList())
                {
                    ddl.Items.Add(new ListItem(sdi.Value, sdi.SelectionKey));
                }
                lbl.Controls.Add(ddl);
                break;
            }

            lblCustomValue.Visible = true;
            spnCustomValue.Controls.Add(lbl);
        }