Example #1
0
        public static MvcHtmlString GetDataGridColumns(this HtmlHelper htmlHelper, string xmlName)
        {
            XElement        targetXml = CommonSearchDialog.GetSearchXml(xmlName);
            List <XElement> fieldList = targetXml.Element("ColumnList").Elements("column").ToList();
            List <Dictionary <string, object> > columsList = new List <Dictionary <string, object> >();
            Dictionary <string, string>         form       = new Dictionary <string, string>();
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("<table id='CommonDialogForm' data-bind='datagrid:gridSetting'>");
            sb.AppendFormat("<thead><tr>");
            foreach (var item in fieldList)
            {
                string title      = ReadXml.getXmlElementAttr(item, "title");
                string field      = ReadXml.getXmlElementAttr(item, "field");
                string hidden     = ReadXml.getXmlElementAttr(item, "hidden");
                string align      = ReadXml.getXmlElementAttr(item, "align");
                string sortable   = ReadXml.getXmlElementAttr(item, "sortable");
                string width      = ReadXml.getXmlElementAttr(item, "width");
                string formatter  = ReadXml.getXmlElementAttr(item, "formatter");
                string checkbox   = ReadXml.getXmlElementAttr(item, "checkbox");
                string gridFormat = "";
                string gridEditor = ReadXml.getXmlElementValue(item, "gridEditor");
                if (formatter != "")
                {
                    if (formatter == "gridFormat")
                    {
                        gridFormat = ReadXml.getXmlElementValue(item, "gridFormat");
                        formatter  = "";
                    }
                    else
                    {
                        formatter = string.Format("formatter='{0}'", formatter);
                    }
                }
                if (hidden != "")
                {
                    hidden = string.Format("hidden='{0}'", hidden);
                }
                if (sortable != "")
                {
                    sortable = string.Format("sortable='{0}'", sortable);
                }
                if (checkbox != "")
                {
                    checkbox = string.Format("checkbox='{0}'", checkbox);
                }
                if (!string.IsNullOrWhiteSpace(gridEditor))
                {
                    gridEditor = string.Format("editor=\"{0}\"", gridEditor);
                }
                sb.AppendFormat("<th field='{0}' {1} align='{2}' width='{3}' {4} {6} {7} {8} {9}>{5}</th>", field, sortable, align, width, formatter, title, checkbox, gridFormat, hidden, gridEditor);
            }
            sb.AppendFormat("</tr></thead></table>");
            return(MvcHtmlString.Create(sb.ToString()));
        }
Example #2
0
        public static MvcHtmlString GetSearchToolbar(this HtmlHelper htmlHelper, string xmlName)
        {
            XElement        targetXml   = CommonSearchDialog.GetSearchXml(xmlName);
            List <XElement> fieldList   = targetXml.Element("ColumnList").Elements("column").Where(f => f.Attribute("searchType") != null).ToList();
            int             coulmnIndex = 1;
            StringBuilder   sb          = new StringBuilder();

            sb.AppendFormat("<div class='container_16' style='background-color: #E0ECFF; border-bottom: 1px solid #8DB2E3;'>");
            foreach (var item in fieldList)
            {
                string searchType = item.Attribute("searchType").Value;
                string title      = item.Attribute("title").Value;
                string field      = item.Attribute("field").Value;
                if (searchType == "text")
                {
                    sb.AppendFormat("<div class='grid_2 lbl'>{0}</div>", title);
                    sb.AppendFormat("<div class='grid_4 val'><input type='text' data-bind='{0}' class='z-txt'/></div>", "value:form." + field);
                }
                if (searchType == "select")
                {
                    string type = item.Element("searchBinding").Attribute("type").Value;
                    if (type == "tree")
                    {
                        string tree = item.Element("searchBinding").Value;
                        sb.AppendFormat("<div class='grid_2 lbl'>{0}</div>", title);
                        sb.AppendFormat("<div class='grid_4 val'><input type='text' data-bind='{0}' {1} class='z-txt easyui-combotree'/></div>", "combotreeValue:form." + field, tree);
                    }
                    else if (type == "single" || type == "dictionary" || type == "fix")
                    {
                        string selectJsonData = CommonSearchDialog.GetSelectList(type, item.Element("searchBinding"));
                        sb.AppendFormat("<div class='grid_2 lbl'>{0}</div>", title);
                        sb.AppendFormat("<div class='grid_4 val'><input type='text' data-bind='{0}' class='z-txt easyui-combobox'/></div>", "comboboxValue:form." + field + ",datasource:" + selectJsonData);
                    }
                }
                if (searchType == "daterange")
                {
                    sb.AppendFormat("<div class='grid_2 lbl'>{0}</div>", title);
                    sb.AppendFormat("<div class='grid_4 val'><input type='text' data-bind='{0}' class='z-txt easyui-daterange'/></div>", "value:form." + field);
                }
                if (coulmnIndex % 2 == 0 && coulmnIndex != fieldList.Count)
                {
                    sb.AppendFormat("<div class='clear'></div>");
                }
                coulmnIndex++;
            }
            sb.AppendFormat("<div class='grid_4 val' style='float:right;'>");
            sb.AppendFormat("<a href='#' plain='true' class='easyui-linkbutton' icon='icon-search' title='查询' data-bind='click:searchClick'>查询</a>");
            sb.AppendFormat("<a href='#' plain='true' class='easyui-linkbutton' icon='icon-clear' title='清空' data-bind='click:clearClick'>清空</a>");
            sb.AppendFormat("</div>");
            sb.AppendFormat("<div class='clear'></div></div>");
            return(MvcHtmlString.Create(sb.ToString()));
        }
Example #3
0
        public ActionResult GetCommonDialogData()
        {
            //获取url中的条件,注意requestData是弹出框中的查询条件,当动态添加的查询条件不在弹出框中时,需要先将requestData中的属性删除
            var requestData = new NameValueCollection(Request.QueryString);
            //获取删选标识字段名
            string PrimaryID = requestData["PrimaryID"];

            //去掉弹出框中不需要的查询条件
            requestData.Remove("xmlName");
            //
            var xmlName = Request.QueryString["xmlName"].ToString();
            //var selectID = Request.QueryString["selectID"].ToString();
            XElement targetXml   = CommonSearchDialog.GetSearchXml(xmlName);
            var      settingsXml = targetXml.Element("settings");
            var      setting     = RequestWrapper.Instance().LoadSettingXmlString(settingsXml.ToString());

            if (Request.QueryString["PrimaryID"] != null)
            {
                requestData.Remove("PrimaryID");
            }

            if (!string.IsNullOrWhiteSpace(PrimaryID))
            {
                requestData.Remove(PrimaryID);
            }

            var query = setting.SetRequestData(requestData).ToParamQuery();

            if (!string.IsNullOrWhiteSpace(PrimaryID))
            {
                string NotInList = Request.QueryString[PrimaryID].ToString();
                if (!string.IsNullOrEmpty(NotInList))
                {
                    query.AndWhere(PrimaryID, NotInList, Cp.NotIn);
                }
            }
            var service = setting.GetService();
            var data    = service.GetDynamicListWithPaging(query);
            //if (Request.QueryString["selectID"].ToString() != "")
            //{
            //    if (data.Count() > 0)
            //    {
            //        //string sql=string.Format(@"")
            //        data = data.Where(i => !selectID.Contains(i.ID.toString())).ToList();
            //    }
            //}
            var json = JsonConvert.SerializeObject(data);

            return(Content(json, "application/json"));
        }
Example #4
0
        public ActionResult GetCommonDialogData1()
        {
            var requestData = new NameValueCollection(Request.QueryString);

            requestData.Remove("xmlName");
            var      selectID    = Request.QueryString["selectID"].ToString();
            var      xmlName     = Request.QueryString["xmlName"].ToString();
            XElement targetXml   = CommonSearchDialog.GetSearchXml(xmlName);
            var      settingsXml = targetXml.Element("settings");
            var      setting     = RequestWrapper.Instance().LoadSettingXmlString(settingsXml.ToString());
            var      query       = setting.SetRequestData(requestData).ToParamQuery();

            var service = setting.GetService();
            var data    = service.GetDynamicListWithPaging(query);
            var json    = JsonConvert.SerializeObject(data);

            return(Content(json, "application/json"));
        }
Example #5
0
        public dynamic GetCommonDialogData()
        {
            //获取url中的条件,注意requestData是弹出框中的查询条件,当动态添加的查询条件不在弹出框中时,需要先将requestData中的属性删除
            var requestData = new NameValueCollection(HttpContext.Current.Request.QueryString);
            //获取删选标识字段名
            string PrimaryID = requestData["PrimaryID"];

            //去掉弹出框中不需要的查询条件
            requestData.Remove("xmlName");
            //
            var xmlName = HttpContext.Current.Request.QueryString["xmlName"].ToString();
            //var selectID = Request.QueryString["selectID"].ToString();
            XElement targetXml   = CommonSearchDialog.GetSearchXml(xmlName);
            var      settingsXml = targetXml.Element("settings");
            var      setting     = RequestWrapper.Instance().LoadSettingXmlString(settingsXml.ToString());

            if (HttpContext.Current.Request.QueryString["PrimaryID"] != null)
            {
                requestData.Remove("PrimaryID");
            }

            if (!string.IsNullOrWhiteSpace(PrimaryID))
            {
                requestData.Remove(PrimaryID);
            }
            var query = setting.SetRequestData(requestData).ToParamQuery();

            if (!string.IsNullOrWhiteSpace(PrimaryID))
            {
                string NotInList = HttpContext.Current.Request.QueryString[PrimaryID].ToString();
                if (!string.IsNullOrEmpty(NotInList))
                {
                    query.AndWhere(PrimaryID, NotInList, Cp.NotIn);
                }
            }
            var service = setting.GetService();
            var data    = service.GetDynamicListWithPaging(query);

            return(data);
        }
Example #6
0
        public ActionResult CommonDialog2(string xmlName, string parm)
        {
            XElement                    targetXml = CommonSearchDialog.GetSearchXml(xmlName);
            List <XElement>             fieldList = targetXml.Element("ColumnList").Elements("column").ToList();
            Dictionary <string, string> form      = new Dictionary <string, string>();

            foreach (var item in fieldList)
            {
                var    searchType = item.Attribute("searchType");
                string field      = ReadXml.getXmlElementAttr(item, "field");
                if (searchType != null)
                {
                    var currentValue = "";
                    if (parm != null)
                    {
                        string[] p = parm.Split(':');
                        if (field == p[0])
                        {
                            form.Add(field, p[1]);
                        }
                        else
                        {
                            form.Add(field, currentValue);
                        }
                    }
                    else
                    {
                        form.Add(field, currentValue);
                    }
                }
            }
            var model = new
            {
                form    = form,
                xmlName = xmlName
            };

            ViewBag.xmlName = xmlName;
            return(View(model));
        }
Example #7
0
        public ActionResult CommonDialog3(string xmlName)
        {
            XElement                    targetXml = CommonSearchDialog.GetSearchXml(xmlName);
            List <XElement>             fieldList = targetXml.Element("ColumnList").Elements("column").ToList();
            Dictionary <string, string> form      = new Dictionary <string, string>();

            foreach (var item in fieldList)
            {
                var    searchType = item.Attribute("searchType");
                string field      = ReadXml.getXmlElementAttr(item, "field");
                if (searchType != null)
                {
                    form.Add(field, "");
                }
            }
            var model = new
            {
                form    = form,
                xmlName = xmlName
            };

            ViewBag.xmlName = xmlName;
            return(View(model));
        }