コード例 #1
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public int Insert(Scripts s)
        {
            string sql = "insert into T_Scripts values(@title,@msg,@pid)";
            SqlParameter[]pas=new SqlParameter[]{
                new SqlParameter("@title",s.Title),
                new SqlParameter("@msg",s.Msg),
                new SqlParameter("@pid",s.ParentId)
            };

            return SqlHelper.ExecuteNonQuery(sql, CommandType.Text, pas);
        }
コード例 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     Scripts s=new Scripts();
     s.Msg=textBox2.Text;
     s.ParentId=_pid;
     s.Title=textBox1.Text;
     bll.Insert(s);
     //更新TreeView
     _method();
     this.Close();
 }
コード例 #3
0
 /// <summary>
 /// 根据Id获取子节点
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public List<Scripts> GetSonNodesById(int id)
 {
     List<Scripts> list = new List<Scripts>();
     string sql = "select * from T_Scripts where ScriptParentId=@id";
     using (SqlDataReader reader=SqlHelper.ExecuteReader(sql, System.Data.CommandType.Text,new SqlParameter("@id",id)))
     {
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 Scripts s = new Scripts();
                 s.ID = reader.GetInt32(0);
                 s.Title = reader.GetString(1);
                 s.Msg = reader.GetString(2);
                 s.ParentId = reader.GetInt32(3);
                 list.Add(s);
             }
         }
     }
     return list;
 }
コード例 #4
0
 /// <summary>
 /// 修改节点
 /// </summary>
 /// <param name="s"></param>
 private void ChangeNode(Scripts s)
 {
     treeView1.SelectedNode.Text = s.Title;
     textBox1.Text = s.Msg;
 }
コード例 #5
0
 /// <summary>
 /// 编辑,弹出窗口编辑
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Scripts s=new Scripts();
     s.ID = (int)treeView1.SelectedNode.Tag;
     s.Msg = textBox1.Text;
     s.Title = treeView1.SelectedNode.Text;
     fmEdit fm=new fmEdit(s,ChangeNode);
     fm.Show();
 }
コード例 #6
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public int Update(Scripts s)
 {
     string sql = "update T_Scripts set ScriptTitle=@title,ScriptMsg=@msg where ScriptId=@id";
     SqlParameter[] pas = new SqlParameter[]{
         new SqlParameter("@title",s.Title),
         new SqlParameter("@msg",s.Msg),
         new SqlParameter("@id",s.ID),
     };
     return SqlHelper.ExecuteNonQuery(sql, CommandType.Text, pas);
 }
コード例 #7
0
 /// <summary>
 /// 构造函数,保存主窗体的数据,已经更新数据的方法
 /// </summary>
 /// <param name="s"></param>
 /// <param name="m"></param>
 public fmEdit(Scripts s,Action<Scripts> m)
     : this()
 {
     this.model = s;
     this._method = m;
 }
コード例 #8
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public int Update(Scripts s)
 {
     return dal.Update(s);
 }
コード例 #9
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public int Insert(Scripts s)
 {
     return dal.Insert(s);
 }