zoukankan      html  css  js  c++  java
  • 类别操作.类

    namespace dal
    {
        public class olecado
        {
            private olehelp olehelper;

            public olecado()
            {
                olehelper = new olehelp();

            }
            /// <summary>
            /// 选出所有
            /// </summary>
            /// <returns>数据表</returns>
            public DataTable selectall()
            {
                return olehelper.execquery("select * from category", CommandType.Text);

            }
            /// <summary>
            /// 根据id选择
            /// </summary>
            /// <param name="id"></param>
            /// <returns></returns>
            public DataTable selectbyid(string id)
            {
                OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@id", id) };
                return olehelper.execquery("select * from category where id=@id", paras, CommandType.Text);
            }
            /// <summary>
            /// 根据内容选择
            /// </summary>
            /// <param name="catename"></param>
            /// <returns></returns>
            public DataTable selectbycatename(string catename)
            {
                OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@catename", catename) };
                return olehelper.execquery("select * from category where catename like '%'+@catename+'%'", paras, CommandType.Text);
            }
            /// <summary>
            /// 增加
            /// </summary>
            /// <param name="catename">名称</param>
            /// <returns>逻辑</returns>
            public bool insertcategory(string catename)
            {
                bool flag = false;
                string cmdtext = "insert into category(catename) values(@catename)";
                OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@catename", catename) };
                int res = olehelper.execnonquery(cmdtext, paras, CommandType.Text);
                if (res > 0)
                {
                    flag = true;
                }
                return flag;
            }
            /// <summary>
            /// 删除
            /// </summary>
            /// <param name="id"></param>
            /// <returns></returns>
            public bool deletecategory(string id)
            {
                bool flag = false;
                string cmdtext = "delete from category where id=@id";
                OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@id", id) };
                int res = olehelper.execnonquery(cmdtext, paras, CommandType.Text);
                if (res > 0)
                {
                    flag = true;
                }
                return flag;
            }
            /// <summary>
            /// 根据id更新
            /// </summary>
            /// <param name="id"></param>
            /// <param name="catename"></param>
            /// <returns></returns>
            public bool fixcategory(string catename, string id)
            {
                bool flag = false;
                string cmdtext = "update category set catename=@catename where id=@id";
                OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@catename", catename), new OleDbParameter("@id", id) };
                int res = olehelper.execnonquery(cmdtext, paras, CommandType.Text);
                if (res > 0)
                {
                    flag = true;
                }
                return flag;
            }
            /// <summary>
            /// 判断是否存在
            /// </summary>
            /// <param name="catename"></param>
            /// <returns></returns>
            public bool exist(string catename)
            {
                bool flag = false;
                OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@catename", catename) };
                DataTable dt = olehelper.execquery("select * from category where catename=@catename", paras, CommandType.Text);
                //DataTable dt = olehelper.execquery("select * from category where catename='" + catename + "'", CommandType.Text);
                if (dt.Rows.Count > 0)
                {
                    flag = true;
                }
                return flag;
            }

        }
    }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Data.OleDb;
    天道酬勤,厚积薄发。 君子之行,静以修身,俭以养德。 非淡泊无以明志,非宁静无以致远。 如有恒,何须三更起,半夜眠;最怕莫,三天打鱼两天晒网,竹篮打水一场空。
  • 相关阅读:
    Java多线程运行机制的基本原理
    JAVA IO中的设计模式
    C++ 内存泄露处理方法 (转)
    使用PageHeap.EXE或GFlags.EXE检查内存越界错误 (转)
    32位Windows7上8G内存使用感受+xp 32位下使用8G内存 (转)
    windows 32位系统中进程最大可用内存空间为3GB (转)
    OpenGL 4.0 GLSL 实现 投影纹理映射(Projective Texture Mapping) (转)
    DebugView 调试工具
    剑桥中国史:“571”——林彪的未遂政变(转)
    邱会作与儿子对话:林彪的莫须有之罪(转)
  • 原文地址:https://www.cnblogs.com/houweidong/p/2921291.html
Copyright © 2011-2022 走看看