Example #1
0
        public BindingSource GetList()
        {
            InvestmentDataHelper DH = new InvestmentDataHelper();
            BindingSource        BS = new BindingSource();
            Hashtable            HT = new Hashtable();

            List <Investment> myList = DH.SelectAll();

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

            BS.DataSource = HT;
            return(BS);
        }
Example #2
0
 public BindingList <Investment> Show(Investment aType)
 {
     try
     {
         var myList      = new InvestmentDataHelper().SelectAll();
         var bindingList = new BindingList <Investment>(myList);
         return(bindingList);
     }
     catch (ArgumentNullException)
     {
         throw new DataExistence("No Data Found! No Investment is yet Added.");
     }
 }
Example #3
0
        public int Add(Investment aType)
        {
            int           returnValue = -1;
            int           returnKey;
            SqlConnection con = new ConnectionString().GetConnection();

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

            aTransaction.ContactID            = aType.InvestorDetails.ID;
            aTransaction.WalletType           = WalletType.Investment;
            aTransaction.Amount               = aType.InHand;
            aTransaction.FlowType             = FlowType.Credit;
            aTransaction.TransactionType      = TransactionType.Cash;
            aTransaction.TransactionReference = aType.Name + " Has Paid inhand amount";
            aTransaction.TransactionDate      = DateTime.Now;

            con.Open();

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

                try
                {
                    returnKey = new InvestmentDataHelper().Insert(aType, tran);

                    aTransaction.WalletReference = returnKey;

                    new FinancialTransactionDataHelper().Insert(aTransaction, tran);

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

            returnValue = returnKey;
            return(returnValue);
        }
Example #4
0
        public Investment Show(int SearchbyID)
        {
            var mySingleItem = new InvestmentDataHelper().SelectByID(SearchbyID);

            return(mySingleItem);
        }
        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;
                }
            }
        }