123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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 DayAndCostService
- {
- List<DayAndCost> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<DayAndCost>.excuteSql(new DayAndCost(), "DayAndCost", sql, CommandType.Text, param);
- }
- DayAndCost excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<DayAndCost> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- //增Add
- public bool Add(DayAndCost Dov)
- {
- string sql = "insert into DayAndCost values(@Diid,@Type,@Days,@Place,@Cost,@Currency,@SubTotal,@OPer,@OPDate,@Isdel);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",Dov.Diid),
- new SqlParameter("@Type",Dov.Type),
- new SqlParameter("@Days",Dov.Days),
- new SqlParameter("@Place",Dov.Place),
- new SqlParameter("@Cost",Dov.Cost),
- new SqlParameter("@Currency",Dov.Currency),
- new SqlParameter("@SubTotal",Dov.SubTotal),
- 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(DayAndCost Dov)
- {
- string sql = "update DayAndCost set Diid=@Diid,Type=@Type,Days=@Days,Place=@Place,Cost=@Cost,Currency=@Currency,SubTotal=@SubTotal,OPer=@OPer,OPDate=@OPDate,Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",Dov.Diid),
- new SqlParameter("@Type",Dov.Type),
- new SqlParameter("@Days",Dov.Days),
- new SqlParameter("@Place",Dov.Place),
- new SqlParameter("@Cost",Dov.Cost),
- new SqlParameter("@Currency",Dov.Currency),
- new SqlParameter("@SubTotal",Dov.SubTotal),
- 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 DayAndCost set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 清空
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool Clean(int id)
- {
- string sql = "update DayAndCost set Place ='"+ "',Cost ='0.00',Currency='" + "',SubTotal='0.00' where Id = @Id";
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- public DayAndCost GetById(string id)
- {
- return excuteType("select * from DayAndCost where Isdel=0 and Id =" + id);
- }
- public List<DayAndCost> Get(string Diid, int type)
- {
- return excuteSql("select * from DayAndCost where Isdel=0 and Diid =" + Diid + " and Type=" + type + " order by Days");
- }
- public bool DelAllDataByDiid(string diid)
- {
- string sql = "update DayAndCost set isdel = 1 where isdel = 0 and diid = '" + diid + "' ";
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text) > 0)
- return true;
- return false;
- }
- }
- }
|