Ejemplo n.º 1
0
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        DateTime fromDate = DateTime.Parse(tbStartDate.Text);
        DateTime toDate   = DateTime.Parse(tbEndDate.Text);

        if (rblInsuranceLifeType.SelectedValue == "NoLife")
        {
            List <PolicyItem>  oldPiList       = PolicyItem.GetFromPreivousMonths(fromDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
            List <FactureInfo> oldFactureInfos = new List <FactureInfo>();
            foreach (PolicyItem pi in oldPiList)
            {
                FactureInfo fi = new FactureInfo();
                fi.ID             = pi.ID;
                fi.IsForFacturing = true;
                fi.PolicyNumber   = pi.PolicyNumber;
                //fi.PremiumValue = pi.PremiumValue;
                fi.PremiumValue = pi.RealPremiumValue;
                //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID);
                oldFactureInfos.Add(fi);
            }
            listFactureInfos         = oldFactureInfos;
            gvOldPolicies.DataSource = oldFactureInfos;
            gvOldPolicies.Caption    = "Полиси од претходни месеци (" + oldFactureInfos.Count.ToString() + ")";
            gvOldPolicies.DataBind();

            List <PolicyItem>  newPiList       = PolicyItem.GetForFacturingFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
            List <FactureInfo> newFactureInfos = new List <FactureInfo>();
            foreach (PolicyItem pi in newPiList)
            {
                FactureInfo fi = new FactureInfo();
                fi.ID             = pi.ID;
                fi.IsForFacturing = true;
                fi.PolicyNumber   = pi.PolicyNumber;
                //fi.PremiumValue = pi.PremiumValue;
                fi.PremiumValue = pi.RealPremiumValue;
                //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID);
                newFactureInfos.Add(fi);
            }
            listNewFactureInfos      = newFactureInfos;
            gvNewPolicies.DataSource = newFactureInfos;
            gvNewPolicies.Caption    = "Полиси од селектираниот период (" + newFactureInfos.Count.ToString() + ")";
            gvNewPolicies.DataBind();
        }
        else if (rblInsuranceLifeType.SelectedValue == "Life")
        {
            List <LifePolicy>  oldPiList       = LifePolicy.GetFromPreviousMonths(fromDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
            List <FactureInfo> oldFactureInfos = new List <FactureInfo>();
            foreach (LifePolicy pi in oldPiList)
            {
                FactureInfo fi = new FactureInfo();
                fi.ID             = pi.ID;
                fi.IsForFacturing = true;
                fi.PolicyNumber   = pi.PolicyNumber;
                //fi.PremiumValue = pi.PremiumValue;
                fi.PremiumValue = pi.TotalPremumValue;
                //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID);
                oldFactureInfos.Add(fi);
            }
            listFactureInfos         = oldFactureInfos;
            gvOldPolicies.DataSource = oldFactureInfos;
            gvOldPolicies.Caption    = "Полиси од претходни месеци (" + oldFactureInfos.Count.ToString() + ")";
            gvOldPolicies.DataBind();

            List <LifePolicy>  newPiList       = LifePolicy.GetForFacturingFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
            List <FactureInfo> newFactureInfos = new List <FactureInfo>();
            foreach (LifePolicy pi in newPiList)
            {
                FactureInfo fi = new FactureInfo();
                fi.ID             = pi.ID;
                fi.IsForFacturing = true;
                fi.PolicyNumber   = pi.PolicyNumber;
                //fi.PremiumValue = pi.PremiumValue;
                fi.PremiumValue = pi.TotalPremumValue;
                //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID);
                newFactureInfos.Add(fi);
            }
            listNewFactureInfos      = newFactureInfos;
            gvNewPolicies.DataSource = newFactureInfos;
            gvNewPolicies.Caption    = "Полиси од селектираниот период (" + newFactureInfos.Count.ToString() + ")";
            gvNewPolicies.DataBind();
        }
    }