public void DeleteBook() { var bookDAL = new BookDAL(); bool success; string idBook = "eBAVuw7ob14C000"; success = bookDAL.Delete(idBook); Assert.False(success); }
public ActionResult Delete(int id) // Affichage des informations d'un livre { BookDAL bookDAL = new BookDAL((List <Book>)Session["Books"]); Book book = bookDAL.Read(id); // R2cupération des infos d'un livre pour un id donné bookDAL.Delete(id); BookModelView model = new BookModelView((List <Book>)Session["Books"]); return(View(model)); }
public async Task PostBooks() { var bookDAL = new BookDAL(); bool successSelect; string search = "Cadeias produtivas de flores e mel"; var service = new BookController(); bookDAL.Delete("eBAVuw7ob14C"); var books = await service.Get(search); successSelect = bookDAL.Insert(books[0]); Assert.True(successSelect); }
public IEnumerable <Book> Delete(string bookId) { try { BookDAL bookDAL = new BookDAL(); bookDAL.Delete(bookId); Books = bookDAL.GetAll(); } catch (Exception ex) { Debug.WriteLine("Exception: " + ex.Message); } return(Books); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; Book book = new Book(); int flag = Convert.ToInt32(context.Request["flag"]); book.ID = Convert.ToInt32(context.Request["ID"]); book.Name = context.Request["Name"]; book.Type = Convert.ToInt32(context.Request["Type"]); book.Concern = context.Request["Concern"]; book.Author = context.Request["Author"]; book.Price = Convert.ToSingle(context.Request["Price"]); book.Time = Convert.ToInt32(context.Request["Time"]); book.Condition = context.Request["Condition"]; if (flag == 0) { DataTable GetBook = BookDAL.GetBook(); string json = Common.JsonHelper.DataSetToJson(GetBook); context.Response.Write(json); } else if (flag == 1) { DataRow GetBook = BookDAL.GetDRByID(book.ID); string json = null; if (GetBook != null) { json = Common.JsonHelper.DataSetToJson(GetBook.Table); } context.Response.Write(json); } else if (flag == 2) { int Insert = BookDAL.Insert(book); context.Response.Write(Insert); } else if (flag == 3) { int Update = BookDAL.Update(book); context.Response.Write(Update); } else if (flag == 4) { int Delete = BookDAL.Delete(book); context.Response.Write(Delete); } }
private void 除书籍ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.book.bkId == 0) { return; } if (dataGridView1.SelectedRows.Count <= 0) { MessageBox.Show("Not Exist!"); return; } if (resultTable.Rows.Count <= 0) { MessageBox.Show("Not Exist!"); return; } DialogResult dr = MessageBox.Show("确认删除" + book.bkName + "?", "对话框标题", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { //点确定的代码 try { BookDAL.Delete(book); }catch (Exception ex) { MessageBox.Show("删除失败!"); return; } MessageBox.Show("删除成功"); FindByCode(null, null);//刷新当前列表 } else { //点取消的代码 return; } }
public static void ConnectDataBase() { #region DAL.ReaderType测试 Console.WriteLine("DAL.SqlHelper:测试数据库连接..."); SqlHelper.OpenConn(); Console.WriteLine("DAL.SqlHelper:测试数据库关闭...\n"); SqlHelper.CloseConn(); Console.WriteLine("Model.ReaderType:测试创建数据单元..."); ReaderType rdt1 = new ReaderType(); rdt1.rdType = 1; rdt1.rdTypeName = "admin"; rdt1.maxBorrowDay = 30; rdt1.maxBorrowNum = 8; rdt1.maxContinueTimes = 1; Console.WriteLine("DAL.ReaderType:测试Delete()..."); ReaderTypeDAL.Delete(rdt1); Console.WriteLine("DAL.ReaderType:测试Add()..."); rdt1.rdType = ReaderTypeDAL.Add(rdt1); string old_rdTypeName = rdt1.rdTypeName; rdt1.rdTypeName = "管理员"; Console.WriteLine("DAL.ReaderType:测试Update()...rdType由" + old_rdTypeName + "改为" + rdt1.rdTypeName + "\n"); ReaderTypeDAL.Update(rdt1); #endregion #region DAL.Reader测试 Console.WriteLine("Model.Reader:测试创建数据单元..."); Reader rd1 = new Reader(); rd1.rdID = 1; rd1.rdUsername = "******"; rd1.rdPassword = "******"; rd1.rdName = "duguying"; rd1.rdSex = "男"; rd1.rdType = 1; rd1.rdDept = "计科院"; rd1.rdPhone = "18900000000"; rd1.rdEmail = "*****@*****.**"; rd1.rdDateReg = DateTime.Now; rd1.rdPhoto = Encoding.Default.GetBytes("test"); rd1.rdStatus = "正常"; rd1.rdHaveBorrowNum = 1; Console.WriteLine("DAL.Reader:测试Delete()..."); ReaderDAL.Delete(rd1); Console.WriteLine("DAL.Reader:测试Add()..."); rd1.rdID = ReaderDAL.Add(rd1); string old_rdPassword = rd1.rdPassword; rd1.rdPassword = "******"; Console.WriteLine("DAL.Reader:测试Update()...rdPassword由" + old_rdPassword + "改为" + rd1.rdPassword + "\n"); ReaderDAL.Update(rd1); #endregion #region DAL.Borrow测试 Console.WriteLine("Model.Borrow:测试创建数据单元..."); Borrow br1 = new Borrow(); br1.borrowId = 1; br1.bkId = 1; br1.ldContinueTimes = 0; br1.ldDateOut = DateTime.Now; br1.ldDateRetPlan = DateTime.Now; br1.ldDateRetAct = DateTime.Now; br1.ldOverDay = 12; br1.ldOverMoney = 1.2f; br1.IsHasReturn = false; br1.OperatorLendId = 1; br1.OperatorRetId = 0; Console.WriteLine("DAL.Borrow:测试Delete()..."); BorrowDAL.Delete(br1); Console.WriteLine("DAL.Borrow:测试Add()..."); br1.borrowId = (decimal)BorrowDAL.Add(br1); float old_ldPunishMoney = br1.ldPunishMoney; br1.ldPunishMoney = 2.4f; Console.WriteLine("DAL.Borrow:测试Update()...ldPunishMoney由" + old_ldPunishMoney + "改为" + br1.ldPunishMoney + "\n"); BorrowDAL.Update(br1); #endregion #region DAL.Book测试 Console.WriteLine("Model.Book:测试创建数据单元..."); Book bk1 = new Book(); bk1.bkId = 1; bk1.bkCode = "1234"; bk1.bkName = "测试书籍"; bk1.bkAuthor = "作者"; bk1.bkPress = "出版社"; bk1.bkDatePress = DateTime.Now; bk1.bkISBN = "92520111234"; bk1.bkCatalog = "计算机科学"; bk1.bkLanguage = 0; bk1.bkPages = 300; bk1.bkPrice = 30.5f; bk1.bkDateIn = DateTime.Now; bk1.bkBrief = "Go语言基础教程"; bk1.bkCover = Encoding.Default.GetBytes("test"); bk1.bkStatus = "在馆"; Console.WriteLine("DAL.Book:测试Delete()..."); BookDAL.Delete(bk1); Console.WriteLine("DAL.Book:测试Add()..."); bk1.bkId = BookDAL.Add(bk1); string old_bkName = bk1.bkName; bk1.bkName = "Go语言云动力"; Console.WriteLine("DAL.Book:测试Update()...bkName由" + old_bkName + "改为" + bk1.bkName + "\n"); BookDAL.Update(bk1); #endregion #region DAL.Admin测试 Console.WriteLine("Model.Admin:测试创建数据单元..."); Admin ad1 = new Admin(); ad1.adminId = 1; ad1.adminUsername = "******"; ad1.adminPassword = "******"; ad1.adminEmail = "*****@*****.**"; ad1.adminLastLoginDate = DateTime.Now; Console.WriteLine("DAL.Admin:测试Delete()..."); AdminDAL.Delete(ad1); Console.WriteLine("DAL.Admin:测试Add()..."); ad1.adminId = AdminDAL.Add(ad1); string old_adminPassword = ad1.adminPassword; ad1.adminPassword = "******"; Console.WriteLine("DAL.Admin:测试Update()...adminPassword由" + old_adminPassword + "改为" + ad1.adminPassword + "\n"); AdminDAL.Update(ad1); #endregion #region 测试数据清理 ReaderTypeDAL.Delete(rdt1); Console.WriteLine("ReaderType:数据已清理"); ReaderDAL.Delete(rd1); Console.WriteLine("Reader:数据已清理"); BorrowDAL.Delete(br1); Console.WriteLine("Borrow:数据已清理"); BookDAL.Delete(bk1); Console.WriteLine("Book:数据已清理"); AdminDAL.Delete(ad1); Console.WriteLine("Admin:数据已清理\n"); #endregion #region DAL.Admin扩展操作测试 AdminDAL.getAdminByUsername("lijun"); #endregion }
public static Int32 SubmitAction(UserAction action) { switch (action.actionSource) { case "ReaderType": switch (action.actionType) { case "Add": try { return(ReaderTypeDAL.Add((ReaderType)action.actionModel)); } catch (Exception) { return(0); } case "Update": try { return(ReaderTypeDAL.Update((ReaderType)action.actionModel)); } catch (Exception) { return(0); } case "Delete": try { return(ReaderTypeDAL.Delete((ReaderType)action.actionModel)); } catch (Exception) { return(0); } default: throw new Exception("Error actionType!"); } case "Reader": switch (action.actionType) { case "Add": try { return(ReaderDAL.Add((Reader)action.actionModel)); } catch (Exception) { return(0); } case "Update": try { return(ReaderDAL.Update((Reader)action.actionModel)); } catch (Exception) { return(0); } case "Delete": try { return(ReaderDAL.Delete((Reader)action.actionModel)); } catch (Exception) { return(0); } case "Password": try { return(ReaderDAL.Password((Reader)action.actionModel)); } catch (Exception) { return(0); } case "Permission": try { return(ReaderDAL.Permission((Reader)action.actionModel)); } catch (Exception) { return(0); } default: throw new Exception("Error actionType!"); } case "Book": switch (action.actionType) { case "Add": try { return(BookDAL.Add((Book)action.actionModel)); } catch (Exception) { return(0); } case "Update": try { return(BookDAL.Update((Book)action.actionModel)); } catch (Exception) { return(0); } case "Delete": try { return(BookDAL.Delete((Book)action.actionModel)); } catch (Exception) { return(0); } default: throw new Exception("Error actionType!"); } case "Borrow": switch (action.actionType) { case "Borrow": try { return(BorrowDAL.Borrow((Borrow)action.actionModel)); } catch (Exception) { return(0); } case "Update": try { return(BorrowDAL.Update((Borrow)action.actionModel)); } catch (Exception) { return(0); } case "Delete": try { return(BorrowDAL.Delete((Borrow)action.actionModel)); } catch (Exception) { return(0); } case "Return": try { return(BorrowDAL.Return((Borrow)action.actionModel)); } catch (Exception) { return(0); } case "Continue": try { return(BorrowDAL.Continue((Borrow)action.actionModel)); } catch (Exception) { return(0); } default: throw new Exception("Error actionType!"); } default: throw (new Exception("Error actionSource!")); } }
public int Delete(Book book) { return(BookDAL.Delete(book)); }
public int Delete(int bookId) { return(bookDal.Delete(bookId)); }
/// <summary> /// 删除 /// </summary> /// <param name="Id">主键Id</param> /// <returns>bool值,判断是否操作成功</returns> public bool Delete(int Id) { return(dal.Delete(Id)); }