Beispiel #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
                }
            }
        }
Beispiel #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
                }
            }
        }
Beispiel #3
0
        protected override void SaveChildEntities(string[] childEntityList, PaymentReceipt entity)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */

                case "PaymentDetails":
                    if (Session[ChildEntity] != null)
                    {
                        PaymentReceiptDetailsLibrary        library    = new PaymentReceiptDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptDetails> resultList = (IList <PaymentReceiptDetails>)Session[ChildEntity];
                        foreach (PaymentReceiptDetails PaymentReceiptDetails in resultList)
                        {
                            if (PaymentReceiptDetails.Apply_Amount > 0)
                            {
                                PaymentReceiptDetails.PaymentReceipt = new PaymentReceipt {
                                    ID = entity.ID
                                };
                                library.Add(PaymentReceiptDetails);
                            }
                        }
                    }
                    break;

                case "PaymentNotes":
                    if (Session[ChildEntity] != null)
                    {
                        PaymentReceiptNotesLibrary        PaymentReceiptNotesLibrary = new PaymentReceiptNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptNotes> resultList = (IList <PaymentReceiptNotes>)Session[ChildEntity];
                        foreach (PaymentReceiptNotes PaymentReceiptNote in resultList)
                        {
                            PaymentReceiptNote.Parent = new PaymentReceipt {
                                ID = entity.ID
                            };
                            //itemNote.Notes = System.Web.HttpUtility.HtmlDecode(itemNote.Notes);
                            PaymentReceiptNotesLibrary.Add(PaymentReceiptNote);
                        }
                    }
                    break;

                case "PaymentAttachments":
                    if (Session[ChildEntity] != null)
                    {
                        PaymentReceiptAttachmentsLibrary        PaymentReceiptLibrary = new PaymentReceiptAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PaymentReceiptAttachments> resultList            = (IList <PaymentReceiptAttachments>)Session[ChildEntity];
                        string      destinationPath;
                        string      sourcePath;
                        FilelHelper fileHelper = new FilelHelper();
                        foreach (PaymentReceiptAttachments PaymentReceipt in resultList)
                        {
                            destinationPath = fileHelper.GetSourceDirByFileRefId(PaymentReceipt.Document_RefId.ToString());     // Path.Combine(Configuration.GetsmARTDocPath(), PaymentReceipt.Document_RefId.ToString());
                            sourcePath      = fileHelper.GetTempSourceDirByFileRefId(PaymentReceipt.Document_RefId.ToString()); // Path.Combine(Configuration.GetsmARTTempDocPath(), PaymentReceipt.Document_RefId.ToString());
                            PaymentReceipt.Document_Path = fileHelper.GetFilePath(sourcePath);
                            fileHelper.MoveFile(PaymentReceipt.Document_Name, sourcePath, destinationPath);

                            PaymentReceipt.Parent = new PaymentReceipt {
                                ID = entity.ID
                            };
                            PaymentReceiptLibrary.Add(PaymentReceipt);
                        }
                    }
                    break;

                case "PaymentExpense":
                    if (Session[ChildEntity] != null)
                    {
                        PaymentExpenseLibrary         lib        = new PaymentExpenseLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <ExpensesRequest> resultList = (IList <ExpensesRequest>)Session[ChildEntity];
                        foreach (ExpensesRequest exp in resultList)
                        {
                            if (exp.Reference_Table == new Model.Scale().GetType().Name || exp.Reference_Table == new Model.DispatcherRequest().GetType().Name)
                            {
                                //ExpensesRequest scaleExp = lib.GetByID(exp.ID.ToString(), new string[] { "Paid_Party_To", "Payment" });
                                exp.Payment = new PaymentReceipt {
                                    ID = entity.ID
                                };
                                exp.Invoice = new Invoice {
                                    ID = 0
                                };
                                lib.Modify(exp, new string[] { "Paid_Party_To", "Payment", "Invoice" });
                            }
                            else
                            {
                                exp.Reference = new PaymentReceipt {
                                    ID = entity.ID
                                };
                                exp.Reference_Table = entity.GetType().Name;
                                exp.Reference_ID    = entity.ID;
                                exp.Payment         = new PaymentReceipt {
                                    ID = entity.ID
                                };
                                lib.Add(exp);
                            }
                        }
                    }
                    break;

                    #endregion
                }
            }
        }