Exemplo n.º 1
0
    protected void btnInsertNewPayments_Click(object sender, EventArgs e)
    {
        Bankslip b            = Bankslip.Get(Convert.ToInt32(dvBankslipForPayments.SelectedValue));
        decimal  totPaidValue = 0;

        foreach (GridViewRow gvr in gvNewPayments.Rows)
        {
            int        polID        = Convert.ToInt32(gvr.Cells[0].Text);
            PolicyItem pi           = Policy.Get(polID).PolicyItems[0];
            TextBox    tbNewPayment = gvr.FindControl("tbNewPayment") as TextBox;
            decimal    newPaidValue = 0;
            decimal.TryParse(tbNewPayment.Text, out newPaidValue);
            totPaidValue += newPaidValue;
        }
        decimal biDemandValue = 0;

        if (ViewState["gvForPaymentsSelectedValue"] != null)
        {
            BankslipItem bi = BankslipItem.Get(Convert.ToInt32(ViewState["gvForPaymentsSelectedValue"]));
            biDemandValue = bi.DemandValue;
        }
        if (totPaidValue != biDemandValue)
        {
            RegisterStartupScript("myAlert", "<script>alert('Вкупниот внесен износ по полиси се разликува од вредноста побарува од ставката на изводот!')</script>");
            return;
        }
        foreach (GridViewRow gvr in gvNewPayments.Rows)
        {
            int        polID        = Convert.ToInt32(gvr.Cells[0].Text);
            PolicyItem pi           = Policy.Get(polID).PolicyItems[0];
            TextBox    tbNewPayment = gvr.FindControl("tbNewPayment") as TextBox;
            decimal    newPaidValue = 0;
            decimal.TryParse(tbNewPayment.Text, out newPaidValue);
            InsertPaymentsForPolicy(pi, newPaidValue, b.Date, b.BankslipNumber, b.BankID);
        }
        if (ViewState["gvForPaymentsSelectedValue"] != null)
        {
            BankslipItem bi = BankslipItem.Get(Convert.ToInt32(ViewState["gvForPaymentsSelectedValue"]));
            bi.IsPaid = true;
            BankslipItem.Table.Context.SubmitChanges();
        }
        mvMain.SetActiveView(viewGrid);
        btnInsertNewPayments.Enabled = false;
    }
Exemplo n.º 2
0
 protected void DetailsViewBankslipItem_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
 {
     if (e.Exception != null)
     {
         e.ExceptionHandled = true;
         ValidationUtility.ShowValidationErrors(this, e.Exception);
     }
     else
     {
         int bankslipID = GXGridView1SelectedValue;
         GXGridViewBankslipItems.TotalRecords = ViewBankslipItem.SelectByFKCountCached("BankslipID", bankslipID);
         GXGridViewBankslipItems.DataBind();
         mvBankslipItems.SetActiveView(viewBankslipGrid);
         Bankslip bk          = Bankslip.Get(GXGridView1SelectedValue);
         decimal  debtValue   = Convert.ToDecimal(e.Values["DebtValue"]);
         decimal  demandValue = Convert.ToDecimal(e.Values["DemandValue"]);
         bk.DebtValue   -= debtValue;
         bk.DemandValue -= demandValue;
         Bankslip.Table.Context.SubmitChanges();
         dvBankslipForItem.DataBind();
     }
 }