⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shopdaoimpl.cs

📁 一个超市管理系统,没有错误,非常好,里面什么都有!很使用,很有用
💻 CS
字号:
using System.Data.SqlClient;
using System.Data;
using System;
using System.Collections.Generic;
using System.Text;
using DaFanRongMIS.Model.Common;
using DaFanRongMIS.Model.Shop;


#region 描述
//类名:ShopDAOImpl
//作用:饭店操作类
//创建者:姜秀鑫
//创建时间:2008年1月16日
//修改者:
//修改时间:
//修改内容:
#endregion

namespace DaFanRongMIS.Model.Shop
{
    #region 饭店操作类
    class ShopDAOImpl:ShopDAO
    {
        SqlCommand cmd=null;
        #region 此方法用来增加饭店信息,用于实现饭店模块新店增加功能
        public string AddShop(ShopEntity shop)
        {
            cmd = new SqlCommand();
            cmd.Connection = ConnectionDataBase.getConOpen();
            //将饭店信息写入数据库
            cmd.CommandText = "insert into Shop values('"+ shop.ShopID +"','"+ shop.ShopName +"','"+ shop.ShopAddress +"','"+ shop.ShopMemo +"')";
            cmd.ExecuteNonQuery();
            cmd.Dispose();//卸载cmd对象
            ConnectionDataBase.getConClose();//关闭数据库连接
            return "OK";
        }//end method AddShop
        #endregion

        #region 此方法用来修改饭店信息,用于实现饭店模块信息修改功能
        public string UpdateShop(ShopEntity shop)
        {
            cmd = new SqlCommand();
            cmd.Connection = ConnectionDataBase.getConOpen();
            //将饭店信息写入数据库
            cmd.CommandText = "update Shop set Name='" + shop.ShopName + "',Address='" + shop.ShopAddress + "',Memo='" + shop.ShopMemo + "' where ID='" + shop.ShopID + "'";
            cmd.ExecuteNonQuery();
            cmd.Dispose();//卸载cmd对象
            ConnectionDataBase.getConClose();//关闭数据库连接
            return "OK";
        }
        #endregion

        #region 此方法用来删除饭店信息,用于实现饭店模块信息删除功能
        public string DeleteShop(ShopEntity shop)
        {
            cmd = new SqlCommand();
            cmd.Connection = ConnectionDataBase.getConOpen();
            //将饭店信息写入数据库
            cmd.CommandText = "delete from shop where ID='" + shop.ShopID + "'";
            cmd.ExecuteNonQuery();
            cmd.Dispose();//卸载cmd对象
            ConnectionDataBase.getConClose();//关闭数据库连接
            return "OK";
        }
        #endregion

        #region 此方法用来查询饭店信息,用于实现饭店模块饭店信息查找功能
        public SqlDataReader SelectShop(ShopEntity shop)
        {
            SqlDataReader dr=null;
            string str="";
           if (shop.ShopName != "" && shop.ShopAddress=="")
            {
                str = "select * from Shop where Name like '" + shop.ShopName + "%'";
            }
            else if (shop.ShopName=="" && shop.ShopAddress != "")
            {
                str = "select * from Shop where Address like '" + shop.ShopAddress + "%'";
            }
            else if (shop.ShopAddress != "" && shop.ShopName != "")
            {
                str = "select * from Shop where Name like '" + shop.ShopName + "%'or Address like'" + shop.ShopAddress + "%'";
            }
            else
            {
                str = "select * from Shop";
            }
            cmd = new SqlCommand();
            cmd.Connection = ConnectionDataBase.getConOpen();
            //将饭店信息写入数据库
            cmd.CommandText = str;
            dr = cmd.ExecuteReader();
            return dr;
        }//end method SelectShop()
        #endregion

        #region 此方法用于查询饭店最大编号,用于实现饭店模块自动编号功能
        public string  MaxID()
        {
            cmd = new SqlCommand();
            cmd.Connection = ConnectionDataBase.getConOpen();
            cmd.CommandText = "select max(ID) from Shop";
            int SID=Convert.ToInt32(cmd.ExecuteScalar());
            cmd.Dispose();//卸载cmd对象
            ConnectionDataBase.getConClose();//关闭数据库连接
            if (SID > 10)
                return Convert.ToString(SID += 1);
            else
                return '0'+Convert.ToString(SID += 1);
        }//end method MaxID()
        #endregion
    }//end class ShopDAOImpl
#endregion
}// end namespace DaFanRongMIS.Model.Shop

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -