Beispiel #1
0
 /// <summary>
 /// 将某一行数据转换为类的对象
 /// </summary>
 /// <param name="dr"></param>
 /// <param name="model"></param>
 public void GetPerson(DataRow dr, MODEL.Person model)
 {
     if (dr["PID"].ToString() != "")
     {
         model.PID = int.Parse(dr["PID"].ToString());
     }
     if (dr["PCID"].ToString() != "")
     {
         model.PCID = int.Parse(dr["PCID"].ToString());
     }
     model.PClaName = dr["PClaName"].ToString();
     if (dr["PType"].ToString() != "")
     {
         model.PType = int.Parse(dr["PType"].ToString());
     }
     model.PLoginName = dr["PLoginName"].ToString();
     model.PCName     = dr["PCName"].ToString();
     model.PPYName    = dr["PPYName"].ToString();
     model.PPwd       = dr["PPwd"].ToString();
     if (dr["PGender"].ToString() != "")
     {
         model.PGender = bool.Parse(dr["PGender"].ToString());
     }
     model.PEmail = dr["PEmail"].ToString();
     model.PAreas = dr["PAreas"].ToString();
     if (dr["PIsDel"].ToString() != "")
     {
         model.PIsDel = bool.Parse(dr["PIsDel"].ToString());
     }
     if (dr["PAddTime"].ToString() != "")
     {
         model.PAddTime = DateTime.Parse(dr["PAddTime"].ToString());
     }
 }
Beispiel #2
0
        /// <summary>
        /// 增加人员信息
        /// </summary>
        /// <param name="addPerson"></param>
        /// <returns></returns>
        public int AddPerson(MODEL.Person addPerson)
        {
            string sql = "";

            if (string.IsNullOrEmpty(addPerson.PAreas))
            {
                sql = "insert into person(pcid,pclaname,ptype,ploginname,pcname,ppyname,ppwd,pgender,pemail) values(@pcid,@pclaname,@ptype,@ploginname,@pcname,@ppyname,@ppwd,@pgender,@pemail)";
            }
            else
            {
                sql = "insert into person(pcid,pclaname,ptype,ploginname,pcname,ppyname,ppwd,pgender,pemail,pareas) values(@pcid,@pclaname,@ptype,@ploginname,@pcname,@ppyname,@ppwd,@pgender,@pemail,@pareas)";
            }
            SqlParameter[] ps =
            {
                new SqlParameter("pcid",       addPerson.PCID),
                new SqlParameter("pclaname",   addPerson.PClaName),
                new SqlParameter("ptype",      addPerson.PType),
                new SqlParameter("ploginname", addPerson.PLoginName),
                new SqlParameter("pcname",     addPerson.PCName),
                new SqlParameter("ppyname",    addPerson.PPYName),
                new SqlParameter("ppwd",       addPerson.PPwd),
                new SqlParameter("pgender",    addPerson.PGender),
                new SqlParameter("pemail",     addPerson.PEmail),
                new SqlParameter("pareas",     addPerson.PAreas)
            };
            return(SqlHelper.ExecuteNonQuery(sql, ps));
        }
        public List<Person> GetPersonList()
        {
            List<Person> people = new List<Person>();
            Random rnd = new Random();
            for (int i = 0; i < 10000; i++)
            {
                Person temp = new Person();
                temp.Name = "Person#" + i.ToString();

                temp.Age = rnd.Next(1, 99);

                temp.Race = (PersonRace)rnd.Next(0, 4);

                switch (temp.Race)
                {
                    case PersonRace.Angles:
                        temp.Height = temp.Age * 0.45 + 1.5;
                        break;
                    case PersonRace.Saxons:
                        temp.Height = temp.Age * 0.45 + 1.5;
                        break;
                    case PersonRace.Jutes:
                        temp.Height = temp.Age * 1.6 / 2;
                        break;
                    case PersonRace.Asians:
                        temp.Height = (temp.Age + 2) * 0.23 + 1.7;
                        break;
                }

                temp.Age = temp.Age + 1;
                people.Add(temp);
            }

            return people;
        }
Beispiel #4
0
        /// <summary>
        /// 修改人员信息
        /// </summary>
        /// <param name="addPerson"></param>
        /// <returns></returns>
        public int UpdatePerson(MODEL.Person addPerson)
        {
            string sql = "update person set pclaname=@pclaname,ptype=@ptype,ploginname=@ploginname,pcname=@pcname,ppyname=@ppyname,ppwd=@ppwd,pgender=@pgender,pemail=@pemail,pareas=@pareas where pid=@pid";

            SqlParameter[] ps =
            {
                new SqlParameter("pclaname",   addPerson.PClaName),
                new SqlParameter("ptype",      addPerson.PType),
                new SqlParameter("ploginname", addPerson.PLoginName),
                new SqlParameter("pcname",     addPerson.PCName),
                new SqlParameter("ppyname",    addPerson.PPYName),
                new SqlParameter("ppwd",       addPerson.PPwd),
                new SqlParameter("pgender",    addPerson.PGender),
                new SqlParameter("pemail",     addPerson.PEmail),
                new SqlParameter("pareas",     addPerson.PAreas),
                new SqlParameter("pid",        addPerson.PID)
            };
            return(SqlHelper.ExecuteNonQuery(sql, ps));
        }
Beispiel #5
0
        /// <summary>
        /// 增加人员信息
        /// </summary>
        /// <param name="addPerson"></param>
        /// <returns></returns>
        public int AddPerson(MODEL.Person addPerson)
        {
            //1.得到拼音
            StringBuilder sb = new StringBuilder();

            foreach (char cname in addPerson.PCName)
            {
                //if (ChineseChar.IsValidChar(cname)) //判断如果是一个有效的中文字符,就进行拼音的获取
                //{
                //    ChineseChar c = new ChineseChar(cname);
                //    System.Collections.ObjectModel.ReadOnlyCollection<string> lists = c.Pinyins;
                //    sb.Append(lists[0].Substring(0, lists[0].Length - 1)); //只是取得其中得到的多种拼音中的每一个,同时去除最后的声调
                //}
                //else //否则就直接获取这个字符
                //{
                //    sb.Append(cname);
                //}
            }
            addPerson.PPYName = sb.ToString();
            //2.得到加密之后的密码
            //addPerson.PPwd= System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(addPerson.PPwd, "md5");
            return(ps.AddPerson(addPerson));
        }
Beispiel #6
0
 /// <summary>
 /// 修改用户信息
 /// </summary>
 /// <param name="upPerson"></param>
 /// <returns></returns>
 public int UpdatePerson(MODEL.Person upPerson)
 {
     return(ps.UpdatePerson(upPerson));
 }