Example #1
0
        //根据查询条件展示招领信息
        public ResData <List <GoodsId> > get(GoodsCon data)
        {
            ResData <List <GoodsId> > res   = new ResData <List <GoodsId> >();
            List <GoodsId>            goods = dbcontext.t_lostgoods
                                              //查询条件
                                              .Where(t => (t.goods.Contains(data.goods) || data.goods == null) && (t.describe.Contains(data.describe) || data.describe == null) && t.collect_date >= data.bdate && t.collect_date <= data.edate)
                                              //查询结果  t_lostgoods==>GoodsId
                                              .Select(t => new GoodsId(t.id, t.goods, t.describe, t.collect_date, t.collect_addr, t.contact_man, t.contact_phone, t.contact_email))
                                              //转换结果
                                              .ToList();

            res.code = 1;
            res.msg  = "查询成功";
            res.data = goods;
            return(res);
        }
Example #2
0
        //根据查询条件展示招领信息
        public ResData <List <GoodsId> > get(string goods, string describe, string bdate, string edate)
        {
            ResData <List <GoodsId> > res = new ResData <List <GoodsId> >();

            res.code = 1;
            GoodsCon data = new GoodsCon();

            //赋值查询条件
            if (string.IsNullOrEmpty(goods))
            {
                data.goods = null;
            }
            else
            {
                data.goods = goods;
            }
            if (string.IsNullOrEmpty(describe))
            {
                data.describe = null;
            }
            else
            {
                data.describe = describe;
            }
            if (string.IsNullOrEmpty(bdate))
            {
                data.bdate = DateTime.MinValue;
            }
            else
            {
                try
                {
                    data.bdate = DateTime.Parse(bdate);
                }
                catch (Exception e) {
                    res.code = -1;
                    res.msg  = "开始日期不是有效的日期格式";
                }
            }
            if (string.IsNullOrEmpty(edate))
            {
                data.edate = DateTime.Now;
            }
            else
            {
                try
                {
                    data.edate = DateTime.Parse(edate);
                }
                catch (Exception e)
                {
                    res.code = -1;
                    res.msg  = "结束日期不是有效的日期格式";
                }
            }
            //如果查询条件有误,则返回提示
            if (res.code == -1)
            {
                return(res);
            }
            //显示查询结果
            res = lostGoodsDal.get(data);
            return(res);
        }