예제 #1
0
        public async Task <IActionResult> Delete(SaleOffer offer)
        {
            _context.SaleOffer.Remove(offer);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }
예제 #2
0
 public void AddSaleOffer(SaleOffer saleOffer)
 {
     using (SalesDB db = new SalesDB())
     {
         db.SalesOffers.Add(saleOffer);
         db.SaveChanges();
     }
 }
예제 #3
0
 public void UpdateSaleOffer(SaleOffer saleOffer)
 {
     using (SalesDB db = new SalesDB())
     {
         db.Entry(saleOffer).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
        private void ExecuteSave()
        {
            Mouse.OverrideCursor = Cursors.Wait;
            DateTime _dt = DateTime.Now;

            _saleOfferServ.AddSaleOffer(_newSaleOffer);
            int _saleOfferID = _saleOfferServ.GetLastSaleOfferID();

            foreach (var item in _saleOfferCategories)
            {
                SaleOfferCategory _saleOfferCategory = new SaleOfferCategory
                {
                    CategoryID              = item.CategoryID,
                    PriceAfterDiscount      = item.PriceAfterDiscount,
                    PriceTotalAfterDiscount = item.PriceTotalAfterDiscount,
                    Price              = item.Price,
                    PriceTotal         = item.PriceTotal,
                    Discount           = item.Discount,
                    DiscountValue      = item.DiscountValue,
                    DiscountValueTotal = item.DiscountValueTotal,
                    SaleOfferID        = _saleOfferID,
                    Qty = item.Qty
                };
                _saleOfferCategoryServ.AddSaleOfferCategory(_saleOfferCategory);
            }

            DS ds = new DS();

            ds.Sale.Rows.Clear();
            int i = 0;

            foreach (var item in _saleOfferCategories)
            {
                ds.Sale.Rows.Add();
                ds.Sale[i]["Client"]     = _selectedClient.Name;
                ds.Sale[i]["Serial"]     = i + 1;
                ds.Sale[i]["Category"]   = item.Category + " " + item.Company;
                ds.Sale[i]["Qty"]        = item.Qty;
                ds.Sale[i]["Price"]      = Math.Round(Convert.ToDecimal(item.PriceAfterDiscount), 2);
                ds.Sale[i]["TotalPrice"] = Math.Round(Convert.ToDecimal(item.PriceTotalAfterDiscount), 2);
                ds.Sale[i]["BillPrice"]  = Math.Round(Convert.ToDecimal(_newSaleOffer.PriceAfterDiscount), 2);;
                i++;
            }
            ReportWindow    rpt          = new ReportWindow();
            SaleOfferReport saleOfferRPT = new SaleOfferReport();

            saleOfferRPT.SetDataSource(ds.Tables["Sale"]);
            rpt.crv.ViewerCore.ReportSource = saleOfferRPT;
            Mouse.OverrideCursor            = null;
            _currentWindow.Hide();
            rpt.ShowDialog();
            NewSaleOffer         = new SaleOffer();
            NewSaleOfferCategory = new SaleOfferCategoryVM();
            SaleOfferCategories  = new ObservableCollection <SaleOfferCategoryVM>();
            NewSaleOffer.Date    = DateTime.Now;
            OldPrices            = new ObservableCollection <SaleCategory>();
            _currentWindow.ShowDialog();
        }
예제 #5
0
    public SaleOffer RescindOffer(SaleOffer sale_offer)
    {
        if (!SaleOffers.Contains(sale_offer))
        {
            SaleOffers.Remove(sale_offer);
        }

        return(sale_offer);
    }
예제 #6
0
 public void DeleteSaleOffer(SaleOffer saleOffer)
 {
     using (SalesDB db = new SalesDB())
     {
         db.SalesOffers.Attach(saleOffer);
         db.SalesOffers.Remove(saleOffer);
         db.SaveChanges();
     }
 }
예제 #7
0
        public async Task <IActionResult> Edit(SaleOffer offer)
        {
            if (!ModelState.IsValid)
            {
                return(View(offer));
            }

            _context.Update(offer);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }
예제 #8
0
 public static IOffer CreateOffer(OfferType type)
 {
     IOffer offer = null;
     switch (type)
     {
         case OfferType.Sale:
             offer = new SaleOffer();
             break;
         case OfferType.Rent:
             offer = new RentOffer();
             break;
         default:
             break;
     }
     return offer;
 }
        public static IOffer CreateOffer(OfferType type)
        {
            Offer offer;
            switch (type)
            {
                    case OfferType.Rent:
                    offer = new RentOffer();
                    break;
                    case OfferType.Sale:
                    offer = new SaleOffer();
                    break;
                default:
                    throw new ArgumentException("Invalid type for offer.");
            }

            return offer;
        }
예제 #10
0
        public async Task <IActionResult> Create(SaleOffer offer)
        {
            if (!ModelState.IsValid)
            {
                return(View(offer));
            }

            var userId = await _context
                         .Users
                         .Where(u => u.UserName == User.Identity.Name)
                         .Select(u => u.Id)
                         .FirstOrDefaultAsync();

            offer.UserId   = userId;
            offer.Created  = DateTime.Now.ToUniversalTime();
            offer.IsActive = true;

            _context.SaleOffer.Add(offer);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }
예제 #11
0
    public SaleOffer PostOffer(SaleOffer sale_offer)
    {
        SaleOffers.Add(sale_offer);

        return(sale_offer);
    }