/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WSS.Model.PubNotice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_PubNotice(");
            strSql.Append("F_Title,F_Note,F_DateTime)");
            strSql.Append(" values (");
            strSql.Append("@F_Title,@F_Note,@F_DateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Title",    SqlDbType.NChar,     10),
                new SqlParameter("@F_Note",     SqlDbType.NVarChar, 500),
                new SqlParameter("@F_DateTime", SqlDbType.NChar, 10)
            };
            parameters[0].Value = model.F_Title;
            parameters[1].Value = model.F_Note;
            parameters[2].Value = model.F_DateTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WSS.Model.PubNotice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_PubNotice set ");
            strSql.Append("F_Title=@F_Title,");
            strSql.Append("F_Note=@F_Note,");
            strSql.Append("F_DateTime=@F_DateTime");
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Title",    SqlDbType.NChar,     10),
                new SqlParameter("@F_Note",     SqlDbType.NVarChar, 500),
                new SqlParameter("@F_DateTime", SqlDbType.NChar,     10),
                new SqlParameter("@F_ID",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.F_Title;
            parameters[1].Value = model.F_Note;
            parameters[2].Value = model.F_DateTime;
            parameters[3].Value = model.F_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtF_Title.Text.Trim().Length == 0)
            {
                strErr += "标题不能为空!\\n";
            }
            if (this.txtF_Note.Text.Trim().Length == 0)
            {
                strErr += "内容不能为空!\\n";
            }
            if (this.txtF_DateTime.Text.Trim().Length == 0)
            {
                strErr += "时间不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string F_Title    = this.txtF_Title.Text;
            string F_Note     = this.txtF_Note.Text;
            string F_DateTime = this.txtF_DateTime.Text;

            WSS.Model.PubNotice model = new WSS.Model.PubNotice();
            model.F_Title    = F_Title;
            model.F_Note     = F_Note;
            model.F_DateTime = F_DateTime;

            WSS.BLL.PubNotice bll = new WSS.BLL.PubNotice();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Ejemplo n.º 4
0
 private void ShowInfo(int F_ID)
 {
     WSS.BLL.PubNotice   bll   = new WSS.BLL.PubNotice();
     WSS.Model.PubNotice model = bll.GetModel(F_ID);
     this.lblF_ID.Text       = model.F_ID.ToString();
     this.txtF_Title.Text    = model.F_Title;
     this.txtF_Note.Text     = model.F_Note;
     this.txtF_DateTime.Text = model.F_DateTime;
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WSS.Model.PubNotice GetModel(int F_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 F_ID,F_Title,F_Note,F_DateTime from T_PubNotice ");
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = F_ID;

            WSS.Model.PubNotice model = new WSS.Model.PubNotice();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["F_ID"].ToString() != "")
                {
                    model.F_ID = int.Parse(ds.Tables[0].Rows[0]["F_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_Title"] != null)
                {
                    model.F_Title = ds.Tables[0].Rows[0]["F_Title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_Note"] != null)
                {
                    model.F_Note = ds.Tables[0].Rows[0]["F_Note"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_DateTime"] != null)
                {
                    model.F_DateTime = ds.Tables[0].Rows[0]["F_DateTime"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <WSS.Model.PubNotice> DataTableToList(DataTable dt)
        {
            List <WSS.Model.PubNotice> modelList = new List <WSS.Model.PubNotice>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                WSS.Model.PubNotice model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new WSS.Model.PubNotice();
                    if (dt.Rows[n]["F_ID"].ToString() != "")
                    {
                        model.F_ID = int.Parse(dt.Rows[n]["F_ID"].ToString());
                    }
                    model.F_Title    = dt.Rows[n]["F_Title"].ToString();
                    model.F_Note     = dt.Rows[n]["F_Note"].ToString();
                    model.F_DateTime = dt.Rows[n]["F_DateTime"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(WSS.Model.PubNotice model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(WSS.Model.PubNotice model)
 {
     return(dal.Add(model));
 }