コード例 #1
0
        public educationgoal saveEducationGoals(educationgoal goals)
        {
            int status = 1;

            try
            {
                dbDataContext ct = new dbDataContext();
                ct.educationgoals.InsertOnSubmit(goals);
                ct.SubmitChanges();
            }
            catch (Exception e)
            {
                status = 0;
                string str = e.Message;
            }

            if (status == 0)
            {
                goals = null;
            }

            return goals;
        }
コード例 #2
0
        private void populateEducationGoal(educationgoal educationGoal, assumption assmptn, EntitySet<countrycostofeducation> cced, string caseid)
        {
            double shortfallSurplus = 0;

            inflationRate.Text = "0";

            maturityValue.Text = "0";
            futureValue.Text = "0";

            if(assmptn!=null && assmptn.percentage!=null)
            {
                inflationRate.Text = assmptn.percentage.ToString();
            }

            int idCountrySel = 0;
            idCountrySel = cced[0].id;

            if (countryList != null && countryList.SelectedValue != null && countryList.SelectedValue!="")
            {
                string countrySel = countryList.SelectedValue;
                idCountrySel = Int16.Parse(countrySel);
            }

            countryList.DataSource = cced;
            countryList.DataValueField = "id";
            countryList.DataTextField = "country";
            countryList.DataBind();
            countryList.SelectedValue = idCountrySel.ToString();

            costEducation.Text = "0";

            futureValue.Text = "0";

            yrsToSave.Text = "0";
            ageWhenFundsNeeded.Text = "0";
            currentAge.Text = "0";
            nameofChild.Text = "";
            existingAssetsEducationGoals.Text = "0";

            totalShortfallSurplus.Text = "0";

            educationGoalNeeded2.Selected = true;

            if (educationGoal != null)
            {
                educationGoalNeeded.SelectedValue = educationGoal.educationGoalNeeded.ToString();

                nameofChild.Text = educationGoal.nameofchild;

                if (educationGoal.currentage != null && educationGoal.currentage != "")
                {
                    currentAge.Text = educationGoal.currentage;
                }

                if (educationGoal.agefundsneeded != null && educationGoal.agefundsneeded != "")
                {
                    ageWhenFundsNeeded.Text = educationGoal.agefundsneeded;
                }

                if (educationGoal.noofyrstosave != null && educationGoal.noofyrstosave != "")
                {
                    yrsToSave.Text = educationGoal.noofyrstosave;
                }

                if (educationGoal.presentcost == null || educationGoal.presentcost == "")
                {
                    foreach (countrycostofeducation cc in cced)
                    {
                        if (cc.id == idCountrySel)
                        {
                            if (cc.costofeducation != null && cc.costofeducation != "")
                            {
                                costEducation.Text = cc.costofeducation;
                            }
                            else
                            {
                                costEducation.Text = "0";
                            }
                            break;
                        }
                    }
                }
                else
                {
                    costEducation.Text = educationGoal.presentcost;
                }

                futureValue.Text = costEducation.Text;

                if (educationGoal.countryofstudyid != null)
                {
                    countryList.SelectedValue = educationGoal.countryofstudyid.ToString();
                }

                futureValue.Text = educationGoal.futurecost;

                if (educationGoal.maturityvalue != null && educationGoal.maturityvalue != "")
                {
                    maturityValue.Text = educationGoal.maturityvalue;
                }

                assetList.DataSource = educationGoal.existingassetegs;
                assetList.DataBind();

                if (educationGoal.inflationrate != null && educationGoal.inflationrate != "")
                {
                    inflationRate.Text = educationGoal.inflationrate;
                }

                if (educationGoal.existingassetegs != null)
                {
                    ViewState["noofassets"] = educationGoal.existingassetegs.Count;

                    if (educationGoal.existingassetegs != null && educationGoal.existingassetegs.Count > 0)
                    {
                        existingAssetsEducationGoals.Text = educationGoal.existingassetstotal;
                    }
                    else
                    {
                        existingAssetsEducationGoals.Text = "0";
                    }

                }

            }

            string ExistingValuesplbl = (double.Parse(existingAssetsEducationGoals.Text) + double.Parse(maturityValue.Text)).ToString();

            if (futureValue.Text == "")
            {
                futureValue.Text = "0";
            }

            shortfallSurplus = double.Parse(ExistingValuesplbl) - double.Parse(futureValue.Text);

            totalShortfallSurplus.Text = Math.Abs(shortfallSurplus).ToString();

            if (shortfallSurplus < 0)
            {
                ttlSS.Text = "Shortfall";
                ttlSS.Style.Add("color", "red");
            }
            else if (shortfallSurplus > 0)
            {
                ttlSS.Text = "Surplus";
                ttlSS.Style.Add("color", "black");
            }
            else
            {
                ttlSS.Text = "Shortfall / Surplus";
                ttlSS.Style.Add("color", "black");
            }

            activityId.Value = caseid;
        }
コード例 #3
0
        public educationgoal updateEducationGoals(educationgoal goals, int egid)
        {
            educationgoal retrievedGoal = null;

            try
            {
                dbDataContext ct = new dbDataContext();

                //retrieve existing education goal
                var queryEducationGoals = from sg in ct.educationgoals
                                       where sg.caseid == goals.caseid && sg.id == egid
                                       select sg;
                foreach (educationgoal sgoals in queryEducationGoals)
                {
                    retrievedGoal = sgoals;
                }

                //update education goal attributes
                retrievedGoal.agefundsneeded = goals.agefundsneeded;
                retrievedGoal.currentage = goals.currentage;
                retrievedGoal.maturityvalue = goals.maturityvalue;
                retrievedGoal.nameofchild = goals.nameofchild;
                retrievedGoal.noofyrstosave = goals.noofyrstosave;
                retrievedGoal.total = goals.total;
                retrievedGoal.existingassetstotal = goals.existingassetstotal;
                retrievedGoal.futurecost = goals.futurecost;
                retrievedGoal.presentcost = goals.presentcost;
                retrievedGoal.inflationrate = goals.inflationrate;
                retrievedGoal.educationGoalNeeded = goals.educationGoalNeeded;

                retrievedGoal.countryofstudyid = goals.countryofstudyid;

                //delete existing assets for the education goal
                var queryExistingAssets = from easg in ct.existingassetegs
                                          where easg.educationgoalsid == retrievedGoal.id
                                          select easg;
                foreach (existingasseteg easgoals in queryExistingAssets)
                {
                    ct.existingassetegs.DeleteOnSubmit(easgoals);
                    //ct.SubmitChanges();
                }

                //update existing assets list for the education goal
                if (goals.existingassetegs != null && goals.existingassetegs.Count > 0)
                {
                    EntitySet<existingasseteg> easgList = new EntitySet<existingasseteg>();
                    foreach (existingasseteg sgea in goals.existingassetegs)
                    {
                        easgList.Add(sgea);
                    }
                    retrievedGoal.existingassetegs = easgList;
                }

                if (retrievedGoal.educationGoalNeeded == 1 || retrievedGoal.educationGoalNeeded == 0)
                {
                    var eduGoalRecords = from edug in ct.educationgoals
                                         where edug.caseid == goals.caseid
                                         select edug;
                    int[] arrRecordIds = null;

                    if (eduGoalRecords != null)
                    {
                        int size = eduGoalRecords.ToArray().Length;
                        arrRecordIds = new int[size];
                    }
                    int index = 0;
                    foreach (educationgoal egl in eduGoalRecords)
                    {
                        arrRecordIds[index] = egl.id;
                        index++;
                    }

                    var todelExistingAssets = from easg in ct.existingassetegs
                                              where arrRecordIds.Contains(easg.educationgoalsid)
                                              select easg;
                    foreach (existingasseteg easgoals in todelExistingAssets)
                    {
                        ct.existingassetegs.DeleteOnSubmit(easgoals);
                    }

                    var toDelEducationGoals = from sg in ct.educationgoals
                                              where sg.caseid == goals.caseid && sg.id != egid
                                              select sg;
                    foreach (educationgoal s in toDelEducationGoals)
                    {
                        ct.educationgoals.DeleteOnSubmit(s);
                    }
                }

                ct.SubmitChanges();

            }
            catch (Exception e)
            {
                string str = e.Message;
            }

            return retrievedGoal;
        }
コード例 #4
0
        protected void submitEducationGoals(object sender, EventArgs e)
        {
            educationgoal goals = new educationgoal();

            goals.educationGoalNeeded = Convert.ToInt16(educationGoalNeeded.SelectedValue);

            if (goals.educationGoalNeeded == 2)
            {
                goals.agefundsneeded = ageWhenFundsNeeded.Text;
                goals.currentage = currentAge.Text;
                goals.maturityvalue = maturityValue.Text;
                goals.nameofchild = nameofChild.Text;
                goals.noofyrstosave = yrsToSave.Text;

                if (totalShortfallSurplus.Text != null && totalShortfallSurplus.Text != "")
                {
                    double ttl = double.Parse(totalShortfallSurplus.Text);
                    if (ttl < 0)
                    {
                        totalShortfallSurplus.Text = Math.Abs(ttl).ToString();
                    }
                }
                goals.total = totalShortfallSurplus.Text;

                goals.existingassetstotal = existingAssetsEducationGoals.Text;
                goals.futurecost = futureValue.Text;
                goals.presentcost = costEducation.Text;
                goals.inflationrate = inflationRate.Text;
            }
            else if (goals.educationGoalNeeded == 1 || goals.educationGoalNeeded == 0)
            {
                goals.agefundsneeded = "0";
                goals.currentage = "0";
                goals.maturityvalue = "0";
                goals.nameofchild = "";
                goals.noofyrstosave = "0";
                goals.total = "0";
                goals.existingassetstotal = "0";
                goals.futurecost = "0";
                goals.presentcost = "0";
                goals.inflationrate = "0";
            }

            goals.deleted = false;

            string caseid = "";
            if (ViewState["caseid"]!=null)
            {
                caseid = ViewState["caseid"].ToString();
                goals.caseid = caseid;
            }

            goals.countryofstudyid = Int16.Parse(countryList.SelectedValue);

            int noofea = 0;
            if (goals.educationGoalNeeded == 2)
            {
                if (noofmembers.Value != "")
                {
                    noofea = Int16.Parse(noofmembers.Value);
                }
            }

            EntitySet<existingasseteg> easgList = new EntitySet<existingasseteg>();
            if (noofea > 0)
            {
                for (int i = 1; i <= noofea; i++)
                {
                    existingasseteg easg = new existingasseteg();
                    easg.asset = Request.Form["pri-" + i];
                    easg.presentvalue = Request.Form["pri_" + i];
                    easg.percentpa = Request.Form["sec_" + i];

                    if ((Request.Form["pri-" + i] != null) && (Request.Form["pri_" + i] != null) && (Request.Form["sec_" + i] != null))
                    {
                        easgList.Add(easg);
                    }

                }
                goals.existingassetegs = easgList;
            }

            int egid = 0;
            if (ViewState["egid"] != null)
            {
                egid = Int32.Parse(ViewState["egid"].ToString());
            }

            if (ViewState["casetype"] != null && ViewState["casetype"].ToString() == "new")
            {
                goals = educationGoalsDao.saveEducationGoals(goals);
            }
            else if (ViewState["casetype"] != null && ViewState["casetype"].ToString() == "update")
            {
                goals = educationGoalsDao.updateEducationGoals(goals, egid);
            }

            string actv = "";
            if (ViewState["activity"] != null)
            {
                actv = ViewState["activity"].ToString();
            }

            string status = activityStatusCheck.getEducationGoalStatus(caseid);
            activityStatusDao.saveOrUpdateActivityStatus(caseid, actv, status);

            markStatusOnTab(caseid);

            string caseStatus = activityStatusCheck.getZPlanStatus(caseid);

            /*if (st == 1)
            {
                lblStatusSubmitted.Visible = false;
            }
            else
            {
                lblStatusSubmissionFailed.Visible = true;
            }*/

            if (goals != null)
            {
                lblEducationGoalSuccess.Visible = true;

                educationGoal = educationGoalsDao.getEducationGoal(caseid);

                educationgoal displaysg = null;
                if (educationGoal != null && educationGoal.Count > 0)
                {
                    if (addandsave.Value == "1")
                    {
                        displaysg = educationGoal[educationGoal.Count-1];
                    }
                    else
                    {
                        bool found = false;
                        int count = 0;
                        foreach (educationgoal sgl in educationGoal)
                        {
                            if (egid == sgl.id)
                            {
                                found = true;
                                break;
                            }
                            count++;
                        }

                        if (found)
                        {
                            displaysg = educationGoal[count];
                        }
                        else
                        {
                            displaysg = educationGoal[0];
                        }
                    }

                    educationgoalid.Value = displaysg.id.ToString();
                    addandsave.Value = "";
                }
                populateEducationGoal(displaysg, assmptn, cced, caseid);

                List<educationgoal> gridgoal = educationGoal;
                foreach (educationgoal s in gridgoal)
                {
                    double damtfv = 0;
                    double dmaturityval = 0;
                    double deattl = 0;

                    if (s.futurecost != null && s.futurecost != "")
                    {
                        damtfv = double.Parse(s.futurecost);
                    }
                    if (s.maturityvalue != null && s.maturityvalue != "")
                    {
                        dmaturityval = double.Parse(s.maturityvalue);
                    }
                    if (s.existingassetstotal != null && s.existingassetstotal != "")
                    {
                        deattl = double.Parse(s.existingassetstotal);
                    }

                    if (((dmaturityval + deattl) - damtfv) < 0)
                    {
                        s.total = "-" + s.total;
                    }
                }

                //existingeggrid.DataSource = educationGoal;
                existingeggrid.DataSource = gridgoal;
                existingeggrid.DataBind();

                //refreshEducationGoal(assmptn, cced);
            }
            else
            {
                lblEducationGoalFailed.Visible = true;
            }
            string url = Server.MapPath("~/_layouts/Zurich/Printpages/");
            pdfData = activityStatusCheck.sendDataToSalesPortal(caseid, caseStatus, url, sendPdf);
        }
コード例 #5
0
ファイル: db.designer.cs プロジェクト: pmehra1/wen-zurich
		private void detach_educationgoals(educationgoal entity)
		{
			this.SendPropertyChanging();
			entity.countrycostofeducation = null;
		}
コード例 #6
0
ファイル: db.designer.cs プロジェクト: pmehra1/wen-zurich
 partial void Deleteeducationgoal(educationgoal instance);
コード例 #7
0
ファイル: db.designer.cs プロジェクト: pmehra1/wen-zurich
 partial void Updateeducationgoal(educationgoal instance);
コード例 #8
0
ファイル: db.designer.cs プロジェクト: pmehra1/wen-zurich
 partial void Inserteducationgoal(educationgoal instance);