示例#1
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);
            }
        }
示例#2
0
文件: ApiBll.cs 项目: zyzhouone/www
 public int Answer(List <tblanswer> lst)
 {
     using (var db = new BFdbContext())
     {
         foreach (var item in lst)
         {
             db.TInsert <tblanswer>(item);
         }
         return(db.SaveChanges());
     }
 }
示例#3
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());
            }
        }
示例#4
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());
            }
        }
示例#5
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());
            }
        }
示例#6
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());
            }
        }
示例#7
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());
                }
            }
        }