Example #1
0
        private void insertInvoice_Product(Invoice invoice)
        {
            DataTable dt = (DataTable)dgInvoiceProduct.DataSource;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int quantity = 0;
                decimal price = 0;
                decimal totalPrice = 0;
                decimal serviceCharge = 0;
                bool subCon = false;
                string description = dt.Rows[i]["Description"].ToString();
                string categoryName = dt.Rows[i]["Name"].ToString();
                //Category selectedCategory = BLCategory.GetCategoryById(APCContext, categoryId);
                Category selectedCategory = BLCategory.GetCategoryByExactName(APCContext, categoryName);
                Kurs selectedKurs = BLKurs.GetKursByExactName(APCContext, dt.Rows[i]["Kurs"].ToString());
                int.TryParse(dt.Rows[i]["Quantity"].ToString(), out quantity);
                decimal.TryParse(dt.Rows[i]["Price"].ToString(), out price);
                decimal.TryParse(dt.Rows[i]["Total"].ToString(), out totalPrice);
                decimal.TryParse(dt.Rows[i]["ServiceCharge"].ToString(), out serviceCharge);
                bool.TryParse(dt.Rows[i]["SubCon"].ToString(), out subCon);

                BLInvoice_Product.insertInvoice_Product(APCContext, invoice, selectedCategory, description, quantity, dt.Rows[i]["Unit"].ToString(), price, selectedKurs, serviceCharge, totalPrice, subCon);
            }
        }
Example #2
0
 private void deleteInvoice_Product(Invoice invoice)
 {
     List<Invoice_Product> invoiceProductList = BLInvoice_Product.GetInvoice_ProductByInvoiceId(APCContext, invoice.Id);
     for (int i = 0; i < invoiceProductList.Count(); i++)
     {
         int invoiceProductId = 0;
         int.TryParse(invoiceProductList[i].Id.ToString(), out invoiceProductId);
         Invoice_Product currentInvoice_Product = BLInvoice_Product.GetInvoice_ProductById(APCContext, invoiceProductId);
         if (currentInvoice_Product != null)
         {
             APCContext.DeleteObject(currentInvoice_Product);
             APCContext.SaveChanges();
         }
     }
 }
Example #3
0
 private bool InsertInvoicePO(Invoice selectedInvoice)
 {
     bool success = true;
     DataTable dtPO = (DataTable)dgPO.DataSource;
     if (dtPO != null)
     {
         for (int i = 0; i < dtPO.Rows.Count; i++)
         {
             PO selectedPO = BLPO.GetPOById(APCContext, int.Parse(dtPO.Rows[i]["POId"].ToString()));
             if (!BLInvoice.insertInvoicePO(APCContext, selectedInvoice, selectedPO))
                 success = false;
         }
     }
     return success;
 }
Example #4
0
 private bool DeleteInvoicePO(Invoice selectedInvoice)
 {
     bool success = true;
     List<Invoice_PO> invoicePOList = BLInvoice.GetListInvoicePOByInvoiceId(APCContext, selectedInvoice.Id);
     if (invoicePOList != null)
     {
         for (int i = 0; i < invoicePOList.Count; i++)
         {
             PO selectedPO = invoicePOList[i].PO;
             selectedPO.Invoiced = false;
             Invoice_PO currentInvoicePO = BLInvoice.GetInvoicePOByInvoiceIdAndPOId(APCContext, selectedInvoice.Id, selectedPO.Id);
             APCContext.DeleteObject(currentInvoicePO);
             APCContext.SaveChanges();
         }
     }
     return success;
 }