コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.T_Administrator model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Administrator set ");
            strSql.Append("user_name=@user_name,");
            strSql.Append("password=@password");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_name", SqlDbType.VarChar,  50),
                new SqlParameter("@password",  SqlDbType.VarChar, 100),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.user_name;
            parameters[1].Value = model.password;
            parameters[2].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.T_Administrator model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Administrator(");
            strSql.Append("user_name,password)");
            strSql.Append(" values (");
            strSql.Append("@user_name,@password)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_name", SqlDbType.VarChar, 50),
                new SqlParameter("@password",  SqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.user_name;
            parameters[1].Value = model.password;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
        /// <summary>
        /// 根据用户名、密码登录
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public Maticsoft.Model.T_Administrator Login(string name, string password)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,user_name,password from T_Administrator ");
            strSql.Append(" where user_name=@name and password=@password");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",     SqlDbType.VarChar, 50),
                new SqlParameter("@password", SqlDbType.VarChar, 100)
            };
            parameters[0].Value = name;
            parameters[1].Value = password;

            Maticsoft.Model.T_Administrator model = new Maticsoft.Model.T_Administrator();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.T_Administrator DataRowToModel(DataRow row)
 {
     Maticsoft.Model.T_Administrator model = new Maticsoft.Model.T_Administrator();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["user_name"] != null)
         {
             model.user_name = row["user_name"].ToString();
         }
         if (row["password"] != null)
         {
             model.password = row["password"].ToString();
         }
     }
     return(model);
 }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.T_Administrator GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,user_name,password from T_Administrator ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Maticsoft.Model.T_Administrator model = new Maticsoft.Model.T_Administrator();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.T_Administrator model)
 {
     return(dal.Update(model));
 }
コード例 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Maticsoft.Model.T_Administrator model)
 {
     return(dal.Add(model));
 }