コード例 #1
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            WS.AllLifePrincingClient WS = new WS.AllLifePrincingClient();
            DataTable ReturnDT;

            ReturnDT = WS.returnPremium(TextBox4.Text, TextBox5.Text, TextBox6.Text, TextBox7.Text, TextBox8.Text, TextBox9.Text, TextBox10.Text, TextBox11.Text, TextBox12.Text, TextBox13.Text);
            //ReturnDT = WS.loginSubscriber(TextBox4.Text, TextBox5.Text, TextBox6.Text);
            GridView1.DataSource = ReturnDT;
            GridView1.DataBind();
            //Label2.Text = strReturnVal;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null)
            {
                //Response.Redirect("~/Login.aspx?ID=9");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "mykey", "CloseSessionExpired('9');", true);
            }

            lblInfo.Text = "";
            strMagnumID = Request.QueryString["MagnumID"].ToString();
            strQuoteAuditID = Request.QueryString["QuoteAuditID"].ToString();

            if (!IsPostBack)
            {
                RadPanelBar1.Items[0].Expanded = true;
                WS.AllLifePrincingClient WS = new WS.AllLifePrincingClient();

                string strSettingValue = string.Empty;

                #region "SQL Section"
                SqlConnection sqlConnectionX;
                SqlCommand sqlCommandX;
                SqlParameter sqlParam;
                SqlDataReader sqlDR;

                try
                {
                    sqlConnectionX = new SqlConnection(ConfigurationManager.AppSettings["SQLConnection"]);
                    sqlConnectionX.Open();

                    sqlCommandX = new SqlCommand();
                    sqlCommandX.Connection = sqlConnectionX;
                    sqlCommandX.CommandType = CommandType.StoredProcedure;
                    sqlCommandX.CommandText = "spx_SELECT_QuoteOptionAuditTrailByAuditTrailID";

                    sqlParam = new SqlParameter("QuoteAuditTrailID", strQuoteAuditID);
                    sqlCommandX.Parameters.Add(sqlParam);

                    sqlDR = sqlCommandX.ExecuteReader();
                    DataTable dt = new DataTable("AuditTrail");
                    dt.Load(sqlDR);

                    sqlDR.Close();
                    sqlCommandX.Cancel();
                    sqlCommandX.Dispose();
                    sqlConnectionX.Close();

                    Telerik.Web.UI.RadGrid OptionsGrid = (Telerik.Web.UI.RadGrid)RadPanelBar1.FindItemByValue("PanelItem1").FindControl("RadGridOptions");

                    OptionsGrid.DataSource = dt;
                    OptionsGrid.DataBind();
                    sqlConnectionX.Close();
                    sqlConnectionX.Dispose();

                }
                catch (Exception ex)
                {
                    lblInfo.Text = ex.Message;
                }

                #endregion
            }
        }
コード例 #3
0
        private string GetSetting(string SettingName)
        {
            WS.AllLifePrincingClient WS = new WS.AllLifePrincingClient();
            DataTable ReturnDT;

            string strSettingValue = string.Empty;

            SqlConnection sqlConnectionX;
            SqlCommand sqlCommandX;
            SqlParameter sqlParam;
            SqlDataReader sqlDR;

            try
            {
                sqlConnectionX = new SqlConnection(ConfigurationManager.AppSettings["SQLConnection"]);
                sqlConnectionX.Open();

                sqlCommandX = new SqlCommand();
                sqlCommandX.Connection = sqlConnectionX;
                sqlCommandX.CommandType = CommandType.StoredProcedure;
                sqlCommandX.CommandText = "spx_SELECT_Setting";

                sqlParam = new SqlParameter("SettingName", SettingName);
                sqlCommandX.Parameters.Add(sqlParam);

                sqlDR = sqlCommandX.ExecuteReader();
                while (sqlDR.Read())
                {
                    strSettingValue = sqlDR.GetValue(0).ToString();
                }

                sqlDR.Close();
                sqlCommandX.Cancel();
                sqlCommandX.Dispose();
                sqlConnectionX.Close();
            }
            catch (Exception ex)
            {
                lblInfo.Text = ex.Message;
            }

            return strSettingValue;
        }
コード例 #4
0
        private void ProcessOptionButton(int buttonNumber)
        {
            SqlConnection sqlConnectionX;
            SqlCommand sqlCommandX;
            SqlCommand sqlCommandX2;
            SqlParameter sqlParam;
            SqlDataReader sqlDR; 
            SqlDataReader sqlDR2;

            try
            {
                //Get the income amount
                decimal decIncome = Convert.ToDecimal(RadNumericTxtIncome.Text.Trim());
                //Get the percentage from the setting table for Option 1
                decimal decPI = 0;
                decimal decRate = 0; decimal decRateLife = 0; decimal decRateDisability = 0;
                string strSubscriberName = string.Empty; string strSubscriberPassword = string.Empty; string strSubscriberCode = string.Empty;
                string strProduct = string.Empty; string strBaseRisk = string.Empty; string strRiskModifier = string.Empty; string strGender = string.Empty;
                Decimal decCover = 0; Decimal decPremium = 0; Decimal decPremiumUnrounded = 0; Decimal decPremiumFixedFee = 0;
                Decimal decCoverDisability = 0; Decimal decPremiumDisability = 0; Decimal decPremiumDisabilityUnrounded = 0;
                string strDiabetesType = string.Empty;
                string strAgeBracket = string.Empty; string strControlLevel = string.Empty; string strDiabetesDuration = string.Empty;
                string strCholesterolIndicator = string.Empty; string strBPIndicator = string.Empty; string strSmokerLevel = string.Empty;
                string strDateDiagnosed = string.Empty; string strQuoteDate = string.Empty;
                string strOptionPISetting = string.Empty; string strControlFee = string.Empty;
                string strQualification = string.Empty; int intClass = 0;
                //decimal decDesiredContribution = 0;
                string strRiskband = string.Empty;
                string strProductType = string.Empty; string strEscalation = string.Empty;
                int LifeOrDisability = 1;
                Decimal decCPRateLife = 0; Decimal decCPRateDisability = 0;

                strOptionPISetting = "Option" + buttonNumber.ToString() + "PI";

                sqlConnectionX = new SqlConnection(ConfigurationManager.AppSettings["SQLConnection"]);
                sqlConnectionX.Open();

                if ((buttonNumber == 1) || (buttonNumber == 2) || (buttonNumber == 3))
                {
                    #region "Get Option PI"
                    sqlCommandX = new SqlCommand();
                    sqlCommandX.Connection = sqlConnectionX;
                    sqlCommandX.CommandType = CommandType.StoredProcedure;
                    sqlCommandX.CommandText = "spx_SELECT_Setting";

                    sqlParam = new SqlParameter("SettingName", strOptionPISetting);
                    sqlCommandX.Parameters.Add(sqlParam);

                    sqlDR = sqlCommandX.ExecuteReader();
                    while (sqlDR.Read())
                    {
                        decPI = Convert.ToDecimal(sqlDR.GetValue(0));
                    }

                    sqlDR.Close();
                    sqlCommandX.Cancel();
                    sqlCommandX.Dispose();
                    #endregion
                }

                #region "Get SubscriberName"
                sqlCommandX = new SqlCommand();
                sqlCommandX.Connection = sqlConnectionX;
                sqlCommandX.CommandType = CommandType.StoredProcedure;
                sqlCommandX.CommandText = "spx_SELECT_Setting";

                sqlParam = new SqlParameter("SettingName", "SubscriberName");
                sqlCommandX.Parameters.Add(sqlParam);

                sqlDR = sqlCommandX.ExecuteReader();
                while (sqlDR.Read())
                {
                    strSubscriberName = sqlDR.GetValue(0).ToString();
                }

                sqlDR.Close();
                sqlCommandX.Cancel();
                sqlCommandX.Dispose();
                #endregion

                #region "Get SubscriberPassword"
                sqlCommandX = new SqlCommand();
                sqlCommandX.Connection = sqlConnectionX;
                sqlCommandX.CommandType = CommandType.StoredProcedure;
                sqlCommandX.CommandText = "spx_SELECT_Setting";

                sqlParam = new SqlParameter("SettingName", "SubscriberPassword");
                sqlCommandX.Parameters.Add(sqlParam);

                sqlDR = sqlCommandX.ExecuteReader();
                while (sqlDR.Read())
                {
                    strSubscriberPassword = sqlDR.GetValue(0).ToString();
                }

                sqlDR.Close();
                sqlCommandX.Cancel();
                sqlCommandX.Dispose();
                #endregion

                #region "Get SubscriberCode"
                sqlCommandX = new SqlCommand();
                sqlCommandX.Connection = sqlConnectionX;
                sqlCommandX.CommandType = CommandType.StoredProcedure;
                sqlCommandX.CommandText = "spx_SELECT_Setting";

                sqlParam = new SqlParameter("SettingName", "SubscriberCode");
                sqlCommandX.Parameters.Add(sqlParam);

                sqlDR = sqlCommandX.ExecuteReader();
                while (sqlDR.Read())
                {
                    strSubscriberCode = sqlDR.GetValue(0).ToString();
                }

                sqlDR.Close();
                sqlCommandX.Cancel();
                sqlCommandX.Dispose();
                #endregion

                #region "Get Default Diabetes Product"
                sqlCommandX = new SqlCommand();
                sqlCommandX.Connection = sqlConnectionX;
                sqlCommandX.CommandType = CommandType.StoredProcedure;
                sqlCommandX.CommandText = "spx_SELECT_Setting";

                sqlParam = new SqlParameter("SettingName", "Default Diabetes Product");
                sqlCommandX.Parameters.Add(sqlParam);

                sqlDR = sqlCommandX.ExecuteReader();
                while (sqlDR.Read())
                {
                    strProduct = sqlDR.GetValue(0).ToString();
                }

                sqlDR.Close();
                sqlCommandX.Cancel();
                sqlCommandX.Dispose();
                #endregion

                if (RadioButtonMale.Checked)
                    strGender = "M";
                if (RadioButtonFemale.Checked)
                    strGender = "F";
                if (RadioButtonOther.Checked)
                    strGender = "M";

                //Compile the baserisk
                //[ANB][Gender][Smoker Status][Class of Life][Benefit Code]
                // Smoker status is always NS AND Benifit Code always WL - From meeting on 2015-06-9

                #region "If no class of life"
                if (HiddenFieldClassOfLife.Value == "0")
                {
                    if (RadioButtonNotMat.Checked)
                        strQualification = "No matric";
                    if (RadioButtonMatriculated.Checked)
                        strQualification = "Matric";
                    if (RadioButtonDiploma.Checked)
                        strQualification = "3 or 4 yr. Diploma/3 yr. Degree";
                    if (RadioButtonDegree.Checked)
                        strQualification = "4 yr. Degree/professional qualification";

                    if ((decIncome >= 0) && (decIncome < 10499))
                    {
                        switch (strQualification)
                        {
                            case "No matric":
                                intClass = 4;
                                break;
                            case "Matric":
                                intClass = 4;
                                break;
                            case "3 or 4 yr. Diploma/3 yr. Degree":
                                intClass = 3;
                                break;
                            case "4 yr. Degree/professional qualification":
                                intClass = 1;
                                break;
                        }
                    }

                    if ((decIncome >= 10500) && (decIncome < 15749))
                    {
                        switch (strQualification)
                        {
                            case "No matric":
                                intClass = 4;
                                break;
                            case "Matric":
                                intClass = 3;
                                break;
                            case "3 or 4 yr. Diploma/3 yr. Degree":
                                intClass = 2;
                                break;
                            case "4 yr. Degree/professional qualification":
                                intClass = 1;
                                break;
                        }
                    }

                    if ((decIncome >= 15750) && (decIncome < 26249))
                    {
                        switch (strQualification)
                        {
                            case "No matric":
                                intClass = 3;
                                break;
                            case "Matric":
                                intClass = 2;
                                break;
                            case "3 or 4 yr. Diploma/3 yr. Degree":
                                intClass = 1;
                                break;
                            case "4 yr. Degree/professional qualification":
                                intClass = 1;
                                break;
                        }
                    }

                    if ((decIncome >= 26250) && (decIncome < 41999))
                    {
                        switch (strQualification)
                        {
                            case "No matric":
                                intClass = 2;
                                break;
                            case "Matric":
                                intClass = 2;
                                break;
                            case "3 or 4 yr. Diploma/3 yr. Degree":
                                intClass = 1;
                                break;
                            case "4 yr. Degree/professional qualification":
                                intClass = 1;
                                break;
                        }
                    }

                    if (decIncome >= 42000)
                    {
                        switch (strQualification)
                        {
                            case "No matric":
                                intClass = 2;
                                break;
                            case "Matric":
                                intClass = 1;
                                break;
                            case "3 or 4 yr. Diploma/3 yr. Degree":
                                intClass = 1;
                                break;
                            case "4 yr. Degree/professional qualification":
                                intClass = 1;
                                break;
                        }
                    }

                    HiddenFieldClassOfLife.Value = intClass.ToString();
                }                

                #endregion

                //strBaseRisk = RadTxtAgeOfNextBirthday.Text.Trim() + strGender + "NS" + HiddenFieldClassOfLife.Value + "WL";

                strBaseRisk = GetBaseRisk(1);  //1 = Life

                //Compile the risk modifier
                //[Diabetes Type][Age Bracket at Quote][Control Level][Diabetes Duration][Cholesterol Indicator][BP Indicator][Smoker Level]

                #region "Diabetes Type"
                if (RadioButtonDiabetesType1.Checked)
                    strDiabetesType = "T1";
                if (RadioButtonDiabetesType2.Checked)
                    strDiabetesType = "T2";
                if (RadioButtonDiabetesTypeNotSure.Checked)
                    strDiabetesType = "T2";

                //if insulin then T1 else T2
                if (RadioButtonInsulinYes.Checked)
                    strDiabetesType = "T1";
                #endregion

                #region "AgeBracket"
                if (Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) < 30)
                {
                    strAgeBracket = "A1";
                }

                if ((Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) >= 30) && (Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) < 40))
                {
                    strAgeBracket = "A2";
                }

                if ((Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) >= 40) && (Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) < 50))
                {
                    strAgeBracket = "A3";
                }

                if ((Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) >= 50) && (Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) < 60))
                {
                    strAgeBracket = "A4";
                }

                if ((Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) >= 60) && (Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) < 70))
                {
                    strAgeBracket = "A5";
                }

                if (Convert.ToInt16(RadTxtAgeOfNextBirthday.Text.Trim()) >= 70)
                {
                    strAgeBracket = "A6";
                }
                #endregion

                #region "Control Level"
                //C1	<=7
                //C2	>7<=8
                //C3	>8<=9
                //C4	>9<=10
                //C5	>10<=11
                //C6	>11<=12
                //C7	>12<=14
                if ((RadioButtonHbA1c3.Checked == true) || (RadioButtonHbA1c4.Checked == true) || (RadioButtonHbA1c6.Checked == true))
                    strControlLevel = "C1";
                if (RadioButtonHbA1c7.Checked == true)
                    strControlLevel = "C2";
                if (RadioButtonHbA1c8.Checked == true)
                    strControlLevel = "C3";
                if (RadioButtonHbA1c9.Checked == true)
                    strControlLevel = "C4";
                if (RadioButtonHbA1c10.Checked == true)
                    strControlLevel = "C5";
                if (RadioButtonHbA1c11.Checked == true)
                    strControlLevel = "C6";
                if (RadioButtonHbA1c12.Checked == true)
                    strControlLevel = "C7";

                if (RadioButtonHbA1cUnknown.Checked == true)
                {
                    //C3	1
                    //C4	2
                    //C5	3
                    //C6	4
                }


                #endregion

                #region "Diabetes Duration"
                /*
                    Duration = CASE 
                    WHEN DATEPART(year,Q.dtFieldValue) – D.iFieldValue < 5 THEN '<5'
                    WHEN DATEPART(year,Q.dtFieldValue) – D.iFieldValue < 15 THEN '5_15'
                    ELSE '>15'
                    END

                    <5	    Less than 5 years
                    5_15	More than 5 but less than 15 years
                    >15	    More than 15 years
                */
                //strDateDiagnosed = RadDatePickerDateOfDiag.SelectedDate.ToString();
                strDateDiagnosed = RadMonthYearPickerDateOfDiag.SelectedDate.ToString();
                strQuoteDate = RadDatePickerQuoteDate.SelectedDate.ToString();

                DateTime DTDateDiagnosed = Convert.ToDateTime(strDateDiagnosed);
                DateTime DTQuoteDate = Convert.ToDateTime(strQuoteDate);

                int YearsPassed = DTQuoteDate.Year - DTDateDiagnosed.Year;
                if (YearsPassed < 5)
                    strDiabetesDuration = "<5";
                if ((YearsPassed >= 5) && (YearsPassed < 15))
                    strDiabetesDuration = "5_15";
                if (YearsPassed >= 15)
                    strDiabetesDuration = ">15";

                #endregion

                #region "Cholesterol Indicator"
                /*    
                    High	Yes
                    Norm	No
                    Norm	Unsure
                 */

                if (RadioButtonCholesterolYes.Checked == true)
                    strCholesterolIndicator = "High";
                if (RadioButtonCholesterolNo.Checked == true)
                    strCholesterolIndicator = "Norm";
                if (RadioButtonCholesterolNotSure.Checked == true)
                    strCholesterolIndicator = "Norm";

                #endregion

                #region "BP Indicator"
                /*    
                    High	Yes
                    Norm	No
                    Norm	Unsure
                 */

                if (RadioButtonHighBPYes.Checked == true)
                    strBPIndicator = "High";
                if (RadioButtonHighBPNo.Checked == true)
                    strBPIndicator = "Norm";
                if (RadioButtonHighBP.Checked == true)
                    strBPIndicator = "Norm";

                #endregion

                #region "Smoker Level"
                /*    
                    S0	Non Smoker (P_M2_Q12 = False or P_TOBACCOFREQ = 0)
                    S1	<=2
                    S2	>2;<=5
                    S3	>5;<=20
                    S4	>20
                 */

                if (RadioButtonListTobacco.SelectedValue == "non-smoker")
                    strSmokerLevel = "S0";
                if (RadioButtonListTobacco.SelectedValue == "< 1")
                    strSmokerLevel = "S1";
                if (RadioButtonListTobacco.SelectedValue == "1 - 5")
                    strSmokerLevel = "S2";
                if (RadioButtonListTobacco.SelectedValue == "6 - 20")
                    strSmokerLevel = "S3";
                if (RadioButtonListTobacco.SelectedValue == "> 20")
                    strSmokerLevel = "S4";

                #endregion

                //strRiskModifier = strDiabetesType + strAgeBracket + strControlLevel + strDiabetesDuration + strCholesterolIndicator + strBPIndicator + strSmokerLevel;
                strRiskModifier = GetRiskModifier();

                HiddenFieldRiskModifier.Value = strRiskModifier;
                HiddenFieldRMDiabetesType.Value = strDiabetesType;

                //Calc Premium
                //e.g. Income * 6%
                decRate = (decIncome * decPI) / 100;
                //Split the Rate 50%-%0%
                decRateLife = decRate / 2;
                decRateDisability = decRate / 2;

                DataTable ReturnDT;
                WS.AllLifePrincingClient WS = new WS.AllLifePrincingClient();
                bool blnUseLife = false;
                bool blnUseDisability = false;

                //Life
                //****************************************
                #region "Life"
                //Get the Cover     

                if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ADB")
                {
                    strRiskModifier = "ACCIDENTAL";
                }

                if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ACDB")
                {
                    strRiskModifier = "ACCIDENTAL_CANCER";
                }

                if (RadNumericTxtEMLoadingLife.Text.Trim() == "")
                    RadNumericTxtEMLoadingLife.Text = "0";

                strProductType = GetBenifitCode(1); //1= life; 2 = Disability

                //if (RadioButtonEscLife6.Checked == true)
                if (RadioButtonEsc6.Checked == true)
                    strEscalation = "06";
                //if (RadioButtonEscLife10.Checked == true)
                if (RadioButtonEsc10.Checked == true)
                    strEscalation = "10";

                if (RadioButtonQuoteLifeNo.Checked == false)
                {
                    if ((buttonNumber != 4) && (buttonNumber != 5))
                    {                        
                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                        {
                            ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decRateLife.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                        }
                        else
                        {
                            ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decRateLife.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                        }
                        
                        //ReturnDT = WS.returnCover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct, strBaseRisk, strRiskModifier, decRateLife.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                        //ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decRateLife.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingLife.Text);

                        foreach (DataRow row in ReturnDT.Rows)
                        {
                            if (row["UnroudedCover"].ToString() == "")
                            {
                                decCover = 0;
                            }
                            else
                            {
                                //decCover = Convert.ToDecimal(row["Cover"].ToString());
                                decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                            }
                        }
                    }
                    else
                    {
                        if (buttonNumber == 4)
                        {
                            decCover = Convert.ToDecimal(RadNumericTxtCoverLife.Text.Trim());
                        }

                        if (buttonNumber == 5)
                        {
                            //decDesiredContribution = Convert.ToDecimal(RadNumericTxtDesireContribution.Text);
                            ////if the disability panel is unavalable then we don't spilt the month;y contribution
                            //if (PanelDisability.GroupingText.Contains("Unavailable") == false)
                            //{
                            //    decDesiredContribution = decDesiredContribution / 2;
                            //}

                            if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                            {
                                ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, RadNumericTxtPremiumLife.Text, RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                            }
                            else
                            {
                                ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, RadNumericTxtPremiumLife.Text, RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                            }
                          //ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, RadNumericTxtPremiumLife.Text, RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingLife.Text);

                            //ReturnDT = WS.returnCover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct, strBaseRisk, strRiskModifier, decDesiredContribution.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");

                            foreach (DataRow row in ReturnDT.Rows)
                            {
                                if (row["Cover"].ToString() == "")
                                {
                                    decCover = 0;
                                }
                                else
                                {
                                    //decCover = Convert.ToDecimal(row["Cover"].ToString());
                                    decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                }
                            }
                        }
                    }


                    if (buttonNumber != 4)
                    {
                        //Match closest cover amount in the CoverRounding table
                        #region "Match closest cover amount in the CoverRounding table"
                        sqlCommandX = new SqlCommand();
                        sqlCommandX.Connection = sqlConnectionX;
                        sqlCommandX.CommandType = CommandType.StoredProcedure;
                        sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                        sqlParam = new SqlParameter("CoverAmount", decCover);
                        sqlCommandX.Parameters.Add(sqlParam);

                        sqlDR = sqlCommandX.ExecuteReader();
                        while (sqlDR.Read())
                        {
                            decCover = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                        }

                        sqlDR.Close();
                        sqlCommandX.Cancel();
                        sqlCommandX.Dispose();
                        #endregion
                    }

                    //sqlConnectionX.Close();

                    //Get the premium
                    //if (buttonNumber != 5)
                    //{
                    ReturnDT = null;     
               
                    //66011307
                    
                    //ReturnDT = WS.returnPremium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct, strBaseRisk, strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                    //ReturnDT = WS.returnPremium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                    {
                        ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                    }
                    else
                    {
                        ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                    }
                    foreach (DataRow row in ReturnDT.Rows)
                    {
                        if (row["LoadedPremium"].ToString() != "")
                        {
                            decPremium = Convert.ToDecimal(row["LoadedPremium"].ToString());
                            decPremiumUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                            decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());
                        }

                    }

                    decPremium = decPremium + decPremiumFixedFee;
                   
                    #region "If less than 130"
                    //if (decPremium < 130)  
                    //{
                    //    decPremium = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee

                    //    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                    //    {
                    //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingLife.Text);
                    //    }
                    //    else
                    //    {
                    //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingLife.Text);
                    //    }
                       
                    //    foreach (DataRow row in ReturnDT.Rows)
                    //    {
                    //        if (row["Cover"].ToString() == "")
                    //        {
                    //            decCover = 0;
                    //        }
                    //        else
                    //        {                                
                    //            decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                    //        }
                    //    }

                    //    //Match closest cover amount in the CoverRounding table
                    //    #region "Match closest cover amount in the CoverRounding table"
                    //    sqlCommandX = new SqlCommand();
                    //    sqlCommandX.Connection = sqlConnectionX;
                    //    sqlCommandX.CommandType = CommandType.StoredProcedure;
                    //    sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                    //    sqlParam = new SqlParameter("CoverAmount", decCover);
                    //    sqlCommandX.Parameters.Add(sqlParam);

                    //    sqlDR = sqlCommandX.ExecuteReader();
                    //    while (sqlDR.Read())
                    //    {
                    //        decCover = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                    //    }

                    //    sqlDR.Close();
                    //    sqlCommandX.Cancel();
                    //    sqlCommandX.Dispose();
                    //    #endregion

                    //    decPremium = decPremium + decPremiumFixedFee;
                    //}

                    #endregion

                    //}
                    //else
                    //{
                    //    decPremium = Convert.ToDecimal(RadNumericTxtPremiumLife.Text);
                    //}
                }
                #endregion

                //Disability
                //****************************************
                #region "Disability"
                if (RadNumericTxtEMLoadingDisability.Text.Trim() == "")
                    RadNumericTxtEMLoadingDisability.Text = "0";

                //if (PanelDisability.GroupingText.Contains("Unavailable") == false)
                //{
                strRiskModifier = GetRiskModifier();

                if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "ADB")
                {
                    strRiskModifier = "ACCIDENTAL";
                }

                if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "ACDB")
                {
                    strRiskModifier = "ACCIDENTAL_CANCER";
                }

                strBaseRisk = GetBaseRisk(2);  //2 = Disability                        

                strProductType = GetBenifitCode(2); //1= life; 2 = Disability

                //if (RadioButtonEscalationDis6.Checked == true)
                //    strEscalation = "06";
                //if (RadioButtonEscalationDis10.Checked == true)
                //    strEscalation = "10";

                //Get the Cover
                if (RadioButtonQuoteDisNo.Checked == false)
                {
                    DataTable ReturnDTDisability;
                    if ((buttonNumber != 4) && (buttonNumber != 5))
                    {
                        //ReturnDTDisability = WS.returnCover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct, strBaseRisk, strRiskModifier, decRateLife.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                        //ReturnDTDisability = WS.returnCover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decRateDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                        if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB")
                        {
                            ReturnDTDisability = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decRateLife.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                        }
                        else
                        {
                            ReturnDTDisability = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decRateLife.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                        }

                        foreach (DataRow row in ReturnDTDisability.Rows)
                        {
                            if (row["Cover"].ToString() == "")
                            {
                                decCoverDisability = 0;
                            }
                            else
                            {
                                decCoverDisability = Convert.ToDecimal(row["Cover"].ToString());
                            }

                            strRiskband = row["Riskband"].ToString();
                        }
                    }
                    else
                    {
                        if (buttonNumber == 4)
                        {
                            if (RadNumericTxtCoverAmnDis.Text.Trim() == "")
                                RadNumericTxtCoverAmnDis.Text = "0";

                            decCoverDisability = Convert.ToDecimal(RadNumericTxtCoverAmnDis.Text.Trim());
                        }

                        if (buttonNumber == 5)
                        {
                            //decDesiredContribution = Convert.ToDecimal(RadNumericTxtDesireContribution.Text);

                                    
                            //ReturnDTDisability = WS.returnCover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, RadNumericTxtPremiumDis.Text, RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                            if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB")
                            {
                                ReturnDTDisability = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, RadNumericTxtPremiumDis.Text.Trim(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                            }
                            else
                            {
                                ReturnDTDisability = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, RadNumericTxtPremiumDis.Text.Trim(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                            }

                            //ReturnDTDisability = WS.returnCover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct, strBaseRisk, strRiskModifier, decDesiredContribution.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");

                            foreach (DataRow row in ReturnDTDisability.Rows)
                            {
                                if (row["Cover"].ToString() == "")
                                {
                                    decCoverDisability = 0;
                                }
                                else
                                {
                                    decCoverDisability = Convert.ToDecimal(row["Cover"].ToString());
                                }

                                strRiskband = row["Riskband"].ToString();
                            }
                        }
                    }

                    //Match closest cover amount in the CoverRounding table
                    if (buttonNumber != 4)
                    {
                        #region "Match closest cover amount in the CoverRounding table"
                        sqlCommandX = new SqlCommand();
                        sqlCommandX.Connection = sqlConnectionX;
                        sqlCommandX.CommandType = CommandType.StoredProcedure;
                        sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                        sqlParam = new SqlParameter("CoverAmount", decCoverDisability);
                        sqlCommandX.Parameters.Add(sqlParam);

                        sqlDR = sqlCommandX.ExecuteReader();
                        while (sqlDR.Read())
                        {
                            decCoverDisability = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                        }

                        sqlDR.Close();
                        sqlCommandX.Cancel();
                        sqlCommandX.Dispose();
                        #endregion
                    }

                    //Get the premium
                    //if (buttonNumber != 5)
                    //{
                    ReturnDT = null;
                    //ReturnDT = WS.returnPremium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct, strBaseRisk, strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                    //ReturnDT = WS.returnPremium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                            
                    //ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingDisability.Text);
                    if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB")
                    {
                        ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                    }
                    else
                    {
                        ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                    }


                    foreach (DataRow row in ReturnDT.Rows)
                    {
                        if (row["LoadedPremium"].ToString() != "")
                        {
                            decPremiumDisability = Convert.ToDecimal(row["LoadedPremium"].ToString());
                            decPremiumDisabilityUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                            decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());
                        }
                        else
                        {
                            decPremiumDisability = 0;
                            decPremiumDisabilityUnrounded = 0;
                            decPremiumFixedFee = 0;
                        }

                    }

                    decPremiumDisability = decPremiumDisability + decPremiumFixedFee;
                            
                    //}
                    //else
                    //{
                    //    decPremium = Convert.ToDecimal(RadNumericTxtPremiumLife.Text);
                    //}
                }
                //}
                #endregion               

                // "Button 1, 2 / 3 only"
                if ((buttonNumber != 4) && (buttonNumber != 5))
                {
                    #region "Button 1, 2 / 3 only"
                    if (decCover > 0)
                        decCPRateLife = (decPremiumUnrounded / decCover);
                    if (decCoverDisability > 0)
                        decCPRateDisability = (decPremiumDisabilityUnrounded / decCoverDisability);                    

                    if (RadioButtonQuoteLifeNo.Checked == false)
                    {
                        if ((PanelLife.GroupingText.Contains("Unavailable") == false) || (RadComboBoxTypeBenefitLife.SelectedItem.Text != "FDB"))
                        {
                            blnUseLife = true;
                        }
                    }

                    if (RadioButtonQuoteDisNo.Checked == false)
                    {
                        if ((PanelDisability.GroupingText.Contains("Unavailable") == false)  || (RadComboBoxTypeBenefitDisability.SelectedItem.Text != "FDB"))
                        {
                            blnUseDisability = true;
                        }
                    }

                    if ((blnUseLife == true) && (blnUseDisability == false))
                    {
                        #region "Life == true | Disability == false"
                        decCover = ((((decIncome * decPI) / 100)) / decCPRateLife);

                        if (buttonNumber != 4)
                        {
                            #region "Match closest cover amount in the CoverRounding table"
                            sqlCommandX = new SqlCommand();
                            sqlCommandX.Connection = sqlConnectionX;
                            sqlCommandX.CommandType = CommandType.StoredProcedure;
                            sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                            sqlParam = new SqlParameter("CoverAmount", decCover);
                            sqlCommandX.Parameters.Add(sqlParam);

                            sqlDR = sqlCommandX.ExecuteReader();
                            while (sqlDR.Read())
                            {
                                decCover = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                            }

                            sqlDR.Close();
                            sqlCommandX.Cancel();
                            sqlCommandX.Dispose();
                            #endregion
                        }

                        strBaseRisk = GetBaseRisk(1);  //1= life; 2 = Disability
                        strProductType = GetBenifitCode(1); //1= life; 2 = Disability
                        ReturnDT = null;
                        //if (RadioButtonEscalationDis6.Checked == true)
                        //    strEscalation = "06";
                        //if (RadioButtonEscalationDis10.Checked == true)
                        //    strEscalation = "10";

                        //2015-10-19 - WG added the below section because it was missing.
                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ADB")
                        {
                            strRiskModifier = "ACCIDENTAL";
                        }

                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ACDB")
                        {
                            strRiskModifier = "ACCIDENTAL_CANCER";
                        }

                        
                        //if (RadioButtonEscLife6.Checked == true)
                        if (RadioButtonEsc6.Checked == true)
                            strEscalation = "06";
                        //if (RadioButtonEscLife10.Checked == true)
                        if (RadioButtonEsc10.Checked == true)
                            strEscalation = "10";
                        //ReturnDT = WS.returnPremium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                        //ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingDisability.Text);
                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                        {
                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingDisability.Text);
                        }
                        else
                        {
                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingDisability.Text);
                        }

                        foreach (DataRow row in ReturnDT.Rows)
                        {
                            if (row["LoadedPremium"].ToString() != "")
                            {
                                decPremium = Convert.ToDecimal(row["LoadedPremium"].ToString());
                                decPremiumUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                                decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());

                            }
                        }

                        decPremium = decPremium + decPremiumFixedFee;
                        #endregion
                    }

                    if ((blnUseLife == false) && (blnUseDisability == true))
                    {
                        #region "Life == false | Disability == true"
                        decCoverDisability = ((((decIncome * decPI) / 100)) / decCPRateDisability);

                        if (buttonNumber != 4)
                        {
                            #region "Match closest cover amount in the CoverRounding table"
                            sqlCommandX = new SqlCommand();
                            sqlCommandX.Connection = sqlConnectionX;
                            sqlCommandX.CommandType = CommandType.StoredProcedure;
                            sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                            sqlParam = new SqlParameter("CoverAmount", decCoverDisability);
                            sqlCommandX.Parameters.Add(sqlParam);

                            sqlDR = sqlCommandX.ExecuteReader();
                            while (sqlDR.Read())
                            {
                                decCoverDisability = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                            }

                            sqlDR.Close();
                            sqlCommandX.Cancel();
                            sqlCommandX.Dispose();
                            #endregion
                        }

                        //Recalculate the disability premium
                        strBaseRisk = GetBaseRisk(2);  //1= life; 2 = Disability
                        strProductType = GetBenifitCode(2); //1= life; 2 = Disability
                        ReturnDT = null;

                        //2015-10-19 - WG added the below section because it was missing.
                        if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "ADB")
                        {
                            strRiskModifier = "ACCIDENTAL";
                        }

                        if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "ACDB")
                        {
                            strRiskModifier = "ACCIDENTAL_CANCER";
                        }

                        //if (RadioButtonEscalationDis6.Checked == true)
                        if (RadioButtonEsc6.Checked == true)
                            strEscalation = "06";
                        //if (RadioButtonEscalationDis10.Checked == true)
                        if (RadioButtonEsc10.Checked == true)
                            strEscalation = "10";
                        //ReturnDT = WS.returnPremium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                        //ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingDisability.Text);
                        if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB")
                        {
                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                        }
                        else
                        {
                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                        }

                        foreach (DataRow row in ReturnDT.Rows)
                        {
                            decPremiumDisability = Convert.ToDecimal(row["LoadedPremium"].ToString());
                            decPremiumDisabilityUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                            decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());
                        }

                        decPremiumDisability = decPremiumDisability + decPremiumFixedFee;
                        #endregion
                    }

                    if ((blnUseLife == true) && (blnUseDisability == true))
                    {
                        #region "Life == true | Disability == true"
                        //decCover = ((decPremiumUnrounded + decPremiumDisabilityUnrounded) / (decCPRateLife + decCPRateDisability));
                        decCover = ((((decIncome * decPI) / 100)) / (decCPRateLife + decCPRateDisability));

                        if (buttonNumber != 4)
                        {
                            #region "Match closest cover amount in the CoverRounding table"
                            sqlCommandX = new SqlCommand();
                            sqlCommandX.Connection = sqlConnectionX;
                            sqlCommandX.CommandType = CommandType.StoredProcedure;
                            sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                            sqlParam = new SqlParameter("CoverAmount", decCover);
                            sqlCommandX.Parameters.Add(sqlParam);

                            sqlDR = sqlCommandX.ExecuteReader();
                            while (sqlDR.Read())
                            {
                                decCover = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                            }

                            sqlDR.Close();
                            sqlCommandX.Cancel();
                            sqlCommandX.Dispose();

                            #endregion
                        }

                        decCoverDisability = decCover;

                        //Recalculate the life premium
                        #region "Life"
                        strRiskModifier = GetRiskModifier();

                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ADB")
                        {
                            strRiskModifier = "ACCIDENTAL";
                        }

                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ACDB")
                        {
                            strRiskModifier = "ACCIDENTAL_CANCER";
                        }

                        //Recalculate the life premium
                        strBaseRisk = GetBaseRisk(1);  //1= life; 2 = Disability
                        strProductType = GetBenifitCode(1); //1= life; 2 = Disability
                        ReturnDT = null;
                        //if (RadioButtonEscLife6.Checked == true)
                        if (RadioButtonEsc6.Checked == true)
                            strEscalation = "06";
                        //if (RadioButtonEscLife10.Checked == true)
                        if (RadioButtonEsc10.Checked == true)
                            strEscalation = "10";

                        //ReturnDT = WS.returnPremium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                        //ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingLife.Text);
                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                        {
                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                        }
                        else
                        {
                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                        }
                        
                        foreach (DataRow row in ReturnDT.Rows)
                        {
                            if (row["LoadedPremium"].ToString() != "")
                            {
                                decPremium = Convert.ToDecimal(row["LoadedPremium"].ToString());
                                decPremiumUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                                decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());

                            }
                        }
                        #endregion

                        decPremium = decPremium + decPremiumFixedFee;

                        //Recalculate the disability premium
                        #region "Disability"
                        strRiskModifier = GetRiskModifier();

                        if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "ADB")
                        {
                            strRiskModifier = "ACCIDENTAL";
                        }

                        if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "ACDB")
                        {
                            strRiskModifier = "ACCIDENTAL_CANCER";
                        }

                        strBaseRisk = GetBaseRisk(2);  //1= life; 2 = Disability
                        strProductType = GetBenifitCode(2); //1= life; 2 = Disability
                        ReturnDT = null;
                        //if (RadioButtonEscalationDis6.Checked == true)
                        if (RadioButtonEsc6.Checked == true)
                            strEscalation = "06";
                        //if (RadioButtonEscalationDis10.Checked == true)
                        if (RadioButtonEsc10.Checked == true)
                            strEscalation = "10";
                        //ReturnDT = WS.returnPremium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "");
                        //ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", RadNumericTxtEMLoadingDisability.Text);
                        if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB")
                        {
                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                        }
                        else
                        {
                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                        }

                        foreach (DataRow row in ReturnDT.Rows)
                        {
                            if (row["LoadedPremium"].ToString() != "")
                            {
                                decPremiumDisability = Convert.ToDecimal(row["LoadedPremium"].ToString());
                                decPremiumDisabilityUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                                decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());
                            }
                            else
                            {
                                decPremiumDisability = 0;
                                decPremiumDisabilityUnrounded = 0;
                                decPremiumFixedFee = 0;
                            }
                        }
                        #endregion

                        decPremiumDisability = decPremiumDisability + decPremiumFixedFee;
                        #endregion
                    }
                    #endregion
                }
               
                //If less than 130       
                //if ((buttonNumber != 4) && (buttonNumber != 5))
                //2015-10-05 - included button option 5 because we were going to add the same logic below for option 5 only
                if (buttonNumber != 4)
                {
                    strControlFee = decPremiumFixedFee.ToString();

                    if (strControlFee == "")
                        strControlFee = "1";
                    
                    //2015-09-19 - The total (decPremium + decPremiumDisability) was commentd out. I am not going back to using the total
                    ///if (decPremium < 130)
                    //if ((decPremium + decPremiumDisability) < 130)
                    if ((((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)))) < 130)
                    {
                        #region "If less than 130"
                        //decPremium = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee
                        //2015-10-13  - commented out the below so that it sets the blnUseLife and\or blnUseDisability
                        //if (decPremiumDisability == 0)
                        //{
                        //    decPremium = 130;
                        //}
                        //else
                        //{
                            //decPremium = 130 - decPremiumDisability + 20;

                            if (RadioButtonQuoteLifeNo.Checked == false)
                            {
                                if ((PanelLife.GroupingText.Contains("Unavailable") == false) || (RadComboBoxTypeBenefitLife.SelectedItem.Text != "FDB"))
                                {
                                    blnUseLife = true;
                                }
                            }

                            if (RadioButtonQuoteDisNo.Checked == false)
                            {
                                if ((PanelDisability.GroupingText.Contains("Unavailable") == false) || (RadComboBoxTypeBenefitDisability.SelectedItem.Text != "FDB"))
                                {
                                    blnUseDisability = true;
                                }
                            }

                            if ((blnUseLife == true) && (blnUseDisability == true))
                            {
                                decPremium = 75;
                                decPremiumDisability = 75;
                            }

                            if ((blnUseLife == true) && (blnUseDisability == false))
                            {
                                decPremium = 130;
                                decPremiumDisability = 0;
                            }

                            if ((blnUseLife == false) && (blnUseDisability == true))
                            {
                                decPremium = 0;
                                decPremiumDisability = 130;
                            }
                        //}

                        strBaseRisk = GetBaseRisk(1);  //1= life; 2 = Disability
                        strProductType = GetBenifitCode(1); //1= life; 2 = Disability
                        //strRiskModifier = GetRiskModifier();

                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ADB")
                        {
                            strRiskModifier = "ACCIDENTAL";
                        }

                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ACDB")
                        {
                            strRiskModifier = "ACCIDENTAL_CANCER";
                        }

                        ReturnDT = null;

                        if (blnUseLife == true)
                        {

                            if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                            {
                                ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                            }
                            else
                            {
                                ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                            }

                            foreach (DataRow row in ReturnDT.Rows)
                            {
                                if (row["Cover"].ToString() == "")
                                {
                                    decCover = 0;
                                }
                                else
                                {
                                    decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                }
                            }

                            //Match closest cover amount in the CoverRounding table
                            #region "Match closest cover amount in the CoverRounding table"
                            sqlCommandX2 = new SqlCommand();
                            sqlCommandX2.Connection = sqlConnectionX;
                            sqlCommandX2.CommandType = CommandType.StoredProcedure;
                            sqlCommandX2.CommandText = "spx_SELECT_CoverRounding";

                            sqlParam = new SqlParameter("CoverAmount", decCover);
                            sqlCommandX2.Parameters.Add(sqlParam);

                            sqlDR2 = sqlCommandX2.ExecuteReader();
                            while (sqlDR2.Read())
                            {
                                decCover = Convert.ToDecimal(sqlDR2.GetValue(0).ToString());
                            }

                            sqlDR2.Close();
                            sqlCommandX2.Cancel();
                            sqlCommandX2.Dispose();
                            #endregion

                            if (decCover == 40000)
                            {
                                if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                {
                                    ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                }
                                else
                                {
                                    ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                }

                                foreach (DataRow row in ReturnDT.Rows)
                                {
                                    if (row["LoadedPremium"].ToString() != "")
                                    {
                                        decPremium = Convert.ToDecimal(row["LoadedPremium"].ToString());
                                        decPremiumUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                                        decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());

                                    }
                                }

                                decPremium = decPremium + decPremiumFixedFee;
                            }                            
                        }


                        if (RadioButtonQuoteDisNo.Checked == false)
                        {
                            //Disability
                            //Recalculate the disability premium
                            strBaseRisk = GetBaseRisk(2);  //1= life; 2 = Disability
                            strProductType = GetBenifitCode(2); //1= life; 2 = Disability
                            ReturnDT = null;
                            if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                            {
                                ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremiumDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                            }
                            else
                            {
                                ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremiumDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                            }

                            foreach (DataRow row in ReturnDT.Rows)
                            {
                                if (row["Cover"].ToString() == "")
                                {
                                    decCoverDisability = 0;
                                }
                                else
                                {
                                    decCoverDisability = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                }
                            }

                            //Match closest cover amount in the CoverRounding table
                            #region "Match closest cover amount in the CoverRounding table"
                            sqlCommandX2 = new SqlCommand();
                            sqlCommandX2.Connection = sqlConnectionX;
                            sqlCommandX2.CommandType = CommandType.StoredProcedure;
                            sqlCommandX2.CommandText = "spx_SELECT_CoverRounding";

                            sqlParam = new SqlParameter("CoverAmount", decCoverDisability);
                            sqlCommandX2.Parameters.Add(sqlParam);

                            sqlDR2 = sqlCommandX2.ExecuteReader();
                            while (sqlDR2.Read())
                            {
                                decCoverDisability = Convert.ToDecimal(sqlDR2.GetValue(0).ToString());
                            }

                            sqlDR2.Close();
                            sqlCommandX2.Cancel();
                            sqlCommandX2.Dispose();
                            #endregion

                            //decPremium = decPremium + decPremiumFixedFee;

                            if (decCoverDisability == 40000)
                            {
                                if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                {
                                    ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                                }
                                else
                                {
                                    ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                                }

                                foreach (DataRow row in ReturnDT.Rows)
                                {
                                    if (row["LoadedPremium"].ToString() != "")
                                    {
                                        decPremiumDisability = Convert.ToDecimal(row["LoadedPremium"].ToString());
                                        decPremiumDisabilityUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                                        decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());
                                    }
                                    else
                                    {
                                        decPremiumDisability = 0;
                                        decPremiumDisabilityUnrounded = 0;
                                        decPremiumFixedFee = 0;
                                    }
                                }

                                decPremiumDisability = decPremiumDisability + decPremiumFixedFee;


                                if ((((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)))) < 130)
                                {
                                    //if the total premium is still less that 130 then use the rounded cover
                                    //decPremium = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee
                                    if (decPremiumDisability == 0)
                                    {
                                        decPremium = 130;
                                    }
                                    else
                                    {
                                        //decPremium = 130 - decPremiumDisability + 20;
                                        if ((blnUseLife == true) && (blnUseDisability == true))
                                        {
                                            decPremium = 75;
                                            decPremiumDisability = 75;
                                        }

                                        if ((blnUseLife == true) && (blnUseDisability == false))
                                        {
                                            decPremium = 130;
                                            decPremiumDisability = 0;
                                        }

                                        if ((blnUseLife == false) && (blnUseDisability == true))
                                        {
                                            decPremium = 0;
                                            decPremiumDisability = 130;
                                        }
                                    }

                                    strBaseRisk = GetBaseRisk(1);  //1= life; 2 = Disability
                                    strProductType = GetBenifitCode(1); //1= life; 2 = Disability
                                    //strRiskModifier = GetRiskModifier();

                                    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ADB")
                                    {
                                        strRiskModifier = "ACCIDENTAL";
                                    }

                                    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ACDB")
                                    {
                                        strRiskModifier = "ACCIDENTAL_CANCER";
                                    }

                                    ReturnDT = null;

                                    if (blnUseLife == true)
                                    {

                                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                        {
                                            ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        }
                                        else
                                        {
                                            ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        }

                                        foreach (DataRow row in ReturnDT.Rows)
                                        {
                                            if (row["Cover"].ToString() == "")
                                            {
                                                decCover = 0;
                                            }
                                            else
                                            {
                                                decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                            }
                                        }

                                        //Match closest cover amount in the CoverRounding table
                                        #region "Match closest cover amount in the CoverRounding table"
                                        sqlCommandX2 = new SqlCommand();
                                        sqlCommandX2.Connection = sqlConnectionX;
                                        sqlCommandX2.CommandType = CommandType.StoredProcedure;
                                        sqlCommandX2.CommandText = "spx_SELECT_CoverRounding";

                                        sqlParam = new SqlParameter("CoverAmount", decCover);
                                        sqlCommandX2.Parameters.Add(sqlParam);

                                        sqlDR2 = sqlCommandX2.ExecuteReader();
                                        while (sqlDR2.Read())
                                        {
                                            decCover = Convert.ToDecimal(sqlDR2.GetValue(0).ToString());
                                        }

                                        sqlDR2.Close();
                                        sqlCommandX2.Cancel();
                                        sqlCommandX2.Dispose();
                                        #endregion

                                        if (decCover == 40000)
                                        {
                                            if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                            {
                                                ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                            }
                                            else
                                            {
                                                ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                            }

                                            foreach (DataRow row in ReturnDT.Rows)
                                            {
                                                if (row["LoadedPremium"].ToString() != "")
                                                {
                                                    decPremium = Convert.ToDecimal(row["LoadedPremium"].ToString());
                                                    decPremiumUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                                                    decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());

                                                }
                                            }

                                            decPremium = decPremium + decPremiumFixedFee;
                                        }
                                    }


                                    if (RadioButtonQuoteDisNo.Checked == false)
                                    {
                                        //Disability
                                        //Recalculate the disability premium
                                        strBaseRisk = GetBaseRisk(2);  //1= life; 2 = Disability
                                        strProductType = GetBenifitCode(2); //1= life; 2 = Disability
                                        ReturnDT = null;
                                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                        {
                                            ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremiumDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        }
                                        else
                                        {
                                            ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremiumDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        }

                                        foreach (DataRow row in ReturnDT.Rows)
                                        {
                                            if (row["Cover"].ToString() == "")
                                            {
                                                decCoverDisability = 0;
                                            }
                                            else
                                            {
                                                decCoverDisability = Convert.ToDecimal(row["Cover"].ToString());
                                            }
                                        }

                                        //Match closest cover amount in the CoverRounding table
                                        #region "Match closest cover amount in the CoverRounding table"
                                        sqlCommandX2 = new SqlCommand();
                                        sqlCommandX2.Connection = sqlConnectionX;
                                        sqlCommandX2.CommandType = CommandType.StoredProcedure;
                                        sqlCommandX2.CommandText = "spx_SELECT_CoverRounding";

                                        sqlParam = new SqlParameter("CoverAmount", decCoverDisability);
                                        sqlCommandX2.Parameters.Add(sqlParam);

                                        sqlDR2 = sqlCommandX2.ExecuteReader();
                                        while (sqlDR2.Read())
                                        {
                                            decCoverDisability = Convert.ToDecimal(sqlDR2.GetValue(0).ToString());
                                        }

                                        sqlDR2.Close();
                                        sqlCommandX2.Cancel();
                                        sqlCommandX2.Dispose();
                                        #endregion

                                        //decPremium = decPremium + decPremiumFixedFee;


                                        //decPremiumDisability = decPremiumDisability + decPremiumFixedFee;

                                    }
                                }
                            }
                        }
                        #endregion
                    }                    
                }
                            
                //If less than 130 for button 4 only
                if (buttonNumber == 4)
                {
                    #region "If less than 130 for button 4 only"
                    
                    strControlFee = decPremiumFixedFee.ToString();

                    if (strControlFee == "")
                        strControlFee = "1";
                   
                        #region "Life Only"
                        if (RadioButtonQuoteLifeYes.Checked == true && RadioButtonQuoteDisYes.Checked == false)
                        {
                            if (decPremium < 130)
                            {
                                decPremium = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee

                                //if (RadioButtonEscalationDis6.Checked == true)
                                if (RadioButtonEsc6.Checked == true)
                                    strEscalation = "06";
                                //if (RadioButtonEscalationDis10.Checked == true)
                                if (RadioButtonEsc10.Checked == true)
                                    strEscalation = "10";

                                strBaseRisk = GetBaseRisk(1);  //1= life; 2 = Disability
                                strProductType = GetBenifitCode(1); //1= life; 2 = Disability
                                ReturnDT = null;

                                if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                {
                                    //ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                    ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                }
                                else
                                {
                                    //ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                    ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                }

                                foreach (DataRow row in ReturnDT.Rows)
                                {
                                    if (row["Cover"].ToString() == "")
                                    {
                                        decCover = 0;
                                    }
                                    else
                                    {
                                        decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                    }
                                }

                                //Match closest cover amount in the CoverRounding table
                                #region "Match closest cover amount in the CoverRounding table"
                                sqlCommandX2 = new SqlCommand();
                                sqlCommandX2.Connection = sqlConnectionX;
                                sqlCommandX2.CommandType = CommandType.StoredProcedure;
                                sqlCommandX2.CommandText = "spx_SELECT_CoverRounding";

                                sqlParam = new SqlParameter("CoverAmount", decCover);
                                sqlCommandX2.Parameters.Add(sqlParam);

                                sqlDR2 = sqlCommandX2.ExecuteReader();
                                while (sqlDR2.Read())
                                {
                                    decCover = Convert.ToDecimal(sqlDR2.GetValue(0).ToString());
                                }

                                sqlDR2.Close();
                                sqlCommandX2.Cancel();
                                sqlCommandX2.Dispose();
                                #endregion

                                //2015-10-13 - taken out because the premium from option 4 was R150 and not matching premium (130) on option 5 (e.g. MagID 67332124)
                                //decPremium = decPremium + decPremiumFixedFee;
                            }
                        }
                        #endregion

                        #region "Disability only"
                        if (RadioButtonQuoteDisYes.Checked == true && RadioButtonQuoteLifeYes.Checked == false)
                        {                            
                            if (decPremiumDisability < 130)
                            {
                                decPremiumDisability = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee
                                RadNumericTxtOption4Total.Text = (decPremium + decPremiumDisability).ToString();
                            }

                            //if (RadioButtonEscalationDis6.Checked == true)
                            if (RadioButtonEsc6.Checked == true)
                                strEscalation = "06";
                            //if (RadioButtonEscalationDis10.Checked == true)
                            if (RadioButtonEsc10.Checked == true)
                                strEscalation = "10";
                            //Recalculate the disability premium
                            strBaseRisk = GetBaseRisk(2);  //1= life; 2 = Disability
                            strProductType = GetBenifitCode(2); //1= life; 2 = Disability

                            if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ADB")
                            {
                                strRiskModifier = "ACCIDENTAL";
                            }

                            if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ACDB")
                            {
                                strRiskModifier = "ACCIDENTAL_CANCER";
                            }

                            ReturnDT = null;
                            if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB")
                            {
                                ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremiumDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                            }
                            else
                            {
                                ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremiumDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingDisability.Text);
                            }

                            foreach (DataRow row in ReturnDT.Rows)
                            {
                                if (row["Cover"].ToString() == "")
                                {
                                    decCoverDisability = 0;
                                }
                                else
                                {
                                    decCoverDisability = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                }
                            }

                            //Match closest cover amount in the CoverRounding table
                            #region "Match closest cover amount in the CoverRounding table"
                            sqlCommandX2 = new SqlCommand();
                            sqlCommandX2.Connection = sqlConnectionX;
                            sqlCommandX2.CommandType = CommandType.StoredProcedure;
                            sqlCommandX2.CommandText = "spx_SELECT_CoverRounding";

                            sqlParam = new SqlParameter("CoverAmount", decCoverDisability);
                            sqlCommandX2.Parameters.Add(sqlParam);

                            sqlDR2 = sqlCommandX2.ExecuteReader();
                            while (sqlDR2.Read())
                            {
                                decCoverDisability = Convert.ToDecimal(sqlDR2.GetValue(0).ToString());
                            }

                            sqlDR2.Close();
                            sqlCommandX2.Cancel();
                            sqlCommandX2.Dispose();
                            #endregion

                            //decPremiumDisability = decPremiumDisability + decPremiumFixedFee;

                        }
                        #endregion

                        if (RadioButtonQuoteDisYes.Checked == true && RadioButtonQuoteLifeYes.Checked == true)
                        {
                            #region "Life and Disability"
                            if ((((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)))) < 130)
                            {
                                //if ((blnUseLife == true) && (blnUseDisability == true))
                                //{
                                decPremium = 75;
                                decPremiumDisability = 75;
                                //}                                                            

                                strBaseRisk = GetBaseRisk(1);  //1= life; 2 = Disability
                                strProductType = GetBenifitCode(1); //1= life; 2 = Disability
                                //strRiskModifier = GetRiskModifier();

                                if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ADB")
                                {
                                    strRiskModifier = "ACCIDENTAL";
                                }

                                if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "ACDB")
                                {
                                    strRiskModifier = "ACCIDENTAL_CANCER";
                                }

                                ReturnDT = null;

                                #region "Life"
                                if (blnUseLife == true)
                                {

                                    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                    {
                                        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                    }
                                    else
                                    {
                                        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                    }

                                    foreach (DataRow row in ReturnDT.Rows)
                                    {
                                        if (row["Cover"].ToString() == "")
                                        {
                                            decCover = 0;
                                        }
                                        else
                                        {
                                            decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                        }
                                    }

                                    //Match closest cover amount in the CoverRounding table
                                    #region "Match closest cover amount in the CoverRounding table"
                                    sqlCommandX2 = new SqlCommand();
                                    sqlCommandX2.Connection = sqlConnectionX;
                                    sqlCommandX2.CommandType = CommandType.StoredProcedure;
                                    sqlCommandX2.CommandText = "spx_SELECT_CoverRounding";

                                    sqlParam = new SqlParameter("CoverAmount", decCover);
                                    sqlCommandX2.Parameters.Add(sqlParam);

                                    sqlDR2 = sqlCommandX2.ExecuteReader();
                                    while (sqlDR2.Read())
                                    {
                                        decCover = Convert.ToDecimal(sqlDR2.GetValue(0).ToString());
                                    }

                                    sqlDR2.Close();
                                    sqlCommandX2.Cancel();
                                    sqlCommandX2.Dispose();
                                    #endregion

                                    if (decCover == 40000)
                                    {
                                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                        {
                                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        }
                                        else
                                        {
                                            ReturnDT = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decCover.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        }

                                        foreach (DataRow row in ReturnDT.Rows)
                                        {
                                            if (row["LoadedPremium"].ToString() != "")
                                            {
                                                decPremium = Convert.ToDecimal(row["LoadedPremium"].ToString());
                                                decPremiumUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                                                decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());

                                            }
                                        }

                                        decPremium = decPremium + decPremiumFixedFee;
                                    }
                                }
                                #endregion

                                #region "Disability"
                                if (RadioButtonQuoteDisNo.Checked == false)
                                {
                                    //Disability
                                    //Recalculate the disability premium
                                    strBaseRisk = GetBaseRisk(2);  //1= life; 2 = Disability
                                    strProductType = GetBenifitCode(2); //1= life; 2 = Disability
                                    ReturnDT = null;
                                    if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB")
                                    {
                                        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremiumDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                    }
                                    else
                                    {
                                        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremiumDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                    }

                                    foreach (DataRow row in ReturnDT.Rows)
                                    {
                                        if (row["Cover"].ToString() == "")
                                        {
                                            decCoverDisability = 0;
                                        }
                                        else
                                        {
                                            decCoverDisability = Convert.ToDecimal(row["Cover"].ToString());
                                        }
                                    }

                                    //Match closest cover amount in the CoverRounding table
                                    #region "Match closest cover amount in the CoverRounding table"
                                    sqlCommandX2 = new SqlCommand();
                                    sqlCommandX2.Connection = sqlConnectionX;
                                    sqlCommandX2.CommandType = CommandType.StoredProcedure;
                                    sqlCommandX2.CommandText = "spx_SELECT_CoverRounding";

                                    sqlParam = new SqlParameter("CoverAmount", decCoverDisability);
                                    sqlCommandX2.Parameters.Add(sqlParam);

                                    sqlDR2 = sqlCommandX2.ExecuteReader();
                                    while (sqlDR2.Read())
                                    {
                                        decCoverDisability = Convert.ToDecimal(sqlDR2.GetValue(0).ToString());
                                    }

                                    sqlDR2.Close();
                                    sqlCommandX2.Cancel();
                                    sqlCommandX2.Dispose();
                                    #endregion

                                    //decPremium = decPremium + decPremiumFixedFee;

                                    //decPremiumDisability = decPremiumDisability + decPremiumFixedFee;
                                }
                                #endregion
                            }
                            #endregion
                        }

                    #endregion
                }

                

                #region "EM Loading"
                //if (RadNumericTxtEMLoadingLife.Enabled == true)
                //{
                //    //EM loading calc is a straight sum onto premium as Final premium = final premium (without EM loading) + unloaded prem *max( (EM loading – 25),0) / 100

                //    if (RadNumericTxtEMLoadingLife.Text.Trim() == "")
                //        RadNumericTxtEMLoadingLife.Text = "0";

                //    decimal decEmLoading = Convert.ToDecimal(RadNumericTxtEMLoadingLife.Text.Trim());
                //    ////decPremium = decPremium + (decPremium * (decEmLoading - 25) / 100);
                //    //decPremium = decPremium + (decPremium * calculation(decEmLoading, 25) / 100); 
                //    strBaseRisk = GetBaseRisk(1);  //1= life; 2 = Disability
                //    strProductType = GetBenifitCode(1); //1= life; 2 = Disability
                //    DataTable DTEMLoading = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", decEmLoading.ToString());
                //    foreach (DataRow row in DTEMLoading.Rows)
                //    {
                //        if (row["LoadedPremium"].ToString() != "")
                //        {
                //            decPremium = Convert.ToDecimal(row["LoadedPremium"].ToString());
                //            decPremiumUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                //            decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());
                //        }
                //        else
                //        {
                //            decPremium = 0;
                //            decPremiumUnrounded = 0;
                //            decPremiumFixedFee = 0;
                //        }
                //    }

                //    decPremium = decPremium + decPremiumFixedFee;
                //}

                //if (RadNumericTxtEMLoadingDisability.Enabled == true)
                //{
                //    if (RadNumericTxtEMLoadingDisability.Text.Trim() == "")
                //        RadNumericTxtEMLoadingDisability.Text = "0";

                //    decimal decEmLoading = Convert.ToDecimal(RadNumericTxtEMLoadingDisability.Text.Trim());
                //    ////decPremiumDisability = decPremiumDisability + (decPremiumDisability * (decEmLoading - 25) / 100);
                //    //decPremiumDisability = decPremiumDisability + (decPremiumDisability * calculation(decEmLoading, 25) / 100);
                //    strBaseRisk = GetBaseRisk(2);  //1= life; 2 = Disability
                //    strProductType = GetBenifitCode(2); //1= life; 2 = Disability
                //    DataTable DTEMLoading = WS.returnEM_Affected_Premium(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decCoverDisability.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), "", "", decEmLoading.ToString());
                //    foreach (DataRow row in DTEMLoading.Rows)
                //    {
                //        if (row["LoadedPremium"].ToString() != "")
                //        {
                //            decPremiumDisability = Convert.ToDecimal(row["LoadedPremium"].ToString());
                //            decPremiumDisabilityUnrounded = Convert.ToDecimal(row["UnroudedStandardPremium"].ToString());
                //            decPremiumFixedFee = Convert.ToDecimal(row["FixedFee"].ToString());
                //        }
                //        else
                //        {
                //            decPremiumDisability = 0;
                //            decPremiumDisabilityUnrounded = 0;
                //            decPremiumFixedFee = 0;
                //        }
                //    }

                //    decPremiumDisability = decPremiumDisability + decPremiumFixedFee;
                //}
                #endregion                

                //strControlFee = GetSetting("ControlFee");

                strControlFee = decPremiumFixedFee.ToString();

                if (strControlFee == "")
                    strControlFee = "1";

                bool blnLifeOk = true;
                bool blnDisabilityOk = true;

                if (RadioButtonQuoteLifeNo.Checked == true)
                {
                    blnLifeOk = false;
                }

                if ((PanelLife.GroupingText.Contains("Unavailable") == true) && (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB"))
                {
                    blnLifeOk = false;
                }

                if (RadioButtonQuoteDisNo.Checked == true)
                {
                    blnDisabilityOk = false;
                }

                if ((PanelDisability.GroupingText.Contains("Unavailable") == true) && (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB"))
                {
                    blnDisabilityOk = false;
                }

                if (RadioButtonQuoteLifeNo.Checked == false)
                {
                    if ((PanelLife.GroupingText.Contains("Unavailable") == false) || (RadComboBoxTypeBenefitLife.SelectedItem.Text != "FDB"))
                    {
                        switch (buttonNumber)
                        {
                            case 1:
                                #region "Button 1"
                                RadNumericTxtOption1RandValue.Visible = true;
                                RadNumericTxtOption1RandValue.Text = decCover.ToString();
                                lblOp1_1.Visible = true;
                                RadNumericTxtOption1Premium.Visible = true;
                                RadNumericTxtOption1Premium.Text = decPremium.ToString();
                                lblOp1_2.Visible = true;
                                if ((PanelDisability.GroupingText.Contains("Unavailable") == true) && (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB"))
                                {
                                    lblOp1_2.Text = "rands per month";
                                   
                                    RadNumericTxtOption1Total.Text = decPremium.ToString();
                                   
                                }
                                else
                                {
                                    lblOp1_2.Text = "rands per month AND";
                                    decimal decTotal = 0;

                                    if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                    {
                                        decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                    }
                                    else
                                    {
                                        decTotal = (decPremium + decPremiumDisability);
                                    }

                                    RadNumericTxtOption1Total.Text = decTotal.ToString();
                                }
                                #endregion
                                break;
                            case 2:
                                #region "Button 2"
                                RadNumericTxtOption2RandValue.Visible = true;
                                RadNumericTxtOption2RandValue.Text = decCover.ToString();
                                lblOp2_1.Visible = true;
                                RadNumericTxtOption2Premium.Visible = true;
                                RadNumericTxtOption2Premium.Text = decPremium.ToString();
                                lblOp2_2.Visible = true;
                                if ((PanelDisability.GroupingText.Contains("Unavailable") == true) && (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB"))
                                {
                                    lblOp2_2.Text = "rands per month";
                                    //if (Convert.ToInt32(RadNumericTxtOption1Premium.Text) >= 130)
                                    if (Convert.ToInt32(RadNumericTxtOption1Total.Text) >= 130)
                                    {
                                        #region "old"
                                        //if (decPremium < 130)
                                        //{
                                        //    #region "Get cover for R130"
                                        //    decPremium = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee

                                        //    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                        //    {
                                        //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        //    }
                                        //    else
                                        //    {
                                        //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        //    }

                                        //    foreach (DataRow row in ReturnDT.Rows)
                                        //    {
                                        //        if (row["Cover"].ToString() == "")
                                        //        {
                                        //            decCover = 0;
                                        //        }
                                        //        else
                                        //        {
                                        //            decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                        //        }
                                        //    }

                                        //    //Match closest cover amount in the CoverRounding table
                                        //    #region "Match closest cover amount in the CoverRounding table"
                                        //    sqlCommandX = new SqlCommand();
                                        //    sqlCommandX.Connection = sqlConnectionX;
                                        //    sqlCommandX.CommandType = CommandType.StoredProcedure;
                                        //    sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                                        //    sqlParam = new SqlParameter("CoverAmount", decCover);
                                        //    sqlCommandX.Parameters.Add(sqlParam);

                                        //    sqlDR = sqlCommandX.ExecuteReader();
                                        //    while (sqlDR.Read())
                                        //    {
                                        //        decCover = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                                        //    }

                                        //    sqlDR.Close();
                                        //    sqlCommandX.Cancel();
                                        //    sqlCommandX.Dispose();
                                        //    #endregion

                                        //    decPremium = decPremium + decPremiumFixedFee;
                                        //    #endregion

                                        //    RadNumericTxtOption2RandValue.Text = decCover.ToString();
                                        //    RadNumericTxtOption2Premium.Text = decPremium.ToString();
                                        //}
                                        #endregion

                                        //dont show option 2 if the total is the same as option 1
                                        if (decPremium == Convert.ToInt32(RadNumericTxtOption1Total.Text))
                                        {
                                            hideOption2Life();
                                            //hideOption2Disability();
                                            lblSuitable0.Visible = false;
                                            lblOr.Visible = false;
                                            RadNumericTxtOption2Total.Text = "0";
                                        }
                                        else
                                        {
                                            RadNumericTxtOption2Total.Text = decPremium.ToString();
                                        }
                                    }
                                    else
                                    {
                                        hideOption2Life();
                                        lblSuitable0.Visible = false;
                                        lblOr.Visible = false;
                                    }
                                }
                                else
                                {
                                    lblOp2_2.Text = "rands per month AND";
                                    decimal decTotal = 0;

                                    if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                    {
                                        decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                    }
                                    else
                                    {
                                        decTotal = (decPremium + decPremiumDisability);
                                    }

                                    RadNumericTxtOption2Total.Text = decTotal.ToString();

                                    //if (Convert.ToInt32(RadNumericTxtOption1Premium.Text) > 130)
                                    if (Convert.ToInt32(RadNumericTxtOption1Total.Text) > 130)
                                    {
                                        //dont show option 2 if the total is the same as option 1
                                        if (decTotal == Convert.ToInt32(RadNumericTxtOption1Total.Text))
                                        {
                                            hideOption2Life();
                                            hideOption2Disability();
                                            lblSuitable0.Visible = false;
                                            lblOr.Visible = false;
                                        }

                                        #region "old"
                                        //if (decPremium < 130)
                                        //{
                                        //    #region "Get cover for R130"
                                        //    decPremium = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee

                                        //    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                        //    {
                                        //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        //    }
                                        //    else
                                        //    {
                                        //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        //    }

                                        //    foreach (DataRow row in ReturnDT.Rows)
                                        //    {
                                        //        if (row["Cover"].ToString() == "")
                                        //        {
                                        //            decCover = 0;
                                        //        }
                                        //        else
                                        //        {
                                        //            decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                        //        }
                                        //    }

                                        //    //Match closest cover amount in the CoverRounding table
                                        //    #region "Match closest cover amount in the CoverRounding table"
                                        //    sqlCommandX = new SqlCommand();
                                        //    sqlCommandX.Connection = sqlConnectionX;
                                        //    sqlCommandX.CommandType = CommandType.StoredProcedure;
                                        //    sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                                        //    sqlParam = new SqlParameter("CoverAmount", decCover);
                                        //    sqlCommandX.Parameters.Add(sqlParam);

                                        //    sqlDR = sqlCommandX.ExecuteReader();
                                        //    while (sqlDR.Read())
                                        //    {
                                        //        decCover = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                                        //    }

                                        //    sqlDR.Close();
                                        //    sqlCommandX.Cancel();
                                        //    sqlCommandX.Dispose();
                                        //    #endregion

                                        //    decPremium = decPremium + decPremiumFixedFee;
                                        //    #endregion

                                        //    RadNumericTxtOption2RandValue.Text = decCover.ToString();
                                        //    RadNumericTxtOption2Premium.Text = decPremium.ToString();
                                        //}
                                        #endregion
                                    }
                                    else
                                    {
                                        hideOption2Life();
                                        hideOption2Disability();
                                        lblSuitable0.Visible = false;
                                        lblOr.Visible = false;
                                    }
                                }
                                #endregion
                                break;
                            case 3:
                                #region "Button 3"
                                RadNumericTxtOption3RandValue.Visible = true;
                                RadNumericTxtOption3RandValue.Text = decCover.ToString();
                                lblOp3_1.Visible = true;
                                RadNumericTxtOption3Premium.Visible = true;
                                RadNumericTxtOption3Premium.Text = decPremium.ToString();
                                lblOp3_2.Visible = true;
                                if ((PanelDisability.GroupingText.Contains("Unavailable") == true) && (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB"))
                                {
                                    lblOp3_2.Text = "rands per month";
                                    //if (Convert.ToInt32(RadNumericTxtOption2Premium.Text) > 130)
                                    if (Convert.ToInt32(RadNumericTxtOption2Total.Text) > 130)
                                    {
                                        #region "Old"
                                        //if (decPremium < 130)
                                        //{
                                        //    #region "Get cover for R130"
                                        //    decPremium = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee

                                        //    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                        //    {
                                        //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        //    }
                                        //    else
                                        //    {
                                        //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        //    }

                                        //    foreach (DataRow row in ReturnDT.Rows)
                                        //    {
                                        //        if (row["Cover"].ToString() == "")
                                        //        {
                                        //            decCover = 0;
                                        //        }
                                        //        else
                                        //        {
                                        //            decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                        //        }
                                        //    }

                                        //    ////Match closest cover amount in the CoverRounding table
                                        //    //#region "Match closest cover amount in the CoverRounding table"
                                        //    //sqlCommandX = new SqlCommand();
                                        //    //sqlCommandX.Connection = sqlConnectionX;
                                        //    //sqlCommandX.CommandType = CommandType.StoredProcedure;
                                        //    //sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                                        //    //sqlParam = new SqlParameter("CoverAmount", decCover);
                                        //    //sqlCommandX.Parameters.Add(sqlParam);

                                        //    //sqlDR = sqlCommandX.ExecuteReader();
                                        //    //while (sqlDR.Read())
                                        //    //{
                                        //    //    decCover = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                                        //    //}

                                        //    //sqlDR.Close();
                                        //    //sqlCommandX.Cancel();
                                        //    //sqlCommandX.Dispose();
                                        //    //#endregion

                                        //    decPremium = decPremium + decPremiumFixedFee;
                                        //    #endregion

                                        //    RadNumericTxtOption3RandValue.Text = decCover.ToString();
                                        //    RadNumericTxtOption3Premium.Text = decPremium.ToString();
                                        //}
                                        #endregion

                                        if (decPremium == Convert.ToInt32(RadNumericTxtOption2Total.Text))
                                        {
                                            hideOption3Life();
                                            //hideOption3Disability();

                                            RadNumericTxtOption3Total.Text = "0";
                                        }
                                        else
                                        {
                                            RadNumericTxtOption3Total.Text = decPremium.ToString();
                                        }
                                    }
                                    else
                                    {
                                        hideOption3Life();
                                        lblAlso.Visible = false;
                                    }
                                }
                                else
                                {
                                    lblOp3_2.Text = "rands per month AND";
                                    decimal decTotal = 0;

                                    if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                    {
                                        decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                    }
                                    else
                                    {
                                        decTotal = (decPremium + decPremiumDisability);
                                    }

                                    RadNumericTxtOption3Total.Text = decTotal.ToString();

                                    if (Convert.ToInt32(RadNumericTxtOption2Total.Text) > 130)
                                    {
                                        if (decTotal == Convert.ToInt32(RadNumericTxtOption2Total.Text))
                                        {
                                            hideOption3Life();
                                            //hideOption3Disability();
                                            lblAlso.Visible = false;
                                        }

                                        #region "Old"
                                        //if (decPremium < 130)
                                        //{
                                        //    #region "Get cover for R130"
                                        //    decPremium = 130; ///Making this 110 - this is the fee of 130 with out the fixed fee

                                        //    if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                                        //    {
                                        //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk + RadTxtRiskBand.Text.Trim(), strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        //    }
                                        //    else
                                        //    {
                                        //        ReturnDT = WS.returnEM_Affected_Cover(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + strProductType + strEscalation, strBaseRisk, strRiskModifier, decPremium.ToString(), RadDatePickerQuoteDate.SelectedDate.ToString(), RadTxtMagnumID.Text.Trim(), "", RadNumericTxtEMLoadingLife.Text);
                                        //    }

                                        //    foreach (DataRow row in ReturnDT.Rows)
                                        //    {
                                        //        if (row["Cover"].ToString() == "")
                                        //        {
                                        //            decCover = 0;
                                        //        }
                                        //        else
                                        //        {
                                        //            decCover = Convert.ToDecimal(row["UnroudedCover"].ToString());
                                        //        }
                                        //    }

                                        //    ////Match closest cover amount in the CoverRounding table
                                        //    //#region "Match closest cover amount in the CoverRounding table"
                                        //    //sqlCommandX = new SqlCommand();
                                        //    //sqlCommandX.Connection = sqlConnectionX;
                                        //    //sqlCommandX.CommandType = CommandType.StoredProcedure;
                                        //    //sqlCommandX.CommandText = "spx_SELECT_CoverRounding";

                                        //    //sqlParam = new SqlParameter("CoverAmount", decCover);
                                        //    //sqlCommandX.Parameters.Add(sqlParam);

                                        //    //sqlDR = sqlCommandX.ExecuteReader();
                                        //    //while (sqlDR.Read())
                                        //    //{
                                        //    //    decCover = Convert.ToDecimal(sqlDR.GetValue(0).ToString());
                                        //    //}

                                        //    //sqlDR.Close();
                                        //    //sqlCommandX.Cancel();
                                        //    //sqlCommandX.Dispose();
                                        //    //#endregion

                                        //    decPremium = decPremium + decPremiumFixedFee;
                                        //    #endregion

                                        //    RadNumericTxtOption3RandValue.Text = decCover.ToString();
                                        //    RadNumericTxtOption3Premium.Text = decPremium.ToString();
                                        //}
                                        #endregion
                                    }
                                    else
                                    {
                                        hideOption3Life();
                                        hideOption3Disability();
                                        lblAlso.Visible = false;
                                    }

                                }
                                #endregion
                                break;
                            case 4:
                                #region "Button 4"
                                hideOption4Life();
                                hideOption4Disability();

                                RadNumericTxtOption4RandValue.Visible = true;
                                RadNumericTxtOption4RandValue.Text = decCover.ToString();
                                lblOp4_1.Visible = true;
                                RadNumericTxtOption4Premium.Visible = true;
                                RadNumericTxtOption4Premium.Text = decPremium.ToString();
                                lblOp4_2.Visible = true;
                                //if (PanelDisability.GroupingText.Contains("Unavailable") == true)
                                if ((PanelDisability.GroupingText.Contains("Unavailable") == true) && (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB"))
                                {
                                    lblOp4_2.Text = "rands per month";
                                    //2015-10-12 - removed the below because it was making the premium and the total the same value on the quote letter
                                    //decimal decTotal = 0;

                                    //if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                    //{
                                    //    decTotal = (decPremium - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee))));
                                    //}
                                    //else
                                    //{
                                    //    decTotal = (decPremium + decPremiumDisability);
                                    //}

                                    //RadNumericTxtOption4Total.Text = decTotal.ToString();
                                    RadNumericTxtOption4Total.Text = decPremium.ToString();
                                }
                                else
                                {
                                    if (RadioButtonQuoteDisNo.Checked == false)
                                    {
                                        lblOp4_2.Text = "rands per month AND";
                                        //decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        decimal decTotal = 0;

                                        if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                        {
                                            decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        }
                                        else
                                        {
                                            decTotal = (decPremium + decPremiumDisability);
                                        }
                                        RadNumericTxtOption4Total.Text = decTotal.ToString();
                                    }
                                    else
                                    {
                                        lblOp4_2.Text = "rands per month";
                                        //2015-10-12 - removed the below because it was making the premium and the total the same value on the quote letter
                                        //decimal decTotal = ((decPremium)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        //RadNumericTxtOption4Total.Text = decTotal.ToString();
                                        RadNumericTxtOption4Total.Text = decPremium.ToString();
                                    }
                                }

                                if (Convert.ToDecimal(RadNumericTxtOption4Total.Text) < 130)
                                {
                                    lblOp4_Problem.Text = "The total premium is too low, please try a different cover values";
                                    lblOp4_Problem.Visible = true;

                                    hideOption4Life();
                                    hideOption4Disability();
                                }
                                else
                                { 
                                    lblOp4_Problem.Text = "";
                                    lblOp4_Problem.Visible = false;
                                }

                                #endregion
                                break;
                            case 5:
                                #region "Button 5"
                                hideOption5Life();
                                hideOption5Disability();

                                RadNumericTxtOption5RandValue.Visible = true;
                                RadNumericTxtOption5RandValue.Text = decCover.ToString();
                                lblOp5_1.Visible = true;
                                RadNumericTxtOption5Premium.Visible = true;

                                RadNumericTxtOption5Premium.Text = decPremium.ToString();
                                //RadNumericTxtOption5Premium.Text = decDesiredContribution.ToString();


                                lblOp5_2.Visible = true;
                                //if (PanelDisability.GroupingText.Contains("Unavailable") == true)
                                if ((PanelDisability.GroupingText.Contains("Unavailable") == true) && (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB"))
                                {
                                    lblOp5_2.Text = "rands per month";
                                    decimal decTotal = 0;
                                    //2015-10-12 - removed the below because it was making the premium and the total the same value on the quote letter
                                    //if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                    //{
                                    //    decTotal = (decPremium - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee))));
                                    //}
                                    //else
                                    //{
                                    //    decTotal = (decPremium + decPremiumDisability);
                                    //}

                                    //RadNumericTxtOption5Total.Text = decTotal.ToString();
                                    RadNumericTxtOption5Total.Text = decPremium.ToString();
                                }
                                else
                                {
                                    if (RadioButtonQuoteDisNo.Checked == false)
                                    {
                                        lblOp5_2.Text = "rands per month AND";
                                        //decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        ////decimal decTotal = ((decDesiredContribution + decDesiredContribution)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));  
                                        decimal decTotal = 0;

                                        if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                        {
                                            decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        }
                                        else
                                        {
                                            decTotal = (decPremium + decPremiumDisability);
                                        }

                                        RadNumericTxtOption5Total.Text = decTotal.ToString();
                                    }
                                    else
                                    {
                                        lblOp5_2.Text = "rands per month";
                                        //2015-10-12 - removed the below because it was making the premium and the total the same value on the quote letter
                                        //decimal decTotal = ((decPremium)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        //RadNumericTxtOption5Total.Text = decTotal.ToString();
                                        RadNumericTxtOption5Total.Text = decPremium.ToString();
                                    }
                                }
                                #endregion
                                break;
                        }

                    }
                    else
                    {
                        switch (buttonNumber)
                        {
                            case 1:
                                hideOption1Life();
                                break;
                            case 2:
                                hideOption2Life();
                                break;
                            case 3:
                                hideOption3Life();
                                break;
                            case 4:
                                hideOption4Life();
                                break;
                            case 5:
                                hideOption5Life();
                                break;
                        }
                    }
                }

                sqlConnectionX.Close();

                if (RadioButtonQuoteDisNo.Checked == false)
                {
                    if ((PanelDisability.GroupingText.Contains("Unavailable") == false) || (RadComboBoxTypeBenefitDisability.SelectedItem.Text != "FDB"))
                    {
                        decimal decTotal = 0;

                        switch (buttonNumber)
                        {
                            case 1:
                                #region "Button 1"
                                RadNumericTxtOption1DisCover.Visible = true;
                                RadNumericTxtOption1DisCover.Text = decCoverDisability.ToString();
                                lblOp1_3.Visible = true;
                                RadNumericTxtOption1DisPremium.Visible = true;
                                RadNumericTxtOption1DisPremium.Text = decPremiumDisability.ToString();
                                lblOp1_4.Visible = true;
                                if (RadioButtonQuoteLifeNo.Checked == true)
                                {
                                    lblOp1_4.Text = "rands per month";
                                    //decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                    
                                    if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                    {
                                        decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                    }
                                    else
                                    {
                                        decTotal = (decPremium + decPremiumDisability);
                                    }

                                    RadNumericTxtOption1Total.Text = decTotal.ToString();
                                    hideOption1Life();
                                    lblOp1_4.Visible = false;
                                    RadNumericTxtOption1Total.Visible = false;
                                    lblOp1_5.Visible = false;
                                }
                                else
                                {
                                    lblOp1_4.Text = "rands per month. So, that's a total monthly premium of";
                                    RadNumericTxtOption1Total.Visible = true;
                                    lblOp1_5.Visible = true;
                                }
                                #endregion
                                break;
                            case 2:
                                #region "Button 2"
                                if (Convert.ToInt32(RadNumericTxtOption1Total.Text) > 130)
                                {
                                    //decimal decTotal;
                                    decimal decTotalTemp;

                                    RadNumericTxtOption2DisCover.Visible = true;
                                    RadNumericTxtOption2DisCover.Text = decCoverDisability.ToString();
                                    lblOp2_3.Visible = true;
                                    RadNumericTxtOption2DisPremium.Visible = true;
                                    RadNumericTxtOption2DisPremium.Text = decPremiumDisability.ToString();
                                    lblOp2_4.Visible = true;
                                    if (RadioButtonQuoteLifeNo.Checked == true)
                                    {
                                        lblOp2_4.Text = "rands per month";
                                        //decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));

                                        if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                        {
                                            decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        }
                                        else
                                        {
                                            decTotal = (decPremium + decPremiumDisability);
                                        }

                                        RadNumericTxtOption2Total.Text = decTotal.ToString();
                                        hideOption2Life();
                                        lblOp2_4.Visible = false;
                                        RadNumericTxtOption2Total.Visible = false;
                                        lblOp2_5.Visible = false;
                                        
                                    }
                                    else
                                    {
                                        lblOp2_4.Text = "rands per month. So, that's a total monthly premium of";
                                        RadNumericTxtOption2Total.Visible = true;
                                        lblOp2_5.Visible = true;
                                    }

                                    decTotalTemp = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                    //dont show option 2 if the total is the same as option 1
                                    if (decTotalTemp == Convert.ToInt32(RadNumericTxtOption1Total.Text))
                                    {
                                        //hideOption2Life();
                                        hideOption2Disability();
                                        lblSuitable0.Visible = false;
                                        lblOr.Visible = false;
                                        RadNumericTxtOption2Total.Text = "0";
                                    }
                                }
                                else
                                {
                                    hideOption2Life();
                                    hideOption2Disability();
                                    RadNumericTxtOption2Total.Text = "0";
                                }
                                #endregion
                                break;
                            case 3:
                                #region "Button 3"
                                if (Convert.ToInt32(RadNumericTxtOption2Total.Text) > 130)
                                {
                                    RadNumericTxtOption3DisCover.Visible = true;
                                    RadNumericTxtOption3DisCover.Text = decCoverDisability.ToString();
                                    lblOp3_3.Visible = true;
                                    RadNumericTxtOption3DisPremium.Visible = true;
                                    RadNumericTxtOption3DisPremium.Text = decPremiumDisability.ToString();
                                    lblOp3_4.Visible = true;
                                    if (RadioButtonQuoteLifeNo.Checked == true)
                                    {
                                        lblOp3_4.Text = "rands per month";
                                        //decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        //decimal decTotalTemp = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        decimal decTotalTemp = 0;

                                        if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                        {
                                            decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                            decTotalTemp = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        }
                                        else
                                        {
                                            decTotal = (decPremium + decPremiumDisability);
                                            decTotalTemp = (decPremium + decPremiumDisability);
                                        }

                                        
                                        RadNumericTxtOption3Total.Text = decTotal.ToString();
                                        hideOption3Life();
                                        lblOp3_4.Visible = false;
                                        RadNumericTxtOption3Total.Visible = false;
                                        lblOp3_5.Visible = false;
                                        //dont show option 2 if the total is the same as option 1
                                        if (decTotalTemp == Convert.ToInt32(RadNumericTxtOption2Total.Text))
                                        {
                                            //hideOption3Life();
                                            hideOption3Disability();
                                            
                                            RadNumericTxtOption3Total.Text = "0";
                                        }

                                    }
                                    else
                                    {
                                        lblOp3_4.Text = "rands per month. So, that's a total monthly premium of";
                                        RadNumericTxtOption3Total.Visible = true;
                                        lblOp3_5.Visible = true;
                                    }
                                }
                                else
                                {
                                    hideOption3Life();
                                    hideOption3Disability();
                                    RadNumericTxtOption3Total.Text = "0";
                                }
                                #endregion
                                break;
                            case 4:
                                #region "Button 4"
                                if (Convert.ToDecimal(RadNumericTxtOption4Total.Text) >= 130)
                                {
                                    RadNumericTxtOption4DisCover.Visible = true;
                                    RadNumericTxtOption4DisCover.Text = decCoverDisability.ToString();
                                    lblOp4_3.Visible = true;
                                    RadNumericTxtOption4DisPremium.Visible = true;
                                    RadNumericTxtOption4DisPremium.Text = decPremiumDisability.ToString();
                                    lblOp4_4.Visible = true;


                                    if (RadioButtonQuoteLifeNo.Checked == true)
                                    {                                        
                                        lblOp4_4.Text = "rands per month";
                                        decTotal = 0;

                                        if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                        {
                                            decTotal = (decPremium - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee))));
                                        }
                                        else
                                        {
                                            decTotal = (decPremium + decPremiumDisability);
                                        }

                                        RadNumericTxtOption4Total.Text = decTotal.ToString();

                                        hideOption4Life();
                                        RadNumericTxtOption4Total.Visible = false;
                                        lblOp4_5.Visible = false;
                                    }
                                    else
                                    {
                                        lblOp4_4.Text = "rands per month. So, that's a total monthly premium of";
                                        //decTotal = ((decPremium)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                        RadNumericTxtOption4Total.Text = decTotal.ToString();

                                        RadNumericTxtOption4Total.Visible = true;
                                        lblOp4_5.Visible = true;
                                    }
                                }
                                
                                #endregion
                                break;
                            case 5:
                                #region "Button 5"
                                RadNumericTxtOption5DisCover.Visible = true;
                                RadNumericTxtOption5DisCover.Text = decCoverDisability.ToString();
                                lblOp5_3.Visible = true;
                                RadNumericTxtOption5DisPremium.Visible = true;
                                //RadNumericTxtOption5DisPremium.Text = decPremium.ToString();
                                //RadNumericTxtOption5DisPremium.Text = decDesiredContribution.ToString();
                                RadNumericTxtOption5DisPremium.Text = decPremiumDisability.ToString();
                                lblOp5_4.Visible = true;
                                if (RadioButtonQuoteLifeNo.Checked == true)
                                {
                                    hideOption5Life();
                                    lblOp5_4.Text = "rands per month";
                                    decTotal = 0;

                                    if ((RadioButtonQuoteLifeNo.Checked == false && RadioButtonQuoteDisNo.Checked == false))
                                    {
                                        //decTotal = (decPremium - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee))));
                                        decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                    }
                                    else
                                    {
                                        decTotal = (decPremium + decPremiumDisability);
                                    }

                                    RadNumericTxtOption5Total.Text = decTotal.ToString();
                                    RadNumericTxtOption5Total.Visible = false;
                                    lblOp5_5.Visible = false;
                                }
                                else
                                {
                                    lblOp5_4.Text = "rands per month. So, that's a total monthly premium of";
                                    decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                                    RadNumericTxtOption5Total.Text = decTotal.ToString();

                                    RadNumericTxtOption5Total.Visible = true;
                                    lblOp5_5.Visible = true;
                                }

                                #endregion
                                break;
                        }
                    }
                    else
                    {
                        switch (buttonNumber)
                        {
                            case 1:
                                hideOption1Disability();
                                break;
                            case 2:
                                hideOption2Disability();
                                break;
                            case 3:
                                hideOption3Disability();
                                break;
                            case 4:
                                hideOption4Disability();
                                break;
                            case 5:
                                hideOption5Disability();
                                break;
                        }
                    }
                }
                else
                {
                    switch (buttonNumber)
                    {
                        case 1:
                            hideOption1Disability();
                            break;
                        case 2:
                            hideOption2Disability();
                            break;
                        case 3:
                            hideOption3Disability();
                            break;
                        case 4:
                            hideOption4Disability();
                            break;
                        case 5:
                            hideOption5Disability();
                            break;
                    }
                }

                #region "old code"

                //if (RadioButtonQuoteLifeNo.Checked == false)
                //{
                //    if (PanelLife.GroupingText.Contains("Unavailable") == false)
                //    {
                //        switch (buttonNumber)
                //        {
                //            case 1:
                //                #region "Button 1"
                //                RadNumericTxtOption1RandValue.Visible = true;
                //                RadNumericTxtOption1RandValue.Text = decCover.ToString();
                //                lblOp1_1.Visible = true;
                //                RadNumericTxtOption1Premium.Visible = true;
                //                RadNumericTxtOption1Premium.Text = decPremium.ToString();
                //                lblOp1_2.Visible = true;
                //                if (PanelDisability.GroupingText.Contains("Unavailable") == true)
                //                {
                //                    lblOp1_2.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp1_2.Text = "rands per month AND";
                //                    decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                //                    RadNumericTxtOption1Total.Text = decTotal.ToString();
                //                }
                //                #endregion
                //                break;
                //            case 2:
                //                #region "Button 2"
                //                RadNumericTxtOption2RandValue.Visible = true;
                //                RadNumericTxtOption2RandValue.Text = decCover.ToString();
                //                lblOp2_1.Visible = true;
                //                RadNumericTxtOption2Premium.Visible = true;
                //                RadNumericTxtOption2Premium.Text = decPremium.ToString();
                //                lblOp2_2.Visible = true;
                //                if (PanelDisability.GroupingText.Contains("Unavailable") == true)
                //                {
                //                    lblOp2_2.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp2_2.Text = "rands per month AND";
                //                    decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                //                    RadNumericTxtOption2Total.Text = decTotal.ToString();
                //                }
                //                #endregion
                //                break;
                //            case 3:
                //                #region "Button 3"
                //                RadNumericTxtOption3RandValue.Visible = true;
                //                RadNumericTxtOption3RandValue.Text = decCover.ToString();
                //                lblOp3_1.Visible = true;
                //                RadNumericTxtOption3Premium.Visible = true;
                //                RadNumericTxtOption3Premium.Text = decPremium.ToString();
                //                lblOp3_2.Visible = true;
                //                if (PanelDisability.GroupingText.Contains("Unavailable") == true)
                //                {
                //                    lblOp3_2.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp3_2.Text = "rands per month AND";
                //                    decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                //                    RadNumericTxtOption3Total.Text = decTotal.ToString();
                //                }
                //                #endregion
                //                break;
                //            case 4:
                //                #region "Button 4"
                //                RadNumericTxtOption4RandValue.Visible = true;
                //                RadNumericTxtOption4RandValue.Text = decCover.ToString();
                //                lblOp4_1.Visible = true;
                //                RadNumericTxtOption4Premium.Visible = true;
                //                RadNumericTxtOption4Premium.Text = decPremium.ToString();
                //                lblOp4_2.Visible = true;
                //                if (PanelDisability.GroupingText.Contains("Unavailable") == true)
                //                {
                //                    lblOp4_2.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp4_2.Text = "rands per month AND";
                //                    decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                //                    RadNumericTxtOption4Total.Text = decTotal.ToString();
                //                }
                //                #endregion
                //                break;
                //            case 5:
                //                #region "Button 5"
                //                RadNumericTxtOption5RandValue.Visible = true;
                //                RadNumericTxtOption5RandValue.Text = decCover.ToString();
                //                lblOp5_1.Visible = true;
                //                RadNumericTxtOption5Premium.Visible = true;

                //                RadNumericTxtOption5Premium.Text = decPremium.ToString();
                //                //RadNumericTxtOption5Premium.Text = decDesiredContribution.ToString();

                //                lblOp5_2.Visible = true;
                //                if (PanelDisability.GroupingText.Contains("Unavailable") == true)
                //                {
                //                    lblOp5_2.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp5_2.Text = "rands per month AND";
                //                    decimal decTotal = ((decPremium + decPremiumDisability)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));
                //                    //decimal decTotal = ((decDesiredContribution + decDesiredContribution)) - (Convert.ToDecimal(1 * Convert.ToDecimal(strControlFee)));  
                //                    RadNumericTxtOption5Total.Text = decTotal.ToString();
                //                }
                //                #endregion
                //                break;
                //        }

                //    }
                //    else
                //    {
                //        switch (buttonNumber)
                //        {
                //            case 1:
                //                hideOption1Life();
                //                break;
                //            case 2:
                //                hideOption2Life();
                //                break;
                //            case 3:
                //                hideOption3Life();
                //                break;
                //            case 4:
                //                hideOption4Life();
                //                break;
                //            case 5:
                //                hideOption5Life();
                //                break;
                //        }
                //    }
                //}

                //if (RadioButtonQuoteDisNo.Checked == false)
                //{
                //    if (PanelDisability.GroupingText.Contains("Unavailable") == false)
                //    {
                //        switch (buttonNumber)
                //        {
                //            case 1:
                //                #region "Button 1"
                //                RadNumericTxtOption1DisCover.Visible = true;
                //                RadNumericTxtOption1DisCover.Text = decCoverDisability.ToString();
                //                lblOp1_3.Visible = true;
                //                RadNumericTxtOption1DisPremium.Visible = true;
                //                RadNumericTxtOption1DisPremium.Text = decPremiumDisability.ToString();
                //                lblOp1_4.Visible = true;                                
                //                if (RadioButtonQuoteLifeNo.Checked == true)
                //                {
                //                    lblOp1_4.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp1_4.Text = "rands per month AND";
                //                    RadNumericTxtOption1Total.Visible = true;
                //                    lblOp1_5.Visible = true;
                //                }
                //                #endregion
                //                break;
                //            case 2:
                //                #region "Button 2"
                //                RadNumericTxtOption2DisCover.Visible = true;
                //                RadNumericTxtOption2DisCover.Text = decCoverDisability.ToString();
                //                lblOp2_3.Visible = true;
                //                RadNumericTxtOption2DisPremium.Visible = true;
                //                RadNumericTxtOption2DisPremium.Text = decPremiumDisability.ToString();
                //                lblOp2_4.Visible = true;                                
                //                if (RadioButtonQuoteLifeNo.Checked == true)
                //                {
                //                    lblOp2_4.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp2_4.Text = "rands per month AND";
                //                    RadNumericTxtOption2Total.Visible = true;
                //                    lblOp2_5.Visible = true;
                //                }
                //                #endregion
                //                break;
                //            case 3:
                //                #region "Button 3"
                //                RadNumericTxtOption3DisCover.Visible = true;
                //                RadNumericTxtOption3DisCover.Text = decCoverDisability.ToString();
                //                lblOp3_3.Visible = true;
                //                RadNumericTxtOption3DisPremium.Visible = true;
                //                RadNumericTxtOption3DisPremium.Text = decPremiumDisability.ToString();
                //                lblOp3_4.Visible = true;                              
                //                if (RadioButtonQuoteLifeNo.Checked == true)
                //                {
                //                    lblOp3_4.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp3_4.Text = "rands per month AND";
                //                    RadNumericTxtOption3Total.Visible = true;
                //                    lblOp3_5.Visible = true;
                //                }
                //                #endregion
                //                break;
                //            case 4:
                //                #region "Button 4"
                //                RadNumericTxtOption4DisCover.Visible = true;
                //                RadNumericTxtOption4DisCover.Text = decCoverDisability.ToString();
                //                lblOp4_3.Visible = true;
                //                RadNumericTxtOption4DisPremium.Visible = true;
                //                RadNumericTxtOption4DisPremium.Text = decPremiumDisability.ToString();
                //                lblOp4_4.Visible = true;                                
                //                if (RadioButtonQuoteLifeNo.Checked == true)
                //                {
                //                    lblOp4_4.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp4_4.Text = "rands per month AND";
                //                    RadNumericTxtOption4Total.Visible = true;
                //                    lblOp4_5.Visible = true;
                //                }
                //                #endregion
                //                break;
                //            case 5:
                //                #region "Button 5"
                //                RadNumericTxtOption5DisCover.Visible = true;
                //                RadNumericTxtOption5DisCover.Text = decCoverDisability.ToString();
                //                lblOp5_3.Visible = true;
                //                RadNumericTxtOption5DisPremium.Visible = true;
                //                //RadNumericTxtOption5DisPremium.Text = decPremium.ToString();
                //                //RadNumericTxtOption5DisPremium.Text = decDesiredContribution.ToString();
                //                RadNumericTxtOption5DisPremium.Text = decPremiumDisability.ToString();
                //                lblOp5_4.Visible = true;                                
                //                if (RadioButtonQuoteLifeNo.Checked == true)
                //                {
                //                    lblOp5_4.Text = "rands per month";
                //                }
                //                else
                //                {
                //                    lblOp5_4.Text = "rands per month AND";
                //                    RadNumericTxtOption5Total.Visible = true;
                //                    lblOp5_5.Visible = true;
                //                }

                //                #endregion
                //                break;
                //        }
                //    }
                //    else
                //    {
                //        switch (buttonNumber)
                //        {
                //            case 1:
                //                hideOption1Disability();
                //                break;
                //            case 2:
                //                hideOption2Disability();
                //                break;
                //            case 3:
                //                hideOption3Disability();
                //                break;
                //            case 4:
                //                hideOption4Disability();
                //                break;
                //            case 5:
                //                hideOption5Disability();
                //                break;
                //        }
                //    }
                //}
                #endregion
            }
            catch (Exception ex)
            {
                lblInfo.Text = ex.Message;
                lblInfo2.Text = ex.Message;   
            }
        }
コード例 #5
0
        protected void RadBtnQualifyClient_Click(object sender, EventArgs e)
        {
            WS.AllLifePrincingClient WS = new WS.AllLifePrincingClient();
            DataTable ReturnDT;

            string strSubscriberName = string.Empty;
            string strSubscriberPassword = string.Empty;
            string strSubscriberCode = string.Empty;
            
            SqlConnection sqlConnectionX;
            SqlCommand sqlCommandX;
            SqlParameter sqlParam;
            SqlDataReader sqlDR;

            try
            {
                hideOption1Life();
                hideOption1Disability();
                hideOption2Life();
                hideOption2Disability();
                hideOption3Life();
                hideOption3Disability();
                hideOption4Life();
                hideOption4Disability();
                hideOption5Life();
                hideOption5Disability();

                lblRequalify.Text = "";

                sqlConnectionX = new SqlConnection(ConfigurationManager.AppSettings["SQLConnection"]);
                sqlConnectionX.Open();

                #region "Get SubscriberName"
                strSubscriberName = GetSetting("SubscriberName");

                //sqlCommandX = new SqlCommand();
                //sqlCommandX.Connection = sqlConnectionX;
                //sqlCommandX.CommandType = CommandType.StoredProcedure;
                //sqlCommandX.CommandText = "spx_SELECT_Setting";

                //sqlParam = new SqlParameter("SettingName", "SubscriberName");
                //sqlCommandX.Parameters.Add(sqlParam);

                //sqlDR = sqlCommandX.ExecuteReader();
                //while (sqlDR.Read())
                //{
                //    strSubscriberName = sqlDR.GetValue(0).ToString();
                //}

                //sqlDR.Close();
                //sqlCommandX.Cancel();
                //sqlCommandX.Dispose();
                #endregion

                #region "Get SubscriberPassword"
                strSubscriberPassword = GetSetting("SubscriberPassword");
                //sqlCommandX = new SqlCommand();
                //sqlCommandX.Connection = sqlConnectionX;
                //sqlCommandX.CommandType = CommandType.StoredProcedure;
                //sqlCommandX.CommandText = "spx_SELECT_Setting";

                //sqlParam = new SqlParameter("SettingName", "SubscriberPassword");
                //sqlCommandX.Parameters.Add(sqlParam);

                //sqlDR = sqlCommandX.ExecuteReader();
                //while (sqlDR.Read())
                //{
                //    strSubscriberPassword = sqlDR.GetValue(0).ToString();
                //}

                //sqlDR.Close();
                //sqlCommandX.Cancel();
                //sqlCommandX.Dispose();
                #endregion

                #region "Get SubscriberCode"
                strSubscriberCode = GetSetting("SubscriberCode");
                //sqlCommandX = new SqlCommand();
                //sqlCommandX.Connection = sqlConnectionX;
                //sqlCommandX.CommandType = CommandType.StoredProcedure;
                //sqlCommandX.CommandText = "spx_SELECT_Setting";

                //sqlParam = new SqlParameter("SettingName", "SubscriberCode");
                //sqlCommandX.Parameters.Add(sqlParam);

                //sqlDR = sqlCommandX.ExecuteReader();
                //while (sqlDR.Read())
                //{
                //    strSubscriberCode = sqlDR.GetValue(0).ToString();
                //}

                //sqlDR.Close();
                //sqlCommandX.Cancel();
                //sqlCommandX.Dispose();
                #endregion

                bool blnTobaccoUse;
                int intHbA1c = 0;
                int intAlcoholUnitsPerDay = 0;
                string strEmployment = string.Empty; string strQualification = string.Empty; string strSpouseQualification = string.Empty;
                string strResultLife = string.Empty;
                string strResultDisability = string.Empty;
                int intClass = 0;                
                int intMarriedTypeID = 0;

                string strTobaccoSelection = RadioButtonListTobacco.SelectedValue;

                if (strTobaccoSelection == "non-smoker")
                    blnTobaccoUse = false;
                else
                    blnTobaccoUse = true;

                //if (RadioButtonListTobacco.Checked == true)
                //    blnTobaccoUse = true;
                //else
                //    blnTobaccoUse = false;

                string strAcoholSelection = RadioButtonListAlcohol.SelectedValue;

                if (strAcoholSelection == "non-drinker")
                    intAlcoholUnitsPerDay = 0;
                if (strAcoholSelection == "0 - 5")
                    intAlcoholUnitsPerDay = 5;
                if (strAcoholSelection == "> 5")
                    intAlcoholUnitsPerDay = 6;

                #region "HbA1c"
                if (RadioButtonHbA1c3.Checked == true)
                    intHbA1c = 4;
                if (RadioButtonHbA1c4.Checked == true)
                    intHbA1c = 4;
                if (RadioButtonHbA1c6.Checked == true)
                    intHbA1c = 6;
                if (RadioButtonHbA1c7.Checked == true)
                    intHbA1c = 7;
                if (RadioButtonHbA1c8.Checked == true)
                    intHbA1c = 8;
                if (RadioButtonHbA1c9.Checked == true)
                    intHbA1c = 9;
                if (RadioButtonHbA1c10.Checked == true)
                    intHbA1c = 10;
                if (RadioButtonHbA1c11.Checked == true)
                    intHbA1c = 11;
                if (RadioButtonHbA1c12.Checked == true)
                    intHbA1c = 12;
                if (RadioButtonHbA1c15.Checked == true)
                    intHbA1c = 15;
                #endregion

                #region "Married"
                if (RadioButtonMaritalStatusNotMarried.Checked == true)
                {
                    intMarriedTypeID = 0;
                }

                if (RadioButtonMaritalStatusMarried.Checked == true)
                {
                    intMarriedTypeID = 1;
                }
               
                #endregion

                if (RadioButtonEsc6.Checked == true)
                    HiddenFieldEscalationLife.Value = "6.00";
                if (RadioButtonEsc10.Checked == true)
                    HiddenFieldEscalationLife.Value = "10.00";

                //if (RadioButtonEscLife6.Checked == true)
                //    HiddenFieldEscalationLife.Value = "6.00";
                //if (RadioButtonEscLife10.Checked == true)
                //    HiddenFieldEscalationLife.Value = "10.00";

                //if (RadioButtonEscalationDis6.Checked == true)
                //    HiddenFieldEscalationDisablility.Value = "6.00";
                //if (RadioButtonEscalationDis10.Checked == true)
                //    HiddenFieldEscalationDisablility.Value = "10.00";

                strEmployment = RadComboBoxOccupation.SelectedItem.Text.ToString().Trim();

                #region "QualifyLife"
                ReturnDT = WS.QualifyLife(strSubscriberName, strSubscriberPassword, strSubscriberCode, RadTxtAgeOfNextBirthday.Text.Trim(), blnTobaccoUse.ToString(), intHbA1c.ToString(), RadNumericTxtBMI.Text.ToString().Trim(), RadNumericTxtPantSize.Text.Trim(), intAlcoholUnitsPerDay.ToString(), strEmployment);
                foreach (DataRow row in ReturnDT.Rows)
                {
                    strResultLife = row["Result"].ToString();
                }

                if (strResultLife == "Successful")
                {
                    LblQualificationMessage.Text = "ok";
                    PanelLife.GroupingText = "Life";
                    //PanelLife.Enabled = true;
                    RadioButtonEscLife6.Enabled = true;
                    RadioButtonEscLife10.Enabled = true;
                    RadNumericTxtCoverLife.Enabled = true;
                    RadNumericTxtPremiumLife.Enabled = true;
                    RadNumericTxtEMLoadingLife.Enabled = true;

                    RadioButtonQuoteLifeYes.Checked = true;
                    //RadioButtonEscLife6.Checked = true;
                    RadioButtonEsc6.Checked = true;
                }
                else
                {
                        LblQualificationMessage.Text = strResultLife;
                        PanelLife.GroupingText = "Life - Unavailable";
                        if (RadComboBoxTypeBenefitLife.SelectedItem.Text == "FDB")
                        {
                            //PanelLife.Enabled = false;
                            RadioButtonEscLife6.Enabled = false;
                            RadioButtonEscLife10.Enabled = false;
                            RadNumericTxtCoverLife.Enabled = false;
                            RadNumericTxtPremiumLife.Enabled = false;
                            RadNumericTxtEMLoadingLife.Enabled = false;
                            hideOption1Life();
                        }
                        else
                        {
                            RadioButtonEscLife6.Enabled = true;
                            RadioButtonEscLife10.Enabled = true;
                            RadNumericTxtCoverLife.Enabled = true;
                            RadNumericTxtPremiumLife.Enabled = true;
                            RadNumericTxtEMLoadingLife.Enabled = true;

                            //RadioButtonQuoteLifeYes.Checked = true;
                            //RadioButtonEscLife6.Checked = true;
                            //RadioButtonEsc6.Checked = true;
                        }
                }
                #endregion

                //Does the client qualify for the disability
                //**********************************************************                        
                #region "QualifyDisability"

                if (RadioButtonNotMat.Checked)
                    strQualification = "No matric";
                if (RadioButtonMatriculated.Checked)
                    strQualification = "Matric";
                if (RadioButtonDiploma.Checked)
                    strQualification = "3 or 4 yr. Diploma/3 yr. Degree";
                if (RadioButtonDegree.Checked)
                    strQualification = "4 yr. Degree/professional qualification";

                if (RadioButtonSNotMat.Checked)
                    strSpouseQualification = "No matric";
                if (RadioButtonSMat.Checked)
                    strSpouseQualification = "Matric";
                if (RadioButtonSDip.Checked)
                    strSpouseQualification = "3 or 4 yr. Diploma/3 yr. Degree";
                if (RadioButtonSDegree.Checked)
                    strSpouseQualification = "4 yr. Degree/professional qualification";

                strEmployment = RadComboBoxOccupation.SelectedItem.Text.ToString().Trim();
                string strSpouseIncome = RadNumericTxtSpouseIncome.Text.Trim();
                if (strSpouseIncome == "")
                    strSpouseIncome = "0";

                string strProduct = string.Empty;

                #region "Get Default Diabetes Product"
                sqlCommandX = new SqlCommand();
                sqlCommandX.Connection = sqlConnectionX;
                sqlCommandX.CommandType = CommandType.StoredProcedure;
                sqlCommandX.CommandText = "spx_SELECT_Setting";

                sqlParam = new SqlParameter("SettingName", "Default Diabetes Product");
                sqlCommandX.Parameters.Add(sqlParam);

                sqlDR = sqlCommandX.ExecuteReader();
                while (sqlDR.Read())
                {
                    strProduct = sqlDR.GetValue(0).ToString();
                }

                sqlDR.Close();
                sqlCommandX.Cancel();
                sqlCommandX.Dispose();
                #endregion

                //Get the risk band
                string strRiskModifier = GetRiskModifier();

                ReturnDT = WS.returnRiskBand(strSubscriberName, strSubscriberPassword, strSubscriberCode, strProduct + "WL06", strRiskModifier, RadDatePickerQuoteDate.SelectedDate.ToString());

                string strRiskBand = ReturnDT.Rows[0][0].ToString();
                RadTxtRiskBand.Text = strRiskBand;

                ReturnDT = WS.QualifyDisability(strSubscriberName, strSubscriberPassword, strSubscriberCode, RadTxtAgeOfNextBirthday.Text.Trim(), blnTobaccoUse.ToString(), intHbA1c.ToString(), RadNumericTxtBMI.Text.ToString().Trim(), RadNumericTxtPantSize.Text.Trim(), intAlcoholUnitsPerDay.ToString(), strEmployment, strQualification, RadNumericTxtIncome.Text.Trim(), strSpouseIncome, strRiskBand);
                foreach (DataRow row in ReturnDT.Rows)
                {
                    strResultDisability = row["Result"].ToString();
                    intClass = Convert.ToInt16(row["Class"].ToString());                    
                }
                
                HiddenFieldClassOfLife.Value = intClass.ToString();

                if (strResultDisability == "Successful")
                {
                    lblDisabilityMessage.Text = "ok";
                    PanelDisability.GroupingText = "Disability";
                    //PanelDisability.Enabled = true;
                    RadioButtonTypeOfDisADW.Enabled = true;
                    RadioButtonTypeOfDisOCC.Enabled = true;
                    RadioButtonEscalationDis6.Enabled = true;
                    RadioButtonEscalationDis10.Enabled = true;
                    RadioButtonQuoteDisYes.Enabled = true;
                    RadioButtonQuoteDisNo.Enabled = true;
                    RadNumericTxtCoverAmnDis.Enabled = true;
                    RadNumericTxtPremiumDis.Enabled = true;
                    RadNumericTxtEMLoadingDisability.Enabled = true;

                    RadioButtonQuoteDisYes.Checked = true;
                    ////RadioButtonEscalationDis6.Checked = true;
                    ////if (intClass > 0)
                    ////{
                    ////    lblDisabilityMessage.Text += ", class:" + intClass.ToString();
                    ////}    


                    sqlCommandX = new SqlCommand();
                    sqlCommandX.Connection = sqlConnectionX;
                    sqlCommandX.CommandType = CommandType.StoredProcedure;
                    sqlCommandX.CommandText = "spx_Select_OccupationLimitsByOccupation";

                    sqlParam = new SqlParameter("Occupation", strEmployment);
                    sqlCommandX.Parameters.Add(sqlParam);

                    bool blnADW = false;
                    bool blnOCC = false;

                    sqlDR = sqlCommandX.ExecuteReader();
                    while (sqlDR.Read())
                    {
                        if (sqlDR.GetBoolean(1) == true)  //sql column 1 = ADW
                            blnADW = true;
                        if (sqlDR.GetBoolean(2) == true)  //sql column 2 = OCC
                            blnOCC = true;
                    }

                    sqlDR.Close();
                    sqlDR.Dispose();

                    if ((intClass >= 1) && (intClass < 4))
                    {
                        if (blnOCC == true)
                        {
                            RadioButtonTypeOfDisOCC.Enabled = true;
                            RadioButtonTypeOfDisOCC.Checked = true;
                            RadioButtonTypeOfDisADW.Enabled = true;
                            RadTxtDisabilityType.Text = "OCC";
                        }
                        else
                        {
                            if (blnADW == true)
                            {
                                RadioButtonTypeOfDisOCC.Enabled = false;
                                RadioButtonTypeOfDisOCC.Checked = false;
                                RadioButtonTypeOfDisADW.Enabled = true;
                                RadioButtonTypeOfDisADW.Checked = true;
                                RadTxtDisabilityType.Text = "ADW";
                            }
                            else
                            {
                                strResultDisability = "Occupation does not allow disability";
                                lblDisabilityMessage.Text = strResultDisability;
                                PanelDisability.GroupingText = "Disability - Unavailable";
                                //PanelDisability.Enabled = false;
                                RadioButtonTypeOfDisADW.Enabled = false;
                                RadioButtonTypeOfDisOCC.Enabled = false;
                                RadioButtonEscalationDis6.Enabled = false;
                                RadioButtonEscalationDis10.Enabled = false;
                                RadioButtonQuoteDisYes.Enabled = false;
                                RadioButtonQuoteDisNo.Enabled = false;
                                RadNumericTxtCoverAmnDis.Enabled = false;
                                RadNumericTxtPremiumDis.Enabled = false;
                                RadNumericTxtEMLoadingDisability.Enabled = false;

                                hideOption1Disability();
                            }
                        }
                    }


                    if (intClass > 3)
                    {                        
                        if (blnADW == true)
                        {
                            RadioButtonTypeOfDisOCC.Enabled = false;
                            RadioButtonTypeOfDisOCC.Checked = false;
                            RadioButtonTypeOfDisADW.Enabled = true;
                            RadioButtonTypeOfDisADW.Checked = true;
                            RadTxtDisabilityType.Text = "ADW";
                        }
                        else
                        {
                            strResultDisability = "Occupation does not allow disability";
                            lblDisabilityMessage.Text = strResultDisability;
                            PanelDisability.GroupingText = "Disability - Unavailable";
                            //PanelDisability.Enabled = false;
                            RadioButtonTypeOfDisADW.Enabled = false;
                            RadioButtonTypeOfDisOCC.Enabled = false;
                            RadioButtonEscalationDis6.Enabled = false;
                            RadioButtonEscalationDis10.Enabled = false;
                            RadioButtonQuoteDisYes.Enabled = false;
                            RadioButtonQuoteDisNo.Enabled = false;
                            RadNumericTxtCoverAmnDis.Enabled = false;
                            RadNumericTxtPremiumDis.Enabled = false;
                            RadNumericTxtEMLoadingDisability.Enabled = false;
                            hideOption1Disability();
                        }
                    }

                   
                }
                else
                {
                    if (RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB")
                    {
                        lblDisabilityMessage.Text = strResultDisability;
                        PanelDisability.GroupingText = "Disability - Unavailable";

                        if ((RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB") && (RadComboBoxTypeBenefitLife.Items.Count() == 1))
                        {
                            //PanelDisability.Enabled = false;
                            RadioButtonTypeOfDisADW.Enabled = false;
                            RadioButtonTypeOfDisOCC.Enabled = false;
                            RadioButtonEscalationDis6.Enabled = false;
                            RadioButtonEscalationDis10.Enabled = false;
                            RadioButtonQuoteDisYes.Enabled = false;
                            RadioButtonQuoteDisNo.Enabled = false;
                            RadNumericTxtCoverAmnDis.Enabled = false;
                            RadNumericTxtPremiumDis.Enabled = false;
                            RadNumericTxtEMLoadingDisability.Enabled = false;

                            hideOption1Disability();
                        }
                        else
                        {
                            RadioButtonTypeOfDisADW.Enabled = true;
                            RadioButtonTypeOfDisOCC.Enabled = true;
                            RadioButtonEscalationDis6.Enabled = true;
                            RadioButtonEscalationDis10.Enabled = true;
                            RadioButtonQuoteDisYes.Enabled = true;
                            RadioButtonQuoteDisNo.Enabled = true;
                            RadNumericTxtCoverAmnDis.Enabled = true;
                            RadNumericTxtPremiumDis.Enabled = true;
                            RadNumericTxtEMLoadingDisability.Enabled = true;
                        }
                    }
                    else
                    {
                        RadioButtonTypeOfDisADW.Enabled = true;
                        RadioButtonTypeOfDisOCC.Enabled = true;
                        RadioButtonEscalationDis6.Enabled = true;
                        RadioButtonEscalationDis10.Enabled = true;
                        RadioButtonQuoteDisYes.Enabled = true;
                        RadioButtonQuoteDisNo.Enabled = true;
                        RadNumericTxtCoverAmnDis.Enabled = true;
                        RadNumericTxtPremiumDis.Enabled = true;
                        RadNumericTxtEMLoadingDisability.Enabled = true;

                        //RadioButtonQuoteDisYes.Checked = true;
                        //////RadioButtonEscalationDis6.Checked = true;
                        //////if (intClass > 0)
                        //////{
                        //////    lblDisabilityMessage.Text += ", class:" + intClass.ToString();
                        //////}    


                        sqlCommandX = new SqlCommand();
                        sqlCommandX.Connection = sqlConnectionX;
                        sqlCommandX.CommandType = CommandType.StoredProcedure;
                        sqlCommandX.CommandText = "spx_Select_OccupationLimitsByOccupation";

                        sqlParam = new SqlParameter("Occupation", strEmployment);
                        sqlCommandX.Parameters.Add(sqlParam);

                        bool blnADW = false;
                        bool blnOCC = false;

                        sqlDR = sqlCommandX.ExecuteReader();
                        while (sqlDR.Read())
                        {
                            if (sqlDR.GetBoolean(1) == true)  //sql column 1 = ADW
                                blnADW = true;
                            if (sqlDR.GetBoolean(2) == true)  //sql column 2 = OCC
                                blnOCC = true;
                        }

                        sqlDR.Close();
                        sqlDR.Dispose();

                        if ((intClass >= 1) && (intClass < 4))
                        {
                            if (blnOCC == true)
                            {
                                RadioButtonTypeOfDisOCC.Enabled = true;
                                RadioButtonTypeOfDisOCC.Checked = true;
                                RadioButtonTypeOfDisADW.Enabled = true;
                                RadTxtDisabilityType.Text = "OCC";
                            }
                            else
                            {
                                if (blnADW == true)
                                {
                                    RadioButtonTypeOfDisOCC.Enabled = false;
                                    RadioButtonTypeOfDisOCC.Checked = false;
                                    RadioButtonTypeOfDisADW.Enabled = true;
                                    RadioButtonTypeOfDisADW.Checked = true;
                                    RadTxtDisabilityType.Text = "ADW";
                                }
                                else
                                {
                                    strResultDisability = "Occupation does not allow disability";
                                    lblDisabilityMessage.Text = strResultDisability;
                                    PanelDisability.GroupingText = "Disability - Unavailable";
                                    if ((RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB") && (RadComboBoxTypeBenefitLife.Items.Count() == 1))
                                    {
                                        //PanelDisability.Enabled = false;
                                        RadioButtonTypeOfDisADW.Enabled = false;
                                        RadioButtonTypeOfDisOCC.Enabled = false;
                                        RadioButtonEscalationDis6.Enabled = false;
                                        RadioButtonEscalationDis10.Enabled = false;
                                        RadioButtonQuoteDisYes.Enabled = false;
                                        RadioButtonQuoteDisNo.Enabled = false;
                                        RadNumericTxtCoverAmnDis.Enabled = false;
                                        RadNumericTxtPremiumDis.Enabled = false;
                                        RadNumericTxtEMLoadingDisability.Enabled = false;

                                        hideOption1Disability();
                                    }
                                    else
                                    {
                                        RadioButtonTypeOfDisADW.Enabled = true;
                                        RadioButtonTypeOfDisOCC.Enabled = true;
                                        RadioButtonEscalationDis6.Enabled = true;
                                        RadioButtonEscalationDis10.Enabled = true;
                                        RadioButtonQuoteDisYes.Enabled = true;
                                        RadioButtonQuoteDisNo.Enabled = true;
                                        RadNumericTxtCoverAmnDis.Enabled = true;
                                        RadNumericTxtPremiumDis.Enabled = true;
                                        RadNumericTxtEMLoadingDisability.Enabled = true;
                                    }
                                }
                            }
                        }


                        if (intClass > 3)
                        {
                            if (blnADW == true)
                            {
                                RadioButtonTypeOfDisOCC.Enabled = false;
                                RadioButtonTypeOfDisOCC.Checked = false;
                                RadioButtonTypeOfDisADW.Enabled = true;
                                RadioButtonTypeOfDisADW.Checked = true;
                                RadTxtDisabilityType.Text = "ADW";
                            }
                            else
                            {
                                strResultDisability = "Occupation does not allow disability";
                                lblDisabilityMessage.Text = strResultDisability;
                                PanelDisability.GroupingText = "Disability - Unavailable";
                                if ((RadComboBoxTypeBenefitDisability.SelectedItem.Text == "FDB") && (RadComboBoxTypeBenefitLife.Items.Count() == 1))
                                {
                                    //PanelDisability.Enabled = false;
                                    RadioButtonTypeOfDisADW.Enabled = false;
                                    RadioButtonTypeOfDisOCC.Enabled = false;
                                    RadioButtonEscalationDis6.Enabled = false;
                                    RadioButtonEscalationDis10.Enabled = false;
                                    RadioButtonQuoteDisYes.Enabled = false;
                                    RadioButtonQuoteDisNo.Enabled = false;
                                    RadNumericTxtCoverAmnDis.Enabled = false;
                                    RadNumericTxtPremiumDis.Enabled = false;
                                    RadNumericTxtEMLoadingDisability.Enabled = false;
                                    hideOption1Disability();
                                }
                                else
                                {
                                    RadioButtonTypeOfDisADW.Enabled = true;
                                    RadioButtonTypeOfDisOCC.Enabled = true;
                                    RadioButtonEscalationDis6.Enabled = true;
                                    RadioButtonEscalationDis10.Enabled = true;
                                    RadioButtonQuoteDisYes.Enabled = true;
                                    RadioButtonQuoteDisNo.Enabled = true;
                                    RadNumericTxtCoverAmnDis.Enabled = true;
                                    RadNumericTxtPremiumDis.Enabled = true;
                                    RadNumericTxtEMLoadingDisability.Enabled = true;
                                }
                            }
                        }
                    }
                }
                #endregion

                #region "Add the quote to the Quote audit table"
                
                sqlCommandX = new SqlCommand();
                sqlCommandX.Connection = sqlConnectionX;
                sqlCommandX.CommandType = CommandType.StoredProcedure;
                sqlCommandX.CommandText = "spx_INSERT_QuoteAuditTrail";

                #region "Parameters"
                string strGender = string.Empty;
                string strHighestQualification = string.Empty;
                string strDiabetesType = string.Empty;
                string strInsulinUse = string.Empty;
                string strTabletUse = string.Empty; string strDoctorsVisits = string.Empty;
                string strDiabeticControl = string.Empty; string strHbA1c = string.Empty;
                string strExercisePlan = string.Empty; string strExHowWellFollowed = string.Empty;
                string strEatingPlan = string.Empty; string strEatHowWellFollowed = string.Empty;
                string strHighBP = string.Empty; string strHighCholesterol = string.Empty;
                string strMedicalAid = string.Empty; string strAlcohol = string.Empty;
                string strAlcoholUnits = string.Empty; string strTobacco = string.Empty; decimal decEscalationLife = 0; decimal decEscalationDisability = 0;
                string strTobaccoUnits = string.Empty;
                string strLifeBenifit = string.Empty; string strDisabilityBenifit = string.Empty;
                int intQuoteLife = 1; int intQuoteDisability = 1;

                sqlParam = new SqlParameter("MagnumID", RadTxtMagnumID.Text);
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("UserID", Session["UserID"].ToString());
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("ClientName", RadTxtClientNameAndSurname.Text);
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("IDType", RadComboIDType.SelectedItem.Text.ToString());
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("IDNumber", RadTxtIDNumber.Text.Trim());
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("QuoteDate", Convert.ToDateTime(RadDatePickerQuoteDate.SelectedDate.ToString()).ToString("yyyy-MM-dd"));
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("EmailAddress", RadTxtEmail.Text);
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("DOB", Convert.ToDateTime(RadDatePickerDOB.SelectedDate.ToString()).ToString("yyyy-MM-dd"));
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("AgeAtNextBD", RadTxtAgeOfNextBirthday.Text);                
                    if (RadioButtonMale.Checked == true)
                        strGender = "M";
                    if (RadioButtonFemale.Checked == true)
                        strGender = "F";
                    if (RadioButtonOther.Checked == true)
                        strGender = "M";
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("Gender", strGender);
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("IDValidation", LabelValidationMsg.Text);
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("HighestQualification", strQualification);
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("OccupationID", Convert.ToInt16(RadComboBoxOccupation.SelectedItem.Value));
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("Income", Convert.ToDecimal(RadNumericTxtIncome.Text.Trim()));
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("@MarriedStatusID", intMarriedTypeID);
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("SpouseQualification", strSpouseQualification);
                sqlCommandX.Parameters.Add(sqlParam);
                sqlParam = new SqlParameter("SpouseIncome", Convert.ToDecimal(strSpouseIncome));
                sqlCommandX.Parameters.Add(sqlParam);
                //sqlParam = new SqlParameter("DateOfDiagnisis", Convert.ToDateTime(RadDatePickerDateOfDiag.SelectedDate.ToString()).ToString("yyyy-MM-dd"));
                sqlParam = new SqlParameter("DateOfDiagnisis", Convert.ToDateTime(RadMonthYearPickerDateOfDiag.SelectedDate.ToString()).ToString("yyyy"));
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonDiabetesType1.Checked)
                {
                    strDiabetesType = "type1";
                    HiddenFieldRMDiabetesType.Value = "T1";
                }
                if (RadioButtonDiabetesType2.Checked)
                {
                    strDiabetesType = "type2";
                    HiddenFieldRMDiabetesType.Value = "T2";
                }
                if (RadioButtonDiabetesTypeNotSure.Checked)
                {
                    strDiabetesType = "NotSure";
                    HiddenFieldRMDiabetesType.Value = "T2";
                }
                sqlParam = new SqlParameter("DiabetesType", strDiabetesType);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonInsulinYes.Checked)
                {
                    strInsulinUse = "Yes";
                    HiddenFieldRMDiabetesType.Value = "T1";
                }
                if (RadioButtonInsulinNo.Checked)
                    strInsulinUse = "No";
                if (RadioButtonInsulinNotSure.Checked)
                    strInsulinUse = "NotSure";
                sqlParam = new SqlParameter("InsulineUse", strInsulinUse);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonTabletUseYes.Checked)
                    strTabletUse = "Yes";
                if (RadioButtonTabletUseNo.Checked)
                    strTabletUse = "No";
                if (RadioButtonTabletUseNotSure.Checked)
                    strTabletUse = "NotSure";
                sqlParam = new SqlParameter("TabletUse", strTabletUse);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonDVYes1.Checked)
                    strDoctorsVisits = "1";
                if (RadioButtonDVYes2.Checked)
                    strDoctorsVisits = "2";
                if (RadioButtonDVYes3.Checked)
                    strDoctorsVisits = "3";
                if (RadioButtonDVNo.Checked)
                    strDoctorsVisits = "4";
                sqlParam = new SqlParameter("DoctorsVisits", strDoctorsVisits);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonDiabetControlExcellent.Checked)
                    strDiabeticControl = "Excellent";
                if (RadioButtonDiabetControlGood.Checked)
                    strDiabeticControl = "Good";
                if (RadioButtonDiabetControlMod.Checked)
                    strDiabeticControl = "Moderate";
                if (RadioButtonDiabetControlPoor.Checked)
                    strDiabeticControl = "Poor";
                sqlParam = new SqlParameter("DiabeticControl", strDiabeticControl);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonHbA1c3.Checked)
                    strHbA1c = "4";
                if (RadioButtonHbA1c4.Checked)
                    strHbA1c = "0";
                if (RadioButtonHbA1c6.Checked)
                    strHbA1c = "6";
                if (RadioButtonHbA1c7.Checked)
                    strHbA1c = "7";
                if (RadioButtonHbA1c8.Checked)
                    strHbA1c = "8";
                if (RadioButtonHbA1c9.Checked)
                    strHbA1c = "9";
                if (RadioButtonHbA1c10.Checked)
                    strHbA1c = "10";
                if (RadioButtonHbA1c11.Checked)
                    strHbA1c = "11";
                if (RadioButtonHbA1c12.Checked)
                    strHbA1c = "12";
                if (RadioButtonHbA1c15.Checked)
                    strHbA1c = "15";
                if (RadioButtonHbA1cUnknown.Checked)
                    strHbA1c = "0";
                sqlParam = new SqlParameter("HbA1c", strHbA1c);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonExPYes.Checked)
                    strExercisePlan = "Yes";
                if (RadioButtonExPNo.Checked)
                    strExercisePlan = "No";
                sqlParam = new SqlParameter("ExercisePlan", strExercisePlan);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonExFollowedVW.Checked)
                    strExHowWellFollowed = "Very Well";
                if (RadioButtonExFollowedok.Checked)
                    strExHowWellFollowed = "Ok";
                if (RadioButtonExFollowedpoor.Checked)
                    strExHowWellFollowed = "Poor";
                sqlParam = new SqlParameter("ExHowWellFollowed", strExHowWellFollowed);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonEatPYes.Checked)
                    strEatingPlan = "Yes";
                if (RadioButtonEatPNo.Checked)
                    strEatingPlan = "No";
                sqlParam = new SqlParameter("EatingPlan", strEatingPlan);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonEatFollowedVW.Checked)
                    strEatHowWellFollowed = "Very Well";
                if (RadioButtonEatFollowedOk.Checked)
                    strEatHowWellFollowed = "Ok";
                if (RadioButtonEatFollowedPoor.Checked)
                    strEatHowWellFollowed = "Poor";
                sqlParam = new SqlParameter("EatHowWellFollowed", strEatHowWellFollowed);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonHighBPYes.Checked)
                    strHighBP = "Yes";
                if (RadioButtonHighBPNo.Checked)
                    strHighBP = "No";
                if (RadioButtonHighBP.Checked)
                    strHighBP = "Not sure";
                sqlParam = new SqlParameter("HighBP", strHighBP);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonCholesterolYes.Checked)
                    strHighCholesterol = "Yes";
                if (RadioButtonCholesterolNo.Checked)
                    strHighCholesterol = "No";
                if (RadioButtonCholesterolNotSure.Checked)
                    strHighCholesterol = "Not sure";
                sqlParam = new SqlParameter("HighCholesterol", strHighCholesterol);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonMedicalAidNone.Checked)
                    strMedicalAid = "None";
                if (RadioButtonMedicalAidNotSure.Checked)
                    strMedicalAid = "Not sure";
                if (RadioButtonMedicalAidComp.Checked)
                    strMedicalAid = "Comprehensive";
                if (RadioButtonMedicalAidHos.Checked)
                    strMedicalAid = "Hospital plan";
                sqlParam = new SqlParameter("MedicalAid", strMedicalAid);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadNumericTxtHeight.Text != "")
                    sqlParam = new SqlParameter("Height", Convert.ToDecimal(RadNumericTxtHeight.Text));
                else
                    sqlParam = new SqlParameter("Height", Convert.ToDecimal("0"));
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadNumericTxtWeight.Text != "")
                    sqlParam = new SqlParameter("Weight", Convert.ToDecimal(RadNumericTxtWeight.Text));
                else
                    sqlParam = new SqlParameter("Weight", Convert.ToDecimal("0"));
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadNumericTxtPantSize.Text != "")
                    sqlParam = new SqlParameter("PantSize", Convert.ToInt16(RadNumericTxtPantSize.Text));
                else
                    sqlParam = new SqlParameter("PantSize", Convert.ToDecimal("0"));
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadNumericTxtBMI.Text != "")
                    sqlParam = new SqlParameter("BMI", Convert.ToDecimal(RadNumericTxtBMI.Text));
                else
                    sqlParam = new SqlParameter("BMI", Convert.ToDecimal("0"));
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonListAlcohol.SelectedValue == "non-drinker")
                    strAlcohol = "No";
                else
                    strAlcohol = "Yes";

                //if (RadioButtonAlcoholYes.Checked)
                //    strAlcohol = "Yes";
                //if (RadioButtonAlcoholNo.Checked)
                //    strAlcohol = "No";
                sqlParam = new SqlParameter("Alcohol", strAlcohol);
                sqlCommandX.Parameters.Add(sqlParam);
                
                sqlParam = new SqlParameter("AlcoholUnits", RadioButtonListAlcohol.SelectedValue.ToString());
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonListTobacco.SelectedValue == "non-smoker")
                    strTobacco = "No";
                else
                    strTobacco = "Yes";

                //if (RadioButtonTobaccoYes.Checked)
                //    strTobacco = "Yes";
                //if (RadioButtonTobaccoNo.Checked)
                //    strTobacco = "No";
                sqlParam = new SqlParameter("Tobacco", strTobacco);
                sqlCommandX.Parameters.Add(sqlParam);

                sqlParam = new SqlParameter("TobaccoUnits", RadioButtonListTobacco.SelectedValue.ToString());
                sqlCommandX.Parameters.Add(sqlParam);

                sqlParam = new SqlParameter("QualifyLife", LblQualificationMessage.Text);
                sqlCommandX.Parameters.Add(sqlParam);

                sqlParam = new SqlParameter("QualifyDisability", lblDisabilityMessage.Text);
                sqlCommandX.Parameters.Add(sqlParam);

                sqlParam = new SqlParameter("RiskBand", RadTxtRiskBand.Text);
                sqlCommandX.Parameters.Add(sqlParam);

                sqlParam = new SqlParameter("DisabilityType", RadTxtDisabilityType.Text);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonEsc6.Checked)
                    decEscalationLife = 6;
                if (RadioButtonEsc10.Checked)
                    decEscalationLife = 10;

                //if (RadioButtonEscLife6.Checked)
                //    decEscalationLife = 6;
                //if (RadioButtonEscLife10.Checked)
                //    decEscalationLife = 10;

                sqlParam = new SqlParameter("EscalationLife", decEscalationLife);
                sqlCommandX.Parameters.Add(sqlParam);

                //if (RadioButtonEscalationDis6.Checked)
                //    decEscalationDisability = 6;
                //if (RadioButtonEscalationDis10.Checked)
                //    decEscalationDisability = 10;
                decEscalationDisability = 0;

                sqlParam = new SqlParameter("EscalationDisability", decEscalationDisability);
                sqlCommandX.Parameters.Add(sqlParam);

                strLifeBenifit = RadComboBoxTypeBenefitLife.SelectedItem.Text;
                sqlParam = new SqlParameter("LifeBenifit", strLifeBenifit);
                sqlCommandX.Parameters.Add(sqlParam);

                strDisabilityBenifit = RadComboBoxTypeBenefitDisability.SelectedItem.Text;
                sqlParam = new SqlParameter("DisabilityBenifit", strDisabilityBenifit);
                sqlCommandX.Parameters.Add(sqlParam);


                if (RadioButtonQuoteLifeNo.Checked == true)
                    intQuoteLife = 0;
                else
                    intQuoteLife = 1;

                sqlParam = new SqlParameter("QuoteLife", intQuoteLife);
                sqlCommandX.Parameters.Add(sqlParam);

                if (RadioButtonQuoteDisNo.Checked == true)
                    intQuoteDisability = 0;
                else
                    intQuoteDisability = 1;

                sqlParam = new SqlParameter("QuoteDisability", intQuoteDisability);
                sqlCommandX.Parameters.Add(sqlParam);        
        


                sqlDR = sqlCommandX.ExecuteReader();
                while (sqlDR.Read())
                {
                    HiddenFieldQuoteAuditID.Value = sqlDR.GetValue(0).ToString();
                }

                sqlDR.Close();
                sqlCommandX.Cancel();
                sqlCommandX.Dispose();
                #endregion

                #endregion

                //The below was added so that if ADB or ACDB are selected iit does not take the qualification into account
                if (RadComboBoxTypeBenefitLife.SelectedItem.Text != "FDB")
                {
                    strResultLife = "Successful";
                }

                if (RadComboBoxTypeBenefitDisability.SelectedItem.Text != "FDB")
                {
                    strResultLife = "Successful";
                }

                if ((strResultLife == "Successful") || (strResultDisability == "Successful"))
                {
                    LblOffer.Text = "We can offer you:";
                    LblAcceptedQuote.Visible = true;
                    //RadBtnOption1.Visible = true;
                    RadioButtonOption1.Visible = true;
                    //RadBtnOption2.Visible = true;
                    RadioButtonOption2.Visible = true;
                    //RadBtnOption3.Visible = true;
                    RadioButtonOption3.Visible = true;
                    RadBtnOption4.Visible = true;
                    RadioButtonOption4.Visible = true;
                    RadBtnOption5.Visible = true;
                    RadioButtonOption5.Visible = true;

                    RadBtnOption1_Click(sender, e);
                    RadBtnOption2_Click(sender, e);
                    RadBtnOption3_Click(sender, e);
                }
                else
                {
                    LblOffer.Text = "Unfortnatley we are unable to offer you cover at this time";
                    LblAcceptedQuote.Visible = false;
                    lblOr.Visible = false;
                    RadBtnOption1.Visible = false;
                    RadioButtonOption1.Visible = false;
                    RadBtnOption2.Visible = false;
                    RadioButtonOption2.Visible = false;
                    RadBtnOption3.Visible = false;
                    RadioButtonOption3.Visible = false;
                    RadBtnOption4.Visible = false;
                    RadioButtonOption4.Visible = false;
                    RadBtnOption5.Visible = false;
                    RadioButtonOption5.Visible = false;
                    lblSuitable0.Visible = false;
                    lblAlso.Visible = false;
                    lblSuitable.Visible = false;
                    lblSpecificCover.Visible = false;
                    lblSpecificPremium.Visible = false;

                }

                PanelQuotePresentation.Visible = true;
                RadBtnQualifyClient.Enabled = true;

                sqlConnectionX.Close();

            }
            catch (Exception ex)
            {
                lblInfo.Text = ex.Message;
                lblInfo2.Text = ex.Message;   
                //throw;
            }
        }
コード例 #6
0
        protected void RadGridCurrentLoad_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            WS.AllLifePrincingClient WS = new WS.AllLifePrincingClient();
            DataTable ReturnDT;

            string strSettingValue = string.Empty;

            SqlConnection sqlConnectionX;
            SqlCommand sqlCommandX;
            SqlParameter sqlParam;
            SqlDataReader sqlDR;

            try
            {
                sqlConnectionX = new SqlConnection(ConfigurationManager.AppSettings["SQLConnection"]);
                sqlConnectionX.Open();

                sqlCommandX = new SqlCommand();
                sqlCommandX.Connection = sqlConnectionX;
                sqlCommandX.CommandType = CommandType.StoredProcedure;
                sqlCommandX.CommandText = "spx_SELECT_QuoteAuditTrailByMagnumID";

                sqlParam = new SqlParameter("MagnumID", strMagnumID);
                sqlCommandX.Parameters.Add(sqlParam);

                //sqlDR = sqlCommandX.ExecuteReader();
                //while (sqlDR.Read())
                //{
                //    strSettingValue = sqlDR.GetValue(0).ToString();
                //}
                sqlDR = sqlCommandX.ExecuteReader();
                DataTable dt = new DataTable("AuditTrail");
                dt.Load(sqlDR);

                sqlDR.Close();
                sqlCommandX.Cancel();
                sqlCommandX.Dispose();
                sqlConnectionX.Close();

                //RadGridCurrentLoad.DataSource = dt;
            }
            catch (Exception ex)
            {
                lblInfo.Text = ex.Message;
            }
        }
コード例 #7
0
        protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
            if (parentItem.Edit)
            {
                return;
            }

            //if (e.DetailTableView.DataMember == "OrderDetails")
            //{
                //DataSet ds = (DataSet)e.DetailTableView.DataSource;
                //DataView dv = ds.Tables["OrderDetails"].DefaultView;
                //dv.RowFilter = "CustomerID = '" + parentItem["CustomerID"].Text + "'";
                //e.DetailTableView.DataSource = dv;

                GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
                string strAuditTrailID = dataItem.GetDataKeyValue("AuditID").ToString();

                WS.AllLifePrincingClient WS = new WS.AllLifePrincingClient();

                string strSettingValue = string.Empty;

                SqlConnection sqlConnectionX;
                SqlCommand sqlCommandX;
                SqlParameter sqlParam;
                SqlDataReader sqlDR;

                try
                {
                    sqlConnectionX = new SqlConnection(ConfigurationManager.AppSettings["SQLConnection"]);
                    sqlConnectionX.Open();

                    sqlCommandX = new SqlCommand();
                    sqlCommandX.Connection = sqlConnectionX;
                    sqlCommandX.CommandType = CommandType.StoredProcedure;
                    sqlCommandX.CommandText = "spx_SELECT_QuoteOptionAuditTrailByAuditTrailID";

                    sqlParam = new SqlParameter("QuoteAuditTrailID", strAuditTrailID);
                    sqlCommandX.Parameters.Add(sqlParam);

                    sqlDR = sqlCommandX.ExecuteReader();
                    DataTable dt = new DataTable("AuditTrail");
                    dt.Load(sqlDR);

                    sqlDR.Close();
                    sqlCommandX.Cancel();
                    sqlCommandX.Dispose();
                    sqlConnectionX.Close();

                    e.DetailTableView.DataSource = dt;
                }
                catch (Exception ex)
                {
                    lblInfo.Text = ex.Message;
                }
            //}
        }