public static BookTypeModel GetBookType(int typeNo) { DBConnection.OpenConnection(); SqlCommand command = new SqlCommand(); command.Connection = DBConnection.ConnectionString; command.CommandText = "SELECT * FROM [BookType] WHERE [typeNo] = @typeNo;"; command.Parameters.AddWithValue("@typeNo", (typeNo / 100) * 100); SqlDataReader reader = command.ExecuteReader(); try { if (reader.Read()) { BookTypeModel bookType = new BookTypeModel() { TypeNo = reader.GetInt32(0), Name = reader[1].ToString(), ColourInt = reader.GetInt32(2) }; return(bookType); } } finally { reader.Close(); DBConnection.CloseConnection(); } return(null); }
private void typeDoubleInput_Leave(object sender, EventArgs e) { BookTypeModel type = BookTypeController.GetBookType( ((int)typeDoubleInput.Value) / 100 * 100); typeLabel.BackColor = type.Colour; }
// GET: BookType/Create public ActionResult Create() { BookTypeModel model = new BookTypeModel() { Parent = bookTypeServices.GetParentList() }; return(View(model)); }
public ActionResult AddBookType(BookTypeModel m) { bool added = bookHelp.AddBookTypeList(m); if (added) { var bookTypeList = bookHelp.GetBookType(); return(Json(bookTypeList, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); }
private void okButton_Click(object sender, EventArgs e) { TypeName = nameTextBox.Text; BookTypeModel bookType = new BookTypeModel() { Name = TypeName, Colour = Colour }; BookTypeController.EditBookType(TypeNo, bookType); }
public bool UpdateType(BookTypeModel bookType) { try { book_type bt = IQueryableType().FirstOrDefault(o => o.book_type_id == bookType.book_type_id); bt.book_type_name = bookType.book_type_name; db.SaveChanges(); return(true); } catch (Exception ex) { throw ex; } }
public static void AddBookType(BookTypeModel bookType) { DBConnection.OpenConnection(); SqlCommand command = new SqlCommand(); command.Connection = DBConnection.ConnectionString; command.CommandText = "INSERT INTO [BookType] VALUES(@typeNo, @name, @colour;"; command.Parameters.AddWithValue("@typeNo", bookType.TypeNo); command.Parameters.AddWithValue("@name", bookType.Name); command.Parameters.AddWithValue("@colour", bookType.ColourInt); command.ExecuteNonQuery(); DBConnection.CloseConnection(); }
public static void EditBookType(int typeNo, BookTypeModel bookType) { DBConnection.OpenConnection(); SqlCommand command = new SqlCommand(); command.Connection = DBConnection.ConnectionString; command.CommandText = "UPDATE [BookType] SET [name] = @name, [colour] = @colour " + "WHERE [typeNo] = @typeNo;"; command.Parameters.AddWithValue("@typeNo", typeNo); command.Parameters.AddWithValue("@name", bookType.Name); command.Parameters.AddWithValue("@colour", bookType.ColourInt); command.ExecuteNonQuery(); DBConnection.CloseConnection(); }
/// <summary> /// 添加类别 /// </summary> /// <param name="item"></param> /// <returns></returns> public int AddBookType(BookTypeModel item) { string sql = "insert into BookType(TypeId,TypeName,ParentTypeId,TypeDESC)"; sql += " values (@typeid,@typename,@parenttypeid,@typedesc)"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@typeid", item.TypeId), new SqlParameter("@typename", item.TypeName), new SqlParameter("@parenttypeid", item.ParentTypeId), new SqlParameter("@typedesc", item.TypeDESC) }; int result = helper.ExecuteSql(sql, para); return(result); }
private void CboBookTypeOne_SelectedIndexChanged(object sender, EventArgs e) { if (cboBookTypeOne.SelectedItem != null) { BookTypeModel btype = (BookTypeModel)cboBookTypeOne.SelectedItem; List <BookTypeModel> typetwo = typelist.FindAll(x => x.ParentTypeId == btype.TypeId); if (typetwo.Count > 0) { cboBookTypeTwo.DataSource = null; cboBookTypeTwo.DataSource = typetwo; cboBookTypeTwo.DisplayMember = "TypeName"; cboBookTypeTwo.ValueMember = "TypeId"; cboBookTypeTwo.SelectedIndex = -1; } } }
public ActionResult AddBookType(BookTypeModel book) { try { bool added = book_typeHelp.AddBookType(book); if (added) { var book_typeList = book_typeHelp.GetBookTypeList(); return(Json(book_typeList, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult UpdateBookType(BookTypeModel bookType) { try { bool updated = bookHelp.UpdateType(bookType); if (updated) { var bt = bookHelp.GetBookType(); return(Json(bt, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public bool AddBookType(BookTypeModel m) { try { if (IQueryableType().Where(o => o.book_type_name == m.book_type_name).ToList().Count == 0) { book_type _obj = Mapping(m); db.book_type.Add(_obj); db.SaveChanges(); return(true); } return(false); } catch (Exception ex) { throw ex; } }
public book_type Mapping(BookTypeModel t) { try { if (t != null) { book_type bt = new book_type(); bt.book_type_id = t.book_type_id; bt.book_type_name = t.book_type_name; return(bt); } return(null); } catch (Exception ex) { throw ex; } }
/// <summary> /// 修改类别 /// </summary> /// <param name="item"></param> /// <returns></returns> public int UpdateBookType(BookTypeModel item) { StringBuilder sb = new StringBuilder(); sb.Append(" update BookType set TypeId=@typeid,"); sb.Append(" TypeName=@typename,"); sb.Append(" ParentTypeId=@parenttypeid,"); sb.Append(" TypeDESC=@typedesc"); sb.Append(" where TypeId=@typeid"); SqlParameter[] para = new SqlParameter[] { new SqlParameter("@typeid", item.TypeId), new SqlParameter("@typename", item.TypeName), new SqlParameter("@parenttypeid", item.ParentTypeId), new SqlParameter("@typedesc", item.TypeDESC) }; return(helper.ExecuteSql(sb.ToString(), para)); }
internal BookTypeModel Mapping(book_type m) { try { if (m != null) { BookTypeModel bt = new BookTypeModel(); bt.book_type_id = m.book_type_id; bt.book_type_name = m.book_type_name; return(bt); } return(null); } catch (Exception ex) { throw ex; } }
/// <summary> /// 保存 /// </summary> /// <param name="model"></param> /// <returns></returns> public ResultInfo Create(BookTypeModel model) { ResultInfo ri = new ResultInfo() { Code = -1 }; if (model.BookType == null) { ri.Msg = "无法获取数据"; return(ri); } BookTypes bookTypes = model.BookType; if (string.IsNullOrWhiteSpace(bookTypes.TypeName)) { ri.Msg = "请输入分类名称"; return(ri); } if (bookTypes.ParentId > 0) { var queryModel = bookTypeRepository.GetItem(bookTypes.ParentId); if (queryModel == null) { ri.Msg = "选择的父类不存在"; return(ri); } } if (bookTypeRepository.GetItemByName(bookTypes.TypeName) != null) { ri.Msg = "添加名称已经存在"; return(ri); } bookTypeRepository.Create(bookTypes); ri.Code = 0; ri.Msg = "Success"; ri.Url = "/BookType"; return(ri); }
internal book_type Mapping(BookTypeModel k) { try { if (k != null) { return(new book_type() { book_type_id = k.book_type_id, book_type_name = k.book_type_name }); } return(null); } catch (Exception ex) { throw ex; } }
public bool AddBookType(BookTypeModel m) { if (m == null) { throw new Exception("no object"); } try { if (IQueryable().Where(b => b.book_type_name == m.book_type_name).ToList().Count == 0) { book_type _obj = Mapping(m); dbh.book_type.Add(_obj); dbh.SaveChanges(); return(true); } return(false); } catch (Exception ex) { throw new Exception(ex.Message); } }
internal List <BookTypeModel> Mapping(List <book_type> list) { try { if (list != null && list.Count > 0) { List <BookTypeModel> bList = new List <BookTypeModel>(); foreach (book_type bt in list) { BookTypeModel b = new BookTypeModel(); b.book_type_id = bt.book_type_id; b.book_type_name = bt.book_type_name; bList.Add(b); } return(bList); } return(null); } catch (Exception ex) { throw ex; } }
private void Editbkfrm() { lblTiele.Text = "【修改图书】"; BookExtModel bkinfo = bkbll.GetBookModelById(bookid); if (bkinfo != null) { //页面控件赋值 txtBookId.Text = bkinfo.BookId; txtBookId.ReadOnly = true; txtBookISBN.Text = bkinfo.ISBN; txtBookName.Text = bkinfo.BookName; txtBookAuthor.Text = bkinfo.BookAuthor; txtBookPrice.Text = bkinfo.BookPrice.ToString(); cboBookPress.Text = bkinfo.BookPress.ToString(); dtpPublishDate.Text = bkinfo.BookPublishDate.ToString(); lblStorageInDate.Text = bkinfo.StorageInDate.ToString(); txtStorageInNum.Value = bkinfo.StorageInNum; lblInventoryNum.Value = bkinfo.InventoryNum; lblBorrowedNum.Value = bkinfo.BorrowedNum; //把文本转成图片 if (string.IsNullOrWhiteSpace(bkinfo.BookImage)) { pbCurrentImage.Image = null; } else { pbCurrentImage.Image = (Image)SerializeObjectToString.DeserializeObject(bkinfo.BookImage); } //处理下拉框 cboBookPress.SelectedItem = presslist.Find(x => x.PressId == bkinfo.BookPress); //得到当前书类别信息 BookTypeExtModel currenttype = btbll.GetBookTypeId(bkinfo.BookType); BookTypeModel typeone = typelist.Find(x => x.TypeId == currenttype.ParentTypeId); cboBookTypeOne.SelectedItem = typeone; } }
public bool UpdateType(BookTypeModel bookType) { return(new BookCateTypeLibrary().UpdateType(bookType)); }
public bool AddBookTypeList(BookTypeModel m) { return(new BookCateTypeLibrary().AddBookType(m)); }
/// <summary> /// 添加类别 /// </summary> /// <param name="item"></param> /// <returns></returns> public int AddBookType(BookTypeModel item) { return(dal.AddBookType(item)); }
/// <summary> /// 修改类别 /// </summary> /// <param name="item"></param> /// <returns></returns> public int UpdateBookType(BookTypeModel item) { return(dal.UpdateBookType(item)); }
public bool AddBookType(BookTypeModel book) { return(new BookTypeLibrary().AddBookType(book)); }
public ActionResult Create(BookTypeModel model, IFormCollection collection) { var ri = bookTypeServices.Create(model); return(Json(ri)); }
/// <summary> /// 提交事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCommit_Click(object sender, EventArgs e) { TreeNode tn = tvBookType.SelectedNode; if (tn == null) { MessageBox.Show("您还没有选择节点"); return; } if (string.IsNullOrWhiteSpace(txtTypeName.Text)) { MessageBox.Show("名称不能为空"); return; } switch (actionFlag) { case 0: MessageBox.Show("操作被中止,请选择相关操作"); break; case 1: //添加 string typeid = tn.Tag.ToString(); BookTypeModel model = new BookTypeModel(); model.ParentTypeId = Convert.ToInt32(typeid); model.TypeName = txtTypeName.Text.Trim(); model.TypeDESC = txtDESC.Text.Trim(); model.TypeId = int.Parse(txtTypeId.Text.Trim()); int rst = btbll.AddBookType(model); if (rst == 1) { MessageBox.Show("类别添加成功"); //刷新页面 btlist = btbll.GetAllBookTypes(); frmBookType_Load(null, null); btnCancel_Click(null, null); } else { MessageBox.Show("类别添加失败"); return; } break; case 2: //修改 BookTypeModel mode2 = new BookTypeModel(); mode2.ParentTypeId = int.Parse(txtParentTypeId.Text.Trim()); mode2.TypeName = txtTypeName.Text.Trim(); mode2.TypeDESC = txtDESC.Text.Trim(); mode2.TypeId = int.Parse(txtTypeId.Text.Trim()); int rst2 = btbll.UpdateBookType(mode2); if (rst2 == 1) { MessageBox.Show("类别修改成功"); //刷新页面 btlist = btbll.GetAllBookTypes(); frmBookType_Load(null, null); btnCancel_Click(null, null); } else { MessageBox.Show("类别修改失败"); return; } break; } }