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;
            }
        }
Exemplo n.º 2
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;
            }
        }