public void CreateNewsGroup(NewsGroup newsGroup) { using (SqlConnection connection = base.GetConnection()) { SqlCommand command = new SqlCommand("_NewsGroupUpdate", connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.AddWithValue("@Type", 0); command.Parameters.AddWithValue("@NewsGroupID", 0); command.Parameters.AddWithValue("@CateNewsID", newsGroup.CateNewsID); command.Parameters.AddWithValue("@ParentNewsID", newsGroup.ParentNewsID); command.Parameters.AddWithValue("@GroupCate", newsGroup.GroupCate); command.Parameters.AddWithValue("@Title", newsGroup.Title); command.Parameters.AddWithValue("@ShortDescribe", newsGroup.ShortDescribe); command.Parameters.AddWithValue("@FullDescribe", newsGroup.FullDescribe); command.Parameters.AddWithValue("@ImageThumb", newsGroup.ImageThumb); command.Parameters.AddWithValue("@ImageLarge", newsGroup.ImageLarge); command.Parameters.AddWithValue("@FileName", newsGroup.FileName); command.Parameters.AddWithValue("@Author", newsGroup.Author); command.Parameters.AddWithValue("@PostDate", newsGroup.PostDate); command.Parameters.AddWithValue("@RelationTotal", newsGroup.RelationTotal); command.Parameters.AddWithValue("@Status", newsGroup.Status); command.Parameters.AddWithValue("@Language", newsGroup.Language); command.Parameters.AddWithValue("@Ishot", newsGroup.Ishot); command.Parameters.AddWithValue("@Isview", newsGroup.Isview); command.Parameters.AddWithValue("@Ishome", newsGroup.Ishome); command.Parameters.AddWithValue("@TypeNews", newsGroup.TypeNews); command.Parameters.AddWithValue("@IsComment", newsGroup.IsComment); command.Parameters.AddWithValue("@ApprovalDate", newsGroup.ApprovalDate); command.Parameters.AddWithValue("@ApprovalUserName", newsGroup.ApprovalUserName); command.Parameters.AddWithValue("@IsApproval", newsGroup.IsApproval); command.Parameters.AddWithValue("@CreatedUserName", newsGroup.CreatedUserName); command.Parameters.AddWithValue("@CommentTotal", newsGroup.CommentTotal); connection.Open(); if (command.ExecuteNonQuery() <= 0) { throw new DataAccessException("Kh\x00f4ng thể th\x00eam mới tin"); } command.Dispose(); } }
//#region ViewCateNews //private void ViewCateNews(int group) //{ // ddlCateNews.Items.Clear(); // CateNewsBSO catenewsBSO = new CateNewsBSO(); // DataTable table = catenewsBSO.GetCateGroupRoles(Language.language, group, Session["Admin_UserName"].ToString()); // commonBSO commonBSO = new commonBSO(); // commonBSO.FillToDropDown(ddlCateNews, table, "", "", "CateNewsName", "CateNewsID", ""); //} //#endregion #region initControl private void initControl(int Id) { AdminBSO adminBSO = new AdminBSO(); ETO.Admin admin = new ETO.Admin(); if (Id > 0) { btn_add.Visible = false; btn_edit.Visible = true; try { NewsGroup newsgroup = new NewsGroup(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); newsgroup = newsgroupBSO.GetNewsGroupById(Id); hddNewsGroupID.Value = Convert.ToString(newsgroup.NewsGroupID); ddlCateNews.SelectedValue = Convert.ToString(newsgroup.CateNewsID); hddParentNewsID.Value = Convert.ToString(newsgroup.ParentNewsID); //rdbGroupCate.SelectedValue = Convert.ToString(newsgroup.GroupCate); //Thêm txtTitle.Text = newsgroup.Title; txtRadShort.Html = newsgroup.ShortDescribe; txtRadFull.Html = newsgroup.FullDescribe; hddImageThumb.Value = newsgroup.ImageThumb; hddImageLarge.Value = newsgroup.ImageLarge; hddFileName.Value = newsgroup.FileName; txtAuthor.Text = newsgroup.Author; txtRadDate.SelectedDate = newsgroup.PostDate; hddRelationTotal.Value = Convert.ToString(newsgroup.RelationTotal); rdbStatus.SelectedValue = Convert.ToString(newsgroup.Status); rdbIshot.SelectedValue = Convert.ToString(newsgroup.Ishot); rdbIshome.SelectedValue = Convert.ToString(newsgroup.Ishome); hddCommentTotal.Value = Convert.ToString(newsgroup.CommentTotal); hddIsView.Value = Convert.ToString(newsgroup.Isview); hddCreateUserName.Value = newsgroup.CreatedUserName; hddApprovalUserName.Value = newsgroup.ApprovalUserName; hddApprovalDate.Value = Convert.ToString(newsgroup.ApprovalDate); rdbComment.SelectedValue = Convert.ToString(newsgroup.IsComment); admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { rdbApproval.SelectedValue = Convert.ToString(newsgroup.IsApproval); rdbApproval.Enabled = true; } else { rdbApproval.SelectedValue = Convert.ToString(newsgroup.IsApproval); rdbApproval.Enabled = false; } hddGroup.Value = newsgroup.GroupCate.ToString(); BindToCateNews(newsgroup.GroupCate); ddlCateNewsGroup.SelectedValue = hddGroup.Value; ddlCateNews.SelectedValue = Convert.ToString(newsgroup.CateNewsID); rdbTypeNews.SelectedValue = Convert.ToString(newsgroup.TypeNews); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } } else { txtRadDate.SelectedDate = DateTime.Now; btn_add.Visible = true; btn_edit.Visible = false; if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { rdbApproval.Enabled = true; } else { rdbApproval.Enabled = false; } } }
public void CreateNewsGroup(NewsGroup newsGroup) { new NewsGroupDAO().CreateNewsGroup(newsGroup); }
private NewsGroup ReceiveHtml() { ConfigBSO configBSO = new ConfigBSO(); Config config = configBSO.GetAllConfig(Language.language); int thumb_w = Convert.ToInt32(config.New_thumb_w); int thumb_h = Convert.ToInt32(config.New_thumb_h); commonBSO commonBSO = new commonBSO(); string path_thumb = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/NewsGroup/NewsGroupThumb/"; string image_thumb = commonBSO.UploadImage(file_image_thumb, path_thumb, thumb_w, thumb_h); int large_w = Convert.ToInt32(config.New_large_w); int large_h = Convert.ToInt32(config.New_large_h); string path_large = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/NewsGroup/NewsGroupLarge/"; string image_large = commonBSO.UploadImage(file_image_thumb, path_large, large_w, large_h); string path = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/NewsGroup/Files/"; string file_upload = commonBSO.UploadFile(file_attached, path, 1800000000000); NewsGroup newsgroup = new NewsGroup(); newsgroup.NewsGroupID = (hddNewsGroupID.Value != "") ? Convert.ToInt32(hddNewsGroupID.Value) : 0; newsgroup.CateNewsID = Convert.ToInt32(ddlCateNews.SelectedValue); newsgroup.ParentNewsID = (hddParentNewsID.Value != "") ? Convert.ToInt32(hddParentNewsID.Value) : 0; //newsgroup.GroupCate = Convert.ToInt32(hddGroup.Value); newsgroup.GroupCate = Convert.ToInt32(ddlCateNewsGroup.SelectedValue); newsgroup.Title = txtTitle.Text; newsgroup.ShortDescribe = txtRadShort.Html; newsgroup.FullDescribe = txtRadFull.Html; newsgroup.ImageThumb = (image_thumb != "") ? image_thumb : hddImageThumb.Value; newsgroup.ImageLarge = (image_large != "") ? image_large : hddImageLarge.Value; newsgroup.FileName = (file_upload != "") ? file_upload : hddFileName.Value; newsgroup.Author = txtAuthor.Text; newsgroup.PostDate = txtRadDate.SelectedDate.Value; newsgroup.RelationTotal = (hddRelationTotal.Value != "") ? Convert.ToInt32(hddRelationTotal.Value) : 0; newsgroup.Status = Convert.ToBoolean(rdbStatus.SelectedItem.Value); newsgroup.Language = Language.language; newsgroup.Ishot = Convert.ToBoolean(rdbIshot.SelectedValue); newsgroup.Ishome = Convert.ToBoolean(rdbIshome.SelectedValue); newsgroup.TypeNews = Convert.ToBoolean(rdbTypeNews.SelectedValue); newsgroup.IsComment = Convert.ToBoolean(rdbComment.SelectedValue); newsgroup.Isview = (hddIsView.Value != "") ? Convert.ToInt32(hddIsView.Value) : 0; newsgroup.CommentTotal = (hddCommentTotal.Value != "") ? Convert.ToInt32(hddCommentTotal.Value) : 0; newsgroup.CreatedUserName = (hddCreateUserName.Value != "") ? hddCreateUserName.Value : Session["Admin_UserName"].ToString(); newsgroup.IsApproval = Convert.ToBoolean(rdbApproval.SelectedValue); if (hddApprovalUserName.Value != "") { newsgroup.ApprovalUserName = hddApprovalUserName.Value; newsgroup.ApprovalDate = Convert.ToDateTime(hddApprovalDate.Value); } else if (Convert.ToBoolean(rdbApproval.SelectedValue)) { newsgroup.ApprovalUserName = Session["Admin_UserName"].ToString(); newsgroup.ApprovalDate = DateTime.Now; } else { newsgroup.ApprovalUserName = ""; newsgroup.ApprovalDate = DateTime.Now; } return newsgroup; }
public void UpdateNewsGroup(NewsGroup newsGroup) { new NewsGroupDAO().UpdateNewsGroup(newsGroup); }