public List <ListViewItem> GetListView(Deal aDeal)
        {
            List <ListViewItem> ListViewItems = new List <ListViewItem>();

            InvestmentGroupDetailDataHelper DH    = new InvestmentGroupDetailDataHelper();
            List <InvestmentGroupDetail>    aList = DH.SelectByGroupID(aDeal.InvestmentGroupID);


            if (aList != null)
            {
                foreach (var item in aList)
                {
                    // Define the list items
                    ListViewItem aListViewItem = new ListViewItem(new InvestmentDataHelper().SelectByID(new InvestmentGroupDetailDataHelper().SelectByID(item.ID).InvestmentID).Name.ToString());
                    aListViewItem.SubItems.Add(item.InHand.ToString());
                    aListViewItem.SubItems.Add(item.BackUp.ToString());
                    aListViewItem.SubItems.Add(item.TotalAmount.ToString());
                    aListViewItem.SubItems.Add(item.ContributionPercentage.ToString());

                    // Add the list items to the ListView
                    ListViewItems.Add(aListViewItem);
                }
            }
            return(ListViewItems);
        }
        public BindingSource GetList(Investor anInvestor)
        {
            InvestmentGroupDetailDataHelper DH = new InvestmentGroupDetailDataHelper();
            BindingSource BS = new BindingSource();
            Hashtable     HT = new Hashtable();

            List <InvestmentGroupDetail> myList = DH.SelectByInvestorID(anInvestor.ID);

            try
            {
                if (myList != null)
                {
                    foreach (var item in myList)
                    {
                        if (item.State == EntityState.Enabled)
                        {
                            HT.Add(item.ID, item.ID);
                        }
                    }
                }
                HT.Add(-1, "Select Grouped Investment");
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }


            BS.DataSource = HT;
            return(BS);
        }
 public BindingList <InvestmentGroupDetail> Show(InvestmentGroup aType)
 {
     try
     {
         var myList      = new InvestmentGroupDetailDataHelper().SelectByGroupID(aType.ID);
         var bindingList = new BindingList <InvestmentGroupDetail>(myList);
         return(bindingList);
     }
     catch (ArgumentNullException)
     {
         throw new DataExistence("No Data Found! No Members are avialable in selected Investment group.");
     }
 }
 public BindingList <InvestmentGroupDetail> Show(InvestmentGroupDetail aType)
 {
     try
     {
         var myList      = new InvestmentGroupDetailDataHelper().SelectAll();
         var bindingList = new BindingList <InvestmentGroupDetail>(myList);
         return(bindingList);
     }
     catch (ArgumentNullException)
     {
         throw new DataExistence("No Data Found! No Members are yet added in Investment group.");
     }
 }
        public int Add(InvestmentGroupDetail aType)
        {
            int returnValue = -1;

            try
            {
                returnValue = new InvestmentGroupDetailDataHelper().Insert(aType);
                DataInserted(this, new EventArgs());
            }
            catch (SqlException ex)
            {
                throw ex;
            }

            return(returnValue);
        }
Exemple #6
0
        public int Add(FinancialTransaction aTransaction)
        {
            int           returnValue = -1;
            SqlConnection con         = new ConnectionString().GetConnection();

            con.Open();

            using (con)
            {
                SqlTransaction tran = con.BeginTransaction();

                try
                {
                    returnValue = new FinancialTransactionDataHelper().Insert(aTransaction, tran);

                    if (aTransaction.CascadeChanges)
                    {
                        if (aTransaction.WalletType == WalletType.Investment)
                        {
                            #region Insert in Investment
                            Investment anInvestment = new Investment();
                            Investor   anInvestor   = new Investor();

                            anInvestment.ID = aTransaction.WalletReference;
                            anInvestor.ID   = aTransaction.ContactID;
                            anInvestment.InvestorDetails = anInvestor;
                            anInvestment.InHand          = (aTransaction.FlowType == FlowType.Debit) ? aTransaction.Amount * -1 : aTransaction.Amount;

                            new InvestmentDataHelper().Update(anInvestment.ID, anInvestment, tran);
                            #endregion Insert in Investment
                        }
                        else if (aTransaction.WalletType == WalletType.InvestmentGroup)
                        {
                            InvestmentGroupDetailDataHelper anInvestmentGroupDetailDH = new InvestmentGroupDetailDataHelper();
                            InvestmentGroupDetail           aInvestmentGroupDetail    = new InvestmentGroupDetail();
                            int ainvestmentID = anInvestmentGroupDetailDH.SelectByID(aTransaction.WalletReference, tran).InvestmentID;

                            aInvestmentGroupDetail.AmountDeducted = true;
                            aInvestmentGroupDetail.ID             = aTransaction.WalletReference;
                            aInvestmentGroupDetail.InHand         = (aTransaction.FlowType == FlowType.Debit) ? aTransaction.Amount * -1 : aTransaction.Amount;

                            //Update Investment/Group Tables
                            anInvestmentGroupDetailDH.Update(aInvestmentGroupDetail.ID, aInvestmentGroupDetail, tran);

                            aTransaction.WalletType = WalletType.Investment;
                            //aInvestmentGroupDetail = anInvestmentGroupDetailDH.SelectByID(aTransaction.WalletReference,tran).InvestmentID;
                            aTransaction.WalletReference = ainvestmentID; //aInvestmentGroupDetail.InvestmentID;
                            aTransaction.FlowType        = (aTransaction.FlowType == FlowType.Debit) ? FlowType.Credit : FlowType.Debit;

                            //double entry rule, 2nd entry in Investment Account
                            new FinancialTransactionDataHelper().Insert(aTransaction, tran);
                        }
                    }

                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
            }

            return(returnValue);
        }
        public void DeductFinancialTransaction(int anInvestmentGroupID)
        {
            SqlConnection con = new ConnectionString().GetConnection();

            List <InvestmentGroupDetail>    anInvestmentGroupDetailList = new List <InvestmentGroupDetail>();
            InvestmentGroupDetailDataHelper aInvestmentGroupDetailDH    = new InvestmentGroupDetailDataHelper();

            Investment anInvestment = new Investment();
            Investor   anInvestor   = new Investor();


            FinancialTransactionDataHelper financialTransactionH = new FinancialTransactionDataHelper();
            FinancialTransaction           aTransaction          = new FinancialTransaction();

            aTransaction.CascadeChanges = false;



            con.Open();

            using (con)
            {
                SqlTransaction tran = con.BeginTransaction();

                try
                {
                    anInvestmentGroupDetailList = aInvestmentGroupDetailDH.SelectByGroupID(anInvestmentGroupID);

                    //Do financial Transaction
                    foreach (var item in anInvestmentGroupDetailList)
                    {
                        if (!item.AmountDeducted)
                        {
                            anInvestment = new InvestmentDataHelper().SelectByID(item.InvestmentID);
                            anInvestor   = anInvestment.InvestorDetails;

                            aTransaction.ContactID            = anInvestor.ID;
                            aTransaction.WalletType           = WalletType.Investment;
                            aTransaction.WalletReference      = item.InvestmentID;
                            aTransaction.Amount               = item.InHand;
                            aTransaction.FlowType             = FlowType.Debit;
                            aTransaction.TransactionType      = TransactionType.ApplicationTransfer;
                            aTransaction.TransactionReference = "Transfered to InvestmentGroup";
                            aTransaction.TransactionDate      = DateTime.Now;

                            // Deduct from Investment
                            financialTransactionH.Insert(aTransaction, tran);

                            //------------------------
                            // Add in InvestmentGroup
                            aTransaction.WalletType           = WalletType.InvestmentGroup;
                            aTransaction.WalletReference      = item.ID;
                            aTransaction.FlowType             = FlowType.Credit;
                            aTransaction.TransactionReference = "Transfered from Investment";

                            financialTransactionH.Insert(aTransaction, tran);
                        }
                    }

                    //do Update requied Tables
                    aInvestmentGroupDetailDH.UpdateDeductFT(anInvestmentGroupID, tran);

                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
            }
        }