Пример #1
0
 public static FullFreeInfo PopulateFullFree(IDataRecord reader)
 {
     if (reader == null)
     {
         return null;
     }
     FullFreeInfo info = new FullFreeInfo();
     info.ActivityId = (int) reader["ActivityId"];
     info.Name = (string) reader["Name"];
     if (DBNull.Value != reader["Description"])
     {
         info.Description = (string) reader["Description"];
     }
     info.Amount = (decimal) reader["Amount"];
     info.ShipChargeFree = (bool) reader["ShipChargeFree"];
     info.ServiceChargeFree = (bool) reader["ServiceChargeFree"];
     info.OptionFeeFree = (bool) reader["OptionFeeFree"];
     return info;
 }
Пример #2
0
        public static PromotionInfo PopulatePromote(IDataRecord reader)
        {
            if (reader == null)
            {
                return null;
            }
            PromotionInfo info = null;
            switch (((PromoteType) reader["PromoteType"]))
            {
                case PromoteType.FullDiscount:
                    info = new FullDiscountInfo();
                    break;

                case PromoteType.FullFree:
                    info = new FullFreeInfo();
                    break;

                case PromoteType.PurchaseGift:
                    info = new PurchaseGiftInfo();
                    break;

                case PromoteType.WholesaleDiscount:
                    info = new WholesaleDiscountInfo();
                    break;
            }
            info.ActivityId = (int) reader["ActivityId"];
            info.Name = (string) reader["Name"];
            if (DBNull.Value != reader["Description"])
            {
                info.Description = (string) reader["Description"];
            }
            return info;
        }
Пример #3
0
        protected void btnAddFeeFree_Click(object sender, EventArgs e)
        {
            decimal Amount = 0m;

            string str = string.Empty;

            if (ValidateValues(out Amount))
            {
                if (!((chkShipChargeFee.Checked || chkServiceChargeFree.Checked) || chkPackingChargeFree.Checked))
                {
                    str = str + Formatter.FormatErrorMessage("请选择此促销活动要免除的订单费用");
                }
                if (chklMemberGrade.SelectedValue.Count <= 0)
                {
                    str = str + Formatter.FormatErrorMessage("适合的客户必须选择一个");
                }
                if (!addpromoteSales.IsValid)
                {
                    ShowMsg(addpromoteSales.CurrentErrors, false);
                }
                else
                {
                    FullFreeInfo target = new FullFreeInfo();

                    target.Name = addpromoteSales.Item.Name;
                    target.Description = addpromoteSales.Item.Description;
                    target.Amount = Amount;
                    target.ShipChargeFree = chkShipChargeFee.Checked;
                    target.OptionFeeFree = chkPackingChargeFree.Checked;
                    target.ServiceChargeFree = chkServiceChargeFree.Checked;
                    target.MemberGradeIds = chklMemberGrade.SelectedValue;

                    ValidationResults results = Hishop.Components.Validation.Validation.Validate<FullFreeInfo>(target, new string[] { "ValPromotion" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
                        {
                            str = str + Formatter.FormatErrorMessage(result.Message);
                        }
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        ShowMsg(str, false);
                    }
                    else
                    {
                        switch (SubsitePromoteHelper.AddPromotion(target))
                        {
                            case PromotionActionStatus.Success:
                                txtAmount.Text = string.Empty;
                                chkShipChargeFee.Checked = false;
                                chkPackingChargeFree.Checked = false;
                                chkServiceChargeFree.Checked = false;
                                addpromoteSales.Reset();
                                ShowMsg("成功添加了一个满额免费用促销活动", true);
                                return;

                            case PromotionActionStatus.DuplicateName:
                                ShowMsg("添加促销活动失败,存在相同的促销活动名称", false);
                                return;

                            case PromotionActionStatus.SameCondition:
                                ShowMsg("已经存在相同满足条件的优惠活动", false);
                                return;
                        }
                        txtAmount.Text = string.Empty;
                        chkShipChargeFee.Checked = false;
                        chkPackingChargeFree.Checked = false;
                        chkServiceChargeFree.Checked = false;
                        addpromoteSales.Reset();
                        ShowMsg("添加促销活动失败", false);
                    }
                }
            }
        }
Пример #4
0
 public abstract PromotionActionStatus CreateFullFree(FullFreeInfo promote);
Пример #5
0
 public override FullFreeInfo GetFullFreeInfo(int activeId)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM distro_Promotions P INNER JOIN distro_FullFree F ON P.ActivityId=F.ActivityId WHERE P.ActivityId=@ActivityId AND P.DistributorUserId=@DistributorUserId");
     database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     database.AddInParameter(sqlStringCommand, "ActivityId", DbType.Int32, activeId);
     PromotionInfo info = new PromotionInfo();
     FullFreeInfo info2 = new FullFreeInfo();
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulatePromote(reader);
             info2 = DataMapper.PopulateFullFree(reader);
         }
         info2.Name = info.Name;
         info2.Description = info.Description;
     }
     return info2;
 }
Пример #6
0
 public override PromotionActionStatus CreateFullFree(FullFreeInfo promote)
 {
     PromotionActionStatus unknowError = PromotionActionStatus.UnknowError;
     using (DbConnection connection = database.CreateConnection())
     {
         connection.Open();
         DbTransaction tran = connection.BeginTransaction();
         try
         {
             int activityId = CreatePromotion(promote, tran);
             if (activityId > 0)
             {
                 if (((promote.MemberGradeIds != null) && (promote.MemberGradeIds.Count > 0)) && (ReSetPromotionMemberGraders(activityId, promote.MemberGradeIds, tran) <= 0))
                 {
                     tran.Rollback();
                 }
                 DbCommand storedProcCommand = database.GetStoredProcCommand("sub_Promotions_AddFullFree");
                 database.AddInParameter(storedProcCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
                 database.AddInParameter(storedProcCommand, "ActivityId", DbType.Int32, activityId);
                 database.AddInParameter(storedProcCommand, "Amount", DbType.Currency, promote.Amount);
                 database.AddInParameter(storedProcCommand, "ShipChargeFree", DbType.Boolean, promote.ShipChargeFree);
                 database.AddInParameter(storedProcCommand, "ServiceChargeFree", DbType.Boolean, promote.ServiceChargeFree);
                 database.AddInParameter(storedProcCommand, "OptionFeeFree", DbType.Boolean, promote.OptionFeeFree);
                 database.AddParameter(storedProcCommand, "ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, string.Empty, DataRowVersion.Default, null);
                 database.ExecuteNonQuery(storedProcCommand, tran);
                 unknowError = (PromotionActionStatus)Convert.ToInt32(database.GetParameterValue(storedProcCommand, "ReturnValue"));
                 if (unknowError == PromotionActionStatus.Success)
                 {
                     tran.Commit();
                 }
                 else
                 {
                     tran.Rollback();
                 }
             }
             else if (activityId == 0)
             {
                 unknowError = PromotionActionStatus.DuplicateName;
                 tran.Rollback();
             }
         }
         catch
         {
             if (tran.Connection != null)
             {
                 tran.Rollback();
             }
             unknowError = PromotionActionStatus.UnknowError;
         }
         connection.Close();
     }
     return unknowError;
 }