Beispiel #1
0
        /// <summary>
        /// 根据编号获取对应名称
        /// </summary>
        /// <param name="TableName">表格名称</param>
        /// <param name="mText">名称字段</param>
        /// <param name="mID">编号字段</param>
        /// <param name="mValue">编号值</param>
        /// <returns>名称,-1:表示获取失败</returns>
        public static string GetTextByID(string TableName, string mText, string mID, string mValue)
        {
            string  Text = "-1";
            string  sql  = "SELECT " + mText + " FROM " + TableName + " where " + mID + " = '" + mValue + "'";
            DataSet ds   = new DataSet();

            ds = CSql.CreateDataSet(sql);
            if (ds.Tables[0].Rows.Count >= 0)
            {
                Text = ds.Tables[0].Rows[0][0].ToString();
            }

            return(Text);
        }
Beispiel #2
0
        /// <summary>
        /// 分页方式获取DataSet
        /// </summary>
        /// <param name="SQL">SQL 语句</param>
        /// <param name="Page">当前页号</param>
        /// <param name="RecsPerPage">每页记录数</param>
        /// <param name="ID">索引字段</param>
        /// <param name="Sort">排序字段</param>
        /// <returns>当前页的记录集合</returns>
        public static DataSet GetPageDataSet(string SQL, int Page, int RecsPerPage, string ID, string Sort)
        {
            int    iPage = RecsPerPage * (Page - 1);
            string sql   = "";

            if (iPage == 0)
            {
                sql = "SELECT  TOP " + RecsPerPage + " * FROM (" + SQL + ") T  ORDER BY " + Sort;
            }
            else
            {
                sql = "SELECT  TOP " + RecsPerPage + " * FROM (" + SQL + ") T WHERE T." + ID + " NOT IN (SELECT  TOP  " + iPage.ToString() + "  " + ID + "  FROM (" + SQL + ") T9 ORDER BY " + Sort + ") ORDER BY " + Sort;
            } DataSet ds = new DataSet();

            ds = CSql.CreateDataSet(sql);

            return(ds);
        }
Beispiel #3
0
        /// <summary>
        ///下拉框数据加载
        /// </summary>
        /// <param name="DDL_Items">下拉框</param>
        /// <param name="tablename">表名</param>
        /// <param name="mtext">名称字段</param>
        /// <param name="mvalue">编号字段</param>
        /// <param name="isTextShowCode">文本带编号显示</param>
        public static void LoadSelection(ref System.Web.UI.WebControls.DropDownList DDL_Items, string tablename, string mtext, string mvalue, bool isShowWithCode)
        {
            string sqlTxt = "";

            if (isShowWithCode == true)
            {
                sqlTxt = "SELECT " + mvalue + "+' | '+" + mtext + " as " + mtext + "," + mvalue + " FROM " + tablename + " order by " + mvalue;
            }
            else
            {
                sqlTxt = "SELECT " + mtext + "," + mvalue + " FROM " + tablename + " order by " + mvalue;
            }
            DDL_Items.DataSource = CSql.CreateDataSet(sqlTxt);
            DDL_Items.Items.Clear();
            DDL_Items.SelectedIndex  = -1;
            DDL_Items.DataTextField  = mtext;
            DDL_Items.DataValueField = mvalue;

            DDL_Items.DataBind();
        }
Beispiel #4
0
        /// <summary>
        /// 根据特定条件,下拉框数据加载
        /// </summary>
        /// <param name="DDL_Items">下拉框</param>
        /// <param name="tablename">表名</param>
        /// <param name="mtext">名称字段</param>
        /// <param name="mvalue">编号字段</param>
        /// <param name="ConStr">条件字段</param>
        /// <param name="defaultText">默认字段(插入第一行的字段)文本内容</param>
        /// <param name="defaultValue">默认字段(插入第一行的字段)值</param>
        public static void LoadSelection(ref System.Web.UI.WebControls.DropDownList DDL_Items, string tablename, string mtext, string mvalue, string ConStr, string defaultText, string defaultValue)
        {
            string sqlTxt = "SELECT * FROM " + tablename + " where " + ConStr;

            DataSet ds = new DataSet();

            ds = CSql.CreateDataSet(sqlTxt);
            //添加一行选择行
            DataRow dr = ds.Tables[0].NewRow();

            dr[mvalue] = defaultValue;
            dr[mtext]  = defaultText;
            ds.Tables[0].Rows.InsertAt(dr, 0);

            DDL_Items.DataSource = ds.Tables[0];
            DDL_Items.Items.Clear();
            DDL_Items.DataTextField  = mtext;
            DDL_Items.DataValueField = mvalue;

            DDL_Items.DataBind();
        }
Beispiel #5
0
        /// <summary>
        /// 特定条件信息获取
        /// </summary>
        /// <param name="TableName">表名</param>
        /// <param name="RowName">条件字段</param>
        /// <param name="mValue">条件值</param>
        /// <returns></returns>
        public static DataSet GetSelections(string TableName, string RowName, string mValue)
        {
            string sqlTxt = "SELECT * FROM " + TableName + " where " + RowName + " = '" + mValue + "'" + " order by " + mValue;;

            return(CSql.CreateDataSet(sqlTxt));
        }
Beispiel #6
0
        /// <summary>
        /// 根据表名数据获取
        /// </summary>
        /// <param name="TableName">表名</param>
        /// <returns>数据集</returns>
        public static DataSet GetSelections(string TableName)
        {
            string sqlTxt = "SELECT * FROM " + TableName;

            return(CSql.CreateDataSet(sqlTxt));
        }