protected void btnSubmit_Click(object sender, EventArgs e) { string _createBy = ""; if (Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY) != null) { _createBy = Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY); } string[] albumArr = Request.Form.GetValues("hide_book_category"); List<Model.BookCategory> bookCategory = new List<Model.BookCategory>(); if (null != albumArr && albumArr.Length > 0) { for (int i = 0; i < albumArr.Length; i++) { bookCategory.Add(new Model.BookCategory { BookID = this.id, CategoryID = Convert.ToInt32(albumArr[i]), Status = 1, CreateBy = _createBy }); } } Model.Book model = new Model.Book(); if (this.id > 0) { model = bll.GetModel(this.id, -1, "", "", "", "", "", "", -1, -1, -1, 1, 1); } model.Title = txtTitle.Text.Trim(); model.TitleUrl = Utils.GenURL(txtTitle.Text.Trim()); model.Author = txtAuthor.Text.Trim(); model.Publisher = txtPublisher.Text.Trim(); model.PublishYear = txtPublishYear.Text.Trim(); model.Language = txtLanguage.Text.Trim(); model.PageNumber = Convert.ToInt32(txtPageNumber.Text.Trim()); model.Price = Convert.ToInt32(txtPrice.Text.Trim()); model.Rating = Convert.ToInt32(txtRating.Text.Trim()); model.Intro = txtIntro.Value; model.Content = txtContent.Value; model.Particular = txtParticular.Value; model.CreateBy = _createBy; model.UpdateBy = _createBy; model.Status = Convert.ToInt32(rbStatus.SelectedValue); model.NewRelease = Convert.ToInt32(rbNewRelease.SelectedValue); model.BookFeature = Convert.ToInt32(rbBookFeature.SelectedValue); model.EnglishBook = Convert.ToInt16(rbEnglishBook.SelectedValue); model.Deleted = 0; // Convert.ToInt32(rbDelete.SelectedValue); model.Amount = Convert.ToInt32(txtAmount.Text.Trim()); model.SmallPicture = txtSmallImage.Value; model.BigPicture = txtBigImage.Value; int ErrCode = 0; int RowEffects = 0; bll.Update(model, ref ErrCode, ref RowEffects); if (RowEffects > 0) { ProcessBookCategory(bookCategory); JscriptMsg(ErrCode.ToString() , "List.aspx", "Success"); } else { JscriptMsg(ErrCode.ToString(), "", "Error"); } }
protected void TreeBuild(List<Model.Category> model, Int64 parent_id, int level, ref DataTable root_table) { var root = (from item in model where item.ParentID == parent_id orderby item.CategoryName ascending select item).ToList(); if (root.Count > 0) { foreach (var x in root) { root_table.Rows.Add(x.CategoryID, x.ParentID, x.CategoryName, level); TreeBuild(model, x.CategoryID, level + 1, ref root_table); } } }
private string GenHTML(List<Model.BookCategory> models) { string hide_name = "hide_book_category"; StringBuilder strTxt = new StringBuilder(); if (models != null && models.Count > 0) { foreach (Model.BookCategory modelt in models) { strTxt.Append("<li>\n"); strTxt.Append("<input type=\"hidden\" rel=\"" + modelt.CategoryName + "\" name=\"" + hide_name + "\" value=\"" + modelt.CategoryID + "\" />\n"); strTxt.Append("<span>" + modelt.CategoryName + "</span>" ); strTxt.Append("<a alt='Xóa' onclick=\"del_category(this);\" href=\"javascript:;\">Xóa</a>\n"); strTxt.Append("</li>\n"); } } return strTxt.ToString(); }
protected void ProcessBookCategory(List<Model.BookCategory> bookCategory) { if (bookCategory.Count > 0) { string BookCategoryList = string.Empty; foreach (Model.BookCategory item in bookCategory) { BookCategoryList += string.Format("{0},", item.BookCategoryID); } Int32 BookID = bookCategory[0].BookID; BLL.BookCategory bll_bookcategory = BLL.BookCategory.Instance; int RowEffects = 0; int ErrCode = 0; // Xóa BookCategoryID cũ bll_bookcategory.Delete(BookID, BookCategoryList, PTSActionKeys.DEL_NOT_IN, ref RowEffects); // Cập nhật BookCategory foreach (Model.BookCategory item in bookCategory) { bll_bookcategory.Update(item, ref ErrCode, ref RowEffects); } } }