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

            System.Data.DataTable dTable = new DataTable();
            try
            {
                string errorMessage = string.Empty;
                dTable = GetSelectedRecords(Common.ToXml(this), SP_GIFTVOUCHER_SEARCH, ref errorMessage);

                if (dTable != null)
                {
                    foreach (System.Data.DataRow drow in dTable.Rows)
                    {
                        GiftVoucherDetail _voucher = CreateVoucherObject(drow);
                        VoucherList.Add(_voucher);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(VoucherList);
        }
 public GiftVoucherDetail CreateVoucherObject(DataRow dr)
 {
     try
     {
         GiftVoucherDetail voucher = new GiftVoucherDetail();
         voucher.EndSeries       = Convert.ToString(dr[CON_FIELD_ENDSERIES]);
         voucher.GiftVoucherCode = Convert.ToString(dr[CON_FIELD_VOUCHERCODE]);
         voucher.SeriesID        = Convert.ToInt32(dr[CON_FIELD_SERIESID]);
         voucher.StartSeries     = Convert.ToString(dr[CON_FIELD_STARTSERIES]);
         voucher.IsActive        = Convert.ToBoolean(dr[CON_FIELD_STATUS]);
         voucher.ApplicableTo    = Convert.ToString(dr[CON_FIELD_APPLICABLETO]);
         voucher.ApplicableFrom  = Convert.ToString(dr[CON_FIELD_APPLICABLEFROM]);
         return(voucher);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
        private void GetVoucherDetailList(DataTable dt)
        {
            try
            {
                List <GiftVoucherDetail> ListVoucher = null;
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow[] drCollection = dt.Select("GiftVoucherCode='" + this.VoucherCode + "'");
                    ListVoucher = new List <GiftVoucherDetail>();

                    for (int i = 0; i < drCollection.Length; i++)
                    {
                        GiftVoucherDetail voucher = new GiftVoucherDetail();
                        voucher = voucher.CreateVoucherObject(drCollection[i]);
                        ListVoucher.Add(voucher);
                    }
                    this.VoucherDetailList = ListVoucher;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }