Beispiel #1
0
 protected void btnAddPolicyToList_Click(object sender, EventArgs e)
 {
     try {
         TextBox          tbPolicyNumberToList  = (TextBox)DetailsView1.FindControl("tbPolicyNumberToList");
         DropDownList     ddlInsuranceCompanies = (DropDownList)DetailsView1.FindControl("ddlInsuranceCompanies");
         int              icID = Convert.ToInt32(ddlInsuranceCompanies.SelectedValue);
         InsuranceCompany ic   = InsuranceCompany.Get(icID);
         PolicyItem       pi   = PolicyItem.GetByNumberAndInsuranceCompany(tbPolicyNumberToList.Text, icID);
         if (pi != null)
         {
             GridView           gvNewPolicies    = (GridView)DetailsView1.FindControl("gvNewPolicies");
             List <FactureInfo> lastFactureInfos = listFactureInfos;
             FactureInfo        fi = listFactureInfos.Where(c => c.PolicyNumber == tbPolicyNumberToList.Text).SingleOrDefault();
             if (fi != null)
             {
                 RegisterStartupScript("myAlert", "<script>alert('Полисата постои во листата!')</script>");
                 return;
             }
             FactureInfo newFactureInfo = new FactureInfo();
             newFactureInfo.PolicyNumber   = tbPolicyNumberToList.Text;
             newFactureInfo.IsForFacturing = true;
             newFactureInfo.ID             = pi.ID;
             lastFactureInfos.Add(newFactureInfo);
             listFactureInfos         = lastFactureInfos;
             gvNewPolicies.DataSource = lastFactureInfos;
             gvNewPolicies.DataBind();
         }
         else
         {
             RegisterStartupScript("myAlert", "<script>alert('Не постои полиса со избраниот број!')</script>");
         }
     } catch {
         RegisterStartupScript("myAlert", "<script>alert('Грешка!')</script>");
     }
 }
Beispiel #2
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string policyNumber       = tbPolicyNumber.Text;
        int    insuranceCompanyID = int.Parse(ddlInsuranceCompany.SelectedValue);

        try {
            PolicyItem pi = PolicyItem.GetByNumberAndInsuranceCompany(policyNumber, insuranceCompanyID);

            if (pi != null)
            {
                UpdateTextBoxes(pi);
                lblFeedback.Text = string.Empty;
                GridViewRates.DataBind();
                btnGenerate.Enabled = true;
            }
            else
            {
                lblFeedback.Text = "Не е пронајдена полиса!";
            }
            odsPaidPayments.SelectParameters.Clear();
            odsPaidPayments.SelectParameters.Add("policyItemID", pi.ID.ToString());
            GridViewPayments.DataBind();
        } catch (Exception ex) {
            pnlInsurancecSubType.Visible = true;
            ddlInsuranceSubTypes.DataBind();
            lblFeedback.Text    = "Изберете полиса!";
            btnGenerate.Enabled = false;
            btnInsert.Enabled   = false;
            // GridViewRates.DataBind();
            // GridViewPayments.DataBind();
        }
    }