Ejemplo n.º 1
0
        public ResponseStatus Login(HttpRequestBase req, Container_List_Status conTa_status, ref UserStatus us)
        {
            if (req.Form.Count == 0)
            {
                return ResponseStatus.REQFORM_COUNT_ISZERO;
            }
            else
            {
                string message = "";
                VerifyUtil2 verify2 = new VerifyUtil2();
                conTa_status.list_ErrMsg = new List<string>();
                conTa_status.user = new UserStatus();

                string userID = req.Form["userID"].ToString();
                Rule[] rules = new Rule[] { Rule.REQUEST, Rule.DIGIT, Rule.LENGTH };
                if (!verify2.Verify("学号", userID, rules, 10,10 , out message))
                {
                    conTa_status.list_ErrMsg.Add(message);
                }
                else
                {
                    conTa_status.user.UserID = userID;
                }

                string pwd = req.Form["pwd"].ToString();
                rules = new Rule[] { Rule.REQUEST, Rule.DIGITABC, Rule.LENGTH };
                if (!verify2.Verify("密码", pwd, rules, 8, 16, out message))
                {
                    conTa_status.list_ErrMsg.Add(message);
                }
                else
                {
                    pwd = MD5Factory.Instance().GetMd5Hash(pwd);
                    conTa_status.user.Password = pwd;
                }

                if (conTa_status.list_ErrMsg.Count == 0)
                {
                    conTa_status.list_ErrMsg = null;
                    UserDAL userDAL = new UserDAL();
                    ResponseStatus resp = userDAL.Login(userID, pwd, ref us);
                    userDAL.ReturnUnitToPool();
                    return resp;
                }
                else
                {
                    return ResponseStatus.LOGIN_FAILED;
                }
            }
        }
Ejemplo n.º 2
0
 //private static UserDAL userDal;
 //public static UserDAL Instance()
 //{
 //    if (userDal == null)
 //    {
 //        userDal = new UserDAL();
 //    }
 //    return userDal;
 //}
 public bool CheckValid(UserStatus us)
 {
     dalBase.sql = "SELECT id FROM db_users WHERE id=@id AND stuNum=@stuNum AND depid=@depid";
     dalBase.List_param = new List<MySqlParameter>()
         {
             new MySqlParameter("@id",us.ID),
             new MySqlParameter("@stuNum",us.UserID),
             new MySqlParameter("@depid",us.Dep.ID)
         };
     dalBase.Run(Behavious.SELECT_WITH_MUTIPARAM, false);
     bool flag = dalBase.DataRead.HasRows;
     dalBase.CloseConnect();
     return flag;
 }
Ejemplo n.º 3
0
 public void Add(UserStatus user)
 {
     dalBase.sql = string.Format("INSERT INTO db_users (stuNum,stuName,depid,grdid,collageid,phone,passwords,sex)" +
         "VALUES(@stuNum,@stuName,@depid,@grdid,@collageid,@phone,@passwords,@sex)");
     dalBase.List_param = new List<MySqlParameter>()
         {
             new MySqlParameter("@stuNum",user.UserID),
             new MySqlParameter("@stuName",user.UserName),
             new MySqlParameter("@depid",user.Dep.ID),
             new MySqlParameter("@grdid",user.Grd.ID),
             new MySqlParameter("@collageid",user.Clg.ID),
             new MySqlParameter("@phone",user.Phone),
             new MySqlParameter("@passwords",user.Password),
             new MySqlParameter("@sex",user.Sex)
         };
     dalBase.Run(Behavious.INSERT_OR_UPDATE_OR_DELETE,true);
 }
Ejemplo n.º 4
0
        public ResponseStatus Login(string userID, string psw, ref UserStatus us)
        {
            dalBase.sql = string.Format("SELECT id,stuNum,stuName,db_users.depid,isWaitForPass FROM db_users,db_department " +
                                                        "WHERE db_users.depid=db_department.depid " +
                                                        "AND stuNum=@stuNum AND passwords=@passwords");//可能有变化,先这么写着
            dalBase.List_param = new List<MySqlParameter>()
            {
                new MySqlParameter("@stuNum",userID),
                new MySqlParameter("@passwords",psw)
            };
            dalBase.Run(Behavious.SELECT_WITH_MUTIPARAM,false);

            if (!dalBase.DataRead.HasRows)
            {
                us = null;
                dalBase.CloseConnect();
                return ResponseStatus.NOT_REGISTER;
            }

            while (dalBase.DataRead.Read())
            {
                if (Convert.ToBoolean(dalBase.DataRead["isWaitForPass"]) == false)
                {
                    us = null;
                    dalBase.CloseConnect();
                    return ResponseStatus.NOT_PASS;
                }
                us = new UserStatus()
                {
                    ID = Convert.ToInt32(dalBase.DataRead["id"]),
                    UserID = dalBase.DataRead["stuNum"].ToString(),
                    UserName = dalBase.DataRead["stuName"].ToString(),
                    Dep = new Department() { ID = Convert.ToInt32(dalBase.DataRead["depid"]) }
                };
            }
            dalBase.CloseConnect();
            return ResponseStatus.SUCCESS;
        }
Ejemplo n.º 5
0
        public void Select(HttpRequestBase req, Container_List_FreeTime container_list_free)
        {
            TmTab_ResearchCon tmTab_RC = new TmTab_ResearchCon();

            //1,2,3,4,5,6,7
            tmTab_RC.WeekStart = !string.IsNullOrEmpty(req.Form["weekStart"]) ?
                Convert.ToInt32(req.Form["weekStart"]) : 1;
            tmTab_RC.WeekEnd = !string.IsNullOrEmpty(req.Form["weekEnd"]) ?
                Convert.ToInt32(req.Form["weekEnd"]) : 7;

            //1,3,5,7,9,10,12
            tmTab_RC.SectionStart = !string.IsNullOrEmpty(req.Form["sectionStart"]) ?
                Convert.ToInt32(req.Form["sectionStart"]) : 1;
            tmTab_RC.SectionEnd = !string.IsNullOrEmpty(req.Form["sectionEnd"]) ?
                Convert.ToInt32(req.Form["sectionEnd"]) : 12;

            object value = null;
            value = req.Form["grdID"];
            UserStatus us = new UserStatus();
            us.Grd = new Grade()
            {
                ID = !string.IsNullOrEmpty(value.ToString()) ? Convert.ToInt32(value) : 0
            };
            value = req.Form["collageID"];
            us.Clg = new Collage()
            {
                ID = !string.IsNullOrEmpty(value.ToString()) ? Convert.ToInt32(value) : 0
            };
            value = req.Form["depID"];
            us.Dep = new Department()
            {
                ID = !string.IsNullOrEmpty(value.ToString()) ? Convert.ToInt32(value) : 0
            };

            tmTabDal = new TimeTableDAL();
            tmTabDal.Select(us, tmTab_RC);
            tmTabDal.ReturnUnitToPool();
            container_list_free.list_free = tmTabDal.list_free;
        }
Ejemplo n.º 6
0
        private string GetCondition(UserStatus user)
        {
            string con = null;
            if (user.Clg.ID != 0)
            {
                con += "AND db_collage.collageid =" + user.Clg.ID;
            }

            if (user.Dep.ID != 0)
            {
                con += "AND db_department.depid =" + user.Dep.ID;
            }

            if (user.Grd.ID != 0)
            {
                con += "AND db_grade.grdid =" + user.Grd.ID;
            }
            return con;
        }
Ejemplo n.º 7
0
        public void Select(UserStatus user, TmTab_ResearchCon tmTab_RC)
        {
            Dictionary<int,string> dayDictionary = null;
            this.GetDays(tmTab_RC.WeekStart, tmTab_RC.WeekEnd,out dayDictionary);
            string strDay = null;
            foreach (var d in dayDictionary)
            {
                strDay += d.Value + ",";
            }

            string con = this.GetCondition(user);
            dalBase.sql = "SELECT db_users.id,db_users.stuNum,db_users.stuName,db_users.phone," +
                                "db_users.sex,db_users.short_phone," +
                                //"db_collage.collagename,db_grade.grdname,db_department.depname" +
                                strDay + "db_user_timetable.class " +
                                "FROM db_users,db_collage,db_department,db_grade,db_user_timetable " +
                                "WHERE db_users.collageid = db_collage.collageid " +
                                "AND db_users.depid = db_department.depid " +
                                "AND db_users.grdid = db_grade.grdid " +
                                "AND db_users.id = db_user_timetable.id " +
                                "AND db_user_timetable.class BETWEEN @classStart AND  @classEnd " +
                                 con; //+ "ORDER BY db_user_timetable.class"//+ " GROUP BY db_user_timetable.class "
            dalBase.List_param = new List<MySqlParameter>()
            {
                new MySqlParameter("@classStart",tmTab_RC.SectionStart),
                new MySqlParameter("@classEnd",tmTab_RC.SectionEnd)
            };
            dalBase.Run(Behavious.SELECT_WITH_MUTIPARAM, false);

            list_free.Clear();
            while (dalBase.DataRead.Read())
            {
                int id = Convert.ToInt32(dalBase.DataRead["id"]);
                string section = Convert.ToString(dalBase.DataRead["class"]);
                string day;
                string free = section;
                int freeCount = 0;
                foreach(var d in dayDictionary)
                {
                    day = Convert.ToString(d.Value);
                    if (Convert.ToChar(dalBase.DataRead[day]) == '0')
                    {
                        free += "*" + d.Key;
                        freeCount++;
                    }
                }
                free += "#";

                if (freeCount == 0) continue;

                UserFreeTime u_ft = list_free.Find(model => model.ID == id);;
                if (u_ft == null)
                {
                    string a = dalBase.DataRead["sex"].ToString();

                    u_ft = new UserFreeTime()
                    {
                        ID = id,
                        UserID = dalBase.DataRead["stuNum"].ToString(),
                        UserName = dalBase.DataRead["stuName"].ToString(),
                        Phone = dalBase.DataRead["phone"].ToString(),
                        Phone_short = dalBase.DataRead["short_phone"].ToString(),
                        Sex = Convert.ToByte(dalBase.DataRead["sex"]),
                        FreeTime = free
                    };
                    list_free.Add(u_ft);
                }
                else
                {
                    u_ft.FreeTime += free;
                }
            }
            dalBase.CloseConnect();
        }