예제 #1
0
파일: FOOT_DAL.cs 프로젝트: yymmhh/C-
        /// <summary>
        /// 查询combox
        /// </summary>
        /// <returns></returns>
        public List <teaminfo> GetCBO()
        {
            string          sql  = "SELECT* FROM teaminfo";
            DataTable       dt   = DBHelper.ExcuteDateSet(sql);
            List <teaminfo> list = new List <teaminfo>();

            foreach (DataRow item in dt.Rows)
            {
                teaminfo info = new teaminfo();
                info.id       = Convert.ToInt32(item["id"].ToString());
                info.teamname = item["teamname"].ToString();


                list.Add(info);
            }
            return(list);
        }
예제 #2
0
파일: FOOT_DAL.cs 프로젝트: yymmhh/C-
        /// <summary>
        /// 主要的查询
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="people"></param>
        /// <returns></returns>
        public List <Super> GetDB(string name, string count, string people)
        {
            //这是试图查询
            string sql = "SELECT * FROM view_cha where 1=1  ";
            //试图的SQL语句
//            SELECT COUNT, n2.teamname AS zhu,n1.teamname AS ke,competitiontime,competitionposition,score,entryperson
//  FROM scheduleinfo INNER JOIN teaminfo n2
// ON  scheduleinfo.hostteamid = n2.id
//INNER JOIN teaminfo n1  ON scheduleinfo.awayteamid = n1.id

// WHERE 1 = 1


            List <SqlParameter> sqlps = new List <SqlParameter>();


            //对于多个参数的判断
            if (!string.IsNullOrWhiteSpace(name))
            {
                sql += "  AND zhu like '%'+@name+'%'";
                sqlps.Add(new SqlParameter("@name", name));
            }

            if (!string.IsNullOrWhiteSpace(count))
            {
                sql += "  and COUNT=@count";
                sqlps.Add(new SqlParameter("@count", count));
            }


            if (!string.IsNullOrWhiteSpace(people))
            {
                sql += "  and author like '%'+@author+'%'";
                sqlps.Add(new SqlParameter("@author", people));
            }

            DataTable    dt   = DBHelper.ExcuteDateSet(sql, sqlps.ToArray());
            List <Super> list = new List <Super>();

            try
            {
                foreach (DataRow item in dt.Rows)
                {
                    Super info = new Super();
                    info.count               = Convert.ToInt32(item["count"].ToString());
                    info.zhu                 = item["zhu"].ToString();
                    info.ke                  = item["ke"].ToString();
                    info.competitiontime     = item["competitiontime"].ToString();
                    info.competitionposition = item["competitionposition"].ToString();
                    info.score               = item["score"].ToString();
                    info.entryperson         = item["entryperson"].ToString();


                    list.Add(info);
                }
            }
            catch (Exception)
            {
                throw;
            }



            return(list);
        }