Example #1
0
 protected bool RegisterUser(string username, string email, string md5)
 {
     Model.Admin.Account account = new Model.Admin.Account();
     account.MD5Identify = md5;
     account.AccountName = username;
     account.Email = email;
     account.CreatedDate = DateTime.Now;
     account.Enable = 1;
     if (acc.Add(account) !=0)
     {
         return true;
     }
     return false;
 }
Example #2
0
        public Model.Admin.Account GetSingleModel(string username, string md5)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,Account,Email,MD5Identify,CreatedDate,ModifedDate,Enable from SYS_ACCOUNT ");
            strSql.Append(" where Account=@Username and MD5Identify=@Md5");
            SqlParameter[] parameters = {
                    new SqlParameter("@Username", SqlDbType.NVarChar,20),
                    new SqlParameter("@Md5", SqlDbType.NVarChar,32)
            };
            parameters[0].Value = username;
            parameters[1].Value = md5;

            Model.Admin.Account model = new Model.Admin.Account();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Account"] != null && ds.Tables[0].Rows[0]["Account"].ToString() != "")
                {
                    model.AccountName = ds.Tables[0].Rows[0]["Account"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Email"] != null && ds.Tables[0].Rows[0]["Email"].ToString() != "")
                {
                    model.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MD5Identify"] != null && ds.Tables[0].Rows[0]["MD5Identify"].ToString() != "")
                {
                    model.MD5Identify = ds.Tables[0].Rows[0]["MD5Identify"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreatedDate"] != null && ds.Tables[0].Rows[0]["CreatedDate"].ToString() != "")
                {
                    model.CreatedDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ModifedDate"] != null && ds.Tables[0].Rows[0]["ModifedDate"].ToString() != "")
                {
                    model.ModifedDate = DateTime.Parse(ds.Tables[0].Rows[0]["ModifedDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Enable"] != null && ds.Tables[0].Rows[0]["Enable"].ToString() != "")
                {
                    model.Enable = int.Parse(ds.Tables[0].Rows[0]["Enable"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Admin.Account GetModel(int Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,Account,Email,MD5Identify,CreatedDate,ModifedDate,Enable from SYS_ACCOUNT ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            Model.Admin.Account model=new Model.Admin.Account();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["Id"]!=null && ds.Tables[0].Rows[0]["Id"].ToString()!="")
                {
                    model.Id=int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Account"]!=null && ds.Tables[0].Rows[0]["Account"].ToString()!="")
                {
                    model.AccountName=ds.Tables[0].Rows[0]["Account"].ToString();
                }
                if(ds.Tables[0].Rows[0]["Email"]!=null && ds.Tables[0].Rows[0]["Email"].ToString()!="")
                {
                    model.Email=ds.Tables[0].Rows[0]["Email"].ToString();
                }
                if(ds.Tables[0].Rows[0]["MD5Identify"]!=null && ds.Tables[0].Rows[0]["MD5Identify"].ToString()!="")
                {
                    model.MD5Identify=ds.Tables[0].Rows[0]["MD5Identify"].ToString();
                }
                if(ds.Tables[0].Rows[0]["CreatedDate"]!=null && ds.Tables[0].Rows[0]["CreatedDate"].ToString()!="")
                {
                    model.CreatedDate=DateTime.Parse(ds.Tables[0].Rows[0]["CreatedDate"].ToString());
                }
                if(ds.Tables[0].Rows[0]["ModifedDate"]!=null && ds.Tables[0].Rows[0]["ModifedDate"].ToString()!="")
                {
                    model.ModifedDate=DateTime.Parse(ds.Tables[0].Rows[0]["ModifedDate"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Enable"]!=null && ds.Tables[0].Rows[0]["Enable"].ToString()!="")
                {
                    model.Enable=int.Parse(ds.Tables[0].Rows[0]["Enable"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }