protected void btnSearch_Click(object sender, EventArgs e)
    {
        try
        {
            VoucherRecievableSearch voucherSearch = new VoucherRecievableSearch();
            voucherSearch.FromDate = dtpFromDate.Date;
            voucherSearch.ToDate = dtpToDate.Date;
            DataSet dsPOs = (new VoucherRecievableDAO()).GetPaymentsReveivedForReporting(voucherSearch);
            Session["PaymentsRecieved"] = dsPOs;

            if (dsPOs != null && dsPOs.Tables[0].Rows.Count > 0)
            {
                dxgvPaymentsReceived.DataSource = dsPOs;
                dxgvPaymentsReceived.DataBind();
            }
            else
            {
                dxgvPaymentsReceived.DataSource = dsPOs;
                dxgvPaymentsReceived.DataBind();
            }
        }
        catch (Exception ex)
        {
            ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnSearch_Click(object sender, EventArgs e)");
            if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty)
            {
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false);
            }
            else
            {
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false);
            }
        }
    }
        public DataSet GetPaymentsReveivedForReporting(VoucherRecievableSearch voucherSearch)
        {
            try
            {
                Database  db        = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Voucher_Report_Payments_ReceivedByDateRange);

                db.AddInParameter(dbCommand, "@dFromDate", DbType.DateTime, voucherSearch.FromDate.Value);
                db.AddInParameter(dbCommand, "@dToDate", DbType.DateTime, voucherSearch.ToDate.Value);

                return(db.ExecuteDataSet(dbCommand));
            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public DataSet GetPaymentsReveivedForReporting(VoucherRecievableSearch voucherSearch)");
                return(null);

                throw ex;
            }
        }
        public DataSet GetPaymentsReveivedForReporting(VoucherRecievableSearch voucherSearch)
        {
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Voucher_Report_Payments_ReceivedByDateRange);

                db.AddInParameter(dbCommand, "@dFromDate", DbType.DateTime, voucherSearch.FromDate.Value);
                db.AddInParameter(dbCommand, "@dToDate", DbType.DateTime, voucherSearch.ToDate.Value);

                return db.ExecuteDataSet(dbCommand);

            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public DataSet GetPaymentsReveivedForReporting(VoucherRecievableSearch voucherSearch)");
                return null;
                throw ex;
            }
        }