예제 #1
0
 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();
     }
 }
예제 #2
0
 private void GenerateVoucher(VoucherJson voucher)
 {
     lblPayMethod.Text          = voucher.PayMethod;
     lblCheque.Text             = voucher.ChequeNo;
     lblVoucherNo.Text          = voucher.VoucherNo;
     lblVoucherDate.Text        = voucher.CreateDate.ToString("dd MMM yyyy");
     lblName.Text               = voucher.EmployeeName;
     lblTotalAmount.Text        = voucher.TotalAmount.ToString().Split('.')[0];
     lblTotalPaisa.Text         = voucher.TotalAmount.ToString().Split('.')[1];
     rptrDescription.DataSource = voucher.VoucherDescriptionList;
     rptrDescription.DataBind();
 }
예제 #3
0
 protected void gvVoucherList_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         VoucherJson voucherJson = JsonConvert.DeserializeObject <VoucherJson>(((DataTable)gvVoucherList.DataSource).Rows[e.Row.RowIndex]["VoucherJson"].ToString());
         if (voucherJson != null)
         {
             Label lblPaidTo = (Label)e.Row.FindControl("lblPaidTo");
             lblPaidTo.Text = voucherJson.EmployeeName;
         }
     }
 }
        private string PrepareVoucherJson()
        {
            string employeeName = string.Empty;
            List <VoucherDescription> voucherDescriptionList = new List <VoucherDescription>();

            foreach (GridViewRow gvr in gvApprovedClaim.Rows)
            {
                CheckBox chkSelect = (CheckBox)gvr.FindControl("chkitem");
                if (chkSelect.Checked)
                {
                    Business.ClaimManagement.ClaimApplication objClaimApplication = new Business.ClaimManagement.ClaimApplication();
                    DataSet dsClaim = objClaimApplication.GetClaimApplicationDetails_ByClaimApplicationId(Convert.ToInt32(gvApprovedClaim.DataKeys[gvr.RowIndex].Values[0].ToString()));
                    if (dsClaim != null && dsClaim.Tables.Count > 0 && dsClaim.Tables[0] != null && dsClaim.Tables[0].Rows.Count > 0)
                    {
                        employeeName = dsClaim.Tables[0].Rows[0]["Requestor"].ToString();
                        string    claimCategories = string.Empty;
                        DataTable dtClaimDetails  = new Business.ClaimManagement.ClaimApplication().ClaimApplicationDetails_GetAll(new ClaimApplicationDetails()
                        {
                            ClaimApplicationId = Convert.ToInt32(dsClaim.Tables[0].Rows[0]["ClaimId"].ToString())
                        });
                        if (dtClaimDetails != null && dtClaimDetails.AsEnumerable().Any())
                        {
                            foreach (DataRow drClaimDetail in dtClaimDetails.Rows)
                            {
                                DataTable dtClaimCategory = new Business.ClaimManagement.ClaimCategory().ClaimCategory_GetById(Convert.ToInt32(drClaimDetail["CategoryId"].ToString()));
                                if (dtClaimCategory != null && dtClaimCategory.AsEnumerable().Any())
                                {
                                    claimCategories = claimCategories + dtClaimCategory.Rows[0]["CategoryName"].ToString() + ",";
                                }
                            }
                        }

                        VoucherDescription voucherPaymentDetails = new VoucherDescription()
                        {
                            Amount      = Convert.ToDecimal(dsClaim.Tables[0].Rows[0]["ApprovedAmount"].ToString()),
                            Description = string.Format("{0}-{1}-{2}", dsClaim.Tables[0].Rows[0]["ClaimNo"].ToString(), dsClaim.Tables[0].Rows[0]["ClaimHeading"].ToString(), claimCategories.Trim(','))
                        };
                        voucherDescriptionList.Add(voucherPaymentDetails);
                    }
                }
            }

            string chequeNo = string.Empty, payMethod = string.Empty;

            foreach (DataRow dr in _ClaimPaymentDetails.Rows)
            {
                chequeNo  += dr["PaymentDetails"] + ",";
                payMethod += dr["PaymentModeName"] + ",";
            }

            VoucherJson voucherJson = new VoucherJson()
            {
                AmountInWords          = "",
                ChequeNo               = chequeNo.TrimEnd(','),
                CreateDate             = DateTime.UtcNow.AddHours(5).AddMinutes(33),
                EmployeeName           = employeeName,
                PayMethod              = payMethod.TrimEnd(','),
                TotalAmount            = Convert.ToDecimal(lblTotalAmountPaying.Text),
                VoucherDescriptionList = voucherDescriptionList
            };

            return(JsonConvert.SerializeObject(voucherJson));
        }