protected void UpdateContent_Click(object sender, EventArgs e) { if (ValidateUpdateFields()) { int contentID = int.Parse(hdnContentID.Value); string contentTitle = tbContentTitle.Text; string contentSmallDesc = SmallDesc.InnerText; string contentDesc = BigDescription.Value; bool hidden = cbContentHidden.Checked; DateTime modifiedDate = DateTime.Parse(ModifiedDate.Text); DateTime createdDate = DateTime.Parse(CreatedDate.Text); try { contentID = AdminContents.UpdateContent(contentID, contentTitle, contentSmallDesc, contentDesc, hidden, createdDate, modifiedDate); if (contentID > 0) { lblMessage.Text = "Content was successfully updated."; } } catch (Exception ex) { logger.Error("Content Update Error: " + ex.Message); lblMessage.Text = "Content Update Error: " + ex.Message; } } }
protected void AddNewContent_Click(object sender, EventArgs e) { if (ValidateInsertFields()) { int categoryID = int.Parse(hdnCategoryID.Value); string contentTitle = tbContentTitle.Text; string contentSmallDesc = SmallDesc.InnerText; string contentDesc = BigDescription.Value; bool hidden = cbContentHidden.Checked; DateTime modifiedDate = DateTime.Parse(ModifiedDate.Text); DateTime createdDate = DateTime.Parse(CreatedDate.Text); int contentID = 0; contentID = AdminContents.AddNewContent(contentTitle, contentSmallDesc, contentDesc, hidden, createdDate, modifiedDate); if (contentID > 0) { AdminContents.AddContentToCategory(contentID, categoryID); lblMessage.Text = "Content was successfully added to " + lblSelectedCategory.Text + "!"; ClearInsertFields(); } else { lblMessage.Text = "Add new content error."; } } }
protected void ContentGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int contentID = int.Parse(ContentGrid.Rows[e.RowIndex].Cells[1].Text); logger.Debug("deleting contents - " + contentID); AdminContents.DeleteContent(contentID); logger.Debug("binding contents - " + _categoryID + " " + hdnCategoryID.Value); int.TryParse(hdnCategoryID.Value, out _categoryID); BindContents(_categoryID); }
private void BindContents(int categoryID) { try { DataTable contents = AdminContents.GetContents(categoryID); ContentGrid.DataSource = contents; ContentGrid.DataBind(); //logger.Debug("contents - " + contents.Rows.Count); } catch (Exception ex) { logger.Error("BindContents Exception - " + ex.Message); } }
private void BindData() { DataTable contents = AdminContents.GetContent(contentID); if (contents.Rows.Count > 0) { DataRow r = contents.Rows[0]; hdnContentID.Value = r["ContentID"].ToString(); tbContentTitle.Text = r["ContentTitle"].ToString(); SmallDesc.InnerText = r["ContentSmallDesc"].ToString(); BigDescription.Value = r["ContentDesc"].ToString(); cbContentHidden.Checked = r["Hidden"] == null? false : bool.Parse(r["Hidden"].ToString()); ModifiedDate.Text = r["Modified"].ToString(); CreatedDate.Text = r["Created"].ToString(); } }