public bool Update(ref Library.Model.Book book) { LendingLibrary.Client.LibraryService.UpdateRequest inValue = new LendingLibrary.Client.LibraryService.UpdateRequest(); inValue.book = book; LendingLibrary.Client.LibraryService.UpdateResponse retVal = ((LendingLibrary.Client.LibraryService.ILibraryService)(this)).Update(inValue); book = retVal.book; return(retVal.UpdateResult); }
public bool Read(string key, out Library.Model.Book book) { LendingLibrary.Client.LibraryService.ReadRequest inValue = new LendingLibrary.Client.LibraryService.ReadRequest(); inValue.key = key; LendingLibrary.Client.LibraryService.ReadResponse retVal = ((LendingLibrary.Client.LibraryService.ILibraryService)(this)).Read(inValue); book = retVal.book; return(retVal.ReadResult); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Library.Model.Book model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update book set "); strSql.Append("name=@name,"); strSql.Append("author=@author,"); strSql.Append("publish=@publish,"); strSql.Append("price=@price,"); strSql.Append("date=@date,"); strSql.Append("isbn=@isbn,"); strSql.Append("cover=@cover"); strSql.Append(" where id=@id"); SQLiteParameter[] parameters = { new SQLiteParameter("@name", DbType.String), new SQLiteParameter("@author", DbType.String), new SQLiteParameter("@publish", DbType.String), new SQLiteParameter("@price", DbType.Int32,8), new SQLiteParameter("@date", DbType.String), new SQLiteParameter("@isbn", DbType.String), new SQLiteParameter("@cover", DbType.String), new SQLiteParameter("@id", DbType.Int32, 8) }; parameters[0].Value = model.name; parameters[1].Value = model.author; parameters[2].Value = model.publish; parameters[3].Value = model.price; parameters[4].Value = model.date; parameters[5].Value = model.isbn; parameters[6].Value = model.cover; parameters[7].Value = model.id; int rows = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Library.Model.Book DataRowToModel(DataRow row) { Library.Model.Book model = new Library.Model.Book(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["name"] != null) { model.name = row["name"].ToString(); } if (row["author"] != null) { model.author = row["author"].ToString(); } if (row["publish"] != null) { model.publish = row["publish"].ToString(); } if (row["price"] != null && row["price"].ToString() != "") { model.price = int.Parse(row["price"].ToString()); } if (row["date"] != null) { model.date = row["date"].ToString(); } if (row["isbn"] != null) { model.isbn = row["isbn"].ToString(); } if (row["cover"] != null) { model.cover = row["cover"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Library.Model.Book model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into book("); strSql.Append("name,author,publish,price,date,isbn,cover)"); strSql.Append(" values ("); strSql.Append("@name,@author,@publish,@price,@date,@isbn,@cover)"); strSql.Append(";select LAST_INSERT_ROWID()"); SQLiteParameter[] parameters = { new SQLiteParameter("@name", DbType.String), new SQLiteParameter("@author", DbType.String), new SQLiteParameter("@publish", DbType.String), new SQLiteParameter("@price", DbType.Int32,8), new SQLiteParameter("@date", DbType.String), new SQLiteParameter("@isbn", DbType.String), new SQLiteParameter("@cover", DbType.String) }; parameters[0].Value = model.name; parameters[1].Value = model.author; parameters[2].Value = model.publish; parameters[3].Value = model.price; parameters[4].Value = model.date; parameters[5].Value = model.isbn; parameters[6].Value = model.cover; object obj = SQLiteHelper.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Library.Model.Book GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,name,author,publish,price,date,isbn,cover from book "); strSql.Append(" where id=@id"); SQLiteParameter[] parameters = { new SQLiteParameter("@id", DbType.Int32, 4) }; parameters[0].Value = id; Library.Model.Book model = new Library.Model.Book(); DataSet ds = SQLiteHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public System.Threading.Tasks.Task <bool> AddAsync(Library.Model.Book book) { return(base.Channel.AddAsync(book)); }
public bool Add(Library.Model.Book book) { return(base.Channel.Add(book)); }
public UpdateResponse(bool UpdateResult, Library.Model.Book book) { this.UpdateResult = UpdateResult; this.book = book; }
public UpdateRequest(Library.Model.Book book) { this.book = book; }
public ReadResponse(bool ReadResult, Library.Model.Book book) { this.ReadResult = ReadResult; this.book = book; }