/// <summary> /// 更新一条数据 /// </summary> public bool Update(TaskManager.Model.T_Base_Admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Base_Admin set "); strSql.Append("LoginName=@LoginName,"); strSql.Append("PassWord=@PassWord"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@LoginName", SqlDbType.VarChar, 50), new SqlParameter("@PassWord", SqlDbType.VarChar, 50), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.LoginName; 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); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TaskManager.Model.T_Base_Admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Base_Admin("); strSql.Append("LoginName,PassWord)"); strSql.Append(" values ("); strSql.Append("@LoginName,@PassWord)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@LoginName", SqlDbType.VarChar, 50), new SqlParameter("@PassWord", SqlDbType.VarChar, 50) }; parameters[0].Value = model.LoginName; parameters[1].Value = model.PassWord; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public TaskManager.Model.T_Base_Admin DataRowToModel(DataRow row) { TaskManager.Model.T_Base_Admin model = new TaskManager.Model.T_Base_Admin(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["LoginName"] != null) { model.LoginName = row["LoginName"].ToString(); } if (row["PassWord"] != null) { model.PassWord = row["PassWord"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public TaskManager.Model.T_Base_Admin GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,LoginName,PassWord from T_Base_Admin "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; TaskManager.Model.T_Base_Admin model = new TaskManager.Model.T_Base_Admin(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }