using System; using System.Collections.Generic; using System.Linq; using System.Text; using CY.IDAL; using System.Data.SqlClient; using System.Data; using CY.Model; using System.Transactions; namespace CY.SQLDAL { public class OA_YujihuikuanDAL : IOA_YujihuikuanDAL { private Database _dataBase = null; #region 常量 #endregion public OA_YujihuikuanDAL() { _dataBase = new Database(); } /// /// 新增 /// /// /// public bool InserModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_Yujihuikuan trueModel = model as Model.OA_Yujihuikuan; IList sqlParms = new List() { new SqlParameter("@Keyid",trueModel.Keyid), new SqlParameter("@BuyerId",trueModel.BuyerId), new SqlParameter("@shoukuanshijian",trueModel.shoukuanshijian), new SqlParameter("@YujihuikuanTime",trueModel.YujihuikuanTime), new SqlParameter("@CreateTime",trueModel.CreateTime), new SqlParameter("@Updater",trueModel.Updater), new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime), new SqlParameter("@Creater",trueModel.Creater), }; string sql = "Insert Into OA_Yujihuikuan ([Keyid],[BuyerId],[shoukuanshijian],[YujihuikuanTime], [Creater],[CreateTime],[Updater],[LastUpdateTime])" + " Values ( @Keyid,@BuyerId,@shoukuanshijian, @YujihuikuanTime, @Creater,@CreateTime,@Updater,@LastUpdateTime )"; try { _dataBase.ExecuteSql(sql, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } /// /// 修改 /// /// /// public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_Yujihuikuan trueModel = model as Model.OA_Yujihuikuan; if (trueModel == null) { return false; } IList sqlParms = new List() { new SqlParameter("@Keyid",trueModel.Keyid), new SqlParameter("@BuyerId",trueModel.BuyerId), new SqlParameter("@shoukuanshijian",trueModel.shoukuanshijian), new SqlParameter("@YujihuikuanTime",trueModel.YujihuikuanTime), new SqlParameter("@CreateTime",trueModel.CreateTime), new SqlParameter("@Updater",trueModel.Updater), new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime), new SqlParameter("@Creater",trueModel.Creater), }; string sql = "Update OA_Yujihuikuan Set [BuyerId]=@BuyerId,[shoukuanshijian]=@shoukuanshijian,[YujihuikuanTime]=@YujihuikuanTime, [Creater]=@Creater,[CreateTime]=@CreateTime,[Updater]=@Updater,[LastUpdateTime]=@LastUpdateTime where [Keyid] =@Keyid "; try { _dataBase.ExecuteSql(sql, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } /// /// 根据编号获得信息 /// /// 编号 /// public OA_Yujihuikuan GetModelByKeyid(Guid? keyid, Guid? BuyerId, string shoukuanshijian="") { try { string condition = " "; if (!keyid.Equals(Guid.Empty)) { condition = " Keyid='" + keyid + "'"; } else { condition = " BuyerId='" + BuyerId + "' and shoukuanshijian='" + shoukuanshijian + "'"; } // return null;//错误数据返会空 IList result = _dataBase.SelectModel("*", "OA_Yujihuikuan", condition) as IList;//执行查询 return (null == result || result.Count == 0) ? null : result[0];//返回结果 } catch (Exception ex) { throw ex; } } /// /// 全部查询 /// /// /// public IEnumerable SelectAllModel(Infrastructure.Query.Query query) { return _dataBase.SelectModel(" * ", " OA_Yujihuikuan ") as IList;//执行查询 } /// /// 全部查询 /// /// /// public IEnumerable GetModelByformid(Guid FirmId) { return _dataBase.SelectModel(" * ", " OA_Yujihuikuan ", " FirmId = '" + FirmId + "'") as IList;//执行查询 } /// /// 分页查询 /// /// /// /// public IEnumerable SelectModelPage(Infrastructure.Query.Query query, Infrastructure.Query.Pagination pagination) { return null; } /// /// 删除 /// /// /// public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_Yujihuikuan trueModel = model as Model.OA_Yujihuikuan; if (trueModel == null) { return false; } IList sqlParms = new List() { new SqlParameter("@Keyid",trueModel.Keyid) }; string sql = "Delete OA_Yujihuikuan Where [Keyid] = @Keyid "; try { _dataBase.ExecuteSql(sql, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } } }