Пример #1
0
        /// <summary>
        /// 删除队伍
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public int DeleteTeam(List <string> ids)
        {
            using (var db = new BFdbContext())
            {
                int res = 0;

                using (var tx = db.BeginTransaction())
                {
                    try
                    {
                        foreach (string id in ids)
                        {
                            tblteams ent = db.tblteams.FirstOrDefault(p => p.teamid == id);
                            ent.Status = 2;
                            db.TUpdate <tblteams>(ent);
                        }
                        db.SaveChanges();
                        tx.Commit();
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();
                        throw ex;
                    }
                }

                return(res);
            }
        }
Пример #2
0
        /// <summary>
        /// 更新队伍线路
        /// </summary>
        /// <param name="ent"></param>
        /// <returns></returns>
        public int AssignsTeams(List <AssignsTeam> AssignsTeam)
        {
            int ret = -1;

            try
            {
                using (var db = new BFdbContext())
                {
                    for (int i = 0; i < AssignsTeam.Count; i++)
                    {
                        tblteams ent = GetTeamById(AssignsTeam[i].teamid);
                        ent.Linesid = AssignsTeam[i].linesid;
                        db.TUpdate <tblteams>(ent);
                    }
                    db.SaveChanges();
                }

                ret = 0;
            }
            catch
            {
                ret = 99;
            }

            return(ret);
        }
Пример #3
0
        public int TeamDis(TeamDisEntiyList r)
        {
            using (var db = new BFdbContext())
            {
                int res = -1;

                using (var tx = db.BeginTransaction())
                {
                    try
                    {
                        for (int i = 0; i < r.teams.Count; i++)
                        {
                            string   id   = r.teams[i].teamid;
                            tblteams team = db.tblteams.FirstOrDefault(p => p.teamid == id);
                            team.Lineid  = r.lineid;
                            team.Linesid = r.linesid;
                            team.Teamno  = r.teams[i].Teamno.PadLeft(5, '0');
                            db.TUpdate <tblteams>(team);
                            //BuildSerial1(id,team.Teamno);
                        }
                        db.SaveChanges();
                        tx.Commit();
                        res = 0;
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();
                        throw ex;
                    }
                }

                return(res);
            }
        }
Пример #4
0
        /// <summary>
        /// zzy 2018-12-30
        /// 设置队长
        /// </summary>
        /// <param name="mid"></param>
        /// <returns></returns>
        public int ReLeader(string mid)
        {
            using (var db = new BFdbContext())
            {
                var player = db.tblmatchusers.FirstOrDefault(p => p.Matchuserid == mid);

                var leader = db.tblmatchusers.FirstOrDefault(p => p.Leader == 1 && p.Teamid == player.Teamid);
                if (leader.Matchuserid == player.Matchuserid)
                {
                    return(-1);
                }

                var team = db.tblteams.FirstOrDefault(p => p.teamid == leader.Teamid);

                leader.Leader = 0;
                leader.Mono   = DateTime.Now.ToString("yyMMddHHmmss");

                player.Leader = 1;
                team.Userid   = player.Userid;

                db.TUpdate <tblmatchusers>(leader);
                db.TUpdate <tblmatchusers>(player);
                db.TUpdate <tblteams>(team);

                return(db.SaveChanges());
            }
        }
Пример #5
0
        public string AddDict(List <CMNDICT> dictEntity)
        {
            try
            {
                var rs = false;

                using (BFdbContext db = new BFdbContext())
                {
                    db.ExecuteSqlCommand("delete from cmn_dict where dictid='3000'");

                    using (db.BeginTransaction())
                    {
                        foreach (var entity in dictEntity)
                        {
                            db.TInsert <CMNDICT>(entity);
                        }
                    }

                    db.SaveChanges();

                    rs = true;
                }

                return(rs ? "0" : "-1");
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }
Пример #6
0
        public string UpdateDict(List <CMNDICT> dictEntity)
        {
            try
            {
                var rs = false;

                using (BFdbContext db = new BFdbContext())
                {
                    using (db.BeginTransaction())
                    {
                        foreach (var entity in dictEntity)
                        {
                            db.TUpdate <CMNDICT>(entity);
                        }
                    }

                    db.SaveChanges();

                    rs = true;
                }

                return(rs ? "0" : "-1");
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }
Пример #7
0
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public int DeleteUser(List <string> ids)
        {
            using (var db = new BFdbContext())
            {
                int res = 0;

                using (var tx = db.BeginTransaction())
                {
                    try
                    {
                        foreach (string id in ids)
                        {
                            sysuser ent = db.sysuser.FirstOrDefault(p => p.Userid == id);
                            ent.Delflag = true;
                            db.TUpdate <sysuser>(ent);
                        }
                        db.SaveChanges();
                        tx.Commit();
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();
                        throw ex;
                    }
                }

                return(res);
            }
        }
Пример #8
0
 public int Answer(List <tblanswer> lst)
 {
     using (var db = new BFdbContext())
     {
         foreach (var item in lst)
         {
             db.TInsert <tblanswer>(item);
         }
         return(db.SaveChanges());
     }
 }
Пример #9
0
        public int RejectReplay(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 musr   = db.tblmatchusers.FirstOrDefault(p => p.Matchuserid == rep.D_Matchuserid);
                var leader = db.tblmatchusers.FirstOrDefault(p => p.Teamid == rep.Teamid && p.Leader == 1);

                if (musr == null)
                {
                    return(-2);
                }

                if (info.Userid == rep.S_Userid)
                {
                    rep.S_Agreetime = DateTime.Now;
                    rep.S_Flag      = "2";
                }
                else
                {
                    rep.D_Agreetime = DateTime.Now;
                    rep.D_Flag      = "2";
                }

                info.Field2 = "2";
                musr.Status = "1";

                tblinfomation tblA = new tblinfomation();
                tblA.Context    = string.Format("用户[{0}]拒绝了你替换队员的请求,请查看.", info.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);

                db.TUpdate <tblinfomation>(info);
                db.TUpdate <tblreplace>(rep);
                db.TUpdate <tblmatchusers>(musr);

                return(db.SaveChanges());
            }
        }
Пример #10
0
        public int RejectMatch(string infoid, string matchuserid)
        {
            using (var db = new BFdbContext())
            {
                var musr = db.tblmatchusers.FirstOrDefault(p => p.Matchuserid == matchuserid);
                if (musr == null)
                {
                    return(-1);
                }
                else
                {
                    var info = db.tblinfomation.FirstOrDefault(p => p.Infoid == infoid);
                    info.Field2 = "2";
                    db.TUpdate <tblinfomation>(info);

                    musr.Status = "9";
                    db.TUpdate <tblmatchusers>(musr);

                    return(db.SaveChanges());
                }
            }
        }
Пример #11
0
        /// <summary>
        /// 录入队员信息
        /// </summary>
        /// <param name="mus"></param>
        /// <param name="tid"></param>
        /// <returns></returns>
        public int InputMb(List <tblmatchusers> mus, int tid)
        {
            using (var db = new BFdbContext())
            {
                //var team = db.tblteams.FirstOrDefault(p => p.Id == tid);
                var team = db.tblteams.FirstOrDefault(p => p.teamid == tid.ToString());
                if (team == null)
                {
                    return(-1);
                }

                var user = db.tblusers.FirstOrDefault(p => p.userid == team.Userid);

                int nov = 1;

                foreach (var item in mus)
                {
                    if (item.Cardtype == "1")
                    {
                        if (string.IsNullOrEmpty(item.Cardno))
                        {
                            item.Age = 0;
                        }
                        else if (item.Cardno.Length == 18)
                        {
                            string dy = item.Cardno.Substring(6, 8);
                            string nw = DateTime.Now.ToString("yyyyMMdd");
                            string m  = (int.Parse(nw) - int.Parse(dy)).ToString();

                            if (m.Length > 4)
                            {
                                item.Age = int.Parse(m.Substring(0, m.Length - 4));
                            }
                            else
                            {
                                item.Age = 0;
                            }
                        }
                        else if (item.Cardno.Length == 15)
                        {
                            string dy = item.Cardno.Substring(6, 6);
                            if (dy.StartsWith("0") || dy.StartsWith("1") || dy.StartsWith("2"))
                            {
                                dy = "20" + dy;
                            }
                            else
                            {
                                dy = "19" + dy;
                            }

                            string nw = DateTime.Now.ToString("yyyyMMdd");
                            string m  = (int.Parse(nw) - int.Parse(dy)).ToString();

                            if (m.Length > 4)
                            {
                                item.Age = int.Parse(m.Substring(0, m.Length - 4));
                            }
                            else
                            {
                                item.Age = 0;
                            }
                        }
                        else
                        {
                            item.Age = 0;
                        }
                    }
                    item.Createtime = DateTime.Now.ToString("yyyy=MM-dd HH:mm:ss");
                    item.Match_Id   = team.match_id;
                    item.Teamid     = tid.ToString();
                    item.Teamname   = team.Teamname;

                    int tn = 0;
                    if (int.TryParse(team.Teamno, out tn))
                    {
                        item.Teamno = tn;
                    }
                    else
                    {
                        item.Teamno = 0;
                    }

                    item.Pay  = 1;
                    item.Pnov = team.Teamno + nov;
                    db.TInsert <tblmatchusers>(item);
                }

                team.Status = 0;
                db.TUpdate <tblteams>(team);

                if (user != null)
                {
                    user.Status = 0;
                    db.TUpdate <tblusers>(user);
                }

                return(db.SaveChanges());
            }
        }
Пример #12
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());
            }
        }
Пример #13
0
        public int Replayer(string usrid, string mobile, string mid)
        {
            using (var db = new BFdbContext())
            {
                var usr = db.tblusers.FirstOrDefault(p => p.Mobile == mobile && p.Status == 0);
                if (usr == null)
                {
                    return(-4);
                }

                var musr = db.tblmatchusers.FirstOrDefault(p => p.Matchuserid == mid);
                if (musr == null || musr.Status != "1")
                {
                    return(-3);
                }

                var match  = db.tblmatch.FirstOrDefault(p => p.Match_id == musr.Match_Id);
                var leader = db.tblmatchusers.FirstOrDefault(p => p.Teamid == musr.Teamid && p.Userid == usrid);

                if (leader.Leader != 1)
                {
                    return(-2);
                }

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

                tblreplace tbl = new tblreplace();
                tbl.Createtime    = DateTime.Now;
                tbl.D_Age         = musr.Age;
                tbl.D_Birthday    = musr.birthday;
                tbl.D_Cardno      = musr.Cardno;
                tbl.D_Cardtype    = musr.Cardtype;
                tbl.D_Flag        = "0";
                tbl.D_Matchuserid = musr.Matchuserid;
                tbl.D_Mobile      = musr.Mobile;
                tbl.D_Nickname    = musr.Nickname;
                tbl.D_Sexy        = musr.Sexy;
                tbl.D_Userid      = musr.Userid;
                tbl.Id            = Guid.NewGuid().ToString();
                tbl.Match_Id      = musr.Match_Id;
                tbl.S_Flag        = "0";
                tbl.S_Userid      = usr.userid;
                tbl.Teamid        = musr.Teamid;

                db.TInsert <tblreplace>(tbl);

                musr.Status = "8";
                db.TUpdate <tblmatchusers>(musr);


                tblinfomation tblA = new tblinfomation();
                tblA.Context    = string.Format("用户[{0}]邀请你加入[{1}]队伍,参加[{2}],请火速接受邀请吧.", leader.Mobile, leader.Teamname, match.Match_name);
                tblA.createtime = DateTime.Now;
                tblA.Field1     = tbl.Id;
                tblA.Field2     = "0";
                tblA.Infoid     = Guid.NewGuid().ToString();
                tblA.Mobile     = usr.Mobile;
                tblA.Status     = "0";
                tblA.Type       = "4";
                tblA.Userid     = usr.userid;
                db.TInsert <tblinfomation>(tblA);

                tblinfomation tblB = new tblinfomation();
                tblB.Context    = string.Format("你参加的[{0}],已被队长替换;如果接受,请点击【同意】按钮.", match.Match_name);
                tblB.createtime = DateTime.Now;
                tblB.Field1     = tbl.Id;
                tblB.Field2     = "0";
                tblB.Infoid     = Guid.NewGuid().ToString();
                tblB.Mobile     = musr.Mobile;
                tblB.Status     = "0";
                tblB.Type       = "4";
                tblB.Userid     = musr.Userid;
                db.TInsert <tblinfomation>(tblB);

                return(db.SaveChanges());
            }
        }
Пример #14
0
        public int AcceptMatch(string infoid, string matchuserid)
        {
            using (var db = new BFdbContext())
            {
                var musr = db.tblmatchusers.FirstOrDefault(p => p.Matchuserid == matchuserid);
                if (musr == null)
                {
                    return(-1);
                }
                else
                {
                    var ur = db.tblusers.FirstOrDefault(p => p.userid == musr.Userid);
                    if (string.IsNullOrEmpty(ur.Isupt) || ur.Isupt == "0")
                    {
                        return(-3);
                    }

                    var lst = db.tblmatchusers.Where(p => p.Match_Id == musr.Match_Id && p.Userid == musr.Userid && p.Matchuserid != musr.Matchuserid);
                    //已经接受别的队伍
                    if (lst.Any(p => p.Status == "1"))
                    {
                        return(-2);
                    }

                    string sql    = string.Format("select a.* from tbl_users a,tbl_teams b where a.userid=b.userid and b.teamid='{0}'", musr.Teamid);
                    var    leader = db.SqlQuery <tblusers>(sql).FirstOrDefault();

                    tblinfomation info = new tblinfomation();
                    info.Context    = string.Format("用户[{0}]已经接受了你的邀请,赶快去报名吧.", musr.Mobile);
                    info.createtime = DateTime.Now;
                    info.Infoid     = Guid.NewGuid().ToString();
                    info.Mobile     = leader.Mobile;
                    info.Status     = "0";
                    info.Type       = "3";
                    info.Userid     = leader.userid;
                    db.TInsert <tblinfomation>(info);

                    foreach (var item in lst)
                    {
                        item.Status = "9";
                        db.TUpdate <tblmatchusers>(item);
                    }

                    var info2 = db.tblinfomation.FirstOrDefault(p => p.Infoid == infoid);
                    info2.Field2 = "1";
                    db.TUpdate <tblinfomation>(info2);

                    musr.Status   = "1";
                    musr.birthday = ur.birthday;
                    SetYearOld(musr);
                    musr.Cardno   = ur.cardno;
                    musr.Cardtype = ur.cardtype;
                    musr.Nickname = ur.Name;
                    musr.Mobile   = ur.Mobile;

                    int sx = 0;
                    if (int.TryParse(ur.sexy, out sx))
                    {
                        musr.Sexy = sx;
                    }

                    db.TUpdate <tblmatchusers>(musr);

                    return(db.SaveChanges());
                }
            }
        }