protected void Page_Load(object sender, EventArgs e) { try { if (Request.QueryString["no"] != null) { Business.ClaimManagement.Voucher objVoucher = new Business.ClaimManagement.Voucher(); DataSet dsVoucher = objVoucher.Voucher_GetAll(new Voucher() { VoucherNo = Request.QueryString["no"].ToString(), PageIndex = 0, PageSize = 10 }); VoucherJson voucher = new VoucherJson(); voucher = JsonConvert.DeserializeObject <VoucherJson>(dsVoucher.Tables[0].Rows[0]["VoucherJson"].ToString()); voucher.VoucherNo = dsVoucher.Tables[0].Rows[0]["VoucherNo"].ToString(); GenerateVoucher(voucher); } else { throw new Exception("Invalid voucher id"); } } catch (Exception ex) { ex.WriteException(); } }
protected void btnGenerateVoucher_Click(object sender, EventArgs e) { try { if (ValidateGenerateVoucher()) { Voucher voucher = PrepareVoucher(); Business.ClaimManagement.Voucher objVoucher = new Business.ClaimManagement.Voucher(); Business.ClaimManagement.VoucherPayment objVoucherPayment = new Business.ClaimManagement.VoucherPayment(); Business.ClaimManagement.VoucherPaymentDetailsDetails objVoucherPaymentDetailsDetails = new Business.ClaimManagement.VoucherPaymentDetailsDetails(); int voucherId = objVoucher.Voucher_Save(voucher); VoucherPayment voucherPayment = voucher.VoucherPayment; voucherPayment.VoucherId = voucherId; int voucherPaymentId = objVoucherPayment.VoucherPayment_Save(voucherPayment); int retValue = 0; List <VoucherPaymentDetails> voucherPaymentDetailsList = new List <VoucherPaymentDetails>(); voucherPaymentDetailsList = voucher.VoucherPayment.VoucherPaymentDetailsList; retValue = VoucherPaymentDetails_Save(objVoucherPaymentDetailsDetails, voucherPaymentId, retValue, voucherPaymentDetailsList); DataTable dtVoucher = objVoucher.Voucher_GetById(voucherId); if (dtVoucher != null && dtVoucher.AsEnumerable().Any() && retValue == voucherPaymentDetailsList.Count()) { ClaimApplicationStatusUpdate(); int claimDisbursementId = ClaimDisbursement_Save(voucherId); ClaimDisbursementDetails_Save(claimDisbursementId); ClaimApplication_GetAll(); ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('VoucherPrint.aspx?no=" + dtVoucher.Rows[0]["VoucherNo"].ToString() + "','mywindow','menubar=1,resizable=1,width=900,height=600');", true); MessageSuccess.IsSuccess = true; MessageSuccess.Text = string.Format("Voucher generated successfully. Voucher number is <a target='_blank' href='../ClaimManagement/VoucherPrint.aspx?no={0}'>{0}</a>", dtVoucher.Rows[0]["VoucherNo"].ToString()); MessageSuccess.Show = true; lblTotalAmountPaying.Text = "0.00"; _ClaimPaymentDetails = null; LoadClaimPaymentDetails(); } else { Message.IsSuccess = false; Message.Text = "Voucher generation failed."; Message.Show = true; ModalPopupExtender1.Show(); } ClearPaymentDetailsControls(); _ClaimPaymentDetails.Clear(); LoadClaimPaymentDetails(); } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }
private void Voucher_GetAll() { Business.ClaimManagement.Voucher objVoucher = new Business.ClaimManagement.Voucher(); DataSet dsVoucher = objVoucher.Voucher_GetAll(new Entity.ClaimManagement.Voucher() { EmployeeName = txtEmployeeName.Text.Trim(), VoucherNo = txtVoucherNo.Text.Trim(), FromDate = (string.IsNullOrEmpty(txtFromDate.Text.Trim()) ? DateTime.MinValue : Convert.ToDateTime(txtFromDate.Text.Trim())), ToDate = (string.IsNullOrEmpty(txtToDate.Text.Trim()) ? DateTime.MinValue : Convert.ToDateTime(txtToDate.Text.Trim())), PageIndex = gvVoucherList.PageIndex, PageSize = gvVoucherList.PageSize }); gvVoucherList.DataSource = dsVoucher.Tables[0]; gvVoucherList.VirtualItemCount = (dsVoucher.Tables[1].Rows.Count > 0) ? Convert.ToInt32(dsVoucher.Tables[1].Rows[0]["TotalCount"].ToString()) : 20; gvVoucherList.DataBind(); }