/// <summary>
        /// Code to Validate Sell Transaction Validation
        /// </summary>
        /// <param name="investementDetails"></param>
        /// <returns></returns>

        private bool SellValidation(InvestDto investementDetails)
        {
            bool IsValid = true;

            try
            {
                if (investementDetails.goldSaleUnits <= 0)
                {
                    MessageBox.Show(" Sale Units should be greater than zero");
                    IsValid = false;
                }
                if (investementDetails.goldSaleUnits > totalAccumalatedGoldUnits)
                {
                    MessageBox.Show(" Sale Units should be equal or less than Total Accumulated Gold Units");
                    IsValid = false;
                }
            }
            catch (Exception ex)
            {
                IsValid = false;
                MessageBox.Show("Error Occured! Please Try Later.");
                LogFile(ex.Message);
            }
            return(IsValid);
        }
 /// <summary>
 /// Code for Sale Transaction
 /// </summary>
 private void SaleGold()
 {
     try
     {
         investementDetails = new InvestDto();
         investementDetails.goldSaleUnits = Convert.ToDecimal(txtGldSaleUnits.Text);
         if (!SellValidation(investementDetails))
         {
             return;
         }
         investementDetails.currentPrice = Convert.ToDecimal(txtGoldRate.Text);
         CalculateComission();
         investementDetails.grossSaleAmount = investementDetails.goldSaleUnits * investementDetails.currentPrice;
         investementDetails.netSaleAmount   = investementDetails.grossSaleAmount - investementDetails.sellingCommission;
         investementDetails.trnsactionType  = "Sale";
         investementDetails.investmentDate  = System.DateTime.Now;
         CalculateTotalValues();
         investmentCollection.Add(investementDetails);
         DisplayTotalDetails();
         BindData(investmentCollection);
         DisplayCalculateProfitorLoss();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error Occured! Please Try Later.");
         LogFile(ex.Message);
     }
 }
        /// <summary>
        /// Code to check Buy Validation
        /// </summary>
        /// <param name="investementDetails"></param>
        /// <returns></returns>
        private bool BuyValidation(InvestDto investementDetails)
        {
            bool IsValid = true;

            if (investementDetails.investmentAmount <= 0)
            {
                MessageBox.Show("Please enter Investment Amount between 1 to 20000");
                IsValid = false;
            }
            return(IsValid);
        }
        /// <summary>
        /// Code to Validate Day Limit Invetment Amount
        /// </summary>
        /// <param name="totalDayInvestment"></param>
        /// <returns></returns>
        private bool DaylimitValidation(decimal totalDayInvestment, InvestDto investementDetails)
        {
            bool isDaylimitValid = true;

            if (totalDayInvestment > 20000)
            {
                MessageBox.Show("Maximum Day Investment Limit is 20000");
                isDaylimitValid = false;
            }

            return(isDaylimitValid);
        }
        /// <summary>
        /// Code to Buy transaction
        /// </summary>
        private void BuyGold()
        {
            try
            {
                investementDetails                  = new InvestDto();
                investementDetails.gstValue         = objOperations.CalculateGST(Convert.ToDecimal(txtInvAmount.Text));
                investementDetails.investedPrice    = Convert.ToDecimal(txtGoldRate.Text);
                investementDetails.investmentAmount = Convert.ToDecimal(txtInvAmount.Text);
                totalDayInvestment                  = totalDayInvestment + investementDetails.investmentAmount;
                if (!DaylimitValidation(totalDayInvestment, investementDetails))
                {
                    totalDayInvestment = totalDayInvestment - investementDetails.investmentAmount;
                    return;
                }

                if (!BuyValidation(investementDetails))
                {
                    return;
                }
                investementDetails.netInvestedAmount    = investementDetails.investmentAmount - investementDetails.gstValue;
                investementDetails.accumulatedGoldUnits = objOperations.CalculateGoldUnits(investementDetails.netInvestedAmount, investementDetails.investedPrice);
                investementDetails.trnsactionType       = "Buy";
                investementDetails.investmentDate       = System.DateTime.Now;
                totalInvestmentAmount     = totalInvestmentAmount + investementDetails.investmentAmount;
                totalAccumalatedGoldUnits = totalAccumalatedGoldUnits + investementDetails.accumulatedGoldUnits;
                investmentCollection.Add(investementDetails);
                DisplayTotalDetails();
                BindData(investmentCollection);
                DisplayCalculateProfitorLoss();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Occured! Please Try Later.");
                LogFile(ex.Message);
            }
        }