Model/BookType/BookTypeDAOImpl.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;
using BookMIS.Model.Common;

namespace BookMIS.Model.BookType
{
    class BookTypeDAOImpl:BookTypeDAO
    {
        #region 定义对象
        ConnectDB con = new ConnectDB();
        SqlCommand cmd = null;
        DataTable dt = null;
        SqlDataAdapter sda = new SqlDataAdapter();
        #endregion

        #region 定义变量
        string str = "";
        #endregion

        #region 查询表中数据并存储
        public DataTable SelectBookType()
        {
            try
            {
                dt = new DataTable();
                cmd = new SqlCommand("select * from BookType", con.Getcon());
                sda.SelectCommand = cmd;
                sda.Fill(dt);
            }
            catch(Exception ex)
            {
                dt = null;
            }
            finally
            {
                con.Close();
            }
            return dt;
        }
        #endregion

        #region 添加操作
        public string AddBookType(BookTypeEntity booktype)
        {
            try
            {
                cmd = new SqlCommand("insert into BookType values(@typeid,@typename)", con.Getcon());
                SqlParameter sptid = new SqlParameter("@typeid", SqlDbType.VarChar, 10);
                sptid.Value = booktype.Typeid;
                cmd.Parameters.Add(sptid);

                SqlParameter sptname = new SqlParameter("@typename", SqlDbType.VarChar, 20);
                sptname.Value = booktype.Typename;
                cmd.Parameters.Add(sptname);

后面还有 89 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。