예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Bsam.Core.Model.Models.Model.Topic model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Topic set ");
            strSql.Append("tLogo=@tLogo,");
            strSql.Append("tName=@tName,");
            strSql.Append("tDetail=@tDetail,");
            strSql.Append("tAuthor=@tAuthor,");
            strSql.Append("tSectendDetail=@tSectendDetail,");
            strSql.Append("tIsDelete=@tIsDelete,");
            strSql.Append("tRead=@tRead,");
            strSql.Append("tCommend=@tCommend,");
            strSql.Append("tGood=@tGood,");
            strSql.Append("tCreatetime=@tCreatetime,");
            strSql.Append("tUpdatetime=@tUpdatetime");
            strSql.Append(" where Id=@Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@tLogo",          DbType.String),
                new SQLiteParameter("@tName",          DbType.String),
                new SQLiteParameter("@tDetail",        DbType.String),
                new SQLiteParameter("@tAuthor",        DbType.String),
                new SQLiteParameter("@tSectendDetail", DbType.String),
                new SQLiteParameter("@tIsDelete",      DbType.bit,       1),
                new SQLiteParameter("@tRead",          DbType.Int32,     8),
                new SQLiteParameter("@tCommend",       DbType.Int32,     8),
                new SQLiteParameter("@tGood",          DbType.Int32,     8),
                new SQLiteParameter("@tCreatetime",    DbType.DateTime),
                new SQLiteParameter("@tUpdatetime",    DbType.DateTime),
                new SQLiteParameter("@Id",             DbType.Int32, 8)
            };
            parameters[0].Value  = model.tLogo;
            parameters[1].Value  = model.tName;
            parameters[2].Value  = model.tDetail;
            parameters[3].Value  = model.tAuthor;
            parameters[4].Value  = model.tSectendDetail;
            parameters[5].Value  = model.tIsDelete;
            parameters[6].Value  = model.tRead;
            parameters[7].Value  = model.tCommend;
            parameters[8].Value  = model.tGood;
            parameters[9].Value  = model.tCreatetime;
            parameters[10].Value = model.tUpdatetime;
            parameters[11].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Bsam.Core.Model.Models.Model.Topic model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Topic(");
            strSql.Append("tLogo,tName,tDetail,tAuthor,tSectendDetail,tIsDelete,tRead,tCommend,tGood,tCreatetime,tUpdatetime)");
            strSql.Append(" values (");
            strSql.Append("@tLogo,@tName,@tDetail,@tAuthor,@tSectendDetail,@tIsDelete,@tRead,@tCommend,@tGood,@tCreatetime,@tUpdatetime)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@tLogo",          DbType.String),
                new SQLiteParameter("@tName",          DbType.String),
                new SQLiteParameter("@tDetail",        DbType.String),
                new SQLiteParameter("@tAuthor",        DbType.String),
                new SQLiteParameter("@tSectendDetail", DbType.String),
                new SQLiteParameter("@tIsDelete",      DbType.bit,       1),
                new SQLiteParameter("@tRead",          DbType.Int32,     8),
                new SQLiteParameter("@tCommend",       DbType.Int32,     8),
                new SQLiteParameter("@tGood",          DbType.Int32,     8),
                new SQLiteParameter("@tCreatetime",    DbType.DateTime),
                new SQLiteParameter("@tUpdatetime",    DbType.DateTime)
            };
            parameters[0].Value  = model.tLogo;
            parameters[1].Value  = model.tName;
            parameters[2].Value  = model.tDetail;
            parameters[3].Value  = model.tAuthor;
            parameters[4].Value  = model.tSectendDetail;
            parameters[5].Value  = model.tIsDelete;
            parameters[6].Value  = model.tRead;
            parameters[7].Value  = model.tCommend;
            parameters[8].Value  = model.tGood;
            parameters[9].Value  = model.tCreatetime;
            parameters[10].Value = model.tUpdatetime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #3
0
 private void ShowInfo(int Id)
 {
     Bsam.Core.Model.Models.BLL.Topic   bll   = new Bsam.Core.Model.Models.BLL.Topic();
     Bsam.Core.Model.Models.Model.Topic model = bll.GetModel(Id);
     this.lblId.Text             = model.Id.ToString();
     this.lbltLogo.Text          = model.tLogo;
     this.lbltName.Text          = model.tName;
     this.lbltDetail.Text        = model.tDetail;
     this.lbltAuthor.Text        = model.tAuthor;
     this.lbltSectendDetail.Text = model.tSectendDetail;
     this.lbltIsDelete.Text      = model.tIsDelete?"是":"否";
     this.lbltRead.Text          = model.tRead.ToString();
     this.lbltCommend.Text       = model.tCommend.ToString();
     this.lbltGood.Text          = model.tGood.ToString();
     this.lbltCreatetime.Text    = model.tCreatetime.ToString();
     this.lbltUpdatetime.Text    = model.tUpdatetime.ToString();
 }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Bsam.Core.Model.Models.Model.Topic GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id,tLogo,tName,tDetail,tAuthor,tSectendDetail,tIsDelete,tRead,tCommend,tGood,tCreatetime,tUpdatetime from Topic ");
            strSql.Append(" where Id=@Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Id", DbType.Int32, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Bsam.Core.Model.Models.Model.Topic DataRowToModel(DataRow row)
 {
     Bsam.Core.Model.Models.Model.Topic model = new Bsam.Core.Model.Models.Model.Topic();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["tLogo"] != null)
         {
             model.tLogo = row["tLogo"].ToString();
         }
         if (row["tName"] != null)
         {
             model.tName = row["tName"].ToString();
         }
         if (row["tDetail"] != null)
         {
             model.tDetail = row["tDetail"].ToString();
         }
         if (row["tAuthor"] != null)
         {
             model.tAuthor = row["tAuthor"].ToString();
         }
         if (row["tSectendDetail"] != null)
         {
             model.tSectendDetail = row["tSectendDetail"].ToString();
         }
         if (row["tIsDelete"] != null && row["tIsDelete"].ToString() != "")
         {
             if ((row["tIsDelete"].ToString() == "1") || (row["tIsDelete"].ToString().ToLower() == "true"))
             {
                 model.tIsDelete = true;
             }
             else
             {
                 model.tIsDelete = false;
             }
         }
         if (row["tRead"] != null && row["tRead"].ToString() != "")
         {
             model.tRead = int.Parse(row["tRead"].ToString());
         }
         if (row["tCommend"] != null && row["tCommend"].ToString() != "")
         {
             model.tCommend = int.Parse(row["tCommend"].ToString());
         }
         if (row["tGood"] != null && row["tGood"].ToString() != "")
         {
             model.tGood = int.Parse(row["tGood"].ToString());
         }
         if (row["tCreatetime"] != null && row["tCreatetime"].ToString() != "")
         {
             model.tCreatetime = DateTime.Parse(row["tCreatetime"].ToString());
         }
         if (row["tUpdatetime"] != null && row["tUpdatetime"].ToString() != "")
         {
             model.tUpdatetime = DateTime.Parse(row["tUpdatetime"].ToString());
         }
     }
     return(model);
 }
예제 #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txttLogo.Text.Trim().Length == 0)
            {
                strErr += "tLogo不能为空!\\n";
            }
            if (this.txttName.Text.Trim().Length == 0)
            {
                strErr += "tName不能为空!\\n";
            }
            if (this.txttDetail.Text.Trim().Length == 0)
            {
                strErr += "tDetail不能为空!\\n";
            }
            if (this.txttAuthor.Text.Trim().Length == 0)
            {
                strErr += "tAuthor不能为空!\\n";
            }
            if (this.txttSectendDetail.Text.Trim().Length == 0)
            {
                strErr += "tSectendDetail不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txttRead.Text))
            {
                strErr += "tRead格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txttCommend.Text))
            {
                strErr += "tCommend格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txttGood.Text))
            {
                strErr += "tGood格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txttCreatetime.Text))
            {
                strErr += "tCreatetime格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txttUpdatetime.Text))
            {
                strErr += "tUpdatetime格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   tLogo          = this.txttLogo.Text;
            string   tName          = this.txttName.Text;
            string   tDetail        = this.txttDetail.Text;
            string   tAuthor        = this.txttAuthor.Text;
            string   tSectendDetail = this.txttSectendDetail.Text;
            bool     tIsDelete      = this.chktIsDelete.Checked;
            int      tRead          = int.Parse(this.txttRead.Text);
            int      tCommend       = int.Parse(this.txttCommend.Text);
            int      tGood          = int.Parse(this.txttGood.Text);
            DateTime tCreatetime    = DateTime.Parse(this.txttCreatetime.Text);
            DateTime tUpdatetime    = DateTime.Parse(this.txttUpdatetime.Text);

            Bsam.Core.Model.Models.Model.Topic model = new Bsam.Core.Model.Models.Model.Topic();
            model.tLogo          = tLogo;
            model.tName          = tName;
            model.tDetail        = tDetail;
            model.tAuthor        = tAuthor;
            model.tSectendDetail = tSectendDetail;
            model.tIsDelete      = tIsDelete;
            model.tRead          = tRead;
            model.tCommend       = tCommend;
            model.tGood          = tGood;
            model.tCreatetime    = tCreatetime;
            model.tUpdatetime    = tUpdatetime;

            Bsam.Core.Model.Models.BLL.Topic bll = new Bsam.Core.Model.Models.BLL.Topic();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }