Exemple #1
0
        private InvestmentSegment getInvestmentSegmentData()
        {
            InvestmentSegment invSeg = new InvestmentSegment();

            invSeg.RiskProfileId = _riskProfileId;
            invSeg.Id            = int.Parse(txtSegmentName.Tag.ToString());
            invSeg.SegmentName   = txtSegmentName.Text;
            if (rdoEquity.Checked)
            {
                invSeg.InvestmentType = rdoEquity.Text;
            }
            if (rdoGold.Checked)
            {
                invSeg.InvestmentType = rdoGold.Text;
            }
            if (rdoDebt.Checked)
            {
                invSeg.InvestmentType = rdoDebt.Text;
            }
            invSeg.SegmentRatio = string.IsNullOrEmpty(txtSegmentRatio.Text) ? 0 : float.Parse(txtSegmentRatio.Text);
            invSeg.CreatedOn    = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
            invSeg.CreatedBy    = Program.CurrentUser.Id;
            invSeg.UpdatedOn    = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
            invSeg.UpdatedBy    = Program.CurrentUser.Id;
            invSeg.MachineName  = Environment.MachineName;
            return(invSeg);
        }
Exemple #2
0
        private void btnSaveSegment_Click(object sender, EventArgs e)
        {
            InvestmentSegment invSegment = getInvestmentSegmentData();
            bool isSaved = false;

            if (invSegment != null && invSegment.Id == 0)
            {
                isSaved = invBifurcationIno.Add(invSegment);
            }
            else
            {
                isSaved = invBifurcationIno.Update(invSegment);
            }

            if (isSaved)
            {
                MessageBox.Show("Record save successfully.", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                fillSegmentInfo();
                grpSegment.Enabled = false;
            }
            else
            {
                MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void Update(InvestmentSegment investmentSegment)
        {
            try
            {
                string riskProfileName = DataBase.DBService.ExecuteCommandScalar(string.Format(GET_RISK_PROFILE_NAME_QUERY, investmentSegment.RiskProfileId));

                DataBase.DBService.BeginTransaction();
                DataBase.DBService.ExecuteCommandString(string.Format(UPDATE_QUERY,
                                                                      investmentSegment.InvestmentType,
                                                                      investmentSegment.SegmentName, investmentSegment.SegmentRatio,
                                                                      investmentSegment.UpdatedOn.ToString("yyyy-MM-dd hh:mm:ss"),
                                                                      investmentSegment.UpdatedBy,
                                                                      investmentSegment.Id), true);

                Activity.ActivitiesService.Add(ActivityType.UpdateInvestmentSegement, EntryStatus.Success,
                                               Source.Server, investmentSegment.UpdatedByUserName, investmentSegment.SegmentName, investmentSegment.MachineName);
                DataBase.DBService.CommitTransaction();
            }
            catch (Exception ex)
            {
                DataBase.DBService.RollbackTransaction();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                throw ex;
            }
        }
        public IList <InvestmentSegment> GetAll(int riskProfileId)
        {
            try
            {
                Logger.LogInfo("Get: Investment segment process start");
                IList <InvestmentSegment> investmentSegments = new List <InvestmentSegment>();

                DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_ALL, riskProfileId));
                foreach (DataRow dr in dtAppConfig.Rows)
                {
                    InvestmentSegment riskPrfile = convertToInvestmentSegmentObject(dr);
                    investmentSegments.Add(riskPrfile);
                }
                Logger.LogInfo("Get: Investment segment process completed.");
                return(investmentSegments);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
        private InvestmentSegment convertToInvestmentSegmentObject(DataRow dr)
        {
            InvestmentSegment invSeg = new InvestmentSegment();

            invSeg.Id             = dr.Field <int>("ID");
            invSeg.RiskProfileId  = dr.Field <int>("RISKPROFIILEID");
            invSeg.InvestmentType = dr.Field <string>("InvestmentType");
            invSeg.SegmentName    = dr.Field <string>("SegmentName");
            invSeg.SegmentRatio   = float.Parse(dr["SegmentRatio"].ToString());
            return(invSeg);
        }
Exemple #6
0
 private void btnDeleteSegment_Click(object sender, EventArgs e)
 {
     if (dtGridSegment.SelectedRows.Count > 0)
     {
         if (MessageBox.Show("Are you sure, you want to delete this record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             InvestmentSegment invSegment = getInvestmentSegmentData();
             invBifurcationIno.Delete(invSegment);
             fillSegmentInfo();
         }
     }
 }
        public Result Delete(InvestmentSegment investmentSegment)
        {
            var result = new Result();

            try
            {
                InvestmentSegmentService invSegmentService = new InvestmentSegmentService();
                invSegmentService.Delete(investmentSegment);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }
 internal bool Delete(InvestmentSegment invSegment)
 {
     try
     {
         FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
         string          apiurl          = Program.WebServiceUrl + "/" + DELETE_InvestmentSegment_API;
         RestAPIExecutor restApiExecutor = new RestAPIExecutor();
         var             restResult      = restApiExecutor.Execute <InvestmentSegment>(apiurl, invSegment, "POST");
         return(true);
     }
     catch (Exception ex)
     {
         StackTrace st = new StackTrace();
         StackFrame sf = st.GetFrame(0);
         MethodBase currentMethodName = sf.GetMethod();
         LogDebug(currentMethodName.Name, ex);
         return(false);
     }
 }