Ejemplo n.º 1
0
        protected override void DeleteChildEntities(string[] childEntityList, string parentID)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */

                case "ReceiptDetails":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        PaymentReceiptDetailsLibrary        PaymentReceiptDetailsLibrary = new PaymentReceiptDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptDetails> resultList = PaymentReceiptDetailsLibrary.GetAllByParentID(Convert.ToInt32(parentID), new string[] { "Invoice", "PaymentReceipt" });
                        foreach (PaymentReceiptDetails PaymentReceiptDetails in resultList)
                        {
                            PaymentReceiptDetailsLibrary.Delete(PaymentReceiptDetails.ID.ToString());
                        }
                    }
                    break;

                case "ReceiptNotes":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        PaymentReceiptNotesLibrary        PaymentReceiptNotesLibrary = new PaymentReceiptNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptNotes> resultList = PaymentReceiptNotesLibrary.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (PaymentReceiptNotes PaymentReceiptNote in resultList)
                        {
                            PaymentReceiptNotesLibrary.Delete(PaymentReceiptNote.ID.ToString());
                        }
                    }
                    break;

                case "ReceiptAttachments":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        PaymentReceiptAttachmentsLibrary        PaymentReceiptLibrary = new PaymentReceiptAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptAttachments> resultList            = PaymentReceiptLibrary.GetAllByParentID(Convert.ToInt32(parentID));

                        foreach (PaymentReceiptAttachments PaymentReceiptAttachment in resultList)
                        {
                            PaymentReceiptLibrary.Delete(PaymentReceiptAttachment.ID.ToString());
                        }
                    }
                    break;

                    #endregion
                }
            }
        }
Ejemplo n.º 2
0
        protected override void DeleteChildEntities(string[] childEntityList, string parentID)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */

                case "PaymentDetails":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        PaymentReceiptDetailsLibrary        PaymentReceiptDetailsLibrary = new PaymentReceiptDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptDetails> resultList = PaymentReceiptDetailsLibrary.GetAllByParentID(Convert.ToInt32(parentID), new string[] { "Settlement", "PaymentReceipt", "ExpenseRequest" });
                        foreach (PaymentReceiptDetails PaymentReceiptDetails in resultList)
                        {
                            PaymentReceiptDetailsLibrary.Delete(PaymentReceiptDetails.ID.ToString());
                        }
                    }
                    break;

                case "PaymentNotes":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        PaymentReceiptNotesLibrary        PaymentReceiptNotesLibrary = new PaymentReceiptNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptNotes> resultList = PaymentReceiptNotesLibrary.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (PaymentReceiptNotes PaymentReceiptNote in resultList)
                        {
                            PaymentReceiptNotesLibrary.Delete(PaymentReceiptNote.ID.ToString());
                        }
                    }
                    break;

                case "PaymentAttachments":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        PaymentReceiptAttachmentsLibrary        PaymentReceiptLibrary = new PaymentReceiptAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptAttachments> resultList            = PaymentReceiptLibrary.GetAllByParentID(Convert.ToInt32(parentID));

                        foreach (PaymentReceiptAttachments PaymentReceiptAttachment in resultList)
                        {
                            PaymentReceiptLibrary.Delete(PaymentReceiptAttachment.ID.ToString());
                        }
                    }
                    break;

                case "PaymentExpense":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        ExpensesRequestLibrary        lib        = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <ExpensesRequest> resultList = lib.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (ExpensesRequest expReq in resultList)
                        {
                            lib.Delete(expReq.ID.ToString());
                        }

                        // Update payment Id
                        IEnumerable <ExpensesRequest> paymentExps = lib.GetAllByPaymentID(Convert.ToInt32(parentID), new[] { "Payment" });
                        foreach (ExpensesRequest expReq in paymentExps)
                        {
                            expReq.Payment.ID = 0;
                            lib.Modify(expReq, new[] { "Payment" });
                        }
                    }
                    break;
                    #endregion
                }
            }
        }