public int CreateInsuranceAccount(InsuranceVo insuranceVo, int userId)
        {
            InsuranceDao insuranceDao = new InsuranceDao();
            int          id           = 0;

            try
            {
                id = insuranceDao.CreateInsuranceAccount(insuranceVo, userId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "InsuranceBo.cs:CreateInsuranceAccount()");


                object[] objects = new object[2];
                objects[0] = insuranceVo;
                objects[1] = userId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(id);
        }
        public bool UpdateInsurancePortfolio(InsuranceVo insuranceVo, int userId)
        {
            bool         bResult      = false;
            InsuranceDao insuranceDao = new InsuranceDao();

            try
            {
                bResult = insuranceDao.UpdateInsurancePortfolio(insuranceVo, userId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "InsuranceBo.cs:UpdateInsurancePortfolio()");
                object[] objects = new object[2];
                objects[0] = insuranceVo;
                objects[1] = userId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(bResult);
        }
        public InsuranceVo GetInsuranceAsset(int insurancePortfolioId)
        {
            InsuranceDao insuranceDao = new InsuranceDao();
            InsuranceVo  insuranceVo  = new InsuranceVo();

            try
            {
                insuranceVo = insuranceDao.GetInsuranceAsset(insurancePortfolioId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "InsuranceBo.cs:GetInsuranceAsset()");


                object[] objects = new object[1];
                objects[0] = insurancePortfolioId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(insuranceVo);
        }
        protected void hiddenassociation_Click(object sender, EventArgs e)
        {
            string val = Convert.ToString(hdnMsgValue.Value);

            if (val == "1")
            {
                bool        DeleteAccount;
                CustomerVo  customervo  = (CustomerVo)Session["customerVo"];
                int         Account     = customervo.CustomerId;
                InsuranceVo insuranceVo = (InsuranceVo)Session["insuranceId"];
                int         InsuranceNo = insuranceVo.AccountId;



                //int Insurance = Session ;
                CustomerPortfolioBo BoCustomerPortfolio = new CustomerPortfolioBo();
                DeleteAccount = BoCustomerPortfolio.DeleteGIAccount(Account, InsuranceNo);


                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('ViewGeneralInsuranceDetails','none');", true);
            }
            if (val == "0")
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('ViewGeneralInsuranceDetails','none');", true);
            }
        }
        //protected void ddlPortfolio_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    portfolioId = int.Parse(ddlPortfolio.SelectedValue.ToString());
        //    Session[SessionContents.PortfolioId] = portfolioId;
        //    BindGeneralInsuranceGridview(portfolioId);
        //}

        protected void ddlMenu_SelectedIndexChanged(object sender, EventArgs e)
        {
            int    insuranceId;
            string qryString = null;

            try
            {
                DropDownList ddlAction   = (DropDownList)sender;
                GridViewRow  gvr         = (GridViewRow)ddlAction.NamingContainer;
                int          selectedRow = gvr.RowIndex;
                int.TryParse(gvGeneralInsurance.DataKeys[selectedRow].Value.ToString(), out insuranceId);
                int Insurance = insuranceId;
                // insuranceId;


                //// Set the VO into the Session
                //insuranceVo = insuranceBo.GetInsuranceAsset(insuranceId);
                InsuranceVo insuranceVo = new InsuranceVo();

                insuranceVo.AccountId  = insuranceId;
                Session["insuranceId"] = insuranceVo;


                //Session["customerAccountVo"] = customerAccountsBo.GetCustomerInsuranceAccount(insuranceVo.AccountId);

                if (ddlAction.SelectedItem.Value.ToString() == "Edit")
                {
                    qryString = "FromPage=ViewGeneralInsuranceDetails&InsuranceId=" + insuranceId + "&action=Edit";
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('PortfolioGeneralInsuranceEntry','" + qryString + "');", true);
                }
                else if (ddlAction.SelectedItem.Value.ToString() == "View")
                {
                    qryString = "FromPage=ViewGeneralInsuranceDetails&InsuranceId=" + insuranceId + "&action=View";
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('PortfolioGeneralInsuranceEntry','" + qryString + "');", true);
                }
                if (ddlAction.SelectedItem.Value.ToString() == "Delete")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Message", "showmessage();", true);
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "ViewGeneralInsuranceDetails.ascx:ddlMenu_SelectedIndexChanged()");
                object[] objects = new object[0];
                FunctionInfo = exBase.AddObject(FunctionInfo, null);/*, objects*/
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        protected void ddlMenu_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //DropDownList ddlAction = (DropDownList)sender;
                RadComboBox  ddlAction = (RadComboBox)sender;
                GridDataItem gvr       = (GridDataItem)ddlAction.NamingContainer;
                //GridViewRow gvr = (GridViewRow)ddlAction.NamingContainer;
                int       selectedRow     = gvr.ItemIndex + 1;
                int       insuranceId     = int.Parse(gvrLifeInsurance.MasterTableView.DataKeyValues[selectedRow - 1]["InsuranceId"].ToString());
                DataTable dtAssociationId = new DataTable();

                // Set the VO into the Session
                insuranceVo = insuranceBo.GetInsuranceAssetLI(insuranceId, out dtAssociationId);
                Session["dtAssociationId"]   = dtAssociationId;
                Session["insuranceVo"]       = insuranceVo;
                Session["customerAccountVo"] = customerAccountsBo.GetCustomerInsuranceAccount(insuranceVo.AccountId);

                if (ddlAction.SelectedItem.Value.ToString() == "Edit")
                {
                    Session.Remove("table");
                    Session.Remove("moneyBackEpisodeList");
                    Session.Remove("insuranceULIPList");
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('PortfolioInsuranceEntry','action=edit');", true);
                }
                if (ddlAction.SelectedItem.Value.ToString() == "View")
                {
                    Session.Remove("table");
                    Session.Remove("moneyBackEpisodeList");
                    Session.Remove("insuranceULIPList");
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('PortfolioInsuranceEntry','action=view');", true);
                }
                if (ddlAction.SelectedItem.Value.ToString() == "Delete")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Message", "showmessage();", true);
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "ViewInsuranceDetails.ascx:ddlMenu_SelectedIndexChanged()");
                object[] objects = new object[1];
                objects[0]   = insuranceVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, null);/*, objects*/
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Ejemplo n.º 7
0
        protected void lnkLifeInsurancePolicy_Click(object sender, EventArgs e)
        {
            GridViewRow gvRow           = ((GridViewRow)(((LinkButton)sender).Parent.Parent));
            int         rowIndex        = gvRow.RowIndex;
            DataKey     dk              = gvLifeInsurance.DataKeys[rowIndex];
            int         insuranceId     = Convert.ToInt32(dk.Value);
            DataTable   dtAssociationId = new DataTable();

            //insuranceVo = insuranceBo.GetInsuranceAsset(insuranceId);
            insuranceVo = insuranceBo.GetInsuranceAssetLI(insuranceId, out dtAssociationId);
            Session["dtAssociationId"]   = dtAssociationId;
            Session["insuranceVo"]       = insuranceVo;
            Session["customerAccountVo"] = customerAccountsBo.GetCustomerInsuranceAccount(insuranceVo.AccountId);

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('PortfolioInsuranceEntry','action=view');", true);
        }
        private void SortGridVIew(string sortExpression, string direction)
        {
            List <InsuranceVo> insuranceList = new List <InsuranceVo>();

            try
            {
                // int count;

                insuranceList = insuranceBo.GetInsurancePortfolio(portfolioId, hdnSort.Value.Trim());

                //if (count > 0)
                //{
                //    //lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                //    //tblPager.Visible = true;
                //}

                InsuranceVo insuranceVo;
                DataTable   dtInsurance = new DataTable();
                dtInsurance.Columns.Add("SI.No");
                dtInsurance.Columns.Add("InsuranceId");
                dtInsurance.Columns.Add("Category");
                dtInsurance.Columns.Add("Particulars");
                dtInsurance.Columns.Add("Premium Amount");
                dtInsurance.Columns.Add("Sum Assured");
                dtInsurance.Columns.Add("Maturity Value");
                DataRow drInsurance;
                for (int i = 0; i < insuranceList.Count; i++)
                {
                    drInsurance    = dtInsurance.NewRow();
                    insuranceVo    = new InsuranceVo();
                    insuranceVo    = insuranceList[i];
                    drInsurance[0] = insuranceVo.CustInsInvId.ToString();
                    drInsurance[1] = insuranceVo.AssetInstrumentCategoryCode.ToString();
                    drInsurance[2] = insuranceVo.Name.ToString();
                    drInsurance[3] = String.Format("{0:n2}", decimal.Parse(insuranceVo.PremiumAmount.ToString("N0")));
                    drInsurance[4] = String.Format("{0:n0}", decimal.Parse(insuranceVo.SumAssured.ToString("N0")));
                    drInsurance[5] = String.Format("{0:n2}", decimal.Parse(insuranceVo.MaturityValue.ToString("N0")));

                    dtInsurance.Rows.Add(drInsurance);
                }

                DataView dv = new DataView(dtInsurance);
                dv.Sort = sortExpression + direction;
                gvrLifeInsurance.DataSource = dv;
                gvrLifeInsurance.DataBind();

                if (Cache["LIList" + customerVo.CustomerId.ToString()] == null)
                {
                    Cache.Insert("LIList" + customerVo.CustomerId.ToString(), dtInsurance);
                }
                else
                {
                    Cache.Remove("LIList" + customerVo.CustomerId.ToString());
                    Cache.Insert("LIList" + customerVo.CustomerId.ToString(), dtInsurance);
                }



                gvrLifeInsurance.Visible = true;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "ViewInsuranceDetails.ascx:SortGridVIew()");
                object[] objects = new object[2];
                objects[0]   = insuranceVo;
                objects[1]   = insuranceList;
                FunctionInfo = exBase.AddObject(FunctionInfo, null);/*, objects*/
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        private void LoadGridview(int portfolioId)
        {
            List <InsuranceVo> insuranceList = new List <InsuranceVo>();

            try
            {
                //int count;
                insuranceList = insuranceBo.GetInsurancePortfolio(portfolioId, hdnSort.Value);

                #region unused
                //if (count > 0)
                //{
                //    //lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                //    //tblPager.Visible = true;
                //    //trPager.Visible = true;
                //}
                //else
                //{
                //    ErrorMessage.Visible = true;
                //    //tblPager.Visible = false;
                //    //trPager.Visible = false;
                //}
                #endregion

                int RecordsCount = 0;
                if (insuranceList != null)
                {
                    RecordsCount = insuranceList.Count;
                }

                if (RecordsCount > 0)
                {
                    btnExportFilteredData.Visible = true;
                    ErrorMessage.Visible          = false;
                    //trPager.Visible = true;
                    InsuranceVo insuranceVo;
                    DataTable   dtInsurance = new DataTable();
                    //dtInsurance.Columns.Add("SI.No");
                    dtInsurance.Columns.Add("InsuranceId");
                    dtInsurance.Columns.Add("Category");
                    dtInsurance.Columns.Add("Particulars");
                    dtInsurance.Columns.Add("CINP_SumAssured", typeof(double));
                    dtInsurance.Columns.Add("Premium Amount", typeof(double));
                    dtInsurance.Columns.Add("Commencement Date", typeof(DateTime));
                    dtInsurance.Columns.Add("Maturity Value", typeof(double));
                    dtInsurance.Columns.Add("Maturity Date", typeof(DateTime));
                    dtInsurance.Columns.Add("Insurance Company");
                    dtInsurance.Columns.Add("XII_InsuranceIssuerName");
                    //dtInsurance.Columns.Add("CINP_FirstPremiumDate");
                    dtInsurance.Columns.Add("Next Due Date", typeof(DateTime));
                    dtInsurance.Columns.Add("XF_Frequency");
                    dtInsurance.Columns.Add("PolicyNo");
                    dtInsurance.Columns.Add("Amount", typeof(double));
                    dtInsurance.Columns.Add("ModeOfPayment");
                    dtInsurance.Columns.Add("PaymentInstrumentNumber");
                    dtInsurance.Columns.Add("PaymentInstrumentDate", typeof(DateTime));
                    dtInsurance.Columns.Add("BankName");
                    dtInsurance.Columns.Add("BankBranch");

                    DataRow drInsurance;

                    for (int i = 0; i < insuranceList.Count; i++)
                    {
                        drInsurance = dtInsurance.NewRow();
                        insuranceVo = new InsuranceVo();
                        insuranceVo = insuranceList[i];
                        //drInsurance[0] = (i + 1).ToString();
                        drInsurance["InsuranceId"] = insuranceVo.CustInsInvId.ToString();
                        drInsurance["Category"]    = insuranceVo.AssetInstrumentCategoryName.ToString();
                        drInsurance["Particulars"] = insuranceVo.Name.ToString();

                        if (insuranceVo.SumAssured.ToString() != "")
                        {
                            drInsurance["CINP_SumAssured"] = insuranceVo.SumAssured;
                        }
                        if (insuranceVo.PremiumAmount.ToString() != "")
                        {
                            drInsurance["Premium Amount"] = insuranceVo.PremiumAmount;
                        }


                        DateTime dtNow = DateTime.Now;

                        #region unused


                        //DateTime dtPremiumPayDate;

                        //********************************************************************************************************************
                        //Code Commented as the premium date is not displayed properly in the grid. Instead adding Commencement date as of now
                        //********************************************************************************************************************

                        //int premiumPayDate = insuranceVo.PremiumPaymentDate;

                        //if (premiumPayDate != 0)
                        //{
                        //    dtPremiumPayDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
                        //    DateTime premiumPayDate1 = dtPremiumPayDate.AddDays(premiumPayDate - 1);

                        //    // Compare the two date time values
                        //    // Less than 0 -- dtNow is earlier than dtPremiumPayDate
                        //    // Greater than 0 -- dtNow is later than dtPremiumPayDate
                        //    // Equal to 0 -- dtNow is equal to dtPremiumPayDate
                        //    int compare = DateTime.Compare(dtNow, dtPremiumPayDate);

                        //    switch (insuranceVo.PremiumFrequencyCode.ToString())
                        //    {
                        //        case "AM":
                        //            drInsurance[5] = "N/A";
                        //            break;
                        //        case "DA":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddDays(1);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "FN":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddDays(15);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "HY":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddMonths(6);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "MN":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddMonths(1);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "NA":
                        //            drInsurance[5] = "N/A";
                        //            break;
                        //        case "QT":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddMonths(3);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "WK":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddDays(7);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "YR":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddYears(1);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //    }
                        //}
                        //else
                        //{
                        //    drInsurance[5] = "";
                        //}
                        #endregion
                        drInsurance["Commencement Date"] = insuranceVo.StartDate.ToShortDateString();
                        if (insuranceVo.MaturityValue.ToString() != "")
                        {
                            drInsurance["Maturity Value"] = insuranceVo.MaturityValue;
                        }


                        drInsurance["Maturity Date"]           = insuranceVo.EndDate.ToShortDateString();
                        drInsurance["Insurance Company"]       = insuranceVo.AssetInstrumentCategoryName;
                        drInsurance["XII_InsuranceIssuerName"] = insuranceVo.InsuranceIssuerName;
                        drInsurance["XF_Frequency"]            = insuranceVo.Frequency;
                        drInsurance["PolicyNo"] = insuranceVo.PolicyNumber;
                        if (insuranceVo.Amount.ToString() != "")
                        {
                            drInsurance["Amount"] = insuranceVo.Amount;
                        }
                        if (insuranceVo.PaymentInstrumentDate != DateTime.MinValue)
                        {
                            drInsurance["PaymentInstrumentDate"] = insuranceVo.PaymentInstrumentDate;
                        }
                        drInsurance["ModeOfPayment"]           = insuranceVo.ModeOfPayment.ToString();
                        drInsurance["PaymentInstrumentNumber"] = insuranceVo.PaymentInstrumentNumber;
                        drInsurance["BankName"]   = insuranceVo.BankName;
                        drInsurance["BankBranch"] = insuranceVo.BankBranch;

                        string   frequency = "";
                        DateTime startDate = insuranceVo.FirstPremiumDate;
                        DateTime endDate   = DateTime.Parse(drInsurance["Maturity Date"].ToString());
                        frequency = insuranceVo.PremiumFrequencyCode;
                        DateTime nextPremiumDate = GetNextPremiumDate(frequency, startDate, endDate);



                        if (nextPremiumDate != DateTime.MinValue)
                        {
                            drInsurance["Next Due Date"] = nextPremiumDate.ToShortDateString();
                        }
                        else
                        {
                            //drLifeInsurance["NextPremiumDate"] = "---";
                        }


                        dtInsurance.Rows.Add(drInsurance);
                    }

                    gvrLifeInsurance.DataSource = dtInsurance;
                    gvrLifeInsurance.DataBind();
                    gvrLifeInsurance.Visible = true;


                    if (Cache["LIList" + customerVo.CustomerId.ToString()] == null)
                    {
                        Cache.Insert("LIList" + customerVo.CustomerId.ToString(), dtInsurance);
                    }
                    else
                    {
                        Cache.Remove("LIList" + customerVo.CustomerId.ToString());
                        Cache.Insert("LIList" + customerVo.CustomerId.ToString(), dtInsurance);
                    }


                    //this.GetPageCount();
                }
                else
                {
                    gvrLifeInsurance.DataSource = null;
                    gvrLifeInsurance.DataBind();
                    ErrorMessage.Visible     = true;
                    gvrLifeInsurance.Visible = false;
                    //trPager.Visible = false;
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "ViewInsuranceDetails.ascx:LoadGridview()");
                object[] objects = new object[3];
                objects[0]   = insuranceList;
                objects[1]   = portfolioId;
                objects[2]   = insuranceVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Ejemplo n.º 10
0
        private void LoadGridview(int portfolioId)
        {
            List <InsuranceVo> insuranceList = new List <InsuranceVo>();

            try
            {
                int count;
                insuranceList = insuranceBo.GetInsurancePortfolio(portfolioId, mypager.CurrentPage, hdnSort.Value, out count);

                if (count > 0)
                {
                    lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                    tblPager.Visible  = true;
                    trPager.Visible   = true;
                }
                else
                {
                    ErrorMessage.Visible = true;
                    tblPager.Visible     = false;
                    trPager.Visible      = false;
                }

                int RecordsCount = 0;
                if (insuranceList != null)
                {
                    RecordsCount = insuranceList.Count;
                }

                if (RecordsCount > 0)
                {
                    ErrorMessage.Visible = false;
                    trPager.Visible      = true;
                    InsuranceVo insuranceVo;
                    DataTable   dtInsurance = new DataTable();
                    //dtInsurance.Columns.Add("SI.No");
                    dtInsurance.Columns.Add("InsuranceId");
                    dtInsurance.Columns.Add("Category");
                    dtInsurance.Columns.Add("Particulars");
                    dtInsurance.Columns.Add("Sum Assured");
                    dtInsurance.Columns.Add("Premium Amount");
                    dtInsurance.Columns.Add("Commencement Date");
                    dtInsurance.Columns.Add("Maturity Value");
                    dtInsurance.Columns.Add("Maturity Date");
                    DataRow drInsurance;

                    for (int i = 0; i < insuranceList.Count; i++)
                    {
                        drInsurance = dtInsurance.NewRow();
                        insuranceVo = new InsuranceVo();
                        insuranceVo = insuranceList[i];
                        //drInsurance[0] = (i + 1).ToString();
                        drInsurance[0] = insuranceVo.CustInsInvId.ToString();
                        drInsurance[1] = insuranceVo.AssetInstrumentCategoryName.ToString();
                        drInsurance[2] = insuranceVo.Name.ToString();
                        drInsurance[3] = String.Format("{0:n0}", decimal.Parse(insuranceVo.SumAssured.ToString("f0")));
                        drInsurance[4] = String.Format("{0:n2}", decimal.Parse(insuranceVo.PremiumAmount.ToString("f2")));

                        DateTime dtNow = DateTime.Now;
                        //DateTime dtPremiumPayDate;

                        //********************************************************************************************************************
                        //Code Commented as the premium date is not displayed properly in the grid. Instead adding Commencement date as of now
                        //********************************************************************************************************************

                        //int premiumPayDate = insuranceVo.PremiumPaymentDate;

                        //if (premiumPayDate != 0)
                        //{
                        //    dtPremiumPayDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
                        //    DateTime premiumPayDate1 = dtPremiumPayDate.AddDays(premiumPayDate - 1);

                        //    // Compare the two date time values
                        //    // Less than 0 -- dtNow is earlier than dtPremiumPayDate
                        //    // Greater than 0 -- dtNow is later than dtPremiumPayDate
                        //    // Equal to 0 -- dtNow is equal to dtPremiumPayDate
                        //    int compare = DateTime.Compare(dtNow, dtPremiumPayDate);

                        //    switch (insuranceVo.PremiumFrequencyCode.ToString())
                        //    {
                        //        case "AM":
                        //            drInsurance[5] = "N/A";
                        //            break;
                        //        case "DA":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddDays(1);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "FN":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddDays(15);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "HY":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddMonths(6);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "MN":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddMonths(1);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "NA":
                        //            drInsurance[5] = "N/A";
                        //            break;
                        //        case "QT":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddMonths(3);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "WK":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddDays(7);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //        case "YR":
                        //            if (compare < 0)
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else if (compare > 0)
                        //            { // Calculate the Next Payment Date and display it
                        //                dtPremiumPayDate.AddYears(1);
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            else
                        //            { // Display the Premium Payment Date
                        //                drInsurance[5] = dtPremiumPayDate.ToShortDateString();
                        //            }
                        //            break;
                        //    }
                        //}
                        //else
                        //{
                        //    drInsurance[5] = "";
                        //}

                        drInsurance[5] = insuranceVo.StartDate.ToShortDateString();
                        drInsurance[6] = String.Format("{0:n2}", decimal.Parse(insuranceVo.MaturityValue.ToString("f2")));
                        drInsurance[7] = insuranceVo.EndDate.ToShortDateString();

                        dtInsurance.Rows.Add(drInsurance);
                    }

                    gvrLifeInsurance.DataSource = dtInsurance;
                    gvrLifeInsurance.DataBind();
                    gvrLifeInsurance.Visible = true;
                    this.GetPageCount();
                }
                else
                {
                    gvrLifeInsurance.DataSource = null;
                    gvrLifeInsurance.DataBind();
                    ErrorMessage.Visible = true;
                    trPager.Visible      = false;
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "ViewInsuranceDetails.ascx:LoadGridview()");
                object[] objects = new object[3];
                objects[0]   = insuranceList;
                objects[1]   = portfolioId;
                objects[2]   = insuranceVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }