Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(ModStamp model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update N_Stamp set ");
            strSql.Append("StampNo=@StampNo,");
            strSql.Append("Password=@Password,");
            strSql.Append("IsUsed=@IsUsed,");
            strSql.Append("StampMoney=@StampMoney,");
            strSql.Append("StampOutTime=@StampOutTime,");
            strSql.Append("StampType=@StampType,");
            strSql.Append("AddTime=@AddTime");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.Int,        4),
                new SqlParameter("@StampNo",      SqlDbType.VarChar,   50),
                new SqlParameter("@Password",     SqlDbType.VarChar,   50),
                new SqlParameter("@IsUsed",       SqlDbType.Int,        4),
                new SqlParameter("@StampMoney",   SqlDbType.Int,        4),
                new SqlParameter("@StampOutTime", SqlDbType.DateTime),
                new SqlParameter("@StampType",    SqlDbType.Int,        4),
                new SqlParameter("@AddTime",      SqlDbType.DateTime)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.StampNo;
            parameters[2].Value = model.Password;
            parameters[3].Value = model.IsUsed;
            parameters[4].Value = model.StampMoney;
            parameters[5].Value = model.StampOutTime;
            parameters[6].Value = model.StampType;
            parameters[7].Value = model.AddTime;

            return(adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters));
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ModStamp model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into N_Stamp(");
            strSql.Append("StampNo,Password,IsUsed,StampMoney,StampOutTime,StampType,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@StampNo,@Password,@IsUsed,@StampMoney,@StampOutTime,@StampType,@AddTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StampNo",      SqlDbType.VarChar,   50),
                new SqlParameter("@Password",     SqlDbType.VarChar,   50),
                new SqlParameter("@IsUsed",       SqlDbType.Int,        4),
                new SqlParameter("@StampMoney",   SqlDbType.Int,        4),
                new SqlParameter("@StampOutTime", SqlDbType.DateTime),
                new SqlParameter("@StampType",    SqlDbType.Int,        4),
                new SqlParameter("@AddTime",      SqlDbType.DateTime)
            };
            parameters[0].Value = model.StampNo;
            parameters[1].Value = model.Password;
            parameters[2].Value = model.IsUsed;
            parameters[3].Value = model.StampMoney;
            parameters[4].Value = model.StampOutTime;
            parameters[5].Value = model.StampType;
            parameters[6].Value = model.AddTime;

            return(adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters));
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ModStamp GetModel(string StampNo)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,StampNo,Password,IsUsed,StampMoney,StampOutTime,StampType,AddTime from N_Stamp ");
            strSql.Append(" where StampNo=@StampNo ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StampNo", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = StampNo;

            ModStamp model = new ModStamp();
            DataSet  ds    = adoHelper.ExecuteSqlDataset(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.StampNo  = ds.Tables[0].Rows[0]["StampNo"].ToString();
                model.Password = ds.Tables[0].Rows[0]["Password"].ToString();
                if (ds.Tables[0].Rows[0]["IsUsed"].ToString() != "")
                {
                    model.IsUsed = int.Parse(ds.Tables[0].Rows[0]["IsUsed"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StampMoney"].ToString() != "")
                {
                    model.StampMoney = int.Parse(ds.Tables[0].Rows[0]["StampMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StampOutTime"].ToString() != "")
                {
                    model.StampOutTime = DateTime.Parse(ds.Tables[0].Rows[0]["StampOutTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StampType"].ToString() != "")
                {
                    model.StampType = int.Parse(ds.Tables[0].Rows[0]["StampType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// 使用消费券充值(1:充值成功,小于0充值失败)
        /// </summary>
        public int RegStamp(string stampNum, string userID)
        {
            //获取消费券信息
            ModStamp modStamp = GetModel(stampNum);

            if (modStamp != null)
            {
                if (modStamp.IsUsed == 1)
                {
                    return(-3);
                }
                //记录到充值明细表
                MemberCZRecordBLL   bllMember = new MemberCZRecordBLL();
                MemberCZRecordModel modMoney  = new MemberCZRecordModel();
                MemberCZRecordDAL   dalMoney  = new MemberCZRecordDAL();
                modMoney.memberId  = int.Parse(userID);
                modMoney.addTime   = DateTime.Now;
                modMoney.addPerson = "平台会员";
                modMoney.moneyType = "XFQ";
                modMoney.shFlag    = 1;//自动审核成功
                modMoney.shTime    = DateTime.Now;
                modMoney.shPerson  = "自动审核";
                modMoney.remarks   = ""; //使用消费券
                modMoney.money     = (int)(modStamp.StampMoney / 100);
                string s = Convert.ToString(modStamp.StampMoney / 100);

                if (bllMember.Add(modMoney) > 0)
                {
                    //修改会员总金额
                    if (dalMoney.UpdateMemberCount("XFQ", s, userID) > 0)
                    {
                        UpdateToUse(stampNum); return(1);
                    }
                    else
                    {
                        return(-2);
                    }
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                return(-9999);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(ModStamp model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ModStamp model)
 {
     return(dal.Add(model));
 }