protected void btnInsert_Click(object sender, EventArgs e) { if (BankslipInfo != null) { Bankslip b = new Bankslip(); b.BankID = BankslipInfo.BankID; b.BankslipNumber = BankslipInfo.BankslipNumber; b.Date = BankslipInfo.Date; b.DebtValue = BankslipInfo.DebtValue; b.DemandValue = BankslipInfo.DemandValue; b.Insert(); foreach (BankslipItemInfo bii in listBankslipItemInfos) { BankslipItem bi = new BankslipItem(); bi.BankslipID = b.ID; bi.CallOnPaymentNumber = bii.CallOnPaymentNumber; bi.ClientAccountNumber = bii.ClientAccountNumber; bi.ClientName = bii.ClientName; bi.Code = bii.Code; bi.DebtValue = bii.DebtValue; bi.DemandValue = bii.DemandValue; bi.PaymentDescription = bii.PaymentDescription; bi.ProvisionValue = bii.ProvisionValue; bi.Insert(); } } }
protected void gvForPayments_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Payment") { int selIndex = Convert.ToInt32(e.CommandArgument); gvForPayments.SelectedIndex = selIndex; ViewState["gvForPaymentsSelectedValue"] = gvForPayments.SelectedValue; BankslipItem bi = BankslipItem.Get(Convert.ToInt32(gvForPayments.SelectedValue)); if (bi.IsPaid) { RegisterStartupScript("myAlert", "<script>alert('Ставката од изводот веќе е евидентирана во плаќања на полисите!')</script>"); ViewState["ClientID"] = null; btnInsertNewPayments.Enabled = false; return; } if (bi.DemandValue > 0) { ClientAccount ca = ClientAccount.GetByAccountNumber(bi.ClientAccountNumber); if (ca != null) { List <FinCardSaldo> lst = Policy.GetForFinCard(ca.ClientID, "OpenItems"); if (lst.Count > 0) { ViewState["ClientID"] = ca.ClientID; gvNewPayments.DataBind(); SetNewPaidValue(lst, bi.DemandValue); btnInsertNewPayments.Enabled = true; } else { RegisterStartupScript("myAlert", "<script>alert('Не постојат неплатени полиси за клиентот!')</script>"); ViewState["ClientID"] = null; btnInsertNewPayments.Enabled = false; } } else { RegisterStartupScript("myAlert", "<script>alert('Не постои сметката!')</script>"); ViewState["ClientID"] = null; btnInsertNewPayments.Enabled = false; } } else { RegisterStartupScript("myAlert", "<script>alert('Износот во ставката на изводот не е внесен како побарува!')</script>"); ViewState["ClientID"] = null; btnInsertNewPayments.Enabled = false; } } }
public static BankslipItemInfo GetFromBankslipItem(BankslipItem bi) { BankslipItemInfo bii = new BankslipItemInfo(); bii.BankslipID = bi.BankslipID; bii.CallOnPaymentNumber = bi.CallOnPaymentNumber; bii.ClientAccountNumber = bi.ClientAccountNumber; bii.ClientName = bi.ClientName; bii.Code = bi.Code; bii.DebtValue = bi.DebtValue; bii.DemandValue = bi.DemandValue; bii.ID = bi.ID; bii.PaymentDescription = bi.PaymentDescription; bii.ProvisionValue = bi.ProvisionValue; return(bii); }
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; }
protected void dvDataSourceBankslipItem_Deleting(object sender, ObjectDataSourceMethodEventArgs e) { BankslipItem bi = e.InputParameters["entityToDelete"] as BankslipItem; bi.ValidateDeleteBankslipItem(); }
protected void dvDataSourceBankslipItem_Updating(object sender, ObjectDataSourceMethodEventArgs e) { BankslipItem bi = e.InputParameters["newEntity"] as BankslipItem; bi.ValidateUpdateBankslipItem(); }
void KomercijalnaBanka() { if (FileUpload1.HasFile) { try { //pateka za dodavanje na datotekata. int len = FileUpload1.PostedFile.ContentLength; Stream s = FileUpload1.FileContent; byte[] data = new byte[len]; s.Read(data, 0, len); MemoryStream ms = new MemoryStream(data); StreamReader sr = new StreamReader(ms, Encoding.Default); string line = ""; Bankslip b = new Bankslip(); decimal totDebtValue = 0; decimal totDemandValue = 0; List <BankslipItem> lstBI = new List <BankslipItem>(); DateTime dt = DateTime.Today; while ((line = sr.ReadLine()) != null) { if (line.Length > 270) { BankslipItem bi = new BankslipItem(); bi.ClientName = ConvertToMacedonian.ConvertToMACEDONIAN(line.Substring(18, 70)); bi.ClientAccountNumber = line.Substring(88, 18); string sDebtValue = line.Substring(107, 18); sDebtValue = sDebtValue.Replace(".", ","); bi.DebtValue = Convert.ToDecimal(sDebtValue); totDebtValue += bi.DebtValue; string sDemandValue = line.Substring(126, 18); sDemandValue = sDemandValue.Replace(".", ","); bi.DemandValue = Convert.ToDecimal(sDemandValue); totDemandValue += bi.DemandValue; string sProvisionValue = line.Substring(145, 18); sProvisionValue = sProvisionValue.Replace(".", ","); bi.ProvisionValue = Convert.ToDecimal(sProvisionValue); dt = new DateTime(Convert.ToInt32(line.Substring(163, 4)), Convert.ToInt32(line.Substring(168, 2)), Convert.ToInt32(line.Substring(171, 2))); bi.PaymentDescription = ConvertToMacedonian.ConvertToMACEDONIAN(line.Substring(173, 70)); bi.Code = line.Substring(243, 3); string povikuvanjeZadolzuvanje = line.Substring(246, 24); string povikuvanjeOdobruvanje = line.Substring(270, 24); bi.CallOnPaymentNumber = povikuvanjeOdobruvanje + "/" + povikuvanjeOdobruvanje; lstBI.Add(bi); } } b.BankID = Convert.ToInt32(ddlBanks.SelectedValue); b.DebtValue = totDebtValue; b.DemandValue = totDemandValue; b.Date = dt; b.BankslipNumber = tbBankslipNumber.Text; List <Bankslip> lstB = new List <Bankslip>(); lstB.Add(b); dvBankslip.DataSource = lstB; dvBankslip.DataBind(); gvBankslipItems.DataSource = lstBI; gvBankslipItems.DataBind(); BankslipInfo = BankslipInfo.GetFromBankslip(b); List <BankslipItemInfo> lstBII = new List <BankslipItemInfo>(); foreach (BankslipItem bi in lstBI) { BankslipItemInfo bii = BankslipItemInfo.GetFromBankslipItem(bi); lstBII.Add(bii); } listBankslipItemInfos = lstBII; } catch (Exception ex) { BankslipInfo = null; RegisterStartupScript("myAlert", "<script>alert('ГРЕШКА ВО ФОРМАТОТ НА ВЛЕЗНАТА ДАТОТЕКА')</script>"); } } else { BankslipInfo = null; RegisterStartupScript("myAlert", "<script>alert('НЕМАТЕ ИЗБРАНО ДАТОТЕКА!')</script>"); } }