Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Bsam.Core.Model.Models.Model.TopicDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TopicDetail(");
            strSql.Append("TopicId,tdLogo,tdName,tdContent,tdDetail,tdSectendDetail,tdIsDelete,tdRead,tdCommend,tdGood,tdCreatetime,tdUpdatetime,tdTop,tdAuthor)");
            strSql.Append(" values (");
            strSql.Append("@TopicId,@tdLogo,@tdName,@tdContent,@tdDetail,@tdSectendDetail,@tdIsDelete,@tdRead,@tdCommend,@tdGood,@tdCreatetime,@tdUpdatetime,@tdTop,@tdAuthor)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@TopicId",         DbType.Int32,     8),
                new SQLiteParameter("@tdLogo",          DbType.String),
                new SQLiteParameter("@tdName",          DbType.String),
                new SQLiteParameter("@tdContent",       DbType.String),
                new SQLiteParameter("@tdDetail",        DbType.String),
                new SQLiteParameter("@tdSectendDetail", DbType.String),
                new SQLiteParameter("@tdIsDelete",      DbType.bit,       1),
                new SQLiteParameter("@tdRead",          DbType.Int32,     8),
                new SQLiteParameter("@tdCommend",       DbType.Int32,     8),
                new SQLiteParameter("@tdGood",          DbType.Int32,     8),
                new SQLiteParameter("@tdCreatetime",    DbType.DateTime),
                new SQLiteParameter("@tdUpdatetime",    DbType.DateTime),
                new SQLiteParameter("@tdTop",           DbType.Int32,     8),
                new SQLiteParameter("@tdAuthor",        DbType.String)
            };
            parameters[0].Value  = model.TopicId;
            parameters[1].Value  = model.tdLogo;
            parameters[2].Value  = model.tdName;
            parameters[3].Value  = model.tdContent;
            parameters[4].Value  = model.tdDetail;
            parameters[5].Value  = model.tdSectendDetail;
            parameters[6].Value  = model.tdIsDelete;
            parameters[7].Value  = model.tdRead;
            parameters[8].Value  = model.tdCommend;
            parameters[9].Value  = model.tdGood;
            parameters[10].Value = model.tdCreatetime;
            parameters[11].Value = model.tdUpdatetime;
            parameters[12].Value = model.tdTop;
            parameters[13].Value = model.tdAuthor;

            object obj = DbHelperSQLite.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
 private void ShowInfo(int Id)
 {
     Bsam.Core.Model.Models.BLL.TopicDetail   bll   = new Bsam.Core.Model.Models.BLL.TopicDetail();
     Bsam.Core.Model.Models.Model.TopicDetail model = bll.GetModel(Id);
     this.lblId.Text              = model.Id.ToString();
     this.lblTopicId.Text         = model.TopicId.ToString();
     this.lbltdLogo.Text          = model.tdLogo;
     this.lbltdName.Text          = model.tdName;
     this.lbltdContent.Text       = model.tdContent;
     this.lbltdDetail.Text        = model.tdDetail;
     this.lbltdSectendDetail.Text = model.tdSectendDetail;
     this.lbltdIsDelete.Text      = model.tdIsDelete?"是":"否";
     this.lbltdRead.Text          = model.tdRead.ToString();
     this.lbltdCommend.Text       = model.tdCommend.ToString();
     this.lbltdGood.Text          = model.tdGood.ToString();
     this.lbltdCreatetime.Text    = model.tdCreatetime.ToString();
     this.lbltdUpdatetime.Text    = model.tdUpdatetime.ToString();
     this.lbltdTop.Text           = model.tdTop.ToString();
     this.lbltdAuthor.Text        = model.tdAuthor;
 }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Bsam.Core.Model.Models.Model.TopicDetail GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id,TopicId,tdLogo,tdName,tdContent,tdDetail,tdSectendDetail,tdIsDelete,tdRead,tdCommend,tdGood,tdCreatetime,tdUpdatetime,tdTop,tdAuthor from TopicDetail ");
            strSql.Append(" where Id=@Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Id", DbType.Int32, 4)
            };
            parameters[0].Value = Id;

            Bsam.Core.Model.Models.Model.TopicDetail model = new Bsam.Core.Model.Models.Model.TopicDetail();
            DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtTopicId.Text))
            {
                strErr += "TopicId格式错误!\\n";
            }
            if (this.txttdLogo.Text.Trim().Length == 0)
            {
                strErr += "tdLogo不能为空!\\n";
            }
            if (this.txttdName.Text.Trim().Length == 0)
            {
                strErr += "tdName不能为空!\\n";
            }
            if (this.txttdContent.Text.Trim().Length == 0)
            {
                strErr += "tdContent不能为空!\\n";
            }
            if (this.txttdDetail.Text.Trim().Length == 0)
            {
                strErr += "tdDetail不能为空!\\n";
            }
            if (this.txttdSectendDetail.Text.Trim().Length == 0)
            {
                strErr += "tdSectendDetail不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txttdRead.Text))
            {
                strErr += "tdRead格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txttdCommend.Text))
            {
                strErr += "tdCommend格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txttdGood.Text))
            {
                strErr += "tdGood格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txttdCreatetime.Text))
            {
                strErr += "tdCreatetime格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txttdUpdatetime.Text))
            {
                strErr += "tdUpdatetime格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txttdTop.Text))
            {
                strErr += "tdTop格式错误!\\n";
            }
            if (this.txttdAuthor.Text.Trim().Length == 0)
            {
                strErr += "tdAuthor不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      TopicId         = int.Parse(this.txtTopicId.Text);
            string   tdLogo          = this.txttdLogo.Text;
            string   tdName          = this.txttdName.Text;
            string   tdContent       = this.txttdContent.Text;
            string   tdDetail        = this.txttdDetail.Text;
            string   tdSectendDetail = this.txttdSectendDetail.Text;
            bool     tdIsDelete      = this.chktdIsDelete.Checked;
            int      tdRead          = int.Parse(this.txttdRead.Text);
            int      tdCommend       = int.Parse(this.txttdCommend.Text);
            int      tdGood          = int.Parse(this.txttdGood.Text);
            DateTime tdCreatetime    = DateTime.Parse(this.txttdCreatetime.Text);
            DateTime tdUpdatetime    = DateTime.Parse(this.txttdUpdatetime.Text);
            int      tdTop           = int.Parse(this.txttdTop.Text);
            string   tdAuthor        = this.txttdAuthor.Text;

            Bsam.Core.Model.Models.Model.TopicDetail model = new Bsam.Core.Model.Models.Model.TopicDetail();
            model.TopicId         = TopicId;
            model.tdLogo          = tdLogo;
            model.tdName          = tdName;
            model.tdContent       = tdContent;
            model.tdDetail        = tdDetail;
            model.tdSectendDetail = tdSectendDetail;
            model.tdIsDelete      = tdIsDelete;
            model.tdRead          = tdRead;
            model.tdCommend       = tdCommend;
            model.tdGood          = tdGood;
            model.tdCreatetime    = tdCreatetime;
            model.tdUpdatetime    = tdUpdatetime;
            model.tdTop           = tdTop;
            model.tdAuthor        = tdAuthor;

            Bsam.Core.Model.Models.BLL.TopicDetail bll = new Bsam.Core.Model.Models.BLL.TopicDetail();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Esempio n. 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Bsam.Core.Model.Models.Model.TopicDetail DataRowToModel(DataRow row)
 {
     Bsam.Core.Model.Models.Model.TopicDetail model = new Bsam.Core.Model.Models.Model.TopicDetail();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["TopicId"] != null && row["TopicId"].ToString() != "")
         {
             model.TopicId = int.Parse(row["TopicId"].ToString());
         }
         if (row["tdLogo"] != null)
         {
             model.tdLogo = row["tdLogo"].ToString();
         }
         if (row["tdName"] != null)
         {
             model.tdName = row["tdName"].ToString();
         }
         if (row["tdContent"] != null)
         {
             model.tdContent = row["tdContent"].ToString();
         }
         if (row["tdDetail"] != null)
         {
             model.tdDetail = row["tdDetail"].ToString();
         }
         if (row["tdSectendDetail"] != null)
         {
             model.tdSectendDetail = row["tdSectendDetail"].ToString();
         }
         if (row["tdIsDelete"] != null && row["tdIsDelete"].ToString() != "")
         {
             if ((row["tdIsDelete"].ToString() == "1") || (row["tdIsDelete"].ToString().ToLower() == "true"))
             {
                 model.tdIsDelete = true;
             }
             else
             {
                 model.tdIsDelete = false;
             }
         }
         if (row["tdRead"] != null && row["tdRead"].ToString() != "")
         {
             model.tdRead = int.Parse(row["tdRead"].ToString());
         }
         if (row["tdCommend"] != null && row["tdCommend"].ToString() != "")
         {
             model.tdCommend = int.Parse(row["tdCommend"].ToString());
         }
         if (row["tdGood"] != null && row["tdGood"].ToString() != "")
         {
             model.tdGood = int.Parse(row["tdGood"].ToString());
         }
         if (row["tdCreatetime"] != null && row["tdCreatetime"].ToString() != "")
         {
             model.tdCreatetime = DateTime.Parse(row["tdCreatetime"].ToString());
         }
         if (row["tdUpdatetime"] != null && row["tdUpdatetime"].ToString() != "")
         {
             model.tdUpdatetime = DateTime.Parse(row["tdUpdatetime"].ToString());
         }
         if (row["tdTop"] != null && row["tdTop"].ToString() != "")
         {
             model.tdTop = int.Parse(row["tdTop"].ToString());
         }
         if (row["tdAuthor"] != null)
         {
             model.tdAuthor = row["tdAuthor"].ToString();
         }
     }
     return(model);
 }
Esempio n. 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Bsam.Core.Model.Models.Model.TopicDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TopicDetail set ");
            strSql.Append("TopicId=@TopicId,");
            strSql.Append("tdLogo=@tdLogo,");
            strSql.Append("tdName=@tdName,");
            strSql.Append("tdContent=@tdContent,");
            strSql.Append("tdDetail=@tdDetail,");
            strSql.Append("tdSectendDetail=@tdSectendDetail,");
            strSql.Append("tdIsDelete=@tdIsDelete,");
            strSql.Append("tdRead=@tdRead,");
            strSql.Append("tdCommend=@tdCommend,");
            strSql.Append("tdGood=@tdGood,");
            strSql.Append("tdCreatetime=@tdCreatetime,");
            strSql.Append("tdUpdatetime=@tdUpdatetime,");
            strSql.Append("tdTop=@tdTop,");
            strSql.Append("tdAuthor=@tdAuthor");
            strSql.Append(" where Id=@Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@TopicId",         DbType.Int32,     8),
                new SQLiteParameter("@tdLogo",          DbType.String),
                new SQLiteParameter("@tdName",          DbType.String),
                new SQLiteParameter("@tdContent",       DbType.String),
                new SQLiteParameter("@tdDetail",        DbType.String),
                new SQLiteParameter("@tdSectendDetail", DbType.String),
                new SQLiteParameter("@tdIsDelete",      DbType.bit,       1),
                new SQLiteParameter("@tdRead",          DbType.Int32,     8),
                new SQLiteParameter("@tdCommend",       DbType.Int32,     8),
                new SQLiteParameter("@tdGood",          DbType.Int32,     8),
                new SQLiteParameter("@tdCreatetime",    DbType.DateTime),
                new SQLiteParameter("@tdUpdatetime",    DbType.DateTime),
                new SQLiteParameter("@tdTop",           DbType.Int32,     8),
                new SQLiteParameter("@tdAuthor",        DbType.String),
                new SQLiteParameter("@Id",              DbType.Int32, 8)
            };
            parameters[0].Value  = model.TopicId;
            parameters[1].Value  = model.tdLogo;
            parameters[2].Value  = model.tdName;
            parameters[3].Value  = model.tdContent;
            parameters[4].Value  = model.tdDetail;
            parameters[5].Value  = model.tdSectendDetail;
            parameters[6].Value  = model.tdIsDelete;
            parameters[7].Value  = model.tdRead;
            parameters[8].Value  = model.tdCommend;
            parameters[9].Value  = model.tdGood;
            parameters[10].Value = model.tdCreatetime;
            parameters[11].Value = model.tdUpdatetime;
            parameters[12].Value = model.tdTop;
            parameters[13].Value = model.tdAuthor;
            parameters[14].Value = model.Id;

            int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }