/// <summary> /// Method to get recoders with condition /// </summary> public IList<Johnny.CMS.OM.SeH.Blog> GetList() { IList<Johnny.CMS.OM.SeH.Blog> list = new List<Johnny.CMS.OM.SeH.Blog>(); StringBuilder strSql = new StringBuilder(); //strSql.Append("SELECT [BlogId], [Title], [BlogCategoryId], [Tag], [Content], [Hits], [IsDisplay], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [Sequence] "); //strSql.Append(" FROM [seh_blog] "); //strSql.Append(" ORDER BY [Sequence]"); strSql.Append("SELECT [BlogId], [Title], [seh_blog].[BlogCategoryId], [seh_blogcategory].[BlogCategoryName], [Tag], [Content], [Hits], [IsDisplay], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [seh_blog].[Sequence] "); strSql.Append(" FROM [seh_blog] "); strSql.Append(" LEFT OUTER JOIN [seh_blogcategory] "); strSql.Append(" ON [seh_blog].[BlogCategoryId] = [seh_blogcategory].[BlogCategoryId] "); strSql.Append(" ORDER BY [seh_blog].[Sequence] DESC"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { Johnny.CMS.OM.SeH.Blog item = new Johnny.CMS.OM.SeH.Blog(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4), sdr.GetString(5), sdr.GetInt32(6), sdr.GetBoolean(7), sdr.GetDateTime(8), sdr.GetInt32(9), sdr.GetString(10), sdr.GetDateTime(11), sdr.GetInt32(12), sdr.GetString(13), sdr.GetInt32(14)); list.Add(item); } } return list; }
/// <summary> /// Method to get one recoder by primary key /// </summary> public Johnny.CMS.OM.SeH.Blog GetModel(int blogid) { //Set up a return value Johnny.CMS.OM.SeH.Blog model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [BlogId], [Title], [BlogCategoryId], [Tag], [Content], [Hits], [IsDisplay], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [Sequence] "); strSql.Append(" FROM [seh_blog] "); strSql.Append(" WHERE [BlogId]=@blogid"); SqlParameter[] parameters = { new SqlParameter("@blogid", SqlDbType.Int, 4) }; parameters[0].Value = blogid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { if (sdr.Read()) { model = new Johnny.CMS.OM.SeH.Blog(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4), sdr.GetInt32(5), sdr.GetBoolean(6), sdr.GetDateTime(7), sdr.GetInt32(8), sdr.GetString(9), sdr.GetDateTime(10), sdr.GetInt32(11), sdr.GetString(12), sdr.GetInt32(13)); } else { model = new Johnny.CMS.OM.SeH.Blog(); } } return(model); }
/// <summary> /// Method to get recoders with condition /// </summary> public IList <Johnny.CMS.OM.SeH.Blog> GetList() { IList <Johnny.CMS.OM.SeH.Blog> list = new List <Johnny.CMS.OM.SeH.Blog>(); StringBuilder strSql = new StringBuilder(); //strSql.Append("SELECT [BlogId], [Title], [BlogCategoryId], [Tag], [Content], [Hits], [IsDisplay], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [Sequence] "); //strSql.Append(" FROM [seh_blog] "); //strSql.Append(" ORDER BY [Sequence]"); strSql.Append("SELECT [BlogId], [Title], [seh_blog].[BlogCategoryId], [seh_blogcategory].[BlogCategoryName], [Tag], [Content], [Hits], [IsDisplay], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [seh_blog].[Sequence] "); strSql.Append(" FROM [seh_blog] "); strSql.Append(" LEFT OUTER JOIN [seh_blogcategory] "); strSql.Append(" ON [seh_blog].[BlogCategoryId] = [seh_blogcategory].[BlogCategoryId] "); strSql.Append(" ORDER BY [seh_blog].[Sequence] DESC"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { Johnny.CMS.OM.SeH.Blog item = new Johnny.CMS.OM.SeH.Blog(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4), sdr.GetString(5), sdr.GetInt32(6), sdr.GetBoolean(7), sdr.GetDateTime(8), sdr.GetInt32(9), sdr.GetString(10), sdr.GetDateTime(11), sdr.GetInt32(12), sdr.GetString(13), sdr.GetInt32(14)); list.Add(item); } } return(list); }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SeH.Blog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("DECLARE @Sequence int"); strSql.Append(" SELECT @Sequence=(max(Sequence)+1) FROM [seh_blog]"); strSql.Append(" if @Sequence is NULL"); strSql.Append(" Set @Sequence=1"); strSql.Append("INSERT INTO [seh_blog]("); strSql.Append("[Title],[BlogCategoryId],[Tag],[Content],[Hits],[IsDisplay],[CreatedTime],[CreatedById],[CreatedByName],[UpdatedTime],[UpdatedById],[UpdatedByName],[Sequence]"); strSql.Append(")"); strSql.Append(" VALUES ("); strSql.Append("@title,@blogcategoryid,@tag,@content,@hits,@isdisplay,@createdtime,@createdbyid,@createdbyname,@updatedtime,@updatedbyid,@updatedbyname,@sequence"); strSql.Append(")"); strSql.Append(";SELECT @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 255), new SqlParameter("@blogcategoryid", SqlDbType.Int, 4), new SqlParameter("@tag", SqlDbType.VarChar, 100), new SqlParameter("@content", SqlDbType.Text), new SqlParameter("@hits", SqlDbType.Int, 4), new SqlParameter("@isdisplay", SqlDbType.Bit), new SqlParameter("@createdtime", SqlDbType.DateTime), new SqlParameter("@createdbyid", SqlDbType.Int, 4), new SqlParameter("@createdbyname", SqlDbType.VarChar, 50), new SqlParameter("@updatedtime", SqlDbType.DateTime), new SqlParameter("@updatedbyid", SqlDbType.Int, 4), new SqlParameter("@updatedbyname", SqlDbType.VarChar, 50) }; parameters[0].Value = model.Title; parameters[1].Value = model.BlogCategoryId; parameters[2].Value = model.Tag; parameters[3].Value = model.Content; parameters[4].Value = model.Hits; parameters[5].Value = model.IsDisplay; parameters[6].Value = model.CreatedTime; parameters[7].Value = model.CreatedById; parameters[8].Value = model.CreatedByName; parameters[9].Value = model.UpdatedTime; parameters[10].Value = model.UpdatedById; parameters[11].Value = model.UpdatedByName; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
protected void Page_Load(object sender, EventArgs e) { int blogid = Convert.ToInt32(Request.QueryString["blogid"]); Johnny.CMS.BLL.SeH.Blog bll = new Johnny.CMS.BLL.SeH.Blog(); Johnny.CMS.OM.SeH.Blog model = bll.GetModel(blogid); if (model != null) { lblTitle.Text = model.Title; lblUpdateTime.Text = DataConvert.GetString(model.UpdatedTime); lblDescription.Text = model.Content; } }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SeH.Blog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE [seh_blog] SET "); strSql.Append("[Title]=@title,"); strSql.Append("[BlogCategoryId]=@blogcategoryid,"); strSql.Append("[Tag]=@tag,"); strSql.Append("[Content]=@content,"); strSql.Append("[Hits]=@hits,"); strSql.Append("[IsDisplay]=@isdisplay,"); //strSql.Append("[CreatedTime]=@createdtime,"); //strSql.Append("[CreatedById]=@createdbyid,"); //strSql.Append("[CreatedByName]=@createdbyname,"); strSql.Append("[UpdatedTime]=@updatedtime,"); strSql.Append("[UpdatedById]=@updatedbyid,"); strSql.Append("[UpdatedByName]=@updatedbyname,"); strSql.Append(" WHERE [BlogId]=@blogid "); SqlParameter[] parameters = { new SqlParameter("@blogid", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.NVarChar, 255), new SqlParameter("@blogcategoryid", SqlDbType.Int, 4), new SqlParameter("@tag", SqlDbType.VarChar, 100), new SqlParameter("@content", SqlDbType.Text), new SqlParameter("@hits", SqlDbType.Int, 4), new SqlParameter("@isdisplay", SqlDbType.Bit), //new SqlParameter("@createdtime", SqlDbType.DateTime), //new SqlParameter("@createdbyid", SqlDbType.Int,4), //new SqlParameter("@createdbyname", SqlDbType.VarChar,50), new SqlParameter("@updatedtime", SqlDbType.DateTime), new SqlParameter("@updatedbyid", SqlDbType.Int, 4), new SqlParameter("@updatedbyname", SqlDbType.VarChar, 50), }; parameters[0].Value = model.BlogId; parameters[1].Value = model.Title; parameters[2].Value = model.BlogCategoryId; parameters[3].Value = model.Tag; parameters[4].Value = model.Content; parameters[5].Value = model.Hits; parameters[6].Value = model.IsDisplay; //parameters[7].Value = model.CreatedTime; //parameters[8].Value = model.CreatedById; //parameters[9].Value = model.CreatedByName; parameters[7].Value = model.UpdatedTime; parameters[8].Value = model.UpdatedById; parameters[9].Value = model.UpdatedByName; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); Johnny.CMS.OM.SeH.Blog model = new Johnny.CMS.OM.SeH.Blog(); base.ManageTable = model.TableName; base.ManageKey = model.PrimaryKey; base.IsDesc = model.IsDesc; if (!IsPostBack) { myManageGridView.Columns[2].HeaderText = GetLabelText("Blog_BlogCategoryId"); myManageGridView.Columns[3].HeaderText = GetLabelText("Blog_Title"); getData(); } }
/// <summary> /// Method to get one recoder by primary key /// </summary> public Johnny.CMS.OM.SeH.Blog GetModel(int blogid) { //Set up a return value Johnny.CMS.OM.SeH.Blog model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [BlogId], [Title], [BlogCategoryId], [Tag], [Content], [Hits], [IsDisplay], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [Sequence] "); strSql.Append(" FROM [seh_blog] "); strSql.Append(" WHERE [BlogId]=@blogid"); SqlParameter[] parameters = { new SqlParameter("@blogid", SqlDbType.Int,4)}; parameters[0].Value = blogid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { if (sdr.Read()) model = new Johnny.CMS.OM.SeH.Blog(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4), sdr.GetInt32(5), sdr.GetBoolean(6), sdr.GetDateTime(7), sdr.GetInt32(8), sdr.GetString(9), sdr.GetDateTime(10), sdr.GetInt32(11), sdr.GetString(12), sdr.GetInt32(13)); else model = new Johnny.CMS.OM.SeH.Blog(); } return model; }
protected void btnAdd_Click(object sender, System.EventArgs e) { //validation if (!CheckInputEmptyAndLength(txtTitle, "E00901", "E00902", false)) { return; } if (!CheckInputEmptyAndLength(txtHits, "E00901", "E00902", false)) { return; } Johnny.CMS.BLL.SeH.Blog bll = new Johnny.CMS.BLL.SeH.Blog(); Johnny.CMS.OM.SeH.Blog model = new Johnny.CMS.OM.SeH.Blog(); if (Request.QueryString["action"] == "modify") { //update model.BlogId = Convert.ToInt32(Request.QueryString["id"]); model.BlogCategoryId = DataConvert.GetInt32(ddlCategory.SelectedValue); model.Title = txtTitle.Text; model.Tag = txtTag.Text; model.Content = fckContent.Value; model.Hits = DataConvert.GetInt32(txtHits.Text); model.IsDisplay = rdbDisplay0.Checked; model.UpdatedTime = System.DateTime.Now; model.UpdatedById = DataConvert.GetInt32(Session["UserId"]); model.UpdatedByName = DataConvert.GetString(Session["UserName"]); bll.Update(model); SetMessage(GetMessage("C00003")); } else { //insert model.BlogCategoryId = DataConvert.GetInt32(ddlCategory.SelectedValue); model.Title = txtTitle.Text; model.Tag = txtTag.Text; model.Content = StringHelper.htmlInputText(fckContent.Value); model.Hits = DataConvert.GetInt32(txtHits.Text); model.IsDisplay = rdbDisplay0.Checked; model.CreatedTime = System.DateTime.Now; model.CreatedById = DataConvert.GetInt32(Session["UserId"]); model.CreatedByName = DataConvert.GetString(Session["UserName"]); model.UpdatedTime = System.DateTime.Now; model.UpdatedById = DataConvert.GetInt32(Session["UserId"]); model.UpdatedByName = DataConvert.GetString(Session["UserName"]); if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); ddlCategory.SelectedIndex = 0; txtTitle.Text = ""; txtTag.Text = ""; fckContent.Value = ""; txtHits.Text = "0"; rdbDisplay0.Checked = true; lblCreatedTime.Text = ""; lblCreatedByName.Text = ""; lblUpdatedTime.Text = ""; lblUpdatedByName.Text = ""; } else { SetMessage(GetMessage("C00002")); } } }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!this.IsPostBack) { litPageTitle.Text = GetLabelText("Blog_Title"); litCategory.Text = GetLabelText("Blog_BlogCategoryId"); ddlCategory.ToolTip = GetLabelText("Blog_BlogCategoryId"); litTitle.Text = GetLabelText("Blog_Title"); txtTitle.ToolTip = GetLabelText("Blog_Title"); litTag.Text = GetLabelText("Blog_Tag"); txtTag.ToolTip = GetLabelText("Blog_Tag"); litContent.Text = GetLabelText("Blog_Content"); litHits.Text = GetLabelText("Blog_Hits"); txtHits.ToolTip = GetLabelText("Blog_Hits"); litIsDisplay.Text = GetLabelText("Blog_IsDisplay"); rdbDisplay0.Text = GetLabelText("Common_Yes"); rdbDisplay1.Text = GetLabelText("Common_No"); litRdbDisplayTip.Text = GetLabelText("Blog_IsDisplay"); litCreatedTime.Text = GetLabelText("Common_CreatedTime"); litCreatedByName.Text = GetLabelText("Common_CreatedByName"); litUpdatedTime.Text = GetLabelText("Common_UpdatedTime"); litUpdatedByName.Text = GetLabelText("Common_UpdatedByName"); if (Request.QueryString["action"] == "modify") { //get id int BlogId = Convert.ToInt32(Request.QueryString["id"]); Johnny.CMS.BLL.SeH.Blog bll = new Johnny.CMS.BLL.SeH.Blog(); Johnny.CMS.OM.SeH.Blog model = new Johnny.CMS.OM.SeH.Blog(); model = bll.GetModel(BlogId); CreateddlCategory(); foreach (ListItem item in ddlCategory.Items) { if (DataConvert.GetInt32(item.Value) == model.BlogCategoryId) { item.Selected = true; break; } } txtTitle.Text = model.Title; txtTag.Text = model.Tag; fckContent.Value = model.Content; txtHits.Text = DataConvert.GetString(model.Hits); if (model.IsDisplay) { rdbDisplay0.Checked = true; } else { rdbDisplay1.Checked = true; } lblCreatedTime.Text = DataConvert.GetLongDateString(model.CreatedTime); lblCreatedByName.Text = model.CreatedByName; lblUpdatedTime.Text = DataConvert.GetLongDateString(model.UpdatedTime); lblUpdatedByName.Text = model.UpdatedByName; btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save; //btnAdd.Text = CONST_BUTTONTEXT_SAVE; } else { CreateddlCategory(); rdbDisplay0.Checked = true; txtHits.Text = "0"; } } }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SeH.Blog model) { dal.Update(model); }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SeH.Blog model) { return(dal.Add(model)); }
protected void btnAdd_Click(object sender, System.EventArgs e) { //validation if (!CheckInputEmptyAndLength(txtTitle, "E00901", "E00902", false)) return; if (!CheckInputEmptyAndLength(txtHits, "E00901", "E00902", false)) return; Johnny.CMS.BLL.SeH.Blog bll = new Johnny.CMS.BLL.SeH.Blog(); Johnny.CMS.OM.SeH.Blog model = new Johnny.CMS.OM.SeH.Blog(); if (Request.QueryString["action"] == "modify") { //update model.BlogId = Convert.ToInt32(Request.QueryString["id"]); model.BlogCategoryId = DataConvert.GetInt32(ddlCategory.SelectedValue); model.Title = txtTitle.Text; model.Tag = txtTag.Text; model.Content = fckContent.Value; model.Hits = DataConvert.GetInt32(txtHits.Text); model.IsDisplay = rdbDisplay0.Checked; model.UpdatedTime = System.DateTime.Now; model.UpdatedById = DataConvert.GetInt32(Session["UserId"]); model.UpdatedByName = DataConvert.GetString(Session["UserName"]); bll.Update(model); SetMessage(GetMessage("C00003")); } else { //insert model.BlogCategoryId = DataConvert.GetInt32(ddlCategory.SelectedValue); model.Title = txtTitle.Text; model.Tag = txtTag.Text; model.Content = StringHelper.htmlInputText(fckContent.Value); model.Hits = DataConvert.GetInt32(txtHits.Text); model.IsDisplay = rdbDisplay0.Checked; model.CreatedTime = System.DateTime.Now; model.CreatedById = DataConvert.GetInt32(Session["UserId"]); model.CreatedByName = DataConvert.GetString(Session["UserName"]); model.UpdatedTime = System.DateTime.Now; model.UpdatedById = DataConvert.GetInt32(Session["UserId"]); model.UpdatedByName = DataConvert.GetString(Session["UserName"]); if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); ddlCategory.SelectedIndex = 0; txtTitle.Text = ""; txtTag.Text = ""; fckContent.Value = ""; txtHits.Text = "0"; rdbDisplay0.Checked = true; lblCreatedTime.Text = ""; lblCreatedByName.Text = ""; lblUpdatedTime.Text = ""; lblUpdatedByName.Text = ""; } else SetMessage(GetMessage("C00002")); } }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!this.IsPostBack) { litPageTitle.Text = GetLabelText("Blog_Title"); litCategory.Text = GetLabelText("Blog_BlogCategoryId"); ddlCategory.ToolTip = GetLabelText("Blog_BlogCategoryId"); litTitle.Text = GetLabelText("Blog_Title"); txtTitle.ToolTip = GetLabelText("Blog_Title"); litTag.Text = GetLabelText("Blog_Tag"); txtTag.ToolTip = GetLabelText("Blog_Tag"); litContent.Text = GetLabelText("Blog_Content"); litHits.Text = GetLabelText("Blog_Hits"); txtHits.ToolTip = GetLabelText("Blog_Hits"); litIsDisplay.Text = GetLabelText("Blog_IsDisplay"); rdbDisplay0.Text = GetLabelText("Common_Yes"); rdbDisplay1.Text = GetLabelText("Common_No"); litRdbDisplayTip.Text = GetLabelText("Blog_IsDisplay"); litCreatedTime.Text = GetLabelText("Common_CreatedTime"); litCreatedByName.Text = GetLabelText("Common_CreatedByName"); litUpdatedTime.Text = GetLabelText("Common_UpdatedTime"); litUpdatedByName.Text = GetLabelText("Common_UpdatedByName"); if (Request.QueryString["action"] == "modify") { //get id int BlogId = Convert.ToInt32(Request.QueryString["id"]); Johnny.CMS.BLL.SeH.Blog bll = new Johnny.CMS.BLL.SeH.Blog(); Johnny.CMS.OM.SeH.Blog model = new Johnny.CMS.OM.SeH.Blog(); model = bll.GetModel(BlogId); CreateddlCategory(); foreach (ListItem item in ddlCategory.Items) { if (DataConvert.GetInt32(item.Value) == model.BlogCategoryId) { item.Selected = true; break; } } txtTitle.Text = model.Title; txtTag.Text = model.Tag; fckContent.Value = model.Content; txtHits.Text = DataConvert.GetString(model.Hits); if (model.IsDisplay) rdbDisplay0.Checked = true; else rdbDisplay1.Checked = true; lblCreatedTime.Text = DataConvert.GetLongDateString(model.CreatedTime); lblCreatedByName.Text = model.CreatedByName; lblUpdatedTime.Text = DataConvert.GetLongDateString(model.UpdatedTime); lblUpdatedByName.Text = model.UpdatedByName; btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save; //btnAdd.Text = CONST_BUTTONTEXT_SAVE; } else { CreateddlCategory(); rdbDisplay0.Checked = true; txtHits.Text = "0"; } } }