protected void btn_add_Click_more(object sender, EventArgs e) { try { NewsGroup newsgroup = ReceiveHtml(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); int _newsgroupID = newsgroupBSO.CreateNewsGroupGet(newsgroup); //Add NewsCate add_NewsCate(_newsgroupID); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog _newsLog = newsLogBSO.GetNewsLog(newsgroup, Session["Admin_UserName"].ToString(), DateTime.Now, 0); int _newsLogID = newsLogBSO.CreateNewsLog(_newsLog); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>"; AspNetCache.Reset(); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
public int CreateNewsLog(NewsLog newsLog) { using (SqlConnection connection = GetConnection()) { SqlCommand command = new SqlCommand("_NewsLogInsert", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Type", 0); command.Parameters.AddWithValue("@NewsLogID", 0); command.Parameters.AddWithValue("@NewsGroupID", newsLog.NewsGroupID); command.Parameters.AddWithValue("@CateNewsID", newsLog.CateNewsID); command.Parameters.AddWithValue("@ParentNewsID", newsLog.ParentNewsID); command.Parameters.AddWithValue("@GroupCate", newsLog.GroupCate); command.Parameters.AddWithValue("@Title", newsLog.Title); command.Parameters.AddWithValue("@ShortDescribe", newsLog.ShortDescribe); command.Parameters.AddWithValue("@FullDescribe", newsLog.FullDescribe); command.Parameters.AddWithValue("@ImageThumb", newsLog.ImageThumb); command.Parameters.AddWithValue("@ImageLarge", newsLog.ImageLarge); command.Parameters.AddWithValue("@FileName", newsLog.FileName); command.Parameters.AddWithValue("@Author", newsLog.Author); command.Parameters.AddWithValue("@PostDate", newsLog.PostDate); command.Parameters.AddWithValue("@RelationTotal", newsLog.RelationTotal); command.Parameters.AddWithValue("@Status", newsLog.Status); command.Parameters.AddWithValue("@Language", newsLog.Language); command.Parameters.AddWithValue("@Ishot", newsLog.Ishot); command.Parameters.AddWithValue("@Isview", newsLog.Isview); command.Parameters.AddWithValue("@Ishome", newsLog.Ishome); command.Parameters.AddWithValue("@TypeNews", newsLog.TypeNews); command.Parameters.AddWithValue("@IsComment", newsLog.IsComment); command.Parameters.AddWithValue("@ApprovalDate", newsLog.ApprovalDate); command.Parameters.AddWithValue("@ApprovalUserName", newsLog.ApprovalUserName); command.Parameters.AddWithValue("@IsApproval", newsLog.IsApproval); command.Parameters.AddWithValue("@CreatedUserName", newsLog.CreatedUserName); command.Parameters.AddWithValue("@CommentTotal", newsLog.CommentTotal); command.Parameters.AddWithValue("@Slug", newsLog.Slug); command.Parameters.AddWithValue("@Keyword", newsLog.Keyword); command.Parameters.AddWithValue("@Tags", newsLog.Tags); command.Parameters.AddWithValue("@ShortTitle", newsLog.ShortTitle); command.Parameters.AddWithValue("@isUrl", newsLog.isUrl); command.Parameters.AddWithValue("@Url", newsLog.Url); command.Parameters.AddWithValue("@isDelete", newsLog.isDelete); command.Parameters.AddWithValue("@ModifyDate", newsLog.ModifyDate); command.Parameters.AddWithValue("@ModifyUserName", newsLog.ModifyUserName); command.Parameters.AddWithValue("@Version", newsLog.Version); SqlParameter sp = new SqlParameter("@pReturnValue", SqlDbType.Int); sp.Direction = ParameterDirection.Output; command.Parameters.Add(sp); connection.Open(); command.ExecuteNonQuery(); int id = Convert.ToInt32(sp.Value.ToString()); return(id); } }
public NewsLog GetNewsLogById(int Id) { NewsLog newsLog = null; using (SqlConnection connection = GetConnection()) { SqlCommand command = new SqlCommand("_NewsLogGetById", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@NewsLogID", Id); connection.Open(); using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection)) { if (reader.Read()) { newsLog = NewsLogReader(reader); } else { // throw new DataAccessException("Không tìm thấy tin"); newsLog = null; } } command.Dispose(); } return(newsLog); }
protected void btn_add_Click(object sender, EventArgs e) { try { NewsGroup newsgroup = ReceiveHtml(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); int _newsgroupID = newsgroupBSO.CreateNewsGroupGet(newsgroup); add_NewsCate(_newsgroupID); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog _newsLog = newsLogBSO.GetNewsLog(newsgroup, Session["Admin_UserName"].ToString(), DateTime.Now, 0); int _newsLogID = newsLogBSO.CreateNewsLog(_newsLog); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>"; initControl(_newsgroupID); AspNetCache.Reset(); ViewNewsLog(_newsgroupID); //Response.Redirect("~/Admin/Group/listnewsgroup/" + hddGroup.Value + "/Default.aspx"); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
protected void btn_edit_Click(object sender, EventArgs e) { try { NewsGroup newsgroup = ReceiveHtml(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); newsgroupBSO.UpdateNewsGroup(newsgroup); //Add NewsCate NewsCateBSO _newscateBSO = new NewsCateBSO(); DataTable tblNewsCate = _newscateBSO.GetNewsCateByNewsGroupID(newsgroup.NewsGroupID); if (tblNewsCate.Rows.Count > 0) { _newscateBSO.DeleteNewsCatebyNewsID(newsgroup.NewsGroupID); } add_NewsCate(newsgroup.NewsGroupID); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog _newsLog = newsLogBSO.GetNewsLog(newsgroup, Session["Admin_UserName"].ToString(), DateTime.Now, 0); int _newsLogID = newsLogBSO.CreateNewsLog(_newsLog); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật thành công !</div>"; initControl(newsgroup.NewsGroupID); ViewNewsLog(newsgroup.NewsGroupID); AspNetCache.Reset(); //ViewCateNews(Convert.ToInt32(hddGroup.Value)); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
protected void grvNewsLog_RowCommand(object sender, GridViewCommandEventArgs e) { int Id = Convert.ToInt32(e.CommandArgument.ToString()); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog newslog = newsLogBSO.GetNewsLogById(Id); string nName = e.CommandName.ToLower(); AdminBSO adminBSO = new AdminBSO(); Admin admin = new Admin(); switch (nName) { case "_view": break; case "_edit": if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { // Response.Redirect("~/Admin/editnewslog/" + Id + "/Default.aspx"); Response.Redirect("~/Admin/s/EditNewsbyUser/" + hddNewsGroupID.Value + "/" + Id + "/Default.aspx"); } break; case "_delete": if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { newsLogBSO.DeleteNewsLog(Id, -1); ViewNewsLog(Convert.ToInt32(hddNewsGroupID.Value)); AspNetCache.Reset(); } break; } }
public void UpdateNewsLog(NewsLog newsLog) { using (SqlConnection connection = GetConnection()) { SqlCommand command = new SqlCommand("_NewsLogUpdate", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Type", 1); command.Parameters.AddWithValue("@NewsLogID", newsLog.NewsLogID); command.Parameters.AddWithValue("@NewsGroupID", newsLog.NewsGroupID); command.Parameters.AddWithValue("@CateNewsID", newsLog.CateNewsID); command.Parameters.AddWithValue("@ParentNewsID", newsLog.ParentNewsID); command.Parameters.AddWithValue("@GroupCate", newsLog.GroupCate); command.Parameters.AddWithValue("@Title", newsLog.Title); command.Parameters.AddWithValue("@ShortDescribe", newsLog.ShortDescribe); command.Parameters.AddWithValue("@FullDescribe", newsLog.FullDescribe); command.Parameters.AddWithValue("@ImageThumb", newsLog.ImageThumb); command.Parameters.AddWithValue("@ImageLarge", newsLog.ImageLarge); command.Parameters.AddWithValue("@FileName", newsLog.FileName); command.Parameters.AddWithValue("@Author", newsLog.Author); command.Parameters.AddWithValue("@PostDate", newsLog.PostDate); command.Parameters.AddWithValue("@RelationTotal", newsLog.RelationTotal); command.Parameters.AddWithValue("@Status", newsLog.Status); command.Parameters.AddWithValue("@Language", newsLog.Language); command.Parameters.AddWithValue("@Ishot", newsLog.Ishot); command.Parameters.AddWithValue("@Isview", newsLog.Isview); command.Parameters.AddWithValue("@Ishome", newsLog.Ishome); command.Parameters.AddWithValue("@TypeNews", newsLog.TypeNews); command.Parameters.AddWithValue("@IsComment", newsLog.IsComment); command.Parameters.AddWithValue("@ApprovalDate", newsLog.ApprovalDate); command.Parameters.AddWithValue("@ApprovalUserName", newsLog.ApprovalUserName); command.Parameters.AddWithValue("@IsApproval", newsLog.IsApproval); command.Parameters.AddWithValue("@CreatedUserName", newsLog.CreatedUserName); command.Parameters.AddWithValue("@CommentTotal", newsLog.CommentTotal); command.Parameters.AddWithValue("@Slug", newsLog.Slug); command.Parameters.AddWithValue("@Keyword", newsLog.Keyword); command.Parameters.AddWithValue("@Tags", newsLog.Tags); command.Parameters.AddWithValue("@ShortTitle", newsLog.ShortTitle); command.Parameters.AddWithValue("@isUrl", newsLog.isUrl); command.Parameters.AddWithValue("@Url", newsLog.Url); command.Parameters.AddWithValue("@isDelete", newsLog.isDelete); command.Parameters.AddWithValue("@ModifyDate", newsLog.ModifyDate); command.Parameters.AddWithValue("@ModifyUserName", newsLog.ModifyUserName); command.Parameters.AddWithValue("@Version", newsLog.Version); connection.Open(); if (command.ExecuteNonQuery() <= 0) { throw new DataAccessException("Không thể cập nhật tin"); } else { command.Dispose(); } } }
public ActionResult AddNews(NewsLog newsLog) { newsLog.Id = Guid.NewGuid(); newsLog.PostTime = DateTime.Now; NewsRepository.Create(newsLog); return(View("Index", newsLog)); }
public void Remove(NewsLog newsLog) { var entity = Db.NewsLog.FirstOrDefault(x => x.Id.Equals(newsLog.Id)); if (entity == null) { return; } Db.SaveChanges(); }
private void ViewNews(int Id) { NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog newsLog = newsLogBSO.GetNewsLogById(Id); if (newsLog != null) { ltlTitle.Text = newsLog.Title; LabelDate.Text = newsLog.PostDate.ToString("dd/MM/yyyy");// Convert.ToString(newsLog.PostDate); ltlDescribe.Text = newsLog.ShortDescribe; FullDescirbe.Text = newsLog.FullDescribe; LabelAuthor.Text = newsLog.Author; //if (newsLog.ImageThumb != "") // ltlImageThumb.Text = @"<img src='" + ResolveUrl("~/") + "Upload/newsLog/newsLogThumb/" + newsLog.ImageThumb + "' align='left' class='border_image' width='250' >"; } }
protected void btn_add_Click(object sender, EventArgs e) { try { NewsGroup newsgroup = ReceiveHtml(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); // MessageBox.Show(); //if (Tool.CountWords2(Tool.StripTagsCharArray(newsgroup.ShortDescribe)) > 60) //{ // String csname = "PopupScript"; // Type cstype = this.GetType(); // ClientScriptManager cs = Page.ClientScript; // if (!cs.IsStartupScriptRegistered(cstype, csname)) // { // String cstext = "Confirmation();"; // cs.RegisterStartupScript(cstype, csname, cstext, true); // } // if (hnd.Value != "") // { int _newsgroupID = newsgroupBSO.CreateNewsGroupGet(newsgroup); //Add NewsCate add_NewsCate(_newsgroupID); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog _newsLog = newsLogBSO.GetNewsLog(newsgroup, Session["Admin_UserName"].ToString(), DateTime.Now, 0); int _newsLogID = newsLogBSO.CreateNewsLog(_newsLog); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>"; initControl(_newsgroupID); AspNetCache.Reset(); ViewNewsLog(_newsgroupID); //Response.Redirect("~/Admin/Group/listnewsgroup/" + hddGroup.Value + "/Default.aspx"); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
public NewsLog GetNewsLog(NewsGroup newGroup, string username, DateTime date, int version) { NewsLog newsLog = new NewsLog(); newsLog.NewsLogID = 0; newsLog.NewsGroupID = newGroup.NewsGroupID; newsLog.CateNewsID = newGroup.CateNewsID; newsLog.ParentNewsID = newGroup.ParentNewsID; newsLog.GroupCate = newGroup.GroupCate; newsLog.Title = newGroup.Title; newsLog.ShortDescribe = newGroup.ShortDescribe; newsLog.FullDescribe = newGroup.FullDescribe; newsLog.ImageThumb = newGroup.ImageThumb; newsLog.ImageLarge = newGroup.ImageLarge; newsLog.FileName = newGroup.FileName; newsLog.Author = newGroup.Author; newsLog.PostDate = newGroup.PostDate; newsLog.RelationTotal = newGroup.RelationTotal; newsLog.Status = newGroup.Status; newsLog.Language = newGroup.Language; newsLog.Ishot = newGroup.Ishot; newsLog.Isview = newGroup.Isview; newsLog.Ishome = newGroup.Ishome; newsLog.TypeNews = newGroup.TypeNews; newsLog.IsComment = newGroup.IsComment; newsLog.ApprovalDate = newGroup.ApprovalDate; newsLog.ApprovalUserName = newGroup.ApprovalUserName; newsLog.IsApproval = newGroup.IsApproval; newsLog.CreatedUserName = newGroup.CreatedUserName; newsLog.CommentTotal = newGroup.CommentTotal; newsLog.Slug = newGroup.Slug; newsLog.Keyword = newGroup.Keyword; newsLog.Tags = newGroup.Tags; newsLog.ShortTitle = newGroup.ShortTitle; newsLog.isUrl = newGroup.isUrl; newsLog.Url = newGroup.Url; newsLog.isDelete = newGroup.isDelete; newsLog.ModifyDate = date; newsLog.ModifyUserName = username; newsLog.Version = version; return(newsLog); }
private NewsLog NewsLogReader(SqlDataReader reader) { NewsLog newsLog = new NewsLog(); newsLog.NewsLogID = (int)reader["NewsLogID"]; newsLog.NewsGroupID = (int)reader["NewsGroupID"]; newsLog.CateNewsID = (int)reader["CateNewsID"]; newsLog.ParentNewsID = (int)reader["ParentNewsID"]; newsLog.GroupCate = (int)reader["GroupCate"]; newsLog.Title = (string)reader["Title"]; newsLog.ShortDescribe = (string)reader["ShortDescribe"]; newsLog.FullDescribe = (string)reader["FullDescribe"]; newsLog.ImageThumb = (string)reader["ImageThumb"]; newsLog.ImageLarge = (string)reader["ImageLarge"]; newsLog.FileName = (string)reader["FileName"]; newsLog.Author = (string)reader["Author"]; newsLog.PostDate = (DateTime)reader["PostDate"]; newsLog.RelationTotal = (int)reader["RelationTotal"]; newsLog.Status = (bool)reader["Status"]; newsLog.Language = (string)reader["Language"]; newsLog.Ishot = (bool)reader["Ishot"]; newsLog.Isview = (int)reader["Isview"]; newsLog.Ishome = (bool)reader["Ishome"]; newsLog.TypeNews = (bool)reader["TypeNews"]; newsLog.IsComment = (bool)reader["IsComment"]; newsLog.ApprovalDate = (DateTime)reader["ApprovalDate"]; newsLog.ApprovalUserName = (string)reader["ApprovalUserName"]; newsLog.IsApproval = (bool)reader["IsApproval"]; newsLog.CreatedUserName = (string)reader["CreatedUserName"]; newsLog.CommentTotal = (int)reader["CommentTotal"]; newsLog.Slug = (string)reader["Slug"]; newsLog.Keyword = (string)reader["Keyword"]; newsLog.Tags = (string)reader["Tags"]; newsLog.ShortTitle = (string)reader["ShortTitle"]; newsLog.isUrl = (bool)reader["isUrl"]; newsLog.Url = (string)reader["Url"]; newsLog.isDelete = (bool)reader["isDelete"]; newsLog.ModifyDate = (DateTime)reader["ModifyDate"]; newsLog.ModifyUserName = (string)reader["ModifyUserName"]; newsLog.Version = (int)reader["Version"]; return(newsLog); }
private void initControl(int Id, int subId) { AdminBSO adminBSO = new AdminBSO(); Admin admin = new Admin(); if (Id > 0) { btn_add.Visible = false; btn_edit.Visible = true; btn_add2.Visible = false; btn_add1.Visible = false; btn_edit1.Visible = true; try { NewsLog newsgroup = new NewsLog(); NewsLogBSO newsgroupBSO = new NewsLogBSO(); newsgroup = newsgroupBSO.GetNewsLogById(subId); //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.Text = System.Net.WebUtility.HtmlDecode(newsgroup.ShortDescribe); txtRadFull.Text = newsgroup.FullDescribe; hddImageThumb.Value = newsgroup.ImageThumb; hddImageLarge.Value = newsgroup.ImageLarge; txtimage4_3.Text = newsgroup.ImageThumb; txtimage16_9.Text = newsgroup.ImageLarge; if (newsgroup.ImageThumb != "") { img_thumb.Text = "<img src='" + newsgroup.ImageThumb + "' width='48px' valign='middle'>"; } if (newsgroup.ImageLarge != "") { img_large.Text = "<img src='" + newsgroup.ImageLarge + "' width='48px' valign='middle'>"; } hddFileName.Value = newsgroup.FileName; txtAuthor.Text = newsgroup.Author; txtRadDate.Text = String.Format("{0:dd/MM/yyyy HH:mm}", newsgroup.PostDate); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString(); hddPostDate.Value = String.Format("{0:dd/MM/yyyy HH:mm}", newsgroup.PostDate); // "9/3/2008 16:05:07" .ToString(); hddRelationTotal.Value = Convert.ToString(newsgroup.RelationTotal); rdbStatus.Checked = newsgroup.Status; rdbIshot.Checked = newsgroup.Ishot; rdbIshome.Checked = 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); txtKeywords.Text = newsgroup.Keyword; txtTags.Text = newsgroup.Tags; txtSlug.Text = newsgroup.Slug; rdbComment.Checked = newsgroup.IsComment; rdbApproval.Checked = newsgroup.IsApproval; if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { rdbApproval.Enabled = true; } else { rdbApproval.Enabled = false; } //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); //if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) //{ // rdbApproval.Checked = newsgroup.IsApproval; // rdbApproval.Enabled = true; //} //else //{ // rdbApproval.Checked = newsgroup.IsApproval; // rdbApproval.Enabled = false; //} hddGroup.Value = newsgroup.GroupCate.ToString(); BindToCateNews(newsgroup.GroupCate); ddlCateNewsGroup.SelectedValue = hddGroup.Value; ddlCateNews.SelectedValue = Convert.ToString(newsgroup.CateNewsID); rdbTypeNews.Checked = newsgroup.TypeNews; txtShortTitle.Text = newsgroup.ShortTitle; chkUrl.Checked = newsgroup.isUrl; txtUrl.Text = newsgroup.Url; if (newsgroup.isUrl) { txtUrl.Visible = true; panelUrl.Visible = true; } else { txtUrl.Visible = false; panelUrl.Visible = false; } hddisDelete.Value = newsgroup.isDelete.ToString(); BindListCate(newsgroup.NewsGroupID); //MultiCate ViewNewsLog(newsgroup.NewsGroupID); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } } else { txtRadDate.Text = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString(); hddPostDate.Value = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); // "9/3/2008 16:05:07" .ToString(); txtUrl.Visible = false; btn_add.Visible = true; btn_edit.Visible = false; btn_add2.Visible = true; btn_add1.Visible = true; btn_edit1.Visible = false; if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { rdbApproval.Enabled = true; } else { rdbApproval.Enabled = false; } txtUrl.Visible = false; panelUrl.Visible = false; chkUrl.Checked = false; } }
public void UpdateNewsLog(NewsLog newsLog) { NewsLogDAO newsLogDAO = new NewsLogDAO(); newsLogDAO.UpdateNewsLog(newsLog); }
public void Create(NewsLog newsLog) { newsLog.Id = Guid.NewGuid(); Db.NewsLog.Add(newsLog); Db.SaveChanges(); }
public void Update(NewsLog newsLog) { Db.SaveChanges(); }
public int CreateNewsLog(NewsLog newsLog) { NewsLogDAO newsLogDAO = new NewsLogDAO(); return(newsLogDAO.CreateNewsLog(newsLog)); }