public CashBackInfo GetCashBackInfo(int cashBackId)
        {
            CashBackInfo info             = null;
            DbCommand    sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_CashBack WHERE CashBackId=@CashBackId");

            this.database.AddInParameter(sqlStringCommand, "CashBackId", DbType.Int32, cashBackId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if ((reader != null) && reader.Read())
                {
                    info = new CashBackInfo {
                        CashBackId     = cashBackId,
                        UserId         = (int)reader["UserId"],
                        CashBackAmount = (decimal)reader["CashBackAmount"],
                        RechargeAmount = (decimal)reader["RechargeAmount"],
                        Percentage     = (decimal)reader["Percentage"],
                        CashBackType   = (CashBackTypes)((int)reader["CashBackType"]),
                        IsValid        = (bool)reader["IsValid"],
                        IsFinished     = (bool)reader["IsFinished"],
                        CreateDate     = (DateTime)reader["CreateDate"]
                    };
                    if (DBNull.Value != reader["FinishedDate"])
                    {
                        info.FinishedDate = new DateTime?((DateTime)reader["FinishedDate"]);
                    }
                }
            }
            return(info);
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.dropCashBackTypes.DataBind();
            }
            string s = base.Request.QueryString["CashBackId"];

            if (int.TryParse(s, out this.cashBackId))
            {
                this.opt = "修改";
                if (!this.Page.IsPostBack)
                {
                    CashBackInfo cashBackInfo = CashBackHelper.GetCashBackInfo(this.cashBackId);
                    if (cashBackInfo != null)
                    {
                        this.hidAction.Value                 = "EDIT";
                        this.txtUserName.Text                = MemberHelper.GetMember(cashBackInfo.UserId).UserName;
                        this.txtUserId.Value                 = cashBackInfo.UserId.ToString();
                        this.txtRechargeAmount.Text          = cashBackInfo.RechargeAmount.ToString("f2");
                        this.txtPercentage.Text              = cashBackInfo.Percentage.ToString("f2");
                        this.cbIsDefault.Checked             = cashBackInfo.IsValid;
                        this.dropCashBackTypes.SelectedValue = new int?((int)cashBackInfo.CashBackType);
                        this.dropCashBackTypes.Enabled       = false;
                        this.txtPercentage.Text              = cashBackInfo.Percentage.ToString("F2");
                    }
                }
            }
        }
        public IList <CashBackInfo> GetUnFinishedCashBackList()
        {
            IList <CashBackInfo> list             = new List <CashBackInfo>();
            CashBackInfo         item             = null;
            DbCommand            sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_CashBack WHERE IsValid=1 AND IsFinished=0");

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                while ((reader != null) && reader.Read())
                {
                    item = new CashBackInfo {
                        CashBackId     = (int)reader["CashBackId"],
                        UserId         = (int)reader["UserId"],
                        CashBackAmount = (decimal)reader["CashBackAmount"],
                        RechargeAmount = (decimal)reader["RechargeAmount"],
                        Percentage     = (decimal)reader["Percentage"],
                        CashBackType   = (CashBackTypes)((int)reader["CashBackType"]),
                        IsValid        = (bool)reader["IsValid"],
                        IsFinished     = (bool)reader["IsFinished"],
                        CreateDate     = (DateTime)reader["CreateDate"]
                    };
                    if (DBNull.Value != reader["FinishedDate"])
                    {
                        item.FinishedDate = new DateTime?((DateTime)reader["FinishedDate"]);
                    }
                    list.Add(item);
                }
            }
            return(list);
        }
        public bool AddCashBack(CashBackInfo cashBackInfo)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Hishop_CashBack (UserId, RechargeAmount,CashBackAmount,Percentage,CashBackType,CreateDate,IsValid,IsFinished) VALUES(@UserId, @RechargeAmount,@CashBackAmount,@Percentage,@CashBackType,@CreateDate,@IsValid,@IsFinished)");

            this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, cashBackInfo.UserId);
            this.database.AddInParameter(sqlStringCommand, "RechargeAmount", DbType.Decimal, cashBackInfo.RechargeAmount);
            this.database.AddInParameter(sqlStringCommand, "CashBackAmount", DbType.Decimal, cashBackInfo.CashBackAmount);
            this.database.AddInParameter(sqlStringCommand, "Percentage", DbType.Decimal, cashBackInfo.Percentage);
            this.database.AddInParameter(sqlStringCommand, "CashBackType", DbType.Int32, (int)cashBackInfo.CashBackType);
            this.database.AddInParameter(sqlStringCommand, "CreateDate", DbType.DateTime, cashBackInfo.CreateDate);
            this.database.AddInParameter(sqlStringCommand, "IsValid", DbType.Boolean, cashBackInfo.IsValid);
            this.database.AddInParameter(sqlStringCommand, "IsFinished", DbType.Boolean, cashBackInfo.IsFinished);
            return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
        }
        protected void btnAddCashBack_Click(object sender, EventArgs e)
        {
            string str = this.hidAction.Value;

            if (str != null)
            {
                if (!(str == "ADD"))
                {
                    if (!(str == "EDIT"))
                    {
                        return;
                    }
                }
                else
                {
                    CashBackInfo info = new CashBackInfo
                    {
                        UserId         = int.Parse(this.txtUserId.Value),
                        RechargeAmount = decimal.Parse(this.txtRechargeAmount.Text),
                        CashBackAmount = 0M,
                        Percentage     = decimal.Parse(this.txtPercentage.Text),
                        IsValid        = this.cbIsDefault.Checked,
                        IsFinished     = false,
                        FinishedDate   = null,
                        CreateDate     = DateTime.Now,
                        CashBackType   = (CashBackTypes)this.dropCashBackTypes.SelectedValue.Value
                    };
                    if (CashBackHelper.AddCashBack(info))
                    {
                        this.ShowMsg("增加充值返现成功", true);
                        return;
                    }
                    this.ShowMsg("增加充值返现失败", false);
                    return;
                }
                CashBackInfo cashBackInfo = CashBackHelper.GetCashBackInfo(this.cashBackId);
                cashBackInfo.UserId         = int.Parse(this.txtUserId.Value);
                cashBackInfo.RechargeAmount = decimal.Parse(this.txtRechargeAmount.Text);
                cashBackInfo.Percentage     = decimal.Parse(this.txtPercentage.Text);
                cashBackInfo.IsValid        = this.cbIsDefault.Checked;
                if (CashBackHelper.UpdateCashBack(cashBackInfo, null))
                {
                    this.ShowMsg("修改充值返现成功", true);
                }
                else
                {
                    this.ShowMsg("修改充值返现失败", false);
                }
            }
        }
Beispiel #6
0
        private void BindCashBack()
        {
            CashBackInfo cashBackInfo = CashBackHelper.GetCashBackInfo(int.Parse(base.Request.QueryString["CashBackId"]));
            MemberInfo   member       = MemberHelper.GetMember(cashBackInfo.UserId);

            this.litUserName.Text       = member.UserName;
            this.litAmount.Text         = member.AvailableAmount.ToString("F2");
            this.litPoints.Text         = member.Points.ToString();
            this.litRechargeAmount.Text = cashBackInfo.RechargeAmount.ToString("f2");
            this.litIsValid.Text        = cashBackInfo.IsValid ? "有效" : "失效";
            this.litCashBackAmount.Text = cashBackInfo.CashBackAmount.ToString("F2");
            this.litPercentage.Text     = cashBackInfo.Percentage.ToString("F2") + "%";
            this.litFinished.Text       = cashBackInfo.IsFinished ? "已完成" : "返现中";
            this.litCashBackType.Text   = cashBackInfo.CashBackType.ToString();
        }
        public bool UpdateCashBack(CashBackInfo cashBackInfo, DbTransaction dbTrans = null)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_CashBack SET RechargeAmount=@RechargeAmount,IsFinished=@IsFinished,CashBackAmount=@CashBackAmount,Percentage=@Percentage,IsValid=@IsValid WHERE CashBackId=@CashBackId");

            this.database.AddInParameter(sqlStringCommand, "RechargeAmount", DbType.Decimal, cashBackInfo.RechargeAmount);
            this.database.AddInParameter(sqlStringCommand, "CashBackAmount", DbType.Decimal, cashBackInfo.CashBackAmount);
            this.database.AddInParameter(sqlStringCommand, "Percentage", DbType.Decimal, cashBackInfo.Percentage);
            this.database.AddInParameter(sqlStringCommand, "CashBackType", DbType.Int32, (int)cashBackInfo.CashBackType);
            this.database.AddInParameter(sqlStringCommand, "IsValid", DbType.Boolean, cashBackInfo.IsValid);
            this.database.AddInParameter(sqlStringCommand, "IsFinished", DbType.Boolean, cashBackInfo.IsFinished);
            this.database.AddInParameter(sqlStringCommand, "CashBackId", DbType.Int32, cashBackInfo.CashBackId);
            if (dbTrans == null)
            {
                return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
            }
            return(this.database.ExecuteNonQuery(sqlStringCommand, dbTrans) > 0);
        }
Beispiel #8
0
 public static bool UpdateCashBack(CashBackInfo cashBackInfo, DbTransaction dbTrans = null)
 {
     return(new CashBackDao().UpdateCashBack(cashBackInfo, dbTrans));
 }
Beispiel #9
0
 public static bool AddCashBack(CashBackInfo cashBackInfo)
 {
     return(new CashBackDao().AddCashBack(cashBackInfo));
 }