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 BackProgressService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new BackProgress(), "BackProgress", sql, CommandType.Text, param); } BackProgress excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } //增Add public bool Add(BackProgress Dov) { string sql = "insert into BackProgress values(@Diid,@BPTime,@BPRemark,@SQTime,@SQRemark,@CPJTime,@CPJRemark," + "@HZTime,@HZRemark,@QZTime,@QZRemark,@SQQZTime,@SQQZRemark,@CQTime,@CQRemark,@XQHTime,@XQHRemark,@SJTime," + "@SJRemark,@OPer,@OPDate,@Isdel);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",Dov.Diid), new SqlParameter("@BPTime",Dov.BPTime), new SqlParameter("@BPRemark",Dov.BPRemark), new SqlParameter("@SQTime",Dov.SQTime), new SqlParameter("@SQRemark",Dov.SQRemark), new SqlParameter("@CPJTime",Dov.CPJTime), new SqlParameter("@CPJRemark",Dov.CPJRemark), new SqlParameter("@HZTime",Dov.HZTime), new SqlParameter("@HZRemark",Dov.HZRemark), new SqlParameter("@QZTime",Dov.QZTime), new SqlParameter("@QZRemark",Dov.QZRemark), new SqlParameter("@SQQZTime",Dov.SQQZTime), new SqlParameter("@SQQZRemark",Dov.SQQZRemark), new SqlParameter("@CQTime",Dov.CQTime), new SqlParameter("@CQRemark",Dov.CQRemark), new SqlParameter("@XQHTime",Dov.XQHTime), new SqlParameter("@XQHRemark",Dov.XQHRemark), new SqlParameter("@SJTime",Dov.SJTime), new SqlParameter("@SJRemark",Dov.SJRemark), 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(BackProgress Dov) { string sql = "update BackProgress set Diid=@Diid,BPTime=@BPTime,BPRemark=@BPRemark,SQTime=@SQTime,SQRemark=@SQRemark,CPJTime=@CPJTime," +"CPJRemark=@CPJRemark,HZTime=@HZTime,HZRemark=@HZRemark,QZTime=@QZTime,QZRemark=@QZRemark,SQQZTime=@SQQZTime,SQQZRemark=@SQQZRemark," +"CQTime=@CQTime,CQRemark=@CQRemark,XQHTime=@XQHTime,XQHRemark=@XQHRemark,SJTime=@SJTime,SJRemark=@SJRemark,OPer=@OPer," +"OPDate=@OPDate,Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",Dov.Diid), new SqlParameter("@BPTime",Dov.BPTime), new SqlParameter("@BPRemark",Dov.BPRemark), new SqlParameter("@SQTime",Dov.SQTime), new SqlParameter("@SQRemark",Dov.SQRemark), new SqlParameter("@CPJTime",Dov.CPJTime), new SqlParameter("@CPJRemark",Dov.CPJRemark), new SqlParameter("@HZTime",Dov.HZTime), new SqlParameter("@HZRemark",Dov.HZRemark), new SqlParameter("@QZTime",Dov.QZTime), new SqlParameter("@QZRemark",Dov.QZRemark), new SqlParameter("@SQQZTime",Dov.SQQZTime), new SqlParameter("@SQQZRemark",Dov.SQQZRemark), new SqlParameter("@CQTime",Dov.CQTime), new SqlParameter("@CQRemark",Dov.CQRemark), new SqlParameter("@XQHTime",Dov.XQHTime), new SqlParameter("@XQHRemark",Dov.XQHRemark), new SqlParameter("@SJTime",Dov.SJTime), new SqlParameter("@SJRemark",Dov.SJRemark), 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 BackProgress set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } public BackProgress getById(int id) { return excuteType("select * from BackProgress where Isdel=0 and Id=@id", new SqlParameter("@id", id)); } public BackProgress getByDiid(string Diid) { return excuteType("select * from BackProgress where Isdel=0 and Diid =@Diid", new SqlParameter("@Diid", Diid)); } } }