Exemplo n.º 1
0
        public List <TodayTakeBillModel> getallTakeBill(DateTime datefrom, DateTime dateto)
        {
            int OutletId = getOutletId();
            List <TodayTakeBillModel> lst = new List <TodayTakeBillModel>();

            var result = (from p in entites.tblBillDetails
                          where System.Data.Entity.DbFunctions.TruncateTime(p.tblBillMaster.BillDate) >= datefrom.Date &&
                          System.Data.Entity.DbFunctions.TruncateTime(p.tblBillMaster.BillDate) >= dateto.Date &&
                          p.tblBillMaster.BillingType.Equals("Door Delivery Hall") && p.tblBillMaster.OutletId == OutletId
                          select new
            {
                ItemName = p.tblItem.Name,
                Quantity = p.FullQty,
                Amount = p.Amount,
                BillId = p.BillId,
            }).ToList();

            foreach (var item in result.GroupBy(a => a.ItemName))
            {
                if (item.FirstOrDefault().Quantity > 0)
                {
                    TodayTakeBillModel model  = new TodayTakeBillModel();
                    decimal            amount = item.Sum(a => a.Amount);
                    model.Amount      = Math.Round(amount, 2);
                    model.TotalAmount = item.Sum(a => a.Amount);
                    model.Name        = item.FirstOrDefault().ItemName;
                    model.Price       = Convert.ToDecimal(item.FirstOrDefault().Amount / item.FirstOrDefault().Quantity);
                    model.Qty         = item.Sum(a => a.Quantity).Value;
                    lst.Add(model);
                }
            }
            return(lst);
        }
Exemplo n.º 2
0
        public List <TodayTakeBillModel> getallTakeBill()
        {
            int OutletId = getOutletId();
            List <TodayTakeBillModel> lst = new List <TodayTakeBillModel>();
            var Date   = DateTime.Today.ToShortDateString();
            var dd     = Convert.ToDateTime(Date);
            var result = (from p in entites.tblBillMasters
                          join q in entites.tblBillDetails on p.BillId equals q.BillId
                          join t in entites.tblItems on q.ItemId equals t.ItemId
                          join b in entites.tblBasePriceItems on t.ItemId equals b.ItemId
                          where p.BillDate.Day == dd.Day && p.BillDate.Month == dd.Month && p.BillDate.Year == dd.Year && p.BillingType == "Take Away Hall" && p.OutletId == OutletId
                          select new
            {
                ItemName = t.Name,
                Quantity = q.FullQty,
                Price = b.FullPrice,
                Amount = q.Amount,
                BillId = p.BillId,
            }).ToList();

            foreach (var item in result.GroupBy(a => a.ItemName))
            {
                TodayTakeBillModel model  = new TodayTakeBillModel();
                decimal            amount = item.Sum(a => a.Amount);
                model.Amount      = Math.Round(amount, 2);
                model.TotalAmount = item.Sum(a => a.Amount);
                model.Name        = item.FirstOrDefault().ItemName;
                model.Price       = Math.Round(item.FirstOrDefault().Price, 2);
                model.Qty         = item.Sum(a => a.Quantity).Value;
                lst.Add(model);
            }
            return(lst);
        }