public List <GiftVoucherDistributor> Search()
        {
            List <GiftVoucherDistributor> VoucherList = new List <GiftVoucherDistributor>();

            System.Data.DataTable dTable = new DataTable();
            try
            {
                string          errorMessage = string.Empty;
                DBParameterList dbParam      = new DBParameterList();
                dbParam.Add(new DBParameter("@VoucherCode", GiftVoucherCode, DbType.String));
                dbParam.Add(new DBParameter("@DistributorID", IssueTo, DbType.Int32));
                dbParam.Add(new DBParameter("@Availed", Availed, DbType.Int32));
                dbParam.Add(new DBParameter(Common.PARAM_OUTPUT, string.Empty, DbType.String, ParameterDirection.Output, Common.PARAM_OUTPUT_LENGTH));

                dTable = GetSelectedRecords(dbParam, SP_GIFTVOUCHER_DISTRIBUTOR_SEARCH, ref errorMessage);

                if (dTable != null)
                {
                    foreach (System.Data.DataRow drow in dTable.Rows)
                    {
                        GiftVoucherDistributor _voucher = CreateVoucherObject(drow);
                        VoucherList.Add(_voucher);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(VoucherList);
        }
 private GiftVoucherDistributor CreateVoucherObject(DataRow dr)
 {
     try
     {
         GiftVoucherDistributor voucher = new GiftVoucherDistributor();
         voucher.ApplicableFrom     = Convert.ToString(dr[CON_FIELD_APPLICABLEFROM]);
         voucher.ApplicableTo       = Convert.ToString(dr[CON_FIELD_APPLICABLETO]);
         voucher.Availed            = Convert.ToInt32(dr[CON_FIELD_AVAILED]);
         voucher.VoucherSrNo        = Convert.ToString(dr[CON_FIELD_VOUCHERSRNO]);
         voucher.AvailedDate        = Convert.ToString(dr[CON_FIELD_AVAILEDDATE]);
         voucher.IssueDate          = Convert.ToString(dr[CON_FIELD_ISSUEDATE]);
         voucher.IssueTo            = Convert.ToInt32(dr[CON_FIELD_ISSUETO]);
         voucher.GiftVoucherCode    = Convert.ToString(dr[CON_FIELD_VOUCHERCODE]);
         voucher.SeriesID           = Convert.ToInt32(dr[CON_FIELD_SERIESID]);
         voucher.MinBuyAmount       = Convert.ToDecimal(dr[CON_FIELD_BUYAMOUNT]);
         voucher.VoucherDescription = Convert.ToString(dr[CON_FIELD_VOUCHERDESCRIPTION]);
         voucher.VoucherName        = Convert.ToString(dr[CON_FIELD_VOUCHERNAME]);
         return(voucher);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }