Example #1
0
        private void SaveACBankAccountTransferEntity()
        {
            if (IsValid)
            {
                try
                {
                    ACBankAccountTransferEntity aCBankAccountTransferEntity = BuildACBankAccountTransferEntity();

                    Int64 result = -1;

                    if (aCBankAccountTransferEntity.IsNew)
                    {
                        result = FCCACBankAccountTransfer.GetFacadeCreate().Add(aCBankAccountTransferEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(ACBankAccountTransferEntity.FLD_NAME_BankAccountTransferID, aCBankAccountTransferEntity.BankAccountTransferID.ToString(), SQLMatchType.Equal);
                        result = FCCACBankAccountTransfer.GetFacadeCreate().Update(aCBankAccountTransferEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        #region Approval Process

                        Boolean apResult = APRobot.CreateApprovalProcessForNewBankAccountTransfer(result, Int64.Parse(ddlAPPanelID.SelectedValue));

                        if (apResult == true)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Approval Process Submited successfully.", UIConstants.MessageType.GREEN);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to Submit Approval Process.", UIConstants.MessageType.RED);
                        }

                        #endregion


                        //try
                        //{
                        //    #region Journal Entry

                        //    //Bank To Bank Tranfer amount
                        //    //Normal Trnasaction without Charge
                        //    //===================================
                        //    //    From Current amount to pretty cash
                        //    //    Current Accont (-) Credit
                        //    //    Petty Cash Account(+) Debit
                        //    //====================================

                        //    //Transaction with Charge
                        //    //===================================
                        //    //    From Current amount to pretty cash
                        //    //    sum of amount transfer + Charge	Current Accont (-) Credit
                        //    //    Petty Cash Account(+) Debit
                        //    //    Charge also (+) Debit but different account Head {Interest and Bank Charges}

                        //    ACBankAccountTransferEntity acBankAccountTransferEntity = FCCACBankAccountTransfer.GetFacadeCreate().GetByID(result);

                        //    if (acBankAccountTransferEntity != null && acBankAccountTransferEntity.BankAccountTransferID > 0)
                        //    {
                        //        Decimal amount, charge, totalAmount;
                        //        Decimal.TryParse(acBankAccountTransferEntity.Amount.ToString(), out amount);
                        //        Decimal.TryParse(acBankAccountTransferEntity.BankCharge.ToString(), out charge);

                        //        totalAmount = amount + charge;

                        //        if (amount > 0)
                        //        {
                        //            #region From Account(Credit Entry)

                        //            ACJournalEntity acJournalEntity = new ACJournalEntity();


                        //            String fe_account = SqlExpressionBuilder.PrepareFilterExpression("ACBankAccount." + ACAccountsHelper_CustomEntity.FLD_NAME_BankAccountID, acBankAccountTransferEntity.FromBankAccountID.ToString(), SQLMatchType.Equal);
                        //            IList<ACAccountsHelper_CustomEntity> lst = FCCACAccountsHelper_Custom.GetFacadeCreate().GetIL(1000, 1, fe_account);

                        //            if (lst != null && lst.Count > 0)
                        //            {
                        //                acJournalEntity.AccountID = lst[0].AccountID;
                        //                acJournalEntity.AccountGroupID = lst[0].AccountGroupID;
                        //                acJournalEntity.ClassID = lst[0].ClassID;
                        //                acJournalEntity.ClassTypeID = lst[0].ClassTypeID;
                        //            }

                        //            String fe_fiscalYear = SqlExpressionBuilder.PrepareFilterExpression(ACFiscalYearEntity.FLD_NAME_IsClosed, "0", SQLMatchType.Equal);
                        //            IList<ACFiscalYearEntity> lstFiscalYear = FCCACFiscalYear.GetFacadeCreate().GetIL(null, null, String.Empty, fe_fiscalYear, DatabaseOperationType.LoadWithFilterExpression);

                        //            if (lstFiscalYear != null && lstFiscalYear.Count > 0)
                        //            {
                        //                acJournalEntity.FiscalYearID = lstFiscalYear[0].FiscalYearID;
                        //            }

                        //            acJournalEntity.TransactionDateTime = acBankAccountTransferEntity.TransferDate;
                        //            acJournalEntity.Amount = totalAmount;
                        //            acJournalEntity.EnteredByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                        //            acJournalEntity.ReferenceOrMemoOrID = acBankAccountTransferEntity.Memo;
                        //            acJournalEntity.Note = acBankAccountTransferEntity.Remarks;
                        //            acJournalEntity.MDDebitCreditID = MasterDataConstants.MDDebitCredit.CREDIT;
                        //            acJournalEntity.DimensionID = null;
                        //            acJournalEntity.ProjectID = null;
                        //            acJournalEntity.IsReverseTransaction = false;

                        //            FCCACJournal.GetFacadeCreate().Add(acJournalEntity, DatabaseOperationType.Add, TransactionRequired.No);

                        //            #endregion

                        //            #region To Account(Debit Entry)

                        //            String fe_TobankAccount = SqlExpressionBuilder.PrepareFilterExpression("ACBankAccount." + ACAccountsHelper_CustomEntity.FLD_NAME_BankAccountID, acBankAccountTransferEntity.ToBankAccountID.ToString(), SQLMatchType.Equal);
                        //            IList<ACAccountsHelper_CustomEntity> lstTobankAccount = FCCACAccountsHelper_Custom.GetFacadeCreate().GetIL(10000, 1, fe_TobankAccount);

                        //            if (lstTobankAccount != null && lstTobankAccount.Count > 0)
                        //            {
                        //                acJournalEntity.AccountID = lstTobankAccount[0].AccountID;
                        //                acJournalEntity.AccountGroupID = lstTobankAccount[0].AccountGroupID;
                        //                acJournalEntity.ClassID = lstTobankAccount[0].ClassID;
                        //                acJournalEntity.ClassTypeID = lstTobankAccount[0].ClassTypeID;
                        //            }

                        //            acJournalEntity.TransactionDateTime = acBankAccountTransferEntity.TransferDate;
                        //            acJournalEntity.Amount = amount;
                        //            acJournalEntity.EnteredByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                        //            acJournalEntity.ReferenceOrMemoOrID = acBankAccountTransferEntity.Memo;
                        //            acJournalEntity.Note = acBankAccountTransferEntity.Remarks;
                        //            acJournalEntity.MDDebitCreditID = MasterDataConstants.MDDebitCredit.DEBIT;
                        //            acJournalEntity.DimensionID = null;
                        //            acJournalEntity.ProjectID = null;
                        //            acJournalEntity.IsReverseTransaction = false;

                        //            FCCACJournal.GetFacadeCreate().Add(acJournalEntity, DatabaseOperationType.Add, TransactionRequired.No);

                        //            if (charge > 0)
                        //            {
                        //                acJournalEntity.Amount = charge;
                        //                acJournalEntity.AccountID = 23;//Should Change Here For Intrest and Loan

                        //                String fe_ChargeAccount = SqlExpressionBuilder.PrepareFilterExpression("ACAccount." + ACAccountsHelper_CustomEntity.FLD_NAME_AccountID, "23".ToString(), SQLMatchType.Equal);
                        //                IList<ACAccountsHelper_CustomEntity> lstChargeAccount = FCCACAccountsHelper_Custom.GetFacadeCreate().GetIL(10000, 1, fe_ChargeAccount);

                        //                if (lstTobankAccount != null && lstTobankAccount.Count > 0)
                        //                {
                        //                    acJournalEntity.AccountID = 23;
                        //                    acJournalEntity.AccountGroupID = lstChargeAccount[0].AccountGroupID;
                        //                    acJournalEntity.ClassID = lstChargeAccount[0].ClassID;
                        //                    acJournalEntity.ClassTypeID = lstChargeAccount[0].ClassTypeID;
                        //                }
                        //                acJournalEntity.MDDebitCreditID = MasterDataConstants.MDDebitCredit.DEBIT;
                        //                FCCACJournal.GetFacadeCreate().Add(acJournalEntity, DatabaseOperationType.Add, TransactionRequired.No);
                        //            }

                        //            #endregion

                        //            acJournalEntity = new ACJournalEntity();
                        //        }
                        //    }

                        //    #endregion
                        //}
                        //catch (Exception ex)
                        //{
                        //    MiscUtil.ShowMessage(lblMessage, "Some Error Occured To Save in Journal Entry", true);
                        //}

                        _BankAccountTransferID       = 0;
                        _ACBankAccountTransferEntity = new ACBankAccountTransferEntity();
                        PrepareInitialView();
                        BindACBankAccountTransferList();

                        if (aCBankAccountTransferEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Bank Account Transfer Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Bank Account Transfer Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (aCBankAccountTransferEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Bank Account Transfer Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Bank Account Transfer Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }