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_AdvanceMoneyRecordDAL : IOA_AdvanceMoneyRecordDAL { private Database _dataBase = null; public OA_AdvanceMoneyRecordDAL() { _dataBase = new Database(); } public OA_AdvanceMoneyRecordDAL(Database database) { _dataBase = database; } /// /// 新增 /// /// /// public bool InserModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_AdvanceMoneyRecord trueModel = model as Model.OA_AdvanceMoneyRecord; if (trueModel == null) { return false; } IList sqlParms = new List() { new SqlParameter("@CustomerId",trueModel.CustomerId), new SqlParameter("@OperatTypeId",trueModel.OperatTypeId), new SqlParameter("@OperatMoney",trueModel.OperatMoney), new SqlParameter("@SubjectName",trueModel.SubjectName), new SqlParameter("@AccountType",trueModel.AccountType), new SqlParameter("@AccountName",trueModel.AccountName), new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime), new SqlParameter("@Operator",trueModel.Operator), new SqlParameter("@Remark",trueModel.Remark) }; try { _dataBase.Query("sp_OA_AdvanceMoneyRecord_Insert", CommandType.StoredProcedure, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } /// /// 修改 /// /// /// public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_AdvanceMoneyRecord trueModel = model as Model.OA_AdvanceMoneyRecord; if (trueModel == null) { return false; } IList sqlParms = new List() { new SqlParameter("@Keyid",trueModel.Keyid), new SqlParameter("@CustomerId",trueModel.CustomerId), new SqlParameter("@OperatTypeId",trueModel.OperatTypeId), new SqlParameter("@OperatMoney",trueModel.OperatMoney), new SqlParameter("@SubjectName",trueModel.SubjectName), new SqlParameter("@AccountType",trueModel.AccountType), new SqlParameter("@AccountName",trueModel.AccountName), new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime), new SqlParameter("@Operator",trueModel.Operator), new SqlParameter("@Remark",trueModel.Remark) }; try { _dataBase.Query("sp_OA_AdvanceMoneyRecord_Update", CommandType.StoredProcedure, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } /// /// 删除 /// /// /// public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_AdvanceMoneyRecord trueModel = model as Model.OA_AdvanceMoneyRecord; if (trueModel == null) { return false; } IList sqlParms = new List() { new SqlParameter("@Keyid",trueModel.Keyid) }; try { _dataBase.Query("sp_OA_AdvanceMoneyRecord_DeleteRow", CommandType.StoredProcedure, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } /// /// 分页查询 /// /// /// /// public IEnumerable SelectModelPage(Infrastructure.Query.Query query, Infrastructure.Query.Pagination pagination) { if (null == pagination || null == query || null == query.Criteria || 1 > query.Criteria.Count) return null; string fromSouce = string.Format("{0}", query.Criteria[0].Value);//拼装条件 return _dataBase.SelectModelPage(pagination, " * ", " OA_AdvanceMoneyRecord ", query.Criteria[1].Value.ToString(), query.Criteria[1].Value.ToString(), fromSouce); } /// /// 单个查询 /// /// /// public IEnumerable SelectAllModel(Infrastructure.Query.Query query) { throw new NotImplementedException(); } /// /// 预付款存入 /// /// /// /// /// /// public bool DepositsMoney(OA_FirmAccount m_OA_FirmAccount, OA_CorporateClients m_OA_CorporateClients, OA_FirmAccountRecord m_OA_FirmAccountRecord, OA_AdvanceMoneyRecord m_OA_AdvanceMoneyRecord) { bool IsSuccess = true; try { OA_FirmAccountDAL dal_OA_FirmAccountDAL = new OA_FirmAccountDAL(_dataBase); OA_CorporateClientsDAL dal_OA_CorporateClientsDAL = new OA_CorporateClientsDAL(_dataBase); OA_FirmAccountRecordDAL dal_OA_FirmAccountRecordDAL = new OA_FirmAccountRecordDAL(_dataBase); OA_AdvanceMoneyRecordDAL dal_OA_AdvanceMoneyRecordDAL = new OA_AdvanceMoneyRecordDAL(_dataBase); using (TransactionScope t_TransactionScope = new TransactionScope()) { if (IsSuccess) { IsSuccess = dal_OA_FirmAccountDAL.UpdateModel(m_OA_FirmAccount); if (IsSuccess) { IsSuccess = dal_OA_CorporateClientsDAL.UpdateModel(m_OA_CorporateClients); if (IsSuccess) { IsSuccess = dal_OA_FirmAccountRecordDAL.InserModel(m_OA_FirmAccountRecord); if (IsSuccess) { IsSuccess = dal_OA_AdvanceMoneyRecordDAL.InserModel(m_OA_AdvanceMoneyRecord); if (IsSuccess) { t_TransactionScope.Complete(); } } } } } } return IsSuccess; } catch (Exception ex) { throw ex; } } } }