Exemple #1
0
        /// <summary>
        /// 转账实体转参数
        /// </summary>
        public static SqlParameter[] ModelToParms(ZhuanZhangInfo zhuan)
        {
            SqlParameter[] parms = {
                    new SqlParameter("@ZhuanZhangID", SqlDbType.Int),
                    new SqlParameter("@ZhuanZhangFrom", SqlDbType.Int),
                    new SqlParameter("@ZhuanZhangTo", SqlDbType.Int),
                    new SqlParameter("@ZhuanZhangDate", SqlDbType.DateTime),
                    new SqlParameter("@ZhuanZhangMoney", SqlDbType.Decimal),
                    new SqlParameter("@ZhuanZhangLive", SqlDbType.TinyInt),
                    new SqlParameter("@Synchronize", SqlDbType.TinyInt),
                    new SqlParameter("@ModifyDate", SqlDbType.DateTime),
                    new SqlParameter("@UserID", SqlDbType.Int),
                    new SqlParameter("@ZhuanZhangNote", SqlDbType.NVarChar, 100),
                    new SqlParameter("@ZZID", SqlDbType.Int)
            };
            parms[0].Value = zhuan.ZhuanZhangID;
            parms[1].Value = zhuan.ZhuanZhangFrom;
            parms[2].Value = zhuan.ZhuanZhangTo;
            parms[3].Value = zhuan.ZhuanZhangDate;
            parms[4].Value = zhuan.ZhuanZhangMoney;
            parms[5].Value = zhuan.ZhuanZhangLive;
            parms[6].Value = zhuan.Synchronize;
            parms[7].Value = zhuan.ModifyDate;
            parms[8].Value = zhuan.UserID;
            parms[9].Value = zhuan.ZhuanZhangNote;
            parms[10].Value = zhuan.ZZID;

            return parms;
        }
Exemple #2
0
        /// <summary>
        /// 数据转转账实体
        /// </summary>
        public static ZhuanZhangInfo DataToModel(SqlDataReader rdr)
        {
            ZhuanZhangInfo zhang = new ZhuanZhangInfo();
            if (!rdr.IsDBNull(0)) zhang.ZhuanZhangID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) zhang.ZhuanZhangFrom = rdr.GetInt32(1);
            if (!rdr.IsDBNull(2)) zhang.ZhuanZhangTo = rdr.GetInt32(2);
            if (!rdr.IsDBNull(3)) zhang.ZhuanZhangDate = rdr.GetDateTime(3);
            if (!rdr.IsDBNull(4)) zhang.ZhuanZhangMoney = rdr.GetDecimal(4);
            if (!rdr.IsDBNull(5)) zhang.ZhuanZhangLive = rdr.GetByte(5);
            if (!rdr.IsDBNull(7)) zhang.Synchronize = rdr.GetByte(6);
            if (!rdr.IsDBNull(6)) zhang.ModifyDate = rdr.GetDateTime(7);
            if (!rdr.IsDBNull(7)) zhang.UserID = rdr.GetInt32(8);
            if (!rdr.IsDBNull(7)) zhang.ZhuanZhangNote = rdr.GetString(9);
            if (!rdr.IsDBNull(7)) zhang.ZZID = rdr.GetInt32(10);

            return zhang;
        }
Exemple #3
0
    //转账
    protected void SubmitButtom_Click(object sender, EventArgs e)
    {
        int cardId = Convert.ToInt32(this.CardIDEditHid.Value);
        int toCardId = Convert.ToInt32(this.CardDownEdit.SelectedValue);
        string cardMoney = this.CardMoneyEdit.Text.Trim();
        string cardDate = this.CardDateEdit.Text;

        if (!ValidHelper.CheckDouble(cardMoney))
        {
            Utility.Alert(this, "金额填写错误!");
            return;
        }

        if (cardId == toCardId)
        {
            Utility.Alert(this, "不允许转给相同钱包!");
            return;
        }

        using (TransactionScope ts = new TransactionScope())
        {
            CardInfo card = new CardInfo();
            UserInfo user = user_bll.GetUserByUserId(userId);
            decimal newMoney = Convert.ToDecimal(cardMoney);

            if (cardId == 0)
            {
                if (user.IsUpdate == 1)
                {
                    user.MoneyStart = user.MoneyStart - newMoney;
                }
                else
                {
                    user.UserMoney = user.UserMoney - newMoney;
                }
                user.ModifyDate = DateTime.Now;
                user.Synchronize = 1;

                user_bll.UpdateUser(user);
            }
            else
            {
                card = bll.GetCardByCardId(userId, cardId);
                if (user.IsUpdate == 1)
                {
                    card.MoneyStart = card.MoneyStart - newMoney;
                }
                else
                {
                    card.CardMoney = card.CardMoney - newMoney;
                }
                card.ModifyDate = DateTime.Now;
                card.Synchronize = 1;

                bll.UpdateCard(card);
            }

            if (toCardId == 0)
            {
                if (user.IsUpdate == 1)
                {
                    user.MoneyStart = user.MoneyStart + newMoney;
                }
                else
                {
                    user.UserMoney = user.UserMoney + newMoney;
                }
                user.ModifyDate = DateTime.Now;
                user.Synchronize = 1;

                user_bll.UpdateUser(user);
            }
            else
            {
                card = bll.GetCardByCardId(userId, toCardId);
                if (user.IsUpdate == 1)
                {
                    card.MoneyStart = card.MoneyStart + newMoney;
                }
                else
                {
                    card.CardMoney = card.CardMoney + newMoney;
                }
                card.ModifyDate = DateTime.Now;
                card.Synchronize = 1;

                bll.UpdateCard(card);
            }

            ZhuanZhangInfo zhuan = new ZhuanZhangInfo();
            zhuan.ZhuanZhangFrom = cardId;
            zhuan.ZhuanZhangTo = toCardId;
            zhuan.ZhuanZhangDate = Convert.ToDateTime(cardDate);
            zhuan.ZhuanZhangMoney = Convert.ToDecimal(cardMoney);
            zhuan.ZhuanZhangLive = 1;
            zhuan.Synchronize = 1;
            zhuan.ModifyDate = DateTime.Now;
            zhuan.UserID = userId;
            zhuan.ZZID = zhuan_bll.GetMaxZhuanZhangId(userId);

            bool success = zhuan_bll.InsertZhuanZhang(zhuan);
            if (!success)
            {
                Utility.Alert(this, "保存转账记录失败!");
            }

            ts.Complete();
        }

        Response.Redirect("UserCardAdmin.aspx");
    }
Exemple #4
0
        /// <summary>
        /// 修改转账
        /// </summary>
        public bool UpdateZhuanZhang(ZhuanZhangInfo zhuan)
        {
            SqlParameter[] parms = ModelToParms(zhuan);

            int result = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.StoredProcedure, SQL_UPDATE_ZHUANZHANG, parms);

            return result > 0;
        }
Exemple #5
0
        /// <summary>
        /// 根据转账ID取转账,返回实体
        /// </summary>
        public ZhuanZhangInfo GetZhuanZhangByZZID(int userId, int zzId)
        {
            ZhuanZhangInfo zhang = new ZhuanZhangInfo();

            SqlParameter[] parms = {
                   new SqlParameter(PARM_USER_ID, SqlDbType.Int),
                   new SqlParameter(PARM_ZZ_ID, SqlDbType.Int)
            };
            parms[0].Value = userId;
            parms[1].Value = zzId;

            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.Text, SQL_SELECT_ZHUANZHANG_BY_ZZID, parms))
            {
                while (rdr.Read())
                {
                    zhang = DataToModel(rdr);
                }
            }

            return zhang;
        }
Exemple #6
0
 /// <summary>
 /// 修改转账
 /// </summary>
 public bool UpdateZhuanZhang(ZhuanZhangInfo zhang)
 {
     return dal.UpdateZhuanZhang(zhang);
 }
Exemple #7
0
 /// <summary>
 /// 插入转账
 /// </summary>
 public bool InsertZhuanZhang(ZhuanZhangInfo zhuan)
 {
     return dal.InsertZhuanZhang(zhuan);
 }