コード例 #1
0
 public static void UpdateCondition(PromotionCondition condition,
                                    int promotionId,
                                    int conditionId,
                                    int conditionTypeId,
                                    string conditionType,
                                    int conditionOnId,
                                    string conditionOn,
                                    int conditionCodeId,
                                    string conditionCode,
                                    decimal minBuyQty,
                                    decimal maxBuyQty,
                                    decimal qty,
                                    int discountTypeId,
                                    string discountType,
                                    decimal discountValue,
                                    int statusId,
                                    string status)
 {
     condition.PromotionId      = promotionId;
     condition.ConditionId      = conditionId;
     condition.ConditionTypeId  = conditionTypeId;
     condition.ConditionTypeVal = conditionType;
     condition.ConditionOnId    = conditionOnId;
     condition.ConditionOnVal   = conditionOn;
     condition.ConditionCodeId  = conditionCodeId;
     condition.ConditionCodeVal = conditionCode;
     condition.MinBuyQty        = minBuyQty;
     condition.MaxBuyQty        = maxBuyQty;
     condition.Qty             = qty;
     condition.DiscountTypeId  = discountTypeId;
     condition.DiscountTypeVal = discountType;
     condition.DiscountValue   = discountValue;
     condition.StatusId        = statusId;
     condition.StatusVal       = status;
 }
コード例 #2
0
        public Promotion Search(string xmlDoc, string spName, ref string errorMessage)
        {
            Promotion       promotion = new Promotion();
            DBParameterList dbParam;

            using (DataTaskManager dtManager = new DataTaskManager())
            {
                dbParam = new DBParameterList();
                dbParam.Add(new DBParameter(Common.PARAM_DATA, xmlDoc, DbType.String));
                dbParam.Add(new DBParameter(Common.PARAM_OUTPUT, errorMessage, DbType.String, ParameterDirection.Output, Common.PARAM_OUTPUT_LENGTH));

                DataSet ds = dtManager.ExecuteDataSet(spName, dbParam);
                errorMessage = dbParam[Common.PARAM_OUTPUT].Value.ToString();

                if (ds != null)
                {
                    //Add promotion Master
                    List <PromotionCondition> conditions = new List <PromotionCondition>();

                    //Add list of condition to the promotion object
                    for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
                    {
                        PromotionCondition condition = new PromotionCondition(
                            Convert.ToInt32(ds.Tables[1].Rows[i]["PromotionId"]),
                            Convert.ToInt32(ds.Tables[1].Rows[i]["ConditionId"]),
                            Convert.ToInt32(ds.Tables[1].Rows[i]["ConditionTypeId"]),
                            Convert.ToString(ds.Tables[1].Rows[i]["ConditionType"]),
                            Convert.ToInt32(ds.Tables[1].Rows[i]["ConditionOnId"]),
                            Convert.ToString(ds.Tables[1].Rows[i]["ConditionOn"]),
                            Convert.ToInt32(ds.Tables[1].Rows[i]["ConditionCodeId"]),
                            Validators.CheckForDBNull(ds.Tables[1].Rows[i]["ConditionCode"], string.Empty),
                            Convert.ToInt32(ds.Tables[1].Rows[i]["MinBuyQty"]),
                            Convert.ToInt32(ds.Tables[1].Rows[i]["MaxBuyQty"]),
                            Validators.CheckForDBNull(ds.Tables[1].Rows[i]["Qty"], (decimal)0),
                            Convert.ToInt32(ds.Tables[1].Rows[i]["DiscountTypeId"]),
                            Validators.CheckForDBNull(Convert.ToString(ds.Tables[1].Rows[i]["DiscountType"]), String.Empty),
                            Convert.ToDecimal(ds.Tables[1].Rows[i]["DiscountValue"]),
                            Convert.ToInt32(ds.Tables[1].Rows[i]["StatusId"]),
                            Convert.ToString(ds.Tables[1].Rows[i]["Status"])
                            );


                        DataRow[] drTiers = ds.Tables[2].Select("ConditionId = " + Convert.ToString(ds.Tables[1].Rows[i]["ConditionId"]));
                        //Add list of tiers to the condition
                        List <PromotionTier> tiers = new List <PromotionTier>();
                        PromotionTier        tier;
                        for (int j = 0; j < drTiers.Length; j++)
                        {
                            tier = new PromotionTier(
                                Convert.ToInt32(drTiers[j]["PromotionId"]),
                                Convert.ToInt32(drTiers[j]["TierId"]),
                                Convert.ToInt32(drTiers[j]["ConditionId"]),
                                Common.INT_DBNULL,
                                Validators.CheckForDBNull(drTiers[j]["ConditionOnId"], Common.INT_DBNULL),
                                Validators.CheckForDBNull(drTiers[j]["ConditionOn"], String.Empty),
                                Validators.CheckForDBNull(drTiers[j]["ConditionCodeId"], Common.INT_DBNULL),
                                Validators.CheckForDBNull(drTiers[j]["ConditionCode"], string.Empty),
                                Convert.ToInt32(drTiers[j]["BuyQtyFrom"]),
                                Convert.ToInt32(drTiers[j]["BuyQtyTo"]),
                                Convert.ToInt32(drTiers[j]["Qty"]),
                                Convert.ToInt32(drTiers[j]["DiscountTypeId"]),
                                Convert.ToString(drTiers[j]["DiscountTypeVal"]),
                                //Convert.ToInt32(drTiers[j]["DiscountValue"]),
                                Convert.ToDecimal(drTiers[j]["DiscountValue"]),
                                Convert.ToInt32(drTiers[j]["StatusId"]),
                                Convert.ToString(drTiers[j]["Status"]));
                            condition.Tiers.Add(tier);
                        }
                        conditions.Add(condition);
                    }

                    List <PromotionLocation> locations = new List <PromotionLocation>();
                    for (int i = 0; i < ds.Tables[3].Rows.Count; i++)
                    {
                        PromotionLocation location = new PromotionLocation(
                            Convert.ToInt32(ds.Tables[3].Rows[i]["LocationId"]),
                            Convert.ToInt32(ds.Tables[3].Rows[i]["PromotionId"]),
                            Convert.ToString(ds.Tables[3].Rows[i]["LocationVal"]),
                            Convert.ToString(ds.Tables[3].Rows[i]["LocationCode"]),
                            Convert.ToString(ds.Tables[3].Rows[i]["LocationType"]),
                            Convert.ToInt32(ds.Tables[3].Rows[i]["LineNumber"]),
                            Convert.ToInt32(ds.Tables[3].Rows[i]["StatusId"]),
                            Convert.ToString(ds.Tables[3].Rows[i]["Status"]));
                        locations.Add(location);
                    }
                    promotion = new Promotion(
                        Convert.ToInt32(ds.Tables[0].Rows[0]["PromotionId"]),
                        Convert.ToString(ds.Tables[0].Rows[0]["PromotionName"]),
                        Convert.ToInt32(ds.Tables[0].Rows[0]["PromotionCategoryId"]),
                        Convert.ToString(ds.Tables[0].Rows[0]["PromotionCategory"]),
                        Convert.ToString(ds.Tables[0].Rows[0]["PromotionCode"]),
                        Convert.ToDateTime(ds.Tables[0].Rows[0]["StartDate"]),
                        Convert.ToDateTime(ds.Tables[0].Rows[0]["EndDate"]),                                //check for null
                        Convert.ToDateTime(ds.Tables[0].Rows[0]["DurationStart"]),                          //check for null
                        Convert.ToDateTime(ds.Tables[0].Rows[0]["DurationEnd"]),                            //check for null
                        Convert.ToInt32(ds.Tables[0].Rows[0]["DiscountTypeId"]),                            //check for null
                        Validators.CheckForDBNull(ds.Tables[0].Rows[0]["DiscountType"], String.Empty),      //check for null
                        Convert.ToDecimal(ds.Tables[0].Rows[0]["DiscountValue"]),                           //check for null
                        Convert.ToDecimal(ds.Tables[0].Rows[0]["MaxOrderQty"]),
                        Convert.ToInt32(ds.Tables[0].Rows[0]["StatusId"]),
                        Convert.ToString(ds.Tables[0].Rows[0]["Status"]),
                        Convert.ToInt32(ds.Tables[0].Rows[0]["CreatedBy"]),
                        Convert.ToInt32(ds.Tables[0].Rows[0]["ModifiedBy"]),
                        Convert.ToDateTime(ds.Tables[0].Rows[0]["CreatedDate"]),
                        Convert.ToDateTime(ds.Tables[0].Rows[0]["ModifiedDate"]),                                 //check for null
                        Validators.CheckForDBNull(ds.Tables[0].Rows[0]["ApplicabilityId"], Common.INT_DBNULL),    //check for null
                        Validators.CheckForDBNull(ds.Tables[0].Rows[0]["Applicability"], string.Empty),           //check for null
                        Validators.CheckForDBNull(ds.Tables[0].Rows[0]["BuyConditionTypeId"], Common.INT_DBNULL), //check for null
                        Validators.CheckForDBNull(ds.Tables[0].Rows[0]["BuyConditionType"], string.Empty),
                        Validators.CheckForDBNull(ds.Tables[0].Rows[0]["GetConditionTypeId"], Common.INT_DBNULL),
                        Validators.CheckForDBNull(ds.Tables[0].Rows[0]["GetConditionType"], string.Empty),
                        Convert.ToInt32(ds.Tables[0].Rows[0]["RepeatFactor"]),
                        conditions, locations, null,
                        #region Shopping Cart
                        Convert.ToBoolean(ds.Tables[0].Rows[0]["POS"]),
                        Convert.ToBoolean(ds.Tables[0].Rows[0]["Web"]),
                        Convert.ToString(ds.Tables[0].Rows[0]["WebImage"])
                        #endregion

                        );
                }
            }
            return(promotion);
        }