예제 #1
0
        private static Coupon[] TransFerToCouponArray(string sqlCommand1, Coupon[] cpArray, DataTable table)
        {
            int n = table.Rows.Count;
            cpArray = new Coupon[n];
            for (int i = 0; i < n; i++)
            {
                cpArray[i] = new Coupon();
                DataRow row = table.Rows[i];
                cpArray[i].DieuKienSuDung = row["DIEUKIENSD"].ToString();
                cpArray[i].DonViTien = row["DVTIENTE"].ToString();
                cpArray[i].GiaHangKhiChuaGiam = row["GIAGOC"].ToString();
                cpArray[i].GiaHangSauKhiGiam = row["GIASGIAM"].ToString();
                cpArray[i].LinkHinhAnh = new string[1];
               // cpArray[i].LinkHinhAnh[0] = "http://www.beatifulhouse.somee.com/Content/images/products/" + row["HINHANH"].ToString();
                cpArray[i].LinkHinhAnh[0] = ConfigurationManager.AppSettings.GetValues("image")[0].ToString() + row["HINHANH"].ToString();
                cpArray[i].MaCoupon = row["MACP"].ToString();
                cpArray[i].MaMatHang = row["MASP"].ToString();
                cpArray[i].MaNhaCungCap = "BIZ";
                cpArray[i].NgayBatDau = DateTime.Parse(row["THOIGIANBD"].ToString());
                cpArray[i].NgayCouponBatDauDuocSuDung = cpArray[i].NgayBatDau;
                cpArray[i].NgayKetThuc = DateTime.Parse(row["THOIGIANKT"].ToString());
                cpArray[i].NgayCouponHetHan = cpArray[i].NgayKetThuc;
                List<SqlParameter> sql = new List<SqlParameter>();
                sql.Add(new SqlParameter("@macp", cpArray[i].MaCoupon));
                SqlParameter output = new SqlParameter("@count", SqlDbType.Int);
                output.Direction = ParameterDirection.Output;
                sql.Add(output);
                provider.executeNonQueryProcedure(sqlCommand1, sql);
                cpArray[i].SoLuongDaDat = (int)output.Value;
                float slcl=float.Parse(row["SLCONLAI"].ToString());
                int slspmin = int.Parse(row["SLSPMIN"].ToString());
                cpArray[i].SoLuongMuaLonNhat =(int)slcl/slspmin;
                cpArray[i].SoLuongThoaCoupon = int.Parse(row["SLCPMINGIAMGIA"].ToString());
                cpArray[i].TenMatHang = row["TENSP"].ToString();
                cpArray[i].TenNhaCungCap = "BeatifulhouseGroup";
                cpArray[i].ThongTinMoTa = row["MOTA"].ToString();
                cpArray[i].ThongTinMoTa += " .Mỗi coupon gồm " + slspmin.ToString()+" "+row["DVTINH"].ToString()+" sản phẩm";

            }
            return cpArray;
        }
예제 #2
0
        public static Coupon FindCouponInfo(string couponId)
        {
            provider.connect();
            string sqlCommand = "sp_FindCouponInfo";
            string sqlCommand1 = "sp_CountOrderCoupon";
            List<SqlParameter> list = new List<SqlParameter>();
            list.Add(new SqlParameter("@couponId", couponId));

            Coupon[] cpArray = new Coupon[0];
            try
            {
                DataTable table = provider.executeQueryDataTableProcedure(sqlCommand, list);
                if (table != null && table.Rows.Count > 0)
                {
                    cpArray = TransFerToCouponArray(sqlCommand1, cpArray, table);
                    return cpArray[0];
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                provider.disconnect();
            }
            return new Coupon();
        }
예제 #3
0
 public static Coupon[] FindCoupons(string productName,DateTime startDate,DateTime endDate,int minPrice,int maxPrice)
 {
     provider.connect();
     string sqlCommand = "sp_FindCoupons";
     string sqlCommand1 = "sp_CountOrderCoupon";
     productName = "%" + productName + "%";
     List<SqlParameter> list = new List<SqlParameter>();
     list.Add(new SqlParameter("@productName", productName));
     list.Add(new SqlParameter("@startDate", startDate));
     list.Add(new SqlParameter("@endDate", endDate));
     list.Add(new SqlParameter("@minPrice", minPrice));
     list.Add(new SqlParameter("@maxPrice", maxPrice));
     Coupon[] cpArray = new Coupon[0];
     try
     {
         DataTable table = provider.executeQueryDataTableProcedure(sqlCommand, list);
         if (table != null && table.Rows.Count > 0)
         {
             cpArray = TransFerToCouponArray(sqlCommand1, cpArray, table);
         }
     }
     catch (Exception e)
     {
     }
     finally
     {
         provider.disconnect();
     }
     return cpArray;
 }
예제 #4
0
 public static Coupon[] FindAllCoupons()
 {
     provider.connect();
     string sqlCommand = "sp_FindAllCoupons";
     string sqlCommand1="sp_CountOrderCoupon";
     List<SqlParameter> list = new List<SqlParameter>();
     Coupon[] cpArray=new Coupon[0];
     try
     {
         DataTable table = provider.executeQueryDataTableProcedure(sqlCommand, list);
         if (table != null && table.Rows.Count > 0)
         {
             cpArray = TransFerToCouponArray(sqlCommand1, cpArray, table);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         provider.disconnect();
     }
     return cpArray;
 }