Beispiel #1
0
    protected void btnCreateClick(object sender, EventArgs e)
    {
        lblFeedBack.Visible = false;
        DateTime          fromDate  = DateTime.Parse(tbStartDate.Text);
        DateTime          toDate    = DateTime.Parse(tbEndDate.Text);
        int               branchID  = this.PageUser.BranchID;
        List <PolicyItem> oldPiList = PolicyItem.GetForRollBackFromPreviousMonths(fromDate, int.Parse(ddlInsuranceCompany.SelectedValue), branchID);
        List <RollBackDistributionInfo> oldPolicyInfos = new List <RollBackDistributionInfo>();
        List <InsuranceSubType>         oldSubTypes    = new List <InsuranceSubType>();
        InsuranceSubType dummy = new InsuranceSubType();

        dummy.Description = string.Empty;
        dummy.ID          = 0;
        oldSubTypes.Add(dummy);
        foreach (PolicyItem pi in oldPiList)
        {
            RollBackDistributionInfo rdbi = new RollBackDistributionInfo();
            rdbi.ID                 = pi.ID;
            rdbi.IsForRollBack      = true;
            rdbi.PolicyNumber       = pi.PolicyNumber;
            rdbi.InsuranceSubTypeID = pi.InsuranceSubTypeID;
            rdbi.BrokerageValue     = pi.BrokerageValue;
            rdbi.PremiumValue       = pi.PremiumValue;
            oldPolicyInfos.Add(rdbi);
            if (!oldSubTypes.Contains(pi.InsuranceSubType))
            {
                oldSubTypes.Add(pi.InsuranceSubType);
            }
        }
        listOldRollBackInfos     = oldPolicyInfos;
        selectedOldRollBackInfos = oldPolicyInfos;

        gvOldPolicies.DataSource = oldPolicyInfos;
        gvOldPolicies.DataBind();
        if (oldSubTypes.Count > 1)
        {
            ddlPreviosSubTypes.Visible    = true;
            lblPreviosSubTypes.Visible    = true;
            ddlPreviosSubTypes.DataSource = oldSubTypes.OrderBy(c => c.ID);
            ddlPreviosSubTypes.DataBind();
        }

        List <PolicyItem> newPiList = PolicyItem.GetForRollBackFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompany.SelectedValue), branchID);
        List <RollBackDistributionInfo> newRollBackInfos = new List <RollBackDistributionInfo>();
        List <InsuranceSubType>         newSubTypes      = new List <InsuranceSubType>();

        newSubTypes.Add(dummy);
        foreach (PolicyItem pi in newPiList)
        {
            RollBackDistributionInfo rbdi = new RollBackDistributionInfo();
            rbdi.ID                 = pi.ID;
            rbdi.IsForRollBack      = true;
            rbdi.PolicyNumber       = pi.PolicyNumber;
            rbdi.BrokerageValue     = pi.BrokerageValue;
            rbdi.InsuranceSubTypeID = pi.InsuranceSubTypeID;
            rbdi.PremiumValue       = pi.PremiumValue;
            newRollBackInfos.Add(rbdi);
            if (!newSubTypes.Contains(pi.InsuranceSubType))
            {
                newSubTypes.Add(pi.InsuranceSubType);
            }
        }
        if (newSubTypes.Count > 1)
        {
            ddlCurrentSubTypes.Visible    = true;
            lblCurentSubTypes.Visible     = true;
            ddlCurrentSubTypes.DataSource = newSubTypes.OrderBy(c => c.ID);
            ddlCurrentSubTypes.DataBind();
        }
        listNewRollBackInfos     = newRollBackInfos;
        selectedNewRollBackInfos = newRollBackInfos;
        gvNewPolicies.DataSource = newRollBackInfos;
        gvNewPolicies.DataBind();
        btnCreate.Visible        = false;
        btnPrintPolicies.Visible = true;
        btnInsert.Visible        = true;
    }