using System; using System.Collections.Generic; using System.Linq; using System.Text; using CY.IDAL.Inquiry; using System.Transactions; using CY.Model; using System.Data; using System.Data.SqlClient; namespace CY.SQLDAL { public class RangeofBusinessDAL : IRangeofBusinessDAL { Database _dataBase = null; public RangeofBusinessDAL() { _dataBase = new Database(); } public IList GetModelList(int printTypeId) { string selectTarget = " PagerId,GramWeightRange "; string fromSouce = " dbo.SysInquiry_RangeofBusiness "; string condition = " PrintingTypeId="+printTypeId; IList result = _dataBase.SelectModel(selectTarget, fromSouce, condition); return result; } public bool SaveModelList(IList list, int printTypeId) { bool isSuccess = true; using (TransactionScope scope = new TransactionScope()) { isSuccess = DeleteModel(printTypeId); if (isSuccess) { foreach (SysInquiry_RangeofBusiness model in list) { isSuccess = InserModel(model); if (!isSuccess) break; } } if (isSuccess) scope.Complete(); } return isSuccess; } public bool InserModel(Infrastructure.Domain.IAggregateRoot model) { Model.SysInquiry_RangeofBusiness trueModel = model as Model.SysInquiry_RangeofBusiness; if (trueModel == null) { return false; } SqlParameter[] parameters = { new SqlParameter("@PrintingTypeId", SqlDbType.Int,4), new SqlParameter("@PagerId", SqlDbType.Int,4), new SqlParameter("@GramWeightRange", SqlDbType.VarChar,200), new SqlParameter("@PageSizeRange", SqlDbType.VarChar,200), new SqlParameter("@AfterParameterRange", SqlDbType.VarChar,200), new SqlParameter("@Operater", SqlDbType.VarChar,20), new SqlParameter("@OperateTime", SqlDbType.DateTime), new SqlParameter("@lastUpdateTime", SqlDbType.DateTime)}; parameters[0].Value = trueModel.PrintingTypeId; parameters[1].Value = trueModel.PagerId; parameters[2].Value = trueModel.GramWeightRange; parameters[3].Value = trueModel.PageSizeRange; parameters[4].Value = trueModel.AfterParameterRange; parameters[5].Value = trueModel.Operater; parameters[6].Value = trueModel.OperateTime; parameters[7].Value = trueModel.lastUpdateTime; try { _dataBase.Query("SysInquiry_RangeofBusiness_ADD", CommandType.StoredProcedure, parameters); } catch (Exception ex) { throw ex; } return true; } public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model) { throw new NotImplementedException(); } public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model) { throw new NotImplementedException(); } public bool DeleteModel(int printTypeId) { SqlParameter[] parameters = { new SqlParameter("@PrintingTypeId", SqlDbType.Int,4)}; parameters[0].Value = printTypeId; try { _dataBase.Query("SysInquiry_RangeofBusiness_Delete", CommandType.StoredProcedure, parameters); } catch (Exception ex) { throw ex; } return true; } } }