Пример #1
0
        /// <summary>
        /// 根据sql得到Combox列表项
        /// </summary>
        /// <param name="dbconn"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public string GetComboxTableHtmlFromSql(string connID, string sql, string value)
        {
            string cid;

            if (!connID.IsGuid(out cid))
            {
                return("");
            }
            DBConnectionBLL dbConn = new DBConnectionBLL();
            var             dbconn = dbConn.FindByID(cid);

            if (dbconn == null)
            {
                return("");
            }
            DataTable dt = dbConn.GetDataTable(dbconn, sql.ReplaceSelectSql());

            if (dt.Rows.Count == 0)
            {
                return("");
            }
            StringBuilder html = new StringBuilder(2000);

            html.Append("<table><thead><tr>");
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                if (dt.Columns.Count > 1 && i == 0)
                {
                    continue;
                }
                html.Append("<th>");
                html.Append(dt.Columns[i].ColumnName);
                html.Append("</th>");
            }
            html.Append("</thead>");
            html.Append("<tbody>");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                html.Append("<tr>");
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    if (dt.Columns.Count > 1 && j == 0)
                    {
                        continue;
                    }
                    html.AppendFormat("<td value=\"{0}\"{1}>", dt.Rows[i][0], dt.Rows[i][0].ToString().Equals(value, StringComparison.CurrentCultureIgnoreCase) ? " selected=\"selected\"" : "");
                    html.Append(dt.Rows[i][j]);
                    html.Append("</td>");
                }
                html.Append("</tr>");
            }
            html.Append("</tr></tbody></table>");

            return(html.ToString());
        }
Пример #2
0
        /// <summary>
        /// 根据sql得到单选按钮组
        /// </summary>
        /// <param name="dbconn"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public string GetRadioFromSql(string connID, string sql, string name, string value, string attr = "")
        {
            string cid;

            if (!connID.IsGuid(out cid))
            {
                return("");
            }
            DBConnectionBLL dbConn = new DBConnectionBLL();
            var             dbconn = dbConn.FindByID(cid);

            if (dbconn == null)
            {
                return("");
            }
            DataTable dt = dbConn.GetDataTable(dbconn, sql.ReplaceSelectSql());

            if (dt.Rows.Count == 0)
            {
                return("");
            }
            List <ListItem> items = new List <ListItem>();

            foreach (DataRow dr in dt.Rows)
            {
                if (dt.Columns.Count == 0)
                {
                    continue;
                }
                string value1 = dr[0].ToString();
                string title  = value1;
                if (dt.Columns.Count > 1)
                {
                    title = dr[1].ToString();
                }

                items.Add(new ListItem(title, value1)
                {
                    Selected = value == value1
                });
            }
            return(Next.WorkFlow.Utility.Tools.GetRadioString(items.ToArray(), name, attr));
        }
Пример #3
0
        /// <summary>
        /// 得到Grid的html
        /// </summary>
        /// <param name="dataFormat"></param>
        /// <param name="dataSource"></param>
        /// <param name="dataSource1"></param>
        /// <returns></returns>
        public string GetFormGridHtml(string connID, string dataFormat, string dataSource, string dataSource1)
        {
            if (!dataFormat.IsInt() || !dataSource.IsInt() || dataSource1.IsNullOrEmpty())
            {
                return("");
            }

            switch (dataSource)
            {
            case "0":
                DBConnectionBLL dbConn = new DBConnectionBLL();
                var             dbconn = dbConn.FindByID(connID.ToGuid());
                if (dbconn == null)
                {
                    return("");
                }
                DataTable dt = dbConn.GetDataTable(dbconn, dataSource1.ReplaceSelectSql());
                switch (dataFormat)
                {
                case "0":
                    return(dataTableToHtml(dt));

                case "1":
                    return(dt.Rows.Count > 0 ? dt.Rows[0][0].ToString() : "");

                case "2":
                    return(dt.Rows.Count > 0 ? jsonToHtml(dt.Rows[0][0].ToString()) : "");

                default:
                    return("");
                }

            case "1":
                string str = string.Empty;
                try
                {
                    str = Next.WorkFlow.Utility.HttpHelper.SendGet(dataSource1);
                    switch (dataFormat)
                    {
                    case "0":
                    case "1":
                        return(str);

                    case "2":
                        return(jsonToHtml(str));

                    default:
                        return("");
                    }
                }
                catch
                {
                    return("");
                }

            case "2":
                WorkFlowCustomEventParams eventParams = new WorkFlowCustomEventParams();
                eventParams.FlowID     = (System.Web.HttpContext.Current.Request.QueryString["FlowID"] ?? "").ToGuid();
                eventParams.GroupID    = (System.Web.HttpContext.Current.Request.QueryString["GroupID"] ?? "").ToGuid();
                eventParams.StepID     = (System.Web.HttpContext.Current.Request.QueryString["StepID"] ?? "").ToGuid();
                eventParams.TaskID     = (System.Web.HttpContext.Current.Request.QueryString["TaskID"] ?? "").ToGuid();
                eventParams.InstanceID = System.Web.HttpContext.Current.Request.QueryString["InstanceID"] ?? "";
                object obj = null;
                try
                {
                    obj = new WorkFlowTaskBLL().ExecuteFlowCustomEvent(dataSource1, eventParams);
                    switch (dataFormat)
                    {
                    case "0":
                        return(dataTableToHtml((DataTable)obj));

                    case "1":
                        return(obj.ToString());

                    case "2":
                        return(jsonToHtml(obj.ToString()));

                    default:
                        return("");
                    }
                }
                catch
                {
                    return("");
                }
            }

            return("");
        }
Пример #4
0
        /// <summary>
        /// 根据显示方式得到显示的字符串
        /// </summary>
        /// <param name="value"></param>
        /// <param name="displayModel"></param>
        /// <returns></returns>
        public string GetDisplayString(string value, string displayModel, string format = "", string dbconnID = "", string sql = "")
        {
            string value1 = string.Empty;

            switch ((displayModel ?? "").ToLower())
            {
            case "normal":
            default:
                value1 = value;
                break;

            case "dict_id_title":
                var dict = new DictBLL().FindByID(value.ToGuid());
                value1 = dict == null ? "" : dict.Title;
                break;

            case "dict_id_code":
                var dict1 = new DictBLL().FindByID(value.ToGuid());
                value1 = dict1 == null ? "" : dict1.Code;
                break;

            case "dict_id_value":
                var dict2 = new DictBLL().FindByID(value.ToGuid());
                value1 = dict2 == null ? "" : dict2.Value;
                break;

            case "dict_id_note":
                var dict3 = new DictBLL().FindByID(value.ToGuid());
                value1 = dict3 == null ? "" : dict3.Note;
                break;

            case "dict_id_other":
                var dict4 = new DictBLL().FindByID(value.ToGuid());
                value1 = dict4 == null ? "" : dict4.Other;
                break;

            case "dict_code_title":
                var dict5 = new DictBLL().GetByCode(value);
                value1 = dict5 == null ? "" : dict5.Title;
                break;

            case "dict_code_id":
                var dict6 = new DictBLL().GetByCode(value);
                value1 = dict6 == null ? "" : dict6.ID.ToString();
                break;

            case "dict_code_value":
                var dict7 = new DictBLL().GetByCode(value);
                value1 = dict7 == null ? "" : dict7.Value;
                break;

            case "dict_code_note":
                var dict8 = new DictBLL().GetByCode(value);
                value1 = dict8 == null ? "" : dict8.Note;
                break;

            case "dict_code_other":
                var dict9 = new DictBLL().GetByCode(value);
                value1 = dict9 == null ? "" : dict9.Other;
                break;

            case "organize_id_name":
                value1 = new DeptBLL().GetNames(value);
                break;

            case "files_link":
                string[]      files = value.Split('|');
                StringBuilder links = new StringBuilder();
                //links.Append("<div>");
                foreach (string file in files)
                {
                    links.AppendFormat("<a target=\"_blank\" class=\"blue\" href=\"{0}\">{1}</a><br/>", file, System.IO.Path.GetFileName(file));
                }
                //links.Append("</div>");
                value1 = links.ToString();
                break;

            case "files_img":
                string[]      files1 = value.Split('|');
                StringBuilder links1 = new StringBuilder();
                //links.Append("<div>");
                foreach (string file in files1)
                {
                    links1.AppendFormat("<img src=\"{0}\" />", file);
                }
                //links.Append("</div>");
                value1 = links1.ToString();
                break;

            case "datetime_format":
                value1 = value.ToDateTime().ToString(format ?? Utility.Config.DateFormat);
                break;

            case "number_format":
                value1 = value.ToDecimal().ToString(format);
                break;

            case "table_fieldvalue":
                DBConnectionBLL dbconn = new DBConnectionBLL();
                DataTable       dt     = dbconn.GetDataTable(dbconn.FindByID(dbconnID.ToGuid()), sql + "'" + value + "'");
                value1 = dt.Rows.Count > 0 && dt.Columns.Count > 0 ? dt.Rows[0][0].ToString() : "";
                break;
            }
            return(value1);
        }