Exemple #1
0
        // GET: InvoiceForPurchases/Edit/5
        public ActionResult Edit(int id)
        {
            InvoiceForPurchase item = InvoiceForPurchaseMethods.GetItem(id);

            if (item == null)
            {
                return(HttpNotFound());
            }
            return(View(item));
        }
Exemple #2
0
        /// <summary>
        /// Общая стоимость
        /// </summary>
        /// <param name="sales">Накладная</param>
        /// <returns>Общая стоимость</returns>
        public static decimal TotalPrice(InvoiceForPurchase sales)
        {
            decimal price = 0;

            foreach (var item in sales.Products)
            {
                price = price + item.Price;
            }
            return(price);
        }
Exemple #3
0
 public ActionResult Edit(InvoiceForPurchase item)
 {
     try
     {
         if (ModelState.IsValid)
         {
             InvoiceForPurchaseMethods.ChangeItem(item);
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException)
     {
         //Log the error (add a variable name after DataException)
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(item));
 }
Exemple #4
0
 /// <summary>
 /// Конвертация в продукт
 /// </summary>
 /// <param name="client">Продукт БД</param>
 /// <returns>Продукт</returns>
 public static Product Convert(ProductEnt product, bool logic = true)
 {
     if (product != null)
     {
         SalesInvoice       sales = null;
         InvoiceForPurchase invoiceForPurchase = null;
         Category           category           = null;
         if (logic == true)
         {
             //sales = Convert(product.SalesInvoice, false);
             category           = Convert(product.Category, false);
             invoiceForPurchase = Convert(product.InvoiceForPurchase, false);
         }
         Product productEnt = new Product
         {
             Description = product.Description,
             //SalesInvoice = sales,
             //SalesInvoiceId=product.SalesInvoiceId,
             InvoiceForPurchase   = invoiceForPurchase,
             Commit               = product.Commit,
             InvoiceForPurchaseId = product.InvoiceForPurchaseId,
             CategoryId           = product.CategoryId,
             CostPrice            = product.CostPrice,
             DateOfPurchase       = product.DateOfPurchase,
             DateOfSale           = product.DateOfSale,
             Id        = product.Id,
             Name      = product.Name,
             Archiving = product.Archiving,
             Category  = category, /*new { Name = product.Category.Name },*/
             Price     = product.Price,
             Status    = product.Status
         };
         return(productEnt);
     }
     else
     {
         return(null);
     }
 }
Exemple #5
0
 /// <summary>
 /// Конвертация в накладную закупок
 /// </summary>
 /// <param name="client">Накладная закупок БД</param>
 /// <returns>Накладная закупок</returns>
 public static InvoiceForPurchase Convert(InvoiceForPurchaseEnt invoiceForPurchase, bool logic = true)
 {
     if (invoiceForPurchase != null)
     {
         List <Product>  productEnts     = null;
         Employee        employee        = null;
         CompanyProvider companyProvider = null;
         if (logic == true)
         {
             companyProvider = Convert(invoiceForPurchase.CompanyProvider, false);
             employee        = Convert(invoiceForPurchase.Employee, false);
             productEnts     = new List <Product>();
             foreach (var item in invoiceForPurchase.ProductEnts)
             {
                 productEnts.Add(Convert(item, false));
             }
         }
         InvoiceForPurchase invoiceForPurchaseEnt = new InvoiceForPurchase
         {
             Date              = invoiceForPurchase.Date,
             Description       = invoiceForPurchase.Description,
             CompanyProviderId = invoiceForPurchase.CompanyProviderId,
             EmployeeId        = invoiceForPurchase.EmployeeId,
             Employee          = employee,
             Id = invoiceForPurchase.Id,
             CompanyProvider = companyProvider,
             Archiving       = invoiceForPurchase.Archiving,
             Products        = productEnts
         };
         return(invoiceForPurchaseEnt);
     }
     else
     {
         return(null);
     }
 }
Exemple #6
0
 /// <summary>
 /// Конвертация в накладную закупок БД
 /// </summary>
 /// <param name="client">Накладная закупок</param>
 /// <returns>Накладная закупок БД</returns>
 public static InvoiceForPurchaseEnt Convert(InvoiceForPurchase invoiceForPurchase)
 {
     if (invoiceForPurchase != null)
     {
         var x = Unit.InvoiceForPurchaseRepository.GetItem(invoiceForPurchase.Id);
         if (x != null)
         {
             return(x);
         }
         else
         {
             List <ProductEnt> productEnts = new List <ProductEnt>();
             foreach (var item in invoiceForPurchase.Products)
             {
                 productEnts.Add(Convert(item));
             }
             InvoiceForPurchaseEnt invoiceForPurchaseEnt = new InvoiceForPurchaseEnt
             {
                 CompanyProvider = Convert(invoiceForPurchase.CompanyProvider),
                 Date            = invoiceForPurchase.Date,
                 Description     = invoiceForPurchase.Description,
                 Employee        = Convert(invoiceForPurchase.Employee),
                 Id = invoiceForPurchase.Id,
                 CompanyProviderId = invoiceForPurchase.CompanyProviderId,
                 EmployeeId        = invoiceForPurchase.EmployeeId,
                 ProductEnts       = productEnts,
                 Archiving         = invoiceForPurchase.Archiving
             };
             return(invoiceForPurchaseEnt);
         }
     }
     else
     {
         return(null);
     }
 }
Exemple #7
0
 /// <summary>
 /// Поиск элемента
 /// </summary>
 /// <param name="item">Элемент</param>
 /// <returns>Логическое значение</returns>
 static public bool ChangeItem(InvoiceForPurchase item)
 {
     return(Unit.InvoiceForPurchaseRepository.ChangeItem(ConvertEntity.Convert(item)));
 }