コード例 #1
0
        public JsonResult PaySupplier(SupplierExpiryVM model)
        {
            var supplier = rpsupplier.Find(model.ID);

            supplier.TotalExpiryValue -= model.Price;
            supplier.PaidExpiryValue  += model.Price;
            rpsupplier.SaveChanges();

            var expiryList = rpsupplierexpiry
                             .GetListWithQuery(x => x.SupplierID == model.ID)
                             .OrderBy(x => x.ExpiryDate);

            decimal gelen = model.Price;

            foreach (var item in expiryList)
            {
                decimal expiry = item.TotalBuyingPrice - item.PaidPrice;
                if (expiry < gelen)
                {
                    decimal fark = model.Price - expiry;
                    item.PaidPrice = model.Price - fark;
                    item.IsDeleted = true;
                    gelen          = model.Price - item.PaidPrice;
                    rpsupplierexpiry.SaveChanges();
                }
                else
                {
                    item.PaidPrice += gelen;
                    rpsupplierexpiry.SaveChanges();
                    gelen = 0;
                }
                if (gelen == 0)
                {
                    break;
                }
            }

            var expiryPayment = new ExpiryPayment
            {
                Price       = model.Price,
                PersonID    = model.ID,
                AdminUserID = UserID()
            };

            rpexpirypayment.Add(expiryPayment);
            //string postValue = "#" + supplier.ID + " " + supplier.CompanyName + " " + supplier.Phone;
            return(Json("", JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        private void SaveOthers(int id, ProductVM model)
        {
            var paymentInfo = new PaymentInfo
            {
                BankName     = model.BankName,
                BankCartName = model.BankCartName,
                CartNumber   = model.CartNumber,
                Payment      = model.Payment,
                CheckNumber  = model.CheckNumber,
                ExpiryDate   = model.ExpiryDate == null ? DateTime.Now : Convert.ToDateTime(model.ExpiryDate),
                ProductID    = id,
                UnitPrice    = model.UnitPrice,
                Count        = model.Count,
                BuyingCount  = model.Count,
                SupplierID   = model.SupplierID
            };

            if (model.CategoryID == 6 || model.CategoryID == 7)
            {
                paymentInfo.IMEICount = model.Count;
            }
            rppaymentinfo.Add(paymentInfo);
            if (model.Payment == "Vadeli")
            {
                var supplierExpiry = new SupplierExpiry
                {
                    ExpiryDate       = model.ExpiryDate == null ? DateTime.Now : Convert.ToDateTime(model.ExpiryDate),
                    PaidPrice        = Convert.ToDecimal(model.PaidPrice),
                    ProductID        = id,
                    ProductCount     = model.Count,
                    SupplierID       = model.SupplierID,
                    TotalBuyingPrice = Calculate(model)
                };
                rpsupplierexpiry.Add(supplierExpiry);
                if (model.PaidPrice != 0)
                {
                    var expiryPayment = new ExpiryPayment
                    {
                        AdminUserID = UserID(),
                        PersonID    = model.SupplierID,
                        Price       = model.PaidPrice
                    };
                    rpexpirypayment.Add(expiryPayment);
                }
                ExpiryService.SetSupplierExpiry(supplierExpiry);
            }
        }
コード例 #3
0
        public ActionResult AddSale(SaleVM model)
        {
            var sepet = (CartVM)Session["Sepet"];

            if (sepet != null)
            {
                int userId = UserID();
                model.InvoiceDate = model.InvoiceDate.Year == 0001 ? DateTime.Now : model.InvoiceDate;
                Sale sale = new Sale()
                {
                    PaymentType = model.PaymentType,
                    UserID      = userId,
                    CustomerID  = model.CustomerID,
                    InvoiceDate = model.InvoiceDate,
                    ExpiryDate  = model.ExpiryDate.Year == 0001 ? DateTime.Now : model.ExpiryDate,
                    TotalPrice  = sepet.TotalSalePrice,
                    IsInvoiced  = model.Invoice == 1 ? true : false
                };
                var list = new List <SaleDetails>();
                foreach (var item in sepet.ProductList)
                {
                    SaleDetails detail = new SaleDetails()
                    {
                        ProductID     = item.ID,
                        KdvPrice      = Math.Round(item.KdvPrice, 2),
                        Quantity      = item.SaleCount,
                        Price         = Math.Round(item.UnitSalePrice, 2),
                        AddDate       = DateTime.Now,
                        IsPhone       = item.CategoryID == 6 || item.CategoryID == 7 ? true : false,
                        UnitSalePrice = item.UnitPrice,
                        CategoryID    = item.CategoryID
                    };
                    list.Add(detail);
                }
                sale.SaleDetails = list;
                rpsale.Add(sale);
                SetPaymentInfoforAdding(sale.SaleDetails, sepet.ProductList);

                if (model.PaymentType == "Vadeli")
                {
                    CustomerExpiry expiry = new CustomerExpiry()
                    {
                        ExpiryDate     = model.ExpiryDate,
                        CustomerID     = model.CustomerID,
                        PaidPrice      = model.PaidExpiryValue,
                        SaleID         = sale.ID,
                        SaleTotalPrice = sepet.TotalSalePrice
                    };
                    ExpiryService.SetCustomerExpiry(expiry);
                    rpcustomerexpiry.Add(expiry);
                    if (model.PaidExpiryValue != 0)
                    {
                        var expiryPayment = new ExpiryPayment
                        {
                            AdminUserID = UserID(),
                            PersonID    = model.CustomerID,
                            Price       = model.PaidExpiryValue
                        };
                        rpexpirypayment.Add(expiryPayment);
                    }
                }
                if (model.Invoice == 1)
                {
                    return(RedirectToAction("SetInvoice", model));
                }
                Session.Remove("Sepet");
            }
            return(RedirectToAction("Index"));
        }