Ejemplo n.º 1
0
        /// <summary>
        /// zzy 2018-12-30
        /// </summary>
        /// <param name="item"></param>
        private void SetYearOld(tblmatchusers item)
        {
            try
            {
                //if (item.Cardtype == "1")
                //{
                if (item.birthday.HasValue)
                {
                    string dy = item.birthday.Value.ToString("yyyyMMdd");
                    string nw = DateTime.Now.ToString("yyyyMMdd");
                    string m  = (int.Parse(nw) - int.Parse(dy) + 1).ToString();

                    if (m.Length > 4)
                    {
                        item.Age = int.Parse(m.Substring(0, m.Length - 4));
                    }
                    else
                    {
                        item.Age = 0;
                    }
                }
                else
                {
                    item.Age = 0;
                }
                //}
            }
            catch (Exception ex)
            {
                item.Age = 0;
            }
        }
Ejemplo n.º 2
0
        public JsonResult editplayer(tblmatchusers tm)
        {
            TeamRegBll bll = new TeamRegBll();
            int        res = bll.UpdatelMatchuser(tm);

            if (res > 0)
            {
                return(RepReurnOK());
            }
            else if (res == -2)
            {
                return(RepReurnError("这个身份证号已经被注册"));
            }
            else
            {
                return(RepReurnError("编辑中出现错误"));
            }
        }
Ejemplo n.º 3
0
        public int AcceptReplay(string infoid)
        {
            using (var db = new BFdbContext())
            {
                var info = db.tblinfomation.FirstOrDefault(p => p.Infoid == infoid);
                if (info == null || info.Field2 != "0")
                {
                    return(-1);
                }

                var rep    = db.tblreplace.FirstOrDefault(p => p.Id == info.Field1);
                var leader = db.tblmatchusers.FirstOrDefault(p => p.Teamid == rep.Teamid && p.Leader == 1);

                string mobile = "";

                //需要替换队员的处理
                if (rep.S_Userid == info.Userid)
                {
                    var usr = db.tblusers.FirstOrDefault(p => p.userid == info.Userid);
                    if (usr.Isupt != "1")
                    {
                        return(-2);
                    }

                    if (db.tblmatchusers.Any(p => p.Match_Id == rep.Match_Id && p.Userid == usr.userid && p.Status == "1"))
                    {
                        return(-3);
                    }

                    var musr = db.tblmatchusers.FirstOrDefault(p => p.Matchuserid == rep.D_Matchuserid);
                    if (musr == null)
                    {
                        return(-8);
                    }

                    mobile = usr.Mobile;

                    //被替换队员已经同意
                    if (rep.D_Flag == "1")
                    {
                        tblmatchusers tm = new tblmatchusers();
                        tm.birthday    = usr.birthday;
                        tm.Cardno      = usr.cardno;
                        tm.Cardtype    = usr.cardtype;
                        tm.Createtime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        tm.Leader      = 0;
                        tm.Match_Id    = rep.Match_Id;
                        tm.Matchuserid = Guid.NewGuid().ToString();
                        tm.Mobile      = usr.Mobile;
                        tm.Nickname    = usr.Name;
                        tm.Pay         = 0;
                        tm.Sexy        = int.Parse(usr.sexy);
                        tm.Status      = "1";
                        tm.Teamid      = rep.Teamid;
                        tm.Teamname    = musr.Teamname;
                        tm.Userid      = usr.userid;
                        SetYearOld(tm);

                        if (tm.Age < 16 || tm.Age > 60)
                        {
                            return(-9);
                        }

                        db.TInsert <tblmatchusers>(tm);
                        db.TDelete <tblmatchusers>(musr);

                        rep.S_Matchuserid = tm.Matchuserid;
                    }

                    rep.S_Agreetime = DateTime.Now;
                    rep.S_Flag      = "1";
                    db.TUpdate <tblreplace>(rep);
                }
                else
                {
                    var usr = db.tblusers.FirstOrDefault(p => p.userid == rep.S_Userid);

                    mobile = rep.D_Mobile;

                    if (rep.S_Flag == "1")
                    {
                        var musr = db.tblmatchusers.FirstOrDefault(p => p.Matchuserid == rep.D_Matchuserid);
                        if (musr == null)
                        {
                            return(-8);
                        }

                        tblmatchusers tm = new tblmatchusers();
                        tm.birthday    = usr.birthday;
                        tm.Cardno      = usr.cardno;
                        tm.Cardtype    = usr.cardtype;
                        tm.Createtime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        tm.Leader      = 0;
                        tm.Match_Id    = rep.Match_Id;
                        tm.Matchuserid = Guid.NewGuid().ToString();
                        tm.Mobile      = usr.Mobile;
                        tm.Nickname    = usr.Name;
                        tm.Pay         = 0;
                        tm.Sexy        = int.Parse(usr.sexy);
                        tm.Status      = "1";
                        tm.Teamid      = rep.Teamid;
                        tm.Teamname    = leader.Teamname;
                        tm.Userid      = usr.userid;
                        SetYearOld(tm);

                        if (tm.Age < 16 || tm.Age > 60)
                        {
                            return(-9);
                        }

                        db.TInsert <tblmatchusers>(tm);
                        db.TDelete <tblmatchusers>(musr);

                        rep.S_Matchuserid = tm.Matchuserid;
                    }

                    rep.D_Agreetime = DateTime.Now;
                    rep.D_Flag      = "1";
                    db.TUpdate <tblreplace>(rep);
                }

                info.Field2 = "1";
                db.TUpdate <tblinfomation>(info);

                tblinfomation tblA = new tblinfomation();
                tblA.Context    = string.Format("用户[{0}]接受了你的替换队员请求,请查看.", mobile);
                tblA.createtime = DateTime.Now;
                tblA.Infoid     = Guid.NewGuid().ToString();
                tblA.Mobile     = leader.Mobile;
                tblA.Status     = "0";
                tblA.Type       = "2";
                tblA.Userid     = leader.Userid;
                db.TInsert <tblinfomation>(tblA);

                return(db.SaveChanges());
            }
        }