Ejemplo n.º 1
0
 // Modify BY QB
 // Modify:
 // Modify Date:2011-3-12
 /// <summary>
 /// 通用字典转换
 /// </summary>
 /// <param name="Module"></param>
 /// <param name="dt"></param>
 /// <returns></returns>
 public static DataTable ConvertDict(string Module, DataTable dt)
 {
     QX.DAL.ADOBse_Dict dictInstance = new QX.DAL.ADOBse_Dict();
     Sys_Config_ListPage M_Model = new Sys_Config_ListPage();
     List<Sys_Config_Fieled> D_List = new List<Sys_Config_Fieled>();
     Bll_Comm.GetListConfig(Module, out M_Model, out D_List);
     if (M_Model != null && D_List.Count > 0 && dt.Rows.Count > 0)
     {
         List<Sys_Config_Fieled> newDList = D_List.Where(o => !string.IsNullOrEmpty(o.D_DictKey)).ToList();
         for (var i = 0; i < dt.Rows.Count; i++)
         {
             foreach (var item in newDList)
             {
                 var model = dictInstance.GetListByWhere(" AND Dict_Key='" + item.D_DictKey + "' AND Dict_Code='" + dt.Rows[i][item.D_Index] + "'");
                 if (model.Count > 0)
                 {
                     dt.Rows[i][item.D_Index] = model.First().Dict_Name;
                 }
             }
         }
     }
     return dt;
 }
Ejemplo n.º 2
0
        // Modify BY QB
        // Modify:
        // Modify Date:2011-3-12
        /// <summary>
        /// 通用字典转换
        /// </summary>
        /// <param name="Module"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static DataTable ConvertDict(string Module, DataTable dt)
        {
            QX.DAL.ADOBse_Dict       dictInstance = new QX.DAL.ADOBse_Dict();
            Sys_Config_ListPage      M_Model      = new Sys_Config_ListPage();
            List <Sys_Config_Fieled> D_List       = new List <Sys_Config_Fieled>();

            Bll_Comm.GetListConfig(Module, out M_Model, out D_List);
            if (M_Model != null && D_List.Count > 0 && dt.Rows.Count > 0)
            {
                List <Sys_Config_Fieled> newDList = D_List.Where(o => !string.IsNullOrEmpty(o.D_DictKey)).ToList();
                for (var i = 0; i < dt.Rows.Count; i++)
                {
                    foreach (var item in newDList)
                    {
                        var model = dictInstance.GetListByWhere(" AND Dict_Key='" + item.D_DictKey + "' AND Dict_Code='" + dt.Rows[i][item.D_Index] + "'");
                        if (model.Count > 0)
                        {
                            dt.Rows[i][item.D_Index] = model.First().Dict_Name;
                        }
                    }
                }
            }
            return(dt);
        }
Ejemplo n.º 3
0
        public static string ChartToolBar(this HtmlHelper hepler,string Module)
        {
            string strOutput = "";
            //Bll_ChartToolBar instance=new Bll_ChartToolBar();
            //Bll_Bse_Dict dictInstance = new Bll_Bse_Dict();
            ADOChartToolBar instance = new ADOChartToolBar();
            ADOBse_Dict dictInstance = new ADOBse_Dict();
            StringBuilder strList = new StringBuilder();
            StringBuilder strJsList = new StringBuilder();
            List<ChartToolBar> list = instance.GetListByWhere(" AND CT_Module='"+Module+"' ").OrderBy(o=>o.CT_Order).ToList();

            //form_textbox  TextBoxReadOnly  popup date
            string Bar_Begin = @"<div id='" + Module + "' class='toolbar_chart'> <ul>";
            string Bar_End = @"</ul>
                                    <div style='clear:both'></div>
                               </div>";
            string Li_Hidden = @"<input type='hidden' name='{CT_Field}' id='{CT_Field}' value='{CT_Default}'>";
            string Li_Input = @"<input type='text' {CT_Attr}  name='{CT_Field}' id='{CT_Field}' value='{CT_Default}'>";
            string Li_Template= @"<li style='float: left'><span>{CT_Name}:</span> {Element} </li>";
            string Li_ButtonDiv = @"<li class='toolbar_btn' style='float: left'>{Element} </li>";
            string Li_Select = @"<select name='{CT_Field}' id='{CT_Field}'>{Option}</select>";
            string Li_Button = @"<a href='#' {CT_Attr} id='{CT_Field}'>{CT_Name}</a>";
            string Document_Js = @" <script> $(function(){ {JsBody}  }); </script> ";
            string defaultStyle = "form_textbox_toolbar  TextBoxReadOnly ";
            string DateStyle="date_icon";

            if (list.Count>0)
            {

            #region 显示值

                foreach (var item in list.Where(o=>string.IsNullOrEmpty(o.CT_Show) || o.CT_Show=="true"))
                {
                    try
                    {
                        string streElement = "";
                        string strLi = "";
                        string ClickJs = "";
                        item.CT_Default = JqGridSys_Config_ListPage.ParseDefaultValue(item.CT_Default);
                        switch (item.CT_Type)
                        {
                            case "text":

                                streElement = Li_Input.Replace("{CT_Attr}", item.CT_Attr)
                                                   .Replace("{CT_Field}", item.CT_Field)
                                                   .Replace("{CT_Default}",item.CT_Default);

                                strLi = Li_Template.Replace("{CT_Name}", item.CT_Name)
                                                       .Replace("{Element}", streElement);

                                strList.AppendLine(strLi);

                                break;
                            case "button":

                                streElement = Li_Button.Replace("{CT_Attr}", item.CT_Attr)
                                                    .Replace("{CT_Field}", item.CT_Field)
                                                    .Replace("{CT_Name}", item.CT_Name);

                                strLi = Li_ButtonDiv.Replace("{Element}", streElement);

                                strList.AppendLine(strLi);

                                break;

                            case "dict":
                                var strOption = new StringBuilder();
                                if (!string.IsNullOrEmpty(item.CT_DictKey))
                                {
                                    var dictList = dictInstance.GetListByWhere(" AND Dict_Key='" + item.CT_DictKey + "' AND Dict_Key!=Dict_Code").OrderBy(o=>o.Dict_Order).ToList();
                                    if (dictList.Count>0)
                                    {
                                        foreach ( var dictItem in dictList)
                                        {
                                            strOption.AppendLine("<option Value='" + dictItem.Dict_Code + "'>" + dictItem.Dict_Name + "</option>");
                                        }
                                    }
                                }
                                var NewList = Li_Select.Replace("{Option}", strOption.ToString())
                                                     .Replace("{CT_Field}", item.CT_Field)
                                                     .Replace("{CT_Name}", item.CT_Name);

                                streElement = Li_Template.Replace("{CT_Name}", item.CT_Name)
                                                       .Replace("{Element}", NewList);

                                strList.AppendLine(streElement);
                                break;

                            case "date":

                                streElement = Li_Input.Replace("{CT_Attr}", "class='"+defaultStyle+DateStyle+"'" + item.CT_Attr)
                                                   .Replace("{CT_Field}", item.CT_Field)
                                                   .Replace("{CT_Default}", item.CT_Default);

                                strLi = Li_Template.Replace("{CT_Name}", item.CT_Name)
                                                       .Replace("{Element}", streElement);

                                strList.AppendLine(strLi);

                                ClickJs = @" $('#" + Module + "').find('#" + item.CT_Field + "').bind('click',function(){ WdatePicker(); });  ";
                                strJsList.AppendLine(ClickJs);

                                break;

                            case "datetime":

                                streElement = Li_Input.Replace("{CT_Attr}", "class='" + defaultStyle + DateStyle + "'" + item.CT_Attr)
                                                   .Replace("{CT_Field}", item.CT_Field)
                                                   .Replace("{CT_Default}", item.CT_Default);

                                strLi = Li_Template.Replace("{CT_Name}", item.CT_Name)
                                                       .Replace("{Element}", streElement);

                                strList.AppendLine(strLi);

                                ClickJs = @" $('#" + Module + "').find('#"+item.CT_Field+"').bind('click',function(){ WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'}); });  ";
                                strJsList.AppendLine(ClickJs);

                                break;
                            default:
                                break;
                        }

                        //加载JS
                        if (!string.IsNullOrEmpty(item.CT_JS))
                        {
                            strJsList.AppendLine(item.CT_JS);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        continue;
                    }
                }
            #endregion

                string hidElement = string.Empty;

                foreach (var item in list.Where(o=>!string.IsNullOrEmpty(o.CT_Show) && o.CT_Show=="false"))
                {
                    hidElement = Li_Hidden.Replace("{CT_Field}", item.CT_Field)
                                                   .Replace("{CT_Default}", item.CT_Default);

                    strList.AppendLine(hidElement);

                }

                Document_Js = Document_Js.Replace("{JsBody}", strJsList.ToString());

            }
            else
            {
                Document_Js = Document_Js.Replace("{JsBody}", "");
            }

            return Bar_Begin+ strList +Bar_End + Document_Js;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 动态解析查询条件
        /// </summary>
        /// <param name="txt"></param>
        /// <param name="module"></param>
        /// <returns></returns>
        public static string BuildSearch(this string txt, string module)
        {
            var QueryLeftTree = string.Empty;
            StringBuilder strQuery = new StringBuilder();
            //Dictionary<string, string> dict = ReturnBuild();
            Dictionary<string, string> dict = new Dictionary<string, string>();
            MetaOper mod = JsonConvert.DeserializeObject<MetaOper>(txt);
            List<MetaRules> oper = JsonConvert.DeserializeObject<List<MetaRules>>(mod.rules.ToString());

            ADOBse_Dict DictInstance = new ADOBse_Dict();
            Sys_Config_ListPage M_Model = new Sys_Config_ListPage();
            List<Sys_Config_Fieled> D_List = new List<Sys_Config_Fieled>();

            GetListConfig(module, out M_Model, out D_List);

            var D_List_Dict = D_List.Where(o => !string.IsNullOrEmpty(o.D_DictKey) && (string.IsNullOrEmpty(o.D_Hidden) || o.D_Hidden == "false"));

            var Str_DictList = D_List.Select(o => o.D_Index);
            var Str_Oper = oper.Select(o => o.field);

            if (D_List_Dict.Count() > 0 && Str_DictList.Intersect(Str_Oper).Count() > 0)
            {

                for (int i = 0; i < oper.Count; i++)
                {
                    string _oper = string.Empty;
                    StringBuilder ConvertData = new StringBuilder();
                    if (i != oper.Count - 1)
                    {
                        _oper = "  " + mod.groupOp + "  ";
                    }
                    var D_ListQuery = D_List_Dict.Where(o => o.D_Index == oper[i].field);

                    if (D_ListQuery.Count() > 0)
                    {
                        dict = ReturnBuildDict();

                        //构建查询条件Field
                        QueryLeftTree = !string.IsNullOrEmpty(D_ListQuery.First().D_DBField) ? D_ListQuery.First().D_DBField : oper[i].field;

                        //获取字典Code
                        if (!string.IsNullOrEmpty(oper[i].data))
                        {
                            var DictResult = DictInstance.GetListByWhere(" AND Dict_Key!=Dict_Code AND Dict_Name like '%" + oper[i].data + "%'");
                            if (DictResult.Count > 0)
                            {
                                foreach (var item in DictResult)
                                {
                                    ConvertData.Append("'" + item.Dict_Code + "',");
                                }
                            }

                            strQuery.Append(dict[oper[i].op].Replace("{field}", QueryLeftTree).Replace("{data}", ConvertData.ToString().TrimEnd(',')) + _oper);
                        }
                    }
                    else
                    {
                        dict = ReturnBuild();
                        if (i != oper.Count - 1)
                        {
                            _oper = "  " + mod.groupOp + "  ";
                        }

                        strQuery.Append(dict[oper[i].op].Replace("{field}", oper[i].field).Replace("{data}", oper[i].data) + _oper);
                    }
                }
            }
            else
            {
                if (oper.Count > 0)
                {
                    dict = ReturnBuild();
                    for (int i = 0; i < oper.Count; i++)
                    {
                        string _oper = string.Empty;
                        if (i != oper.Count - 1)
                        {
                            _oper = "  " + mod.groupOp + "  ";
                        }

                        strQuery.Append(dict[oper[i].op].Replace("{field}", oper[i].field).Replace("{data}", oper[i].data) + _oper);
                    }
                }
            }

            return strQuery.ToString();
        }