protected void btnCreate_Click(object sender, EventArgs e)
    {
        List <RightRestrictionDistribution> addedDistributions = new List <RightRestrictionDistribution>();
        int    docTypeID   = int.Parse(ddlDocumentType.SelectedValue);
        string endNumber   = tbEndNumber.Text;
        string startNumber = tbStartNumber.Text;
        int    count       = int.Parse(endNumber) - int.Parse(startNumber);

        for (int i = 0; i <= count; i++)
        {
            RightRestrictionDistribution d = new RightRestrictionDistribution();
            d.Date = DateTime.Today;
            d.InsuranceCompanyID = int.Parse(ddlInsuranceCompany.SelectedValue);
            d.UserID             = int.Parse(ddlUsers.SelectedValue);
            string zeros = string.Empty;

            string number = (int.Parse(tbStartNumber.Text) + i).ToString();
            for (int j = 0; j < (endNumber.Length - int.Parse(number).ToString().Length); j++)
            {
                number = "0" + number;
            }
            d.Number = number;

            d.IsUsed         = false;
            d.DocumentTypeID = docTypeID;


            d.ValidateNumber();
            if (d.ValidationErrors.Count > 0)
            {
                lblError.Visible = true;
                lblError.Text    = "Бројот " + d.Number + " е веќе задолжен";
                gvNewDistrirutions.DataSource = addedDistributions;
                gvNewDistrirutions.DataBind();
                gvDistributions.DataBind();
                return;
            }
            else
            {
                lblError.Visible = false;
                d.Insert();
                addedDistributions.Add(d);
                //distributions.Add(d);
            }

            //ViewState["NewDistributions"] = addedDistributions;
            gvNewDistrirutions.DataSource = addedDistributions;
            gvNewDistrirutions.DataBind();


            gvDistributions.TotalRecords = ViewRightRestrictionDistribution.SelectCountCached();
            gvDistributions.DataBind();
        }
        //   mvMain.SetActiveView(viewGrid);
    }
Esempio n. 2
0
    protected void dvDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
    {
        LifePolicy p = (LifePolicy)e.ReturnValue;

        if (p != null)
        {
            LifeDeal lifeDeal                       = LifeDeal.Get(DealID);
            decimal  totalBrokerageValue            = (p.InsuranceCoverageOne * (lifeDeal.PercentageFromSumForRestLiving / 100)) + (p.YearlyPremiumValueForAccident * (lifeDeal.PercentageFromPremiumForAccident / 100));
            List <LifeDealBrokerage> lstLPBrokerage = LifeDealBrokerage.GetByLifeDeal(lifeDeal.ID);
            int counter = 1;
            foreach (LifeDealBrokerage ldb in lstLPBrokerage)
            {
                LifePolicyBrokerage lpb = new LifePolicyBrokerage();
                lpb.FromDate      = p.ApplicationDate.AddYears(counter - 1);
                lpb.IsFactured    = false;
                lpb.LifePolicyID  = p.ID;
                lpb.OrdinalNumber = counter;
                lpb.ToDate        = p.ApplicationDate.AddYears(counter);
                lpb.Value         = (ldb.BrokeragePecentForYear / 100) * totalBrokerageValue;
                lpb.Insert();
                counter++;
            }
            for (int i = 1; i <= PolicyDurationYears; i++)
            {
                LifePolicyPremiumValue lppv = new LifePolicyPremiumValue();
                lppv.FromDate                    = p.StartDate.AddYears(i - 1);
                lppv.LifePolicyID                = p.ID;
                lppv.OrdinalNumberYear           = i;
                lppv.PremiumValueForAccident     = p.YearlyPremiumValueForAccident;
                lppv.PremiumValueForAccidentEuro = p.YearlyPremiumValueForAccidentEuro;
                lppv.PremiumValueForLife         = p.YearlyPremiumValueForLife;
                lppv.PremiumValueForLifeEuro     = p.YearlyPremiumValueForLifeEuro;
                lppv.ToDate = p.StartDate.AddYears(i);
                lppv.Insert();
            }
            Distribution d = Distribution.GetByNumberAndSubTypeAndCompany(p.InsuranceSubTypeID, p.PolicyNumber, p.InsuranceCompanyID);
            if (d != null)
            {
                d.IsUsed = true;
            }
            else
            {
                RightRestrictionDistribution rrd = RightRestrictionDistribution.GetForCompanyAndType(p.InsuranceCompanyID, p.PolicyNumber, DistributionDocumentType.GetByCode(DistributionDocumentType.BLANKO).ID);
                rrd.IsUsed = true;
            }
            Policy.Table.Context.SubmitChanges();
        }
    }
Esempio n. 3
0
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        RightRestrictionDistribution rrd = (RightRestrictionDistribution.ExistForCompany(int.Parse(ddlInsuranceCompany.SelectedValue), tbRestrictionNumber.Text.Trim()));

        if (rrd != null)
        {
            if (rrd.IsUsed)
            {
                lblError.Text      = "Винкулацијата со број " + tbRestrictionNumber.Text + " е искористена";
                lblError.Visible   = true;
                lblSuccess.Visible = false;
            }
            else
            {
                RightRestriction rr = new RightRestriction();
                rr.PolicyItemID       = PolicyItemID;
                rr.Number             = tbRestrictionNumber.Text;
                rr.BankID             = int.Parse(ddlBanks.SelectedValue);
                rr.ApplicationDate    = DateTime.Today;
                rr.Description        = tbDescription.Text;
                rr.Discard            = false;
                rr.Value              = decimal.Parse(tbCoverage.Text);
                rr.IsRollBacked       = false;
                rr.InsuranceCompanyID = int.Parse(ddlInsuranceCompany.SelectedValue);
                rr.Insert();
                RightRestrictionDistribution.UpdateUsed(int.Parse(ddlInsuranceCompany.SelectedValue), rr.Number);
                lblError.Visible   = false;
                lblSuccess.Visible = true;
            }
        }
        else
        {
            lblError.Text      = "Винкулацијата со број " + tbRestrictionNumber.Text + " не е задолжена";
            lblError.Visible   = true;
            lblSuccess.Visible = false;
        }
    }