Beispiel #1
0
        //-----标签建立,用于标签助手,旧和新的
        /// <summary>
        /// 字段创建方法,用于系统SQL
        /// </summary>
        public string SetLabelColumn(string sField, string TableName, string LabelName, string connStr)
        {
            string tlp = "<div class=\"list-group-item spanfixdiv\" outtype=\"0\" onclick=\"cit(this)\" code='{SField sid=\"" + LabelName + "\" FD=\"@fd\" page=\"0\"/}'>{SField FD=\"@fd\"/}</div>";
            string T1 = "", T2 = "", result = "";

            B_Label.GetT1AndT2(TableName, ref T1, ref T2);
            //扩展支持 sField:ZL_CommonModel.*,ZL_C_Announce.*
            if (sField.Equals("*") || sField.EndsWith("*"))
            {
                DataTable dt = DBCenter.DB.Field_List(T1);
                if (!string.IsNullOrEmpty(T2))
                {
                    DataTable dt2 = DBCenter.DB.Field_List(T2);
                    if (dt2 != null && dt2.Rows.Count > 0)
                    {
                        dt.Merge(dt2);
                    }
                }
                dt = dt.DefaultView.ToTable(true);
                foreach (DataRow dr in dt.Rows)
                {
                    result += tlp.Replace("@fd", dr["Name"].ToString());
                }
            }
            else
            {
                string[] fieldArr = sField.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string field in fieldArr)
                {
                    string name = "";
                    if (field.Contains("."))
                    {
                        name = field.Split('.')[1];
                    }
                    else
                    {
                        name = field;
                    }
                    result += tlp.Replace("@fd", name);
                }
            }
            return(result);
        }
Beispiel #2
0
        private string ContentSourceLabelProc(string ilabel, int Cpage, int InfoID, string Result)
        {
            M_Label label = new M_Label();
            B_Label bll = new B_Label();
            Hashtable hb = GetParam(ilabel);
            string temp = Result;
            if (!hb.Contains("id"))
            {
                temp.Replace(ilabel, "[err:标签不正确]");
                return temp;
            }
            label = bll.GetLabel(hb["id"].ToString());
            string strSql = "Select ";
            string sqlCount = "";
            string sqlField = "";
            string sqlTable = "";
            string sqlWhere = "";
            string sqlOrder = "";

            if (string.IsNullOrEmpty(label.LabelField))
            {
                temp.Replace(ilabel, "[err:标签没有定义查询的字段数据]");
                return temp;
            }
            else
            {
                sqlField = label.LabelField;
            }
            if (string.IsNullOrEmpty(label.LabelTable))
            {
                temp.Replace(ilabel, "[err:标签没有定义查询的数据表]");
                return temp;
            }
            else
            {
                sqlTable = label.LabelTable;
            }
            if (!string.IsNullOrEmpty(label.LabelCount))
                sqlCount = label.LabelCount;
            if (!string.IsNullOrEmpty(label.LabelWhere))
                sqlWhere = label.LabelWhere;
            if (!string.IsNullOrEmpty(label.LabelOrder))
                sqlOrder = label.LabelOrder;
            //替换参数
            if (!string.IsNullOrEmpty(label.Param))
            {
                string[] pa = label.Param.Split(new char[] { '|' });
                string paname = "";
                for (int i = 0; i < pa.Length; i++)
                {
                    paname = pa[i].Split(new char[] { ',' })[0];
                    if (DataConverter.CLng(pa[i].Split(new char[] { ',' })[2]) == 2)
                    {
                        sqlWhere = sqlWhere.Replace("@" + paname, InfoID.ToString());
                    }
                    else
                    {
                        sqlField = sqlField.Replace("@" + paname, hb["" + paname + ""].ToString());
                        sqlWhere = sqlWhere.Replace("@" + paname, hb["" + paname + ""].ToString());
                        sqlCount = sqlCount.Replace("@" + paname, hb["" + paname + ""].ToString());
                    }
                }
            }
            //组合查询语句
            if (DataConverter.CLng(sqlCount) > 0)
                strSql = strSql + "top " + sqlCount + " ";
            strSql = strSql + sqlField + " ";
            strSql = strSql + "From " + sqlTable + " ";
            if (!string.IsNullOrEmpty(sqlWhere))
                strSql = strSql + "Where " + sqlWhere + " ";
            if (!string.IsNullOrEmpty(sqlOrder))
                strSql = strSql + "Order by " + sqlOrder;
            DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, strSql, null);
            temp = temp.Replace(ilabel, "");
            return GetHtmlSource(temp, hb["id"].ToString(), dt);
        }
Beispiel #3
0
        /// <summary>
        /// 处理标签取得换算后的标签Html的代码
        /// </summary>
        /// <param name="ilabel"></param>
        /// <returns></returns>
        private string ContentLabelProc(string ilabel, int Cpage, int InfoID)
        {
            M_Label label = new M_Label();
            B_Label bll = new B_Label();
            Hashtable hb = GetParam(ilabel);
            if (!hb.Contains("id"))
            {
                return "[err:标签不正确]";
            }
            label = bll.GetLabel(hb["id"].ToString());
            if (label.LableType == 1)
            {
                return label.Content;
            }
            else
            {
                string labelcontent = label.Content;
                string strSql = "Select ";
                string sqlCount = "";
                string sqlField = "";
                string sqlTable = "";
                string sqlWhere = "";
                string sqlOrder = "";
                string sqlIdentity = "";
                sqlCount = label.LabelCount;

                if (string.IsNullOrEmpty(label.LabelField))
                {
                    return "[err:标签没有定义查询的字段数据]";
                }
                else
                {
                    sqlField = label.LabelField;
                }
                if (string.IsNullOrEmpty(label.LabelTable))
                {
                    return "[err:标签没有定义查询的数据表]";
                }
                else
                {
                    sqlTable = label.LabelTable;
                }
                if (!string.IsNullOrEmpty(label.LabelWhere))
                    sqlWhere = label.LabelWhere;
                if (!string.IsNullOrEmpty(label.LabelOrder))
                    sqlOrder = label.LabelOrder;

                if (!string.IsNullOrEmpty(label.Param))
                {
                    string[] pa = label.Param.Split(new char[] { '|' });
                    string paname = "";
                    for (int i = 0; i < pa.Length; i++)
                    {
                        paname = pa[i].Split(new char[] { ',' })[0];
                        if (DataConverter.CLng(pa[i].Split(new char[] { ',' })[2]) == 2)
                        {
                            sqlWhere = sqlWhere.Replace("@" + paname, InfoID.ToString());
                        }
                        else
                        {
                            labelcontent = labelcontent.Replace("@" + paname, hb["" + paname + ""].ToString());
                            sqlField = sqlField.Replace("@" + paname, hb["" + paname + ""].ToString());
                            sqlWhere = sqlWhere.Replace("@" + paname, hb["" + paname + ""].ToString());
                            sqlCount = sqlCount.Replace("@" + paname, hb["" + paname + ""].ToString());
                        }
                    }
                }
                if (label.LableType == 2)
                {
                    if (DataConverter.CLng(sqlCount) > 0)
                        strSql = strSql + "top " + sqlCount + " ";
                    strSql = strSql + sqlField + " ";
                    strSql = strSql + "From " + sqlTable + " ";
                    if (!string.IsNullOrEmpty(sqlWhere))
                        strSql = strSql + "Where " + sqlWhere + " ";
                    if (!string.IsNullOrEmpty(sqlOrder))
                        strSql = strSql + "Order by " + sqlOrder;
                    DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, strSql, null);
                    return GetHtmlContent(labelcontent, dt);
                }
                else
                {
                    strSql = "PR_GetRecordFromPage";
                    SqlParameter[] cmdParam = new SqlParameter[] {
                        new SqlParameter("@TableName",SqlDbType.VarChar),       //表名,可以是多个表
                        new SqlParameter("@Identity",SqlDbType.VarChar),
                        new SqlParameter("@Fields",SqlDbType.VarChar),          //要取出的字段,可以是多个表的字段,可以为空,为空表示select *
                        new SqlParameter("@sqlWhere",SqlDbType.VarChar),        //条件,可以为空,不用填 where
                        new SqlParameter("@OrderField",SqlDbType.VarChar),      //排序字段,可以为空,为空默认按主键升序排列,不用填 order by
                        new SqlParameter("@pageSize",SqlDbType.Int),            //每页记录数
                        new SqlParameter("@pageIndex",SqlDbType.Int)            //当前页,1表示第1页
                    };
                    cmdParam[0].Value = sqlTable;
                    cmdParam[1].Value = sqlIdentity;
                    cmdParam[2].Value = sqlField;
                    cmdParam[3].Value = sqlWhere;
                    cmdParam[4].Value = sqlOrder;
                    cmdParam[5].Value = DataConverter.CLng(sqlCount);
                    cmdParam[6].Value = Cpage - 1;

                    DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, strSql, cmdParam);
                    DataTable dt = ds.Tables[0];
                    DataTable dt1 = ds.Tables[1];

                    int Count = DataConverter.CLng(dt.Rows[0][0]);
                    labelcontent = labelcontent.Replace("{ZL.Page/}", function.ShowlistPage(Count, DataConverter.CLng(sqlCount), Cpage, true, InfoID));
                    return GetHtmlContent(labelcontent, dt1);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 获取标签所在的路径
        /// </summary>
        public static string GetLabelVPath(M_Label label)
        {
            B_Label labelBll = new B_Label();

            return(labelBll.vdir + label.LabelCate + "/" + label.LableName + ".label");
        }
Beispiel #5
0
        private string ContentSourceLabelProc(string ilabel, int Cpage, int InfoID, string Result)
        {
            M_Label   label = new M_Label();
            B_Label   bll   = new B_Label();
            Hashtable hb    = GetParam(ilabel);
            string    temp  = Result;

            if (!hb.Contains("id"))
            {
                temp.Replace(ilabel, "[err:标签不正确]");
                return(temp);
            }
            label = bll.GetLabel(hb["id"].ToString());
            string strSql   = "Select ";
            string sqlCount = "";
            string sqlField = "";
            string sqlTable = "";
            string sqlWhere = "";
            string sqlOrder = "";

            if (string.IsNullOrEmpty(label.LabelField))
            {
                temp.Replace(ilabel, "[err:标签没有定义查询的字段数据]");
                return(temp);
            }
            else
            {
                sqlField = label.LabelField;
            }
            if (string.IsNullOrEmpty(label.LabelTable))
            {
                temp.Replace(ilabel, "[err:标签没有定义查询的数据表]");
                return(temp);
            }
            else
            {
                sqlTable = label.LabelTable;
            }
            if (!string.IsNullOrEmpty(label.LabelCount))
            {
                sqlCount = label.LabelCount;
            }
            if (!string.IsNullOrEmpty(label.LabelWhere))
            {
                sqlWhere = label.LabelWhere;
            }
            if (!string.IsNullOrEmpty(label.LabelOrder))
            {
                sqlOrder = label.LabelOrder;
            }
            //替换参数
            if (!string.IsNullOrEmpty(label.Param))
            {
                string[] pa     = label.Param.Split(new char[] { '|' });
                string   paname = "";
                for (int i = 0; i < pa.Length; i++)
                {
                    paname = pa[i].Split(new char[] { ',' })[0];
                    if (DataConverter.CLng(pa[i].Split(new char[] { ',' })[2]) == 2)
                    {
                        sqlWhere = sqlWhere.Replace("@" + paname, InfoID.ToString());
                    }
                    else
                    {
                        sqlField = sqlField.Replace("@" + paname, hb["" + paname + ""].ToString());
                        sqlWhere = sqlWhere.Replace("@" + paname, hb["" + paname + ""].ToString());
                        sqlCount = sqlCount.Replace("@" + paname, hb["" + paname + ""].ToString());
                    }
                }
            }
            //组合查询语句
            if (DataConverter.CLng(sqlCount) > 0)
            {
                strSql = strSql + "top " + sqlCount + " ";
            }
            strSql = strSql + sqlField + " ";
            strSql = strSql + "From " + sqlTable + " ";
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                strSql = strSql + "Where " + sqlWhere + " ";
            }
            if (!string.IsNullOrEmpty(sqlOrder))
            {
                strSql = strSql + "Order by " + sqlOrder;
            }
            DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, strSql, null);

            temp = temp.Replace(ilabel, "");
            return(GetHtmlSource(temp, hb["id"].ToString(), dt));
        }
Beispiel #6
0
        /// <summary>
        /// 处理标签取得换算后的标签Html的代码
        /// </summary>
        /// <param name="ilabel"></param>
        /// <returns></returns>
        private string ContentLabelProc(string ilabel, int Cpage, int InfoID)
        {
            M_Label   label = new M_Label();
            B_Label   bll   = new B_Label();
            Hashtable hb    = GetParam(ilabel);

            if (!hb.Contains("id"))
            {
                return("[err:标签不正确]");
            }
            label = bll.GetLabel(hb["id"].ToString());
            if (label.LableType == 1)
            {
                return(label.Content);
            }
            else
            {
                string labelcontent = label.Content;
                string strSql       = "Select ";
                string sqlCount     = "";
                string sqlField     = "";
                string sqlTable     = "";
                string sqlWhere     = "";
                string sqlOrder     = "";
                string sqlIdentity  = "";
                sqlCount = label.LabelCount;


                if (string.IsNullOrEmpty(label.LabelField))
                {
                    return("[err:标签没有定义查询的字段数据]");
                }
                else
                {
                    sqlField = label.LabelField;
                }
                if (string.IsNullOrEmpty(label.LabelTable))
                {
                    return("[err:标签没有定义查询的数据表]");
                }
                else
                {
                    sqlTable = label.LabelTable;
                }
                if (!string.IsNullOrEmpty(label.LabelWhere))
                {
                    sqlWhere = label.LabelWhere;
                }
                if (!string.IsNullOrEmpty(label.LabelOrder))
                {
                    sqlOrder = label.LabelOrder;
                }

                if (!string.IsNullOrEmpty(label.Param))
                {
                    string[] pa     = label.Param.Split(new char[] { '|' });
                    string   paname = "";
                    for (int i = 0; i < pa.Length; i++)
                    {
                        paname = pa[i].Split(new char[] { ',' })[0];
                        if (DataConverter.CLng(pa[i].Split(new char[] { ',' })[2]) == 2)
                        {
                            sqlWhere = sqlWhere.Replace("@" + paname, InfoID.ToString());
                        }
                        else
                        {
                            labelcontent = labelcontent.Replace("@" + paname, hb["" + paname + ""].ToString());
                            sqlField     = sqlField.Replace("@" + paname, hb["" + paname + ""].ToString());
                            sqlWhere     = sqlWhere.Replace("@" + paname, hb["" + paname + ""].ToString());
                            sqlCount     = sqlCount.Replace("@" + paname, hb["" + paname + ""].ToString());
                        }
                    }
                }
                if (label.LableType == 2)
                {
                    if (DataConverter.CLng(sqlCount) > 0)
                    {
                        strSql = strSql + "top " + sqlCount + " ";
                    }
                    strSql = strSql + sqlField + " ";
                    strSql = strSql + "From " + sqlTable + " ";
                    if (!string.IsNullOrEmpty(sqlWhere))
                    {
                        strSql = strSql + "Where " + sqlWhere + " ";
                    }
                    if (!string.IsNullOrEmpty(sqlOrder))
                    {
                        strSql = strSql + "Order by " + sqlOrder;
                    }
                    DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, strSql, null);
                    return(GetHtmlContent(labelcontent, dt));
                }
                else
                {
                    strSql = "PR_GetRecordFromPage";
                    SqlParameter[] cmdParam = new SqlParameter[] {
                        new SqlParameter("@TableName", SqlDbType.VarChar),       //表名,可以是多个表
                        new SqlParameter("@Identity", SqlDbType.VarChar),
                        new SqlParameter("@Fields", SqlDbType.VarChar),          //要取出的字段,可以是多个表的字段,可以为空,为空表示select *
                        new SqlParameter("@sqlWhere", SqlDbType.VarChar),        //条件,可以为空,不用填 where
                        new SqlParameter("@OrderField", SqlDbType.VarChar),      //排序字段,可以为空,为空默认按主键升序排列,不用填 order by
                        new SqlParameter("@pageSize", SqlDbType.Int),            //每页记录数
                        new SqlParameter("@pageIndex", SqlDbType.Int)            //当前页,1表示第1页
                    };
                    cmdParam[0].Value = sqlTable;
                    cmdParam[1].Value = sqlIdentity;
                    cmdParam[2].Value = sqlField;
                    cmdParam[3].Value = sqlWhere;
                    cmdParam[4].Value = sqlOrder;
                    cmdParam[5].Value = DataConverter.CLng(sqlCount);
                    cmdParam[6].Value = Cpage - 1;

                    DataSet   ds  = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, strSql, cmdParam);
                    DataTable dt  = ds.Tables[0];
                    DataTable dt1 = ds.Tables[1];

                    int Count = DataConverter.CLng(dt.Rows[0][0]);
                    labelcontent = labelcontent.Replace("{ZL.Page/}", function.ShowlistPage(Count, DataConverter.CLng(sqlCount), Cpage, true, InfoID));
                    return(GetHtmlContent(labelcontent, dt1));
                }
            }
        }