123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using Models;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- namespace DAL
- {
- public class AirGoodsService
- {
- List<AirGoods> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<AirGoods>.excuteSql(new AirGoods(), "AirGoods", sql, CommandType.Text, param);
- }
- AirGoods excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<AirGoods> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- //增Add
- public bool Add(AirGoods Dov)
- {
- string sql = "insert into AirGoods values(@Diid,@Goods,@Price,@Num,@SubPrices,@Remark,@Oper,@Opdate,@Isdel);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",Dov.Diid),
- new SqlParameter("@Goods",Dov.Goods),
- new SqlParameter("@Price",Dov.Price),
- new SqlParameter("@Num",Dov.Num),
- new SqlParameter("@SubPrices",Dov.SubPrices),
- new SqlParameter("@Remark",Dov.Remark),
- new SqlParameter("@Oper",Dov.Oper),
- new SqlParameter("@Opdate",Dov.Opdate),
- new SqlParameter("@Isdel",Dov.Isdel)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- //改Update
- public bool Edit(AirGoods Dov)
- {
- string sql = "update AirGoods set Diid=@Diid,Goods=@Goods,Price=@Price,Num=@Num,SubPrices=@SubPrices,Remark=@Remark,"
- + "Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",Dov.Diid),
- new SqlParameter("@Goods",Dov.Goods),
- new SqlParameter("@Price",Dov.Price),
- new SqlParameter("@Num",Dov.Num),
- new SqlParameter("@SubPrices",Dov.SubPrices),
- new SqlParameter("@Remark",Dov.Remark),
- new SqlParameter("@Oper",Dov.Oper),
- new SqlParameter("@Opdate",Dov.Opdate),
- new SqlParameter("@Isdel",Dov.Isdel),
- new SqlParameter("@Id",Dov.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- //删
- public bool delOA(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update AirGoods set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 查找所有数据 - 分页
- /// </summary>
- /// <returns></returns>
- public List<AirGoods> GetAll(int diid)
- {
- return excuteSql("select * from AirGoods where Isdel=0 and Diid="+diid);
- }
- public AirGoods getById(int id)
- {
- return excuteType("select * from AirGoods where Isdel=0 and Id=@id", new SqlParameter("@id", id));
- }
- }
- }
|