2011-12-21 6 views
1

レコードをinsetingながら、私はnopcommerce 1.9を使用していますし、割引を作成する際に、私は次のコード使用Excelのインポート

discount = new Discount() 
      { 
       DiscountTypeId = (int)discountType, 
       DiscountRequirementId = (int)discountRequirement, 
       RequirementSpentAmount = requirementSpentAmount, 
       RequirementBillingCountryIs = requirementBillingCountryIs, 
       RequirementShippingCountryIs = requirementShippingCountryIs, 
       DiscountLimitationId = (int)discountLimitation, 
       LimitationTimes = limitationTimes, 
       Name = name, 
       UsePercentage = usePercentage, 
       DiscountPercentage = discountPercentage, 
       DiscountAmount = discountAmount, 
       StartDate = discountStartDate, 
       EndDate = discountEndDate, 
       RequiresCouponCode = requiresCouponCode, 
       CouponCode = couponCode 
      }; 
      this.DiscountService.InsertDiscount(discount); 

を持っている今、私の仕事は、'CouponCode = couponCode'に私はExcelシートから、このクーポンコードを交換する必要があることです割引を保存するときにクライアントによってアップロードされる列。各クーポンは、割引の同じ情報を持っているので、

、これはシートをExcelが50000のクーポンコードを持つことができます。

このソリューションでは、エンティティフレームワークがあります。そして、私たちは私がループの各レコードに持ってway.stillこの中にこのような状況に対処する方法を発見し、このフォーマット

D1 10% C1(coupon code from excel sheet) 
D1 10% C2(coupon code from excel sheet) 
D1 10% C3(coupon code from excel sheet) 
D1 10% C4(coupon code from excel sheet) 
D1 10% C5(coupon code from excel sheet) 
D1 10% C6(coupon code from excel sheet) 
D1 10% C7(coupon code from excel sheet) 
+0

あなたはおそらく問題が何であるかを明確にすることができますか? – Pynner

+0

私はcouponcode = dataをexcelから変更して、このコードを何度も失う必要があります – rahularyansharma

答えて

0
if (fuXlsFile.PostedFile != null && !String.IsNullOrEmpty(fuXlsFile.FileName)) 
      { 
       DataTable dt = GetDataFromExcel(filePath, "Sheet1"); 
       foreach (DataRow dr in dt.Rows) 
       { 
        discount = new Discount() 
       { 
        DiscountTypeId = (int)discountType, 
        DiscountRequirementId = (int)discountRequirement, 
        RequirementSpentAmount = requirementSpentAmount, 
        RequirementBillingCountryIs = requirementBillingCountryIs, 
        RequirementShippingCountryIs = requirementShippingCountryIs, 
        DiscountLimitationId = (int)discountLimitation, 
        LimitationTimes = limitationTimes, 
        Name = name, 
        UsePercentage = usePercentage, 
        DiscountPercentage = discountPercentage, 
        DiscountAmount = discountAmount, 
        StartDate = discountStartDate, 
        EndDate = discountEndDate, 
        RequiresCouponCode = requiresCouponCode, 
        CouponCode = dr[0].ToString() 
       }; 


        this.DiscountService.InsertDiscount(discount); 
       } 
      } 

にデータを保存する必要があるが、私は、これは私の仕事の必要性だと思います。

関連する問題