Esempio n. 1
0
    bool Delete(int SalesID)
    {
        //return     objSalesMaster.Delete(p => p.SalesID == SalesID);

        objSalesMaster = objSalesMaster.Single(p => p.SalesID == SalesID);
        // totalpurchase-payments
        Double             rest      = objSalesMaster.Rest;//محصله الفاتوره النهائيه الا هى عباره عن اجمالى الفاتوره ناقص مدفوع العميل
        List <SalesDetail> itemslist = objSalesMaster.SalesDetails.ToList();
        var payments = objSalesMaster.CustomersPayment;

        objCustomer = objSalesMaster.Customer;


        try
        {
            objSalesMaster.BeginTransaction();

            //update Customer balance
            objCustomer.Balance -= rest;
            objCustomer.Update(p => p.CustomerID == objCustomer.CustomerID);
            //update products (store)
            itemslist.ForEach(p =>
            {
                //update qty
                SalesManager.UpdateproductQTY(QTYOperation.Increment, p.ProductID, p.Quantity);
            }
                              );



            // delete purchaseitems(PurchasesDetails)
            itemslist.DeleteAll();



            //delete masetr(PurchasesMaster)

            objSalesMaster.Delete(p => p.SalesID == SalesID);
            //delete payments
            if (payments != null)
            {
                payments.Delete(p => p.CustomerPaymentID == payments.CustomerPaymentID);
            }
            objSalesMaster.EndTransaction();
        }
        catch (Exception ex)
        {
            ExtenssionClass.Rollback();
            Page.Show(ex.Message);
            return(false);
        }
        return(true);
    }
Esempio n. 2
0
    bool Delete(int discardsID)
    {
        objPurchaseDiscardsMaster = objPurchaseDiscardsMaster.Single(p => p.PurchaseDiscardsID == discardsID);

        List <PurchaseDiscardsDetail> itemsList = objPurchaseDiscardsMaster.PurchaseDiscardsDetails.ToList();

        objSupplier = objPurchaseDiscardsMaster.PurchasesMaster.Supplier;

        try
        {
            objPurchaseDiscardsMaster.BeginTransaction();


            //update Supplier balance
            // هيزيد
            objSupplier.Balance += objPurchaseDiscardsMaster.TotalReturn;
            objSupplier.Update(p => p.SupplierID == objSupplier.SupplierID);


            //update products (store)
            itemsList.ForEach(p =>
            {
                //update qty
                //هيزيد
                SalesManager.UpdateproductQTY(QTYOperation.Increment, p.ProductID, p.Quantity);
            }
                              );

            // delete purchaseitems(PurchasesDetails)
            itemsList.DeleteAll();

            //delete masetr(PurchasesMaster)
            objPurchaseDiscardsMaster.Delete(p => p.PurchaseDiscardsID == discardsID);

            objPurchaseDiscardsMaster.EndTransaction();
        }
        catch (Exception ex)
        {
            ExtenssionClass.Rollback();
            Page.Show(ex.Message);
            return(false);
        }
        return(true);
    }