Beispiel #1
0
        private void DataLoad()
        {
            using (DictionaryProvider domain = new DictionaryProvider())
            {
                object val = domain.GetProductDictionaryText(this.RequestDictionaryEntityID, this.DictionaryTreeID);
                //Aspect.Domain.Product prod = domain.GetProduct(this.RequestDictionaryEntityID);

                //if (prod == null) return;
                this.Title = HeaderLiteral.Text = string.Format("Редактирование {0}", val.ToString());
                if (this.IsNew) this.Title = HeaderLiteral.Text = string.Format("Добавление по аналогу {0}", val.ToString());
                HeaderDateLiteral.Text = string.Format(HeaderDateLiteral.Text, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());

                BindGeneralPropertyList();
                BindDictionaryList();
            }
        }
Beispiel #2
0
        private void BindDictionaryList(List<ITreeNode> parents, bool isEmpty)
        {
            using (DictionaryProvider provider = new DictionaryProvider())
            {
                //--- dictionary property -----
                Product product = provider.Products.SingleOrDefault(p => p.ID == this.RequestProductID);
                if (product == null) this.RedirectToErrorPage();

                List<DictionaryTree> list = provider.GetDictionaryTreeList(Guid.Empty, this.Roles);
                var q = from l in list.Where(f => f.ClassificationID.HasValue)
                        join m in parents on l.ClassificationID.Value equals m.ID
                        select new Pair<DictionaryTree, string>(l, m.Name);

                List<DictionaryDDLSource> source = new List<DictionaryDDLSource>();
                foreach (Pair<DictionaryTree, string> item in q.ToList())
                {
                    DictionaryDDLSource entity = new DictionaryDDLSource();
                    entity.DictionaryTreeID = item.First.ID;
                    //set dictionary property title
                    entity.Title = string.Format("{0} ({1})", item.First.Name, item.Second);
                    //get product dicitonary value
                    object value = provider.GetProductDicitonaryValue(this.RequestProductID, item.First.FK);

                    if (value != null && !string.IsNullOrEmpty(value.ToString()) && !isEmpty)
                    {
                        entity.ID = new Guid(value.ToString());//entity.SelectedValue = value.ToString();
                        string valueText = provider.GetProductDictionaryText(entity.ID, item.First).ToString();
                        if (!string.IsNullOrEmpty(valueText) && valueText.Trim().Length > 0) entity.ValueText = valueText;
                    }

                    source.Add(entity);
                }
                DictionaryPropertyRepeater.DataSource = source;
                DictionaryPropertyRepeater.DataBind();
            }
        }
Beispiel #3
0
        private void BindDictionaryList()
        {
            using (DictionaryProvider provider = new DictionaryProvider())
            {
                List<DictionaryTree> list = provider.GetDictionaryTreeList(this.DictionaryTreeID, this.Roles);

                List<DictionaryDDLSource> source = new List<DictionaryDDLSource>();
                foreach (DictionaryTree item in list)
                {
                    DictionaryDDLSource entity = new DictionaryDDLSource();
                    entity.DictionaryTreeID = item.ID;
                    //set dictionary property title
                    entity.Title = item.Name; //string.Format("{0} ({1})", item.First.Name, item.Second);
                    //get product dicitonary value
                    object value = provider.GetDictionaryItemValue(this.DictionaryTreeID, this.RequestDictionaryEntityID, item.FK);

                    if (value != null && !string.IsNullOrEmpty(value.ToString()))
                    {
                        entity.ID = new Guid(value.ToString());//entity.SelectedValue = value.ToString();
                        string valueText = provider.GetProductDictionaryText(entity.ID, item).ToString();
                        if (!string.IsNullOrEmpty(valueText) && valueText.Trim().Length > 0) entity.ValueText = valueText;
                    }

                    source.Add(entity);
                }
                DictionaryPropertyRepeater.DataSource = source;
                DictionaryPropertyRepeater.DataBind();
            }
        }
Beispiel #4
0
        protected void SelectorGrid_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.DataItem != null)
                {
                    if (e.Row.RowState == DataControlRowState.Alternate) e.Row.CssClass += " row2";

                    //HyperLink link = e.Row.Cells[0].FindControl("СhooseButton") as HyperLink;
                    HyperLink link = e.Row.Cells[0].Controls[0] as HyperLink;
                    link.NavigateUrl = "javascript:void(0);";
                    using (DictionaryProvider provider = new DictionaryProvider())
                    {
                        if (tree == null) tree = provider.GetDictionaryTreeNode(this.DictionaryTreeID);
                        Guid id = new Guid(DataBinder.Eval(e.Row.DataItem, /*this.ValueField*/"ID").ToString());
                        string text = provider.GetProductDictionaryText(id, tree).ToString();
                        string function;
                        if (MultiMode)
                        {
                            function = String.Format("fnSelectRow('{0}','{1}');return false;", id, text);
                            e.Row.CssClass += " " + id.ToString();

                            var pair = MultiSelection.Value.Split(';').Where(i => !String.IsNullOrEmpty(i));
            ;
                            var idsList = pair.Select(i => new Guid (i.Split(':').First()));

                            if (idsList.Contains(id)) e.Row.CssClass += " RowSelected";
                        }
                        else
                        {
                            function = String.Format("self.parent.setSelectedValue('{0}','{1}','{2}','{3}');self.parent.tb_remove();return false;", this.HiddenControlID, id, this.TextControlID, text);
                        }

                        //string function = String.Format("self.parent.setSelectedValue('{0}','{1}','{2}','{3}');self.parent.tb_remove();return false;", this.HiddenControlID, DataBinder.Eval(e.Row.DataItem, /*this.ValueField*/"ID"), this.TextControlID, DataBinder.Eval(e.Row.DataItem, this.TextField));
                        link.Attributes.Add("onclick", function);
                    }

                    e.Row.Attributes["onmouseover"] = "highLightRow(this)";
                    e.Row.Attributes["onmouseout"] = "unHighLightRow(this)";
                }
            }
        }