//Deletes an item in the  database T Table
 public void DeleteTableItem(T item)
 {
     if (item != null)
     {
         using (ErpDataManagerDataContext dbc = new ErpDataManagerDataContext())
         {
             dbc.GetTable <T>().DeleteOnSubmit(item);
             dbc.SubmitChanges();
         }
     }
 }
        //Updates a product in the database
        public override void UpdateTableItem(int itemID, Product item)
        {
            if (item != null)
            {
                using (ErpDataManagerDataContext dbc = new ErpDataManagerDataContext())
                {
                    var product = (from p in dbc.Products
                                   where p.Id == itemID
                                   select p).Single();
                    product.Name = item.Name;

                    dbc.SubmitChanges();
                }
            }
        }
Exemple #3
0
        //Updates the BusinessPartnerType in the database
        public override void UpdateTableItem(int itemID, BusinessPartnerType item)
        {
            if (item != null)
            {
                using (ErpDataManagerDataContext dbc = new ErpDataManagerDataContext())
                {
                    var bpt = (from p in dbc.BusinessPartnerTypes
                               where p.Id == itemID
                               select p).Single();
                    bpt.TypeName = item.TypeName;

                    dbc.SubmitChanges();
                }
            }
        }
Exemple #4
0
        // Updates an InvoicedProduct in the database
        public override void UpdateTableItem(int itemID, InvoicedProduct item)
        {
            if (item != null)
            {
                using (ErpDataManagerDataContext dbc = new ErpDataManagerDataContext())
                {
                    var invoicedProduct = (from ip in dbc.InvoicedProducts
                                           where ip.Id == itemID
                                           select ip).Single();
                    invoicedProduct.OrderId          = item.OrderId;
                    invoicedProduct.InvoicedQuantity = item.InvoicedQuantity;
                    invoicedProduct.InvoicePrice     = item.InvoicePrice;

                    dbc.SubmitChanges();
                }
            }
        }
        public void AddTo_ProductStock(List <InvoicedProduct> incomingProducts)
        {
            if (incomingProducts.Count() > 0)
            {
                using (ErpDataManagerDataContext dbc = new ErpDataManagerDataContext())
                {
                    for (int i = 0; i < incomingProducts.Count(); i++)
                    {
                        var tempProductStockItem = (from ps in dbc.ProductStocks
                                                    where ps.ProductId == incomingProducts[i].ProductId
                                                    select ps).Single();
                        tempProductStockItem.Quantity += incomingProducts[i].InvoicedQuantity;
                        tempProductStockItem.Cost      = ProductPurchaseCostAmortisation(incomingProducts[i].InvoicePrice);
                    }

                    dbc.SubmitChanges();
                }
            }
        }
        public void RemoveFrom_ProductStock(List <InvoicedProduct> outgoingProducts)
        {
            if (outgoingProducts.Count() > 0)
            {
                using (ErpDataManagerDataContext dbc = new ErpDataManagerDataContext())
                {
                    for (int i = 0; i < outgoingProducts.Count(); i++)
                    {
                        var tempProductStockItem = (from ps in dbc.ProductStocks
                                                    where ps.ProductId == outgoingProducts[i].ProductId
                                                    select ps).Single();
                        if (tempProductStockItem.Quantity >= outgoingProducts[i].InvoicedQuantity)
                        {
                            tempProductStockItem.Quantity -= outgoingProducts[i].InvoicedQuantity;
                        }
                    }

                    dbc.SubmitChanges();
                }
            }
        }
        public override void UpdateTableItem(int itemID, BusinessPartner item)
        {
            if (item != null)
            {
                using (ErpDataManagerDataContext dbc = new ErpDataManagerDataContext())
                {
                    var bp = (from p in dbc.BusinessPartners
                              where p.Id == itemID
                              select p).Single();
                    bp.Name            = item.Name;
                    bp.LegalInfo       = item.LegalInfo;
                    bp.ContactInfo     = item.ContactInfo;
                    bp.DeliveryInfo    = item.DeliveryInfo;
                    bp.Type            = item.Type;
                    bp.PaymentTerms    = item.PaymentTerms;
                    bp.CustomPriceList = item.CustomPriceList;
                    bp.IsMasterPartner = item.IsMasterPartner;

                    dbc.SubmitChanges();
                }
            }
        }
Exemple #8
0
        //Updates the changes made to an order, in the Orders database table
        public override void UpdateTableItem(int itemID, Order item)
        {
            if (item != null)
            {
                using (ErpDataManagerDataContext dbc = new ErpDataManagerDataContext())
                {
                    var _order = (from o in dbc.Orders
                                  where o.Id == itemID
                                  select o).Single();
                    _order.OrderInfo    = item.OrderInfo;
                    _order.VendorId     = item.VendorId;
                    _order.CustomerId   = item.CustomerId;
                    _order.DocumentDate = item.DocumentDate;
                    _order.DeliveryDate = item.DeliveryDate;
                    _order.DueDate      = item.DueDate;
                    _order.IsOpen       = item.IsOpen;
                    _order.TaxRateId    = item.TaxRateId;
                    _order.Remarks      = item.Remarks;

                    dbc.SubmitChanges();
                }
            }
        }