Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCWeiXin.Model.wx_ucard_users GetStoreUserInfo(string oepnid, int sid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wid,sid,openid,cardNo,pwd,degreeId,sex,birthday,wxName,realName,age,qq,regTime,regIp,telphone,mobile,email,addr,endDate,ttScore,qdScore,consumeScore,consumeMoney,subscribe,language,city,province,country,headimgul,subscribe_time,unsubscribe_time,groupid,groupname from wx_ucard_users ");
            strSql.Append(" where sid=@sid and openid=@openid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sid",    SqlDbType.Int,     4),
                new SqlParameter("@openid", SqlDbType.VarChar, 100)
            };
            parameters[0].Value = sid;
            parameters[1].Value = oepnid;
            XCWeiXin.Model.wx_ucard_users model = new XCWeiXin.Model.wx_ucard_users();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string _action = MyCommFun.QueryString("myact");
            string openid  = MyCommFun.RequestOpenid(); //得到微信用户的openid
            Dictionary <string, string> jsonDict = new Dictionary <string, string>();
            int sid = MyCommFun.RequestInt("sid");
            int uid = 0;

            BLL.wx_ucard_store               storeBll = new BLL.wx_ucard_store();
            BLL.wx_ucard_users_consumeinfo   conBll   = new BLL.wx_ucard_users_consumeinfo();
            BLL.wx_ucard_score               scoreBll = new BLL.wx_ucard_score();
            BLL.wx_ucard_users               userBll  = new BLL.wx_ucard_users();
            Model.wx_ucard_users_consumeinfo consume  = new Model.wx_ucard_users_consumeinfo();
            Model.wx_ucard_score             score    = new Model.wx_ucard_score();
            Model.wx_ucard_store             store    = storeBll.GetModel(sid);
            if (store == null)
            {
                jsonDict.Add("ret", "err");
                jsonDict.Add("msg", "店铺不存在");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                return;
            }

            if (_action == "userreg")
            {
                #region //用户第一次领取卡
                jsonDict = new Dictionary <string, string>();

                if (sid == 0)
                {
                    jsonDict.Add("ret", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                string tel      = MyCommFun.QueryString("tel");
                string realName = MyCommFun.QueryString("truename");

                XCWeiXin.Model.wx_ucard_users user = userBll.GetStoreUserInfo(openid, sid);
                if (user == null)
                { //第一次添加
                    user              = new Model.wx_ucard_users();
                    user.mobile       = tel;
                    user.realName     = realName;
                    user.regTime      = DateTime.Now;
                    user.sid          = sid;
                    user.openid       = openid;
                    user.ttScore      = 0;
                    user.consumeScore = 0;
                    user.qdScore      = 0;
                    user.consumeMoney = 0;
                    user.regIp        = MXRequest.GetIP();
                    int ret = userBll.Add(user);
                    if (ret > 0)
                    {
                        jsonDict.Add("ret", "succ");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    }
                    else
                    {
                        jsonDict.Add("ret", "err");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    }
                }
                else
                {
                    user.mobile   = tel;
                    user.realName = realName;
                    user.regTime  = DateTime.Now;
                    user.sid      = sid;
                    user.openid   = openid;
                    user.regIp    = MXRequest.GetIP();
                    bool ret = userBll.Update(user);
                    if (ret)
                    {
                        jsonDict.Add("ret", "succ");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    }
                    else
                    {
                        jsonDict.Add("ret", "err");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    }
                }

                context.Response.End();
                #endregion
            }
            else if (_action == "qiandao")
            {
                #region 签到
                jsonDict = new Dictionary <string, string>();
                sid      = MyCommFun.RequestInt("sid");
                uid      = MyCommFun.RequestInt("uid");
                if (sid == 0 || uid == 0)
                {
                    jsonDict.Add("ret", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                bool hasqd    = conBll.hasDayQD(sid, uid, DateTime.Now);
                int  retScore = 0;
                if (!hasqd)
                {
                    //新增
                    //取签到积分策略
                    score = scoreBll.GetStoreModel(sid);
                    if (score != null)
                    {
                        //判断是否6天连续签到,并且6天内没有给额外的奖励

                        DateTime day6before = DateTime.Now.AddDays(-6);

                        int record = conBll.GetRecordCount("sId=" + sid + " and uid=" + uid + " and moduleType='签到' and addTime>='" + day6before.ToShortDateString() + "' and addTime<'" + DateTime.Now.ToShortDateString() + "' and  moduleActionId=6 ");

                        if (record >= 5)
                        {
                            consume                  = new Model.wx_ucard_users_consumeinfo();
                            consume.sId              = sid;
                            consume.uid              = uid;
                            consume.moduleType       = "签到";
                            consume.moduleActionName = "连续6天签到奖励";
                            consume.moduleActionId   = 6;
                            consume.score            = MyCommFun.Obj2Int(score.qiandao6Score) + score.qiandaoScore.Value;
                            conBll.AddJiFen(consume, 0);
                            retScore = MyCommFun.Obj2Int(score.qiandao6Score) + score.qiandaoScore.Value;
                        }
                        else
                        {
                            consume            = new Model.wx_ucard_users_consumeinfo();
                            consume.sId        = sid;
                            consume.uid        = uid;
                            consume.moduleType = "签到";
                            consume.score      = score.qiandaoScore.Value;
                            conBll.AddJiFen(consume, 0);
                            retScore = score.qiandaoScore.Value;
                        }
                    }
                }

                jsonDict.Add("ret", "succ");
                jsonDict.Add("msg", "+" + retScore + "分,明天继续");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));

                #endregion
            }
            else if (_action == "tequan")
            {
                #region  //消费: 特权 ,注意,只有在新增这个的时候记录user表总积分,修改的时候 对user表的总积分和金额先减后加

                jsonDict = new Dictionary <string, string>();
                sid      = MyCommFun.RequestInt("sid"); //店铺id
                uid      = MyCommFun.RequestInt("uid"); //用户id
                string sn    = MyCommFun.QueryString("sncode");
                string pwd   = MyCommFun.QueryString("parssword");
                float  money = MyCommFun.RequestFloat("money", 0);
                int    pid   = MyCommFun.RequestInt("pid");   //特权主键id
                string type  = MyCommFun.QueryString("type"); //tequan:特权
                if (sid == 0 || uid == 0 || pid == 0)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (pwd != store.consumePwd)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "密码错误");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int ssid = userBll.ExistsStoreAndUser(uid);
                if (ssid == 0 || sid != ssid)
                {  //验证,用户存在,店铺存在,并且用户属于这个店铺
                    return;
                }
                BLL.wx_ucard_privileges   privBll    = new BLL.wx_ucard_privileges();
                Model.wx_ucard_privileges privileges = privBll.GetModel(pid);
                if (privileges == null)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "特权不存在");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                //积分策略
                score = scoreBll.GetStoreModel(sid);
                int avgScore = score.consumeMoneyScore.Value / score.consumeMoney.Value;
                //1先添加消费明细,和修改用户的总积分和总消费金额
                //IList<Model.wx_ucard_users_consumeinfo> conlist = conBll.GetModelList("moduleType='特权' and moduleActionId=" + privileges.id + " and sid=" + sid + " and uid=" + uid);
                //if (conlist == null || conlist.Count <= 0 || conlist[0] == null)
                //{
                //新增
                consume = new Model.wx_ucard_users_consumeinfo();
                consume.moduleActionId   = 10;
                consume.moduleType       = "特权";
                consume.moduleActionId   = privileges.id;
                consume.moduleActionName = privileges.pName;
                consume.sId          = sid;
                consume.uid          = uid;
                consume.consumeMoney = (decimal)money;
                consume.addTime      = DateTime.Now;
                consume.sn           = sn;
                consume.pwd          = pwd;
                consume.cMoneyType   = 2;
                consume.score        = (int)(avgScore * money);
                consume.cScoreType   = 1;
                conBll.Add(consume, true);

                //}
                //else
                //{
                //    //修改
                //    consume = conlist[0];
                //    decimal oldMoney = MyCommFun.Obj2Decimal(consume.consumeMoney, 0);
                //    int oldScore = MyCommFun.Obj2Int(consume.score);


                //    consume.moduleActionName = privileges.pName;
                //    consume.consumeMoney = (decimal)money;
                //    consume.sn = sn;
                //    consume.pwd = pwd;
                //    consume.cMoneyType = 2;
                //    consume.score = (int)(avgScore * money);
                //    conBll.UpdateInfoAndUserTT(consume, oldMoney, oldScore);
                //}
                jsonDict.Add("ret", "succ");
                jsonDict.Add("msg", "获得" + consume.score.Value + "积分 ");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));

                #endregion
            }
            else if (_action == "lq_yhq")
            {
                #region 领取优惠券

                jsonDict = new Dictionary <string, string>();
                sid      = MyCommFun.RequestInt("sid"); //店铺id
                uid      = MyCommFun.RequestInt("uid"); //用户id
                string sn       = MyCommFun.QueryString("sncode");
                string pwd      = MyCommFun.QueryString("parssword");
                float  money    = MyCommFun.RequestFloat("money", 0);
                int    ticketId = MyCommFun.RequestInt("cid");//优惠券主键id

                if (sid == 0 || uid == 0 || ticketId == 0)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (pwd != store.consumePwd)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "密码错误");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int ssid = userBll.ExistsStoreAndUser(uid);
                if (ssid == 0 || sid != ssid)
                {  //验证,用户存在,店铺存在,并且用户属于这个店铺
                    return;
                }
                BLL.wx_ucard_ticket   ticketBll = new BLL.wx_ucard_ticket();
                Model.wx_ucard_ticket ticket    = ticketBll.GetModel(ticketId);
                if (ticket == null)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "优惠券不存在");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int syTimes = ticketBll.getsyTimesByTicket(uid, ticketId);
                if (syTimes <= 0)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "已没有使用次数");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                //积分策略
                score = scoreBll.GetStoreModel(sid);
                int avgScore = score.consumeMoneyScore.Value / score.consumeMoney.Value;
                //1先添加消费明细,和修改用户的总积分和总消费金额

                //新增
                consume = new Model.wx_ucard_users_consumeinfo();
                consume.moduleActionId   = 10;
                consume.moduleType       = "优惠券";
                consume.moduleActionId   = ticket.id;
                consume.moduleActionName = ticket.tName;
                consume.sId          = sid;
                consume.uid          = uid;
                consume.consumeMoney = (decimal)money;
                consume.addTime      = DateTime.Now;
                consume.sn           = sn;
                consume.pwd          = pwd;
                consume.cMoneyType   = 2;
                consume.score        = (int)(avgScore * money);
                consume.cScoreType   = 1;
                conBll.Add(consume, true);
                syTimes -= 1;

                jsonDict.Add("ret", "succ");
                jsonDict.Add("msg", "获得" + consume.score.Value + "积分 ");
                jsonDict.Add("sy", syTimes.ToString());
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));


                #endregion
            }
            else if (_action == "gift")
            {
                #region 兑换礼品券

                jsonDict = new Dictionary <string, string>();
                sid      = MyCommFun.RequestInt("sid"); //店铺id
                uid      = MyCommFun.RequestInt("uid"); //用户id
                string sn     = MyCommFun.QueryString("sncode");
                string pwd    = MyCommFun.QueryString("parssword");
                float  money  = MyCommFun.RequestFloat("money", 0);
                int    giftId = MyCommFun.RequestInt("gid");//礼品主键id

                if (sid == 0 || uid == 0 || giftId == 0)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (pwd != store.consumePwd)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "密码错误");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int ssid = userBll.ExistsStoreAndUser(uid);
                if (ssid == 0 || sid != ssid)
                {  //验证,用户存在,店铺存在,并且用户属于这个店铺
                    return;
                }
                BLL.wx_ucard_gift   giftBll = new BLL.wx_ucard_gift();
                Model.wx_ucard_gift gift    = giftBll.GetModel(giftId);
                if (gift == null)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "优惠券不存在");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int userTTScore = userBll.GetUserJiFen(uid);
                if (userTTScore < gift.score.Value)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "积分不够");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                //1先添加消费明细,和修改用户的总积分和总消费金额

                //新增
                consume = new Model.wx_ucard_users_consumeinfo();
                consume.moduleActionId   = 10;
                consume.moduleType       = "礼品券";
                consume.moduleActionId   = gift.id;
                consume.moduleActionName = gift.gName;
                consume.sId        = sid;
                consume.uid        = uid;
                consume.addTime    = DateTime.Now;
                consume.sn         = sn;
                consume.pwd        = pwd;
                consume.score      = -gift.score.Value;
                consume.cScoreType = 1;
                conBll.Add(consume, false);

                jsonDict.Add("ret", "succ");
                jsonDict.Add("msg", "成功兑换礼品扣除 " + gift.score.Value + " 积分 ");

                context.Response.Write(MyCommFun.getJsonStr(jsonDict));


                #endregion
            }
        }
Beispiel #3
0
        public string appsecret = ""; //公众微信平台下可以找到

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //获取从wxProcess.aspx传递过来的跳转地址reurl
                string              reurl   = HttpContext.Current.Session["session_reurl"].ToString();
                int                 wid     = int.Parse(HttpContext.Current.Session["session_wid"].ToString());
                BLL.wx_userweixin   wx      = new BLL.wx_userweixin();
                Model.wx_userweixin wxModel = wx.GetModel(wid);
                appid     = wxModel.AppId;
                appsecret = wxModel.AppSecret;
                string code = "";
                if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
                {
                    //获取微信回传的code
                    code = Request.QueryString["code"].ToString();
                    OAuth_Token Model           = Get_token(code);                      //获取token
                    OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                    if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
                    {
                        //绑定数据
                        wx_ucard_users       userBLL   = new wx_ucard_users();
                        Model.wx_ucard_users userModel = new XCWeiXin.Model.wx_ucard_users();
                        bool Isuser = userBLL.getUserExists(OAuthUser_Model.openid);
                        if (Isuser)
                        {
                            userModel = userBLL.GetModel(OAuthUser_Model.openid);
                        }
                        userModel.wid       = wid;
                        userModel.openid    = OAuthUser_Model.openid;
                        userModel.wxName    = OAuthUser_Model.nickname;
                        userModel.sex       = OAuthUser_Model.sex;
                        userModel.language  = OAuthUser_Model.language;
                        userModel.province  = OAuthUser_Model.province;
                        userModel.city      = OAuthUser_Model.city;
                        userModel.country   = OAuthUser_Model.country;
                        userModel.headimgul = OAuthUser_Model.headimgurl;
                        userModel.subscribe = OAuthUser_Model.subscribe;
                        //   userModel.subscribe_time =DateTime.Parse(OAuthUser_Model.subscribe_time.Trim());
                        userModel.groupid = OAuthUser_Model.groupid;


                        if (!Isuser)//没有记录,添加
                        {
                            HttpCookie cookie = new HttpCookie("xcopenid");
                            cookie.Value   = OAuthUser_Model.openid;
                            cookie.Expires = DateTime.Now.AddDays(3650);
                            HttpContext.Current.Response.Cookies.Add(cookie);

                            userBLL.Add(userModel);
                        }
                        else//有记录更新
                        {
                            HttpCookie cookie = new HttpCookie("xcopenid");
                            cookie.Value   = OAuthUser_Model.openid;
                            cookie.Expires = DateTime.Now.AddDays(3650);
                            HttpContext.Current.Response.Cookies.Add(cookie);

                            ;                            userBLL.Update(userModel);
                        }
                        Response.Redirect("" + reurl + "&openid=" + OAuthUser_Model.openid + "");
                        //   Response.Redirect(reurl);
                    }
                    else  //未获得openid,回到wxProcess.aspx,访问弹出微信授权页面,提示用户授权
                    {
                        Response.Redirect("wxProcess.aspx?auth=1");
                    }
                }
            }
        }
Beispiel #4
0
        public int init()
        {
            BLL.wx_userweixin   wx      = new BLL.wx_userweixin();
            Model.wx_userweixin wxModel = wx.GetModel(wid);
            appid     = wxModel.AppId;
            appsecret = wxModel.AppSecret;
            string code = "";

            if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
            {
                //获取微信回传的code
                code = Request.QueryString["code"].ToString();
                OAuth_Token Model           = Get_token(code);                      //获取token
                OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
                {
                    //绑定数据
                    wx_ucard_users       userBLL   = new wx_ucard_users();
                    Model.wx_ucard_users userModel = new XCWeiXin.Model.wx_ucard_users();
                    bool Isuser = userBLL.getUserExists(OAuthUser_Model.openid);
                    if (Isuser)
                    {
                        userModel = userBLL.GetModel(OAuthUser_Model.openid);
                    }
                    userModel.wid       = wid;
                    userModel.openid    = OAuthUser_Model.openid;
                    userModel.wxName    = OAuthUser_Model.nickname;
                    userModel.sex       = OAuthUser_Model.sex;
                    userModel.language  = OAuthUser_Model.language;
                    userModel.province  = OAuthUser_Model.province;
                    userModel.city      = OAuthUser_Model.city;
                    userModel.country   = OAuthUser_Model.country;
                    userModel.headimgul = OAuthUser_Model.headimgurl;
                    userModel.subscribe = OAuthUser_Model.subscribe;
                    //   userModel.subscribe_time =DateTime.Parse(OAuthUser_Model.subscribe_time.Trim());
                    userModel.groupid = OAuthUser_Model.groupid;

                    openid = OAuthUser_Model.openid;
                    if (!Isuser)//没有记录,添加
                    {
                        HttpCookie cookie = new HttpCookie("xcopenid" + wid + "");
                        cookie.Value   = OAuthUser_Model.openid;
                        cookie.Expires = DateTime.Now.AddDays(3650);
                        HttpContext.Current.Response.Cookies.Add(cookie);

                        userBLL.Add(userModel);
                        return(0);
                    }
                    else//有记录更新
                    {
                        HttpCookie cookie = new HttpCookie("xcopenid" + wid + "");
                        cookie.Value   = OAuthUser_Model.openid;
                        cookie.Expires = DateTime.Now.AddDays(3650);
                        HttpContext.Current.Response.Cookies.Add(cookie);

                        userBLL.Update(userModel);
                        return(0);
                    }

                    //  Response.Redirect("" + reurl + "&openid=" + OAuthUser_Model.openid + "");
                    //   Response.Redirect(reurl);
                }
                else      //未获得openid,回到wxProcess.aspx,访问弹出微信授权页面,提示用户授权
                {
                    return(1);
                }
            }
            else       //取code失败
            {
                return(2);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XCWeiXin.Model.wx_ucard_users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_ucard_users set ");
            strSql.Append("wid=@wid,");
            strSql.Append("sid=@sid,");
            strSql.Append("openid=@openid,");
            strSql.Append("cardNo=@cardNo,");
            strSql.Append("pwd=@pwd,");
            strSql.Append("degreeId=@degreeId,");
            strSql.Append("sex=@sex,");
            strSql.Append("birthday=@birthday,");
            strSql.Append("wxName=@wxName,");
            strSql.Append("realName=@realName,");
            strSql.Append("age=@age,");
            strSql.Append("qq=@qq,");
            strSql.Append("regTime=@regTime,");
            strSql.Append("regIp=@regIp,");
            strSql.Append("telphone=@telphone,");
            strSql.Append("mobile=@mobile,");
            strSql.Append("email=@email,");
            strSql.Append("addr=@addr,");
            strSql.Append("endDate=@endDate,");
            strSql.Append("ttScore=@ttScore,");
            strSql.Append("qdScore=@qdScore,");
            strSql.Append("consumeScore=@consumeScore,");
            strSql.Append("consumeMoney=@consumeMoney,");

            //2016.4.28将userinfo合并到此表中
            strSql.Append("subscribe=@subscribe,");
            strSql.Append("language=@language,");
            strSql.Append("city=@city,");
            strSql.Append("province=@province,");
            strSql.Append("country=@country,");
            strSql.Append("headimgul=@headimgul,");
            strSql.Append("subscribe_time=@subscribe_time,");
            strSql.Append("unsubscribe_time=@unsubscribe_time,");
            strSql.Append("groupid=@groupid,");
            strSql.Append("groupname=@groupname");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",              SqlDbType.Int,         4),
                new SqlParameter("@sid",              SqlDbType.Int,         4),
                new SqlParameter("@openid",           SqlDbType.VarChar,   100),
                new SqlParameter("@cardNo",           SqlDbType.VarChar,    50),
                new SqlParameter("@pwd",              SqlDbType.VarChar,   100),
                new SqlParameter("@degreeId",         SqlDbType.Int,         4),
                new SqlParameter("@sex",              SqlDbType.VarChar,    10),
                new SqlParameter("@birthday",         SqlDbType.DateTime),
                new SqlParameter("@wxName",           SqlDbType.VarChar,   100),
                new SqlParameter("@realName",         SqlDbType.VarChar,    50),
                new SqlParameter("@age",              SqlDbType.Int,         4),
                new SqlParameter("@qq",               SqlDbType.VarChar,    20),
                new SqlParameter("@regTime",          SqlDbType.DateTime),
                new SqlParameter("@regIp",            SqlDbType.VarChar,    20),
                new SqlParameter("@telphone",         SqlDbType.VarChar,    50),
                new SqlParameter("@mobile",           SqlDbType.VarChar,    20),
                new SqlParameter("@email",            SqlDbType.VarChar,   100),
                new SqlParameter("@addr",             SqlDbType.VarChar,   300),
                new SqlParameter("@endDate",          SqlDbType.DateTime),
                new SqlParameter("@ttScore",          SqlDbType.Int,         4),
                new SqlParameter("@qdScore",          SqlDbType.Int,         4),
                new SqlParameter("@consumeScore",     SqlDbType.Int,         4),
                new SqlParameter("@consumeMoney",     SqlDbType.Float,       8),
                //2016.4.28
                new SqlParameter("@subscribe",        SqlDbType.Int,         4),
                new SqlParameter("@language",         SqlDbType.VarChar,    20),
                new SqlParameter("@city",             SqlDbType.VarChar,    20),
                new SqlParameter("@province",         SqlDbType.VarChar,    20),
                new SqlParameter("@country",          SqlDbType.VarChar,    20),
                new SqlParameter("@headimgul",        SqlDbType.VarChar,   500),
                new SqlParameter("@subscribe_time",   SqlDbType.DateTime),
                new SqlParameter("@unsubscribe_time", SqlDbType.DateTime),
                new SqlParameter("@groupid",          SqlDbType.Int,         4),
                new SqlParameter("@groupname",        SqlDbType.VarChar,   100),
                new SqlParameter("@id",               SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.wid;
            parameters[1].Value  = model.sid;
            parameters[2].Value  = model.openid;
            parameters[3].Value  = model.cardNo;
            parameters[4].Value  = model.pwd;
            parameters[5].Value  = model.degreeId;
            parameters[6].Value  = model.sex;
            parameters[7].Value  = model.birthday;
            parameters[8].Value  = model.wxName;
            parameters[9].Value  = model.realName;
            parameters[10].Value = model.age;
            parameters[11].Value = model.qq;
            parameters[12].Value = model.regTime;
            parameters[13].Value = model.regIp;
            parameters[14].Value = model.telphone;
            parameters[15].Value = model.mobile;
            parameters[16].Value = model.email;
            parameters[17].Value = model.addr;
            parameters[18].Value = model.endDate;
            parameters[19].Value = model.ttScore;
            parameters[20].Value = model.qdScore;
            parameters[21].Value = model.consumeScore;
            parameters[22].Value = model.consumeMoney;
            //2016.4.28
            parameters[23].Value = model.subscribe;
            parameters[24].Value = model.language;
            parameters[25].Value = model.city;
            parameters[26].Value = model.province;
            parameters[27].Value = model.country;
            parameters[28].Value = model.headimgul;
            parameters[29].Value = model.subscribe_time;
            parameters[30].Value = model.unsubscribe_time;
            parameters[31].Value = model.groupid;
            parameters[32].Value = model.groupname;

            parameters[33].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(XCWeiXin.Model.wx_ucard_users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_ucard_users(");
            strSql.Append("wid,sid,openid,cardNo,pwd,degreeId,sex,birthday,wxName,realName,age,qq,regTime,regIp,telphone,mobile,email,addr,endDate,ttScore,qdScore,consumeScore,consumeMoney,subscribe,language,city,province,country,headimgul,subscribe_time,unsubscribe_time,groupid,groupname)");
            strSql.Append(" values (");
            strSql.Append("@wid,@sid,@openid,dbo.ufn_ucard_maxCardNo(),@pwd,@degreeId,@sex,@birthday,@wxName,@realName,@age,@qq,@regTime,@regIp,@telphone,@mobile,@email,@addr,@endDate,@ttScore,@qdScore,@consumeScore,@consumeMoney,@subscribe,@language,@city,@province,@country,@headimgul,@subscribe_time,@unsubscribe_time,@groupid,@groupname)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",              SqlDbType.Int,         4),
                new SqlParameter("@sid",              SqlDbType.Int,         4),
                new SqlParameter("@openid",           SqlDbType.VarChar,   100),
                //new SqlParameter("@cardNo", SqlDbType.VarChar,50),
                new SqlParameter("@pwd",              SqlDbType.VarChar,   100),
                new SqlParameter("@degreeId",         SqlDbType.Int,         4),
                new SqlParameter("@sex",              SqlDbType.VarChar,    10),
                new SqlParameter("@birthday",         SqlDbType.DateTime),
                new SqlParameter("@wxName",           SqlDbType.VarChar,   100),
                new SqlParameter("@realName",         SqlDbType.VarChar,    50),
                new SqlParameter("@age",              SqlDbType.Int,         4),
                new SqlParameter("@qq",               SqlDbType.VarChar,    20),
                new SqlParameter("@regTime",          SqlDbType.DateTime),
                new SqlParameter("@regIp",            SqlDbType.VarChar,    20),
                new SqlParameter("@telphone",         SqlDbType.VarChar,    50),
                new SqlParameter("@mobile",           SqlDbType.VarChar,    20),
                new SqlParameter("@email",            SqlDbType.VarChar,   100),
                new SqlParameter("@addr",             SqlDbType.VarChar,   300),
                new SqlParameter("@endDate",          SqlDbType.DateTime),
                new SqlParameter("@ttScore",          SqlDbType.Int,         4),
                new SqlParameter("@qdScore",          SqlDbType.Int,         4),
                new SqlParameter("@consumeScore",     SqlDbType.Int,         4),
                new SqlParameter("@consumeMoney",     SqlDbType.Float,       8),
                //2016.4.28
                new SqlParameter("@subscribe",        SqlDbType.Int,         4),
                new SqlParameter("@language",         SqlDbType.VarChar,    20),
                new SqlParameter("@city",             SqlDbType.VarChar,    20),
                new SqlParameter("@province",         SqlDbType.VarChar,    20),
                new SqlParameter("@country",          SqlDbType.VarChar,    20),
                new SqlParameter("@headimgul",        SqlDbType.VarChar,   500),
                new SqlParameter("@subscribe_time",   SqlDbType.DateTime),
                new SqlParameter("@unsubscribe_time", SqlDbType.DateTime),
                new SqlParameter("@groupid",          SqlDbType.Int,         4),
                new SqlParameter("@groupname",        SqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.sid;
            parameters[2].Value = model.openid;
            // parameters[3].Value = model.cardNo;
            parameters[3].Value  = model.pwd;
            parameters[4].Value  = model.degreeId;
            parameters[5].Value  = model.sex;
            parameters[6].Value  = model.birthday;
            parameters[7].Value  = model.wxName;
            parameters[8].Value  = model.realName;
            parameters[9].Value  = model.age;
            parameters[10].Value = model.qq;
            parameters[11].Value = model.regTime;
            parameters[12].Value = model.regIp;
            parameters[13].Value = model.telphone;
            parameters[14].Value = model.mobile;
            parameters[15].Value = model.email;
            parameters[16].Value = model.addr;
            parameters[17].Value = model.endDate;
            parameters[18].Value = model.ttScore;
            parameters[19].Value = model.qdScore;
            parameters[20].Value = model.consumeScore;
            parameters[21].Value = model.consumeMoney;

            //2016.4.28
            parameters[22].Value = model.subscribe;
            parameters[23].Value = model.language;
            parameters[24].Value = model.city;
            parameters[25].Value = model.province;
            parameters[26].Value = model.country;
            parameters[27].Value = model.headimgul;
            parameters[28].Value = model.subscribe_time;
            parameters[29].Value = model.unsubscribe_time;
            parameters[30].Value = model.groupid;
            parameters[31].Value = model.groupname;



            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XCWeiXin.Model.wx_ucard_users DataRowToModel(DataRow row)
 {
     XCWeiXin.Model.wx_ucard_users model = new XCWeiXin.Model.wx_ucard_users();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["wid"] != null && row["wid"].ToString() != "")
         {
             model.wid = int.Parse(row["wid"].ToString());
         }
         if (row["sid"] != null && row["sid"].ToString() != "")
         {
             model.sid = int.Parse(row["sid"].ToString());
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
         if (row["cardNo"] != null)
         {
             model.cardNo = row["cardNo"].ToString();
         }
         if (row["pwd"] != null)
         {
             model.pwd = row["pwd"].ToString();
         }
         if (row["degreeId"] != null && row["degreeId"].ToString() != "")
         {
             model.degreeId = int.Parse(row["degreeId"].ToString());
         }
         if (row["sex"] != null && row["sex"].ToString() != "")
         {
             model.sex = int.Parse(row["sex"].ToString());
         }
         if (row["birthday"] != null && row["birthday"].ToString() != "")
         {
             model.birthday = DateTime.Parse(row["birthday"].ToString());
         }
         if (row["wxName"] != null)
         {
             model.wxName = row["wxName"].ToString();
         }
         if (row["realName"] != null)
         {
             model.realName = row["realName"].ToString();
         }
         if (row["age"] != null && row["age"].ToString() != "")
         {
             model.age = int.Parse(row["age"].ToString());
         }
         if (row["qq"] != null)
         {
             model.qq = row["qq"].ToString();
         }
         if (row["regTime"] != null && row["regTime"].ToString() != "")
         {
             model.regTime = DateTime.Parse(row["regTime"].ToString());
         }
         if (row["regIp"] != null)
         {
             model.regIp = row["regIp"].ToString();
         }
         if (row["telphone"] != null)
         {
             model.telphone = row["telphone"].ToString();
         }
         if (row["mobile"] != null)
         {
             model.mobile = row["mobile"].ToString();
         }
         if (row["email"] != null)
         {
             model.email = row["email"].ToString();
         }
         if (row["addr"] != null)
         {
             model.addr = row["addr"].ToString();
         }
         if (row["endDate"] != null && row["endDate"].ToString() != "")
         {
             model.endDate = DateTime.Parse(row["endDate"].ToString());
         }
         if (row["ttScore"] != null && row["ttScore"].ToString() != "")
         {
             model.ttScore = int.Parse(row["ttScore"].ToString());
         }
         if (row["qdScore"] != null && row["qdScore"].ToString() != "")
         {
             model.qdScore = int.Parse(row["qdScore"].ToString());
         }
         if (row["consumeScore"] != null && row["consumeScore"].ToString() != "")
         {
             model.consumeScore = int.Parse(row["consumeScore"].ToString());
         }
         if (row["consumeMoney"] != null && row["consumeMoney"].ToString() != "")
         {
             model.consumeMoney = decimal.Parse(row["consumeMoney"].ToString());
         }
         //2016.4.28
         if (row["unsubscribe_time"] != null && row["unsubscribe_time"].ToString() != "")
         {
             model.unsubscribe_time = DateTime.Parse(row["unsubscribe_time"].ToString());
         }
         if (row["subscribe_time"] != null && row["subscribe_time"].ToString() != "")
         {
             model.subscribe_time = DateTime.Parse(row["subscribe_time"].ToString());
         }
         if (row["language"] != null)
         {
             model.language = row["language"].ToString();
         }
         if (row["city"] != null)
         {
             model.city = row["city"].ToString();
         }
         if (row["province"] != null)
         {
             model.province = row["province"].ToString();
         }
         if (row["country"] != null)
         {
             model.country = row["country"].ToString();
         }
         if (row["headimgul"] != null)
         {
             model.headimgul = row["headimgul"].ToString();
         }
         if (row["groupname"] != null)
         {
             model.groupname = row["groupname"].ToString();
         }
         if (row["subscribe"] != null && row["subscribe"].ToString() != "")
         {
             model.subscribe = int.Parse(row["subscribe"].ToString());
         }
         if (row["groupid"] != null && row["groupid"].ToString() != "")
         {
             model.groupid = int.Parse(row["groupid"].ToString());
         }
     }
     return(model);
 }