📄 cashregisterdaoimpl.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DaFanRongMIS.Model.Common;
namespace DaFanRongMIS.Model.CashRegister
{
class CashRegisterDAOImpl:CashRegisterDAO
{
public SqlDataReader SelectAll()
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = ConnectionDataBase.getConOpen();
cmd.CommandText = "select Shop.Name,CashRegister.ID,CashRegister.Name,CashRegister.IP,CashRegister.HostName,CashRegister.MAC,CashRegister.Hard,CashRegister.Memo from Shop,CashRegister where CashRegister.ShopID=Shop.ID";
SqlDataReader dr = cmd.ExecuteReader();
return dr;
}
public SqlDataReader CRCheck(CashRegisterEntity crEntity)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = ConnectionDataBase.getConOpen();
cmd.CommandText = "select Shop.Name,CashRegister.ID,CashRegister.Name,CashRegister.IP,CashRegister.HostName,CashRegister.MAC,CashRegister.Hard,CashRegister.Memo from Shop,CashRegister where Shop.ID=CashRegister.ShopID and CashRegister.Name like '%" + crEntity.Name + "%' and CashRegister.HostName like '%" + crEntity.Hostname + "%'";
SqlDataReader dr = cmd.ExecuteReader();
return dr;
}
public string getID(String shopName)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = ConnectionDataBase.getConOpen();
cmd.CommandText = "select ID from Shop where Name='" + shopName+ "'";
string name = cmd.ExecuteScalar().ToString();
cmd.Dispose();
ConnectionDataBase.getConClose();
return name;
}
public void CrDelete(CashRegisterEntity crEntity)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = ConnectionDataBase.getConOpen();
cmd.CommandText = "delete CashRegister where ShopID='" + crEntity.Shopid + "' and id='" + crEntity.Id + "'";
cmd.ExecuteNonQuery();
cmd.Dispose();
ConnectionDataBase.getConClose();
}
public string CrAdd(CashRegisterEntity crEntity)
{
string str = "";
try
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = ConnectionDataBase.getConOpen();
cmd.CommandText = "Insert into CashRegister values('" + crEntity.Shopid + "','" + crEntity.Id + "','" + crEntity.Name + "','" +crEntity.Ip + "','" +crEntity.Hostname+ "','" + crEntity.Mac + "','" + crEntity.Hard + "','" +crEntity.Memo + "')";
cmd.ExecuteNonQuery();
cmd.Dispose();
str = "OK";
}
catch (Exception e)
{
str = e.Message;
}
finally
{
ConnectionDataBase.getConClose();
}
return str;
}
public string CrUpdate(CashRegisterEntity crEntity)
{
string str = "";
try
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = ConnectionDataBase.getConOpen();
cmd.CommandText = "update CashRegister set Name='" +crEntity.Name + "',IP='" + crEntity.Ip+ "',HostName='" + crEntity.Hostname + "',MAC='" + crEntity.Mac+ "',Hard='" + crEntity.Hard + "',Memo='" +crEntity.Memo+ "' where ShopID='" + crEntity.Shopid + "' and ID='" + crEntity.Id+ "'";
cmd.ExecuteNonQuery();
str = "OK";
cmd.Dispose();
}
catch (Exception e)
{
str = e.Message;
}
finally
{
ConnectionDataBase.getConClose();
}
return str;
}
public SqlDataReader getShopName()
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = ConnectionDataBase.getConOpen();
cmd.CommandText = "select distinct Name from Shop";
SqlDataReader dr = cmd.ExecuteReader();
return dr;
}
public SqlDataReader AutoID(string shopname)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = ConnectionDataBase.getConOpen();
cmd.CommandText = "select top 1 CashRegister.ID from CashRegister where shopid=(select ID from shop where name='" + shopname + "') order by CashRegister.ID desc";
SqlDataReader dr = cmd.ExecuteReader();
return dr;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -