Beispiel #1
0
        /// <summary>
        /// 获取产品信息集合
        /// </summary>
        /// <param name="pageSize">页记录数</param>
        /// <param name="pageIndex">页序号</param>
        /// <param name="recordCount">总记录数</param>
        /// <param name="chaXun">查询</param>
        /// <returns></returns>
        public IList <EyouSoft.Model.MChanPinInfo> GetChanPins(int pageSize, int pageIndex, ref int recordCount, EyouSoft.Model.MChanPinChaXunInfo chaXun)
        {
            IList <EyouSoft.Model.MChanPinInfo> items = new List <EyouSoft.Model.MChanPinInfo>();

            string        fields        = "*,(SELECT A1.Name FROM tbl_YongHu AS A1 WHERE A1.YongHuId=tbl_ChanPin.CaoZuoRenId) AS CaoZuoRenName,(SELECT A1.Name FROM tbl_GongSi AS A1 WHERE A1.GongSiId=tbl_ChanPin.GysId) AS GysName";
            StringBuilder sql           = new StringBuilder();
            string        tableName     = "tbl_ChanPin";
            string        orderByString = " IssueTime DESC ";
            string        heJiString    = "";

            #region sql
            sql.Append(" IsDelete='0' ");

            if (chaXun != null)
            {
                if (!string.IsNullOrEmpty(chaXun.BianMa))
                {
                    sql.AppendFormat(" AND BianMa LIKE '%{0}%' ", chaXun.BianMa);
                }
                if (chaXun.FaBuTime1.HasValue)
                {
                    sql.AppendFormat(" AND IssueTime>'{0}' ", chaXun.FaBuTime1.Value.AddMinutes(-1));
                }
                if (chaXun.FaBuTime2.HasValue)
                {
                    sql.AppendFormat(" AND IssueTime<'{0}' ", chaXun.FaBuTime1.Value.AddDays(1).AddMinutes(-1));
                }
                if (!string.IsNullOrEmpty(chaXun.GysId))
                {
                    sql.AppendFormat(" AND GysId='{0}' ", chaXun.GysId);
                }
                if (!string.IsNullOrEmpty(chaXun.GysName))
                {
                    sql.AppendFormat(" AND EXISTS(SELECT 1 FROM dbo.tbl_GongSi G WHERE G.GongSiId=tbl_ChanPin.GysId AND G.Name LIKE '%{0}%') ", chaXun.GysName);
                }
                if (!string.IsNullOrEmpty(chaXun.Name))
                {
                    sql.AppendFormat(" AND Name LIKE '%{0}%' ", chaXun.Name);
                }

                if (!string.IsNullOrEmpty(chaXun.CgsId))
                {
                    sql.AppendFormat(" AND EXISTS(SELECT 1 FROM tbl_GongSiGuanXi AS A1 WHERE A1.GongSiId2=tbl_ChanPin.GysId AND A1.GongSiId1='{0}') ", chaXun.CgsId);
                }
                if (!string.IsNullOrEmpty(chaXun.PinPai))
                {
                    sql.AppendFormat(" AND PinPai LIKE '%{0}%' ", chaXun.PinPai);
                }
                if (!string.IsNullOrEmpty(chaXun.GuiGe))
                {
                    sql.AppendFormat(" AND GuiGe LIKE '%{0}%' ", chaXun.GuiGe);
                }
            }

            #endregion

            using (IDataReader rdr = DbHelper.ExecuteReader1(_db, pageSize, pageIndex, ref recordCount, tableName, fields, sql.ToString(), orderByString, heJiString))
            {
                while (rdr.Read())
                {
                    var info = new EyouSoft.Model.MChanPinInfo();

                    info.BianMa        = rdr["BianMa"].ToString();
                    info.CaoZuoRenId   = rdr["CaoZuoRenId"].ToString();
                    info.ChanPinId     = rdr["ChanPinId"].ToString();
                    info.FuJians       = null;
                    info.GuiGe         = rdr["GuiGe"].ToString();
                    info.GysId         = rdr["GysId"].ToString();
                    info.IssueTime     = rdr.GetDateTime(rdr.GetOrdinal("IssueTime"));
                    info.JiaGe1        = rdr.GetDecimal(rdr.GetOrdinal("JiaGe1"));
                    info.JiaGe2        = rdr.GetDecimal(rdr.GetOrdinal("JiaGe2"));
                    info.JieShao       = rdr["JieShao"].ToString();
                    info.JiLiangDanWei = rdr["JiLiangDanWei"].ToString();
                    info.Name          = rdr["Name"].ToString();
                    info.PinPai        = rdr["PinPai"].ToString();
                    info.CaoZuoRenName = rdr["CaoZuoRenName"].ToString();
                    info.GysName       = rdr["GysName"].ToString();

                    items.Add(info);
                }
            }

            return(items);
        }
Beispiel #2
0
        /// <summary>
        /// 获取产品信息集合
        /// </summary>
        /// <param name="pageSize">页记录数</param>
        /// <param name="pageIndex">页序号</param>
        /// <param name="recordCount">总记录数</param>
        /// <param name="chaXun">查询</param>
        /// <returns></returns>
        public IList <EyouSoft.Model.MChanPinInfo> GetChanPins(int pageSize, int pageIndex, ref int recordCount, EyouSoft.Model.MChanPinChaXunInfo chaXun)
        {
            if (pageSize <= 0)
            {
                pageSize = 1;
            }
            if (pageIndex <= 0)
            {
                pageIndex = 1;
            }

            var items = dal.GetChanPins(pageSize, pageIndex, ref recordCount, chaXun);

            return(items);
        }