/// <summary> /// Процедура сохранения записи в базе данных. /// </summary> /// <param name="model">Текущая модель.</param> /// <param name="error">Переменная для возврата текста сообщения об ошибке.</param> public bool SaveGpdRefDetailDialog(GpdRefDetailDialogModel model, out string error) { error = string.Empty; //UserRole currentUserRole = AuthenticationService.CurrentUser.UserRole; IUser currentUseId = AuthenticationService.CurrentUser; try { GpdRefDetail gpdrefDetail = GpdRefDetailDao.Get(model.Id); if (model.Id == 0) { gpdrefDetail = new GpdRefDetail { Name = model.Name, ContractorName = model.ContractorName, //DTID = 1,//model.DTID, INN = model.INN, KPP = model.KPP, Account = model.Account, BankName = model.BankName, BankBIK = model.BankBIK, CorrAccount = model.CorrAccount, PersonAccount = model.PersonAccount, CreatorID = currentUseId.Id, }; } else { gpdrefDetail.Name = model.Name; gpdrefDetail.ContractorName = model.ContractorName; //gpdrefDetail.DTID = 1;// model.DTID; gpdrefDetail.INN = model.INN; gpdrefDetail.KPP = model.KPP; gpdrefDetail.Account = model.Account; gpdrefDetail.BankName = model.BankName; gpdrefDetail.BankBIK = model.BankBIK; gpdrefDetail.CorrAccount = model.CorrAccount; gpdrefDetail.PersonAccount = model.PersonAccount; //gpdrefDetail.CreatorID = model.CreatorID; gpdrefDetail.EditorID = currentUseId.Id; gpdrefDetail.EditDate = DateTime.Now; } GpdRefDetailDao.SaveAndFlush(gpdrefDetail); model.Id = gpdrefDetail.Id; model.DetailID = gpdrefDetail.Id; return true; } catch (Exception ex) { GpdRefDetailDao.RollbackTran(); Log.Error("Error on SaveMissionOrderEditModel:", ex); error = string.Format("Исключение:{0}", ex.GetBaseException().Message); return false; } }
/// <summary> /// Процедура сохранения записи в базе данных. /// </summary> /// <param name="model">Текущая модель.</param> /// <param name="error">Переменная для возврата текста сообщения об ошибке.</param> public bool SaveGpdRefDetail(GpdRefDetailEditModel model, out string error) { error = string.Empty; if (model.StatusID == 3) return true; //UserRole currentUserRole = AuthenticationService.CurrentUser.UserRole; IUser currentUseId = AuthenticationService.CurrentUser; //набор if (model.Operation == 1) { try { GpdDetailSet gpdDetailSet = GpdDetailSetDao.Get(model.Id); if (gpdDetailSet == null) { gpdDetailSet = new GpdDetailSet { Name = model.Name, PersonID = model.PersonID, PayerID = model.PayerID, PayeeID = model.PayeeID, Account = model.Account, CreatorID = currentUseId.Id, }; } else { gpdDetailSet.Name = model.Name; gpdDetailSet.PersonID = model.PersonID; gpdDetailSet.PayerID = model.PayerID; gpdDetailSet.PayeeID = model.PayeeID; gpdDetailSet.Account = model.Account; gpdDetailSet.CreatorID = model.CreatorID; gpdDetailSet.EditorID = currentUseId.Id; gpdDetailSet.EditDate = DateTime.Now; } GpdDetailSetDao.SaveAndFlush(gpdDetailSet); model.Id = gpdDetailSet.Id; model.StatusID = 2; return true; } catch (Exception ex) { GpdDetailSetDao.RollbackTran(); Log.Error("Error on SaveMissionOrderEditModel:", ex); error = string.Format("Исключение:{0}", ex.GetBaseException().Message); return false; } } else //реквизиты { try { GpdRefDetail gpdrefDetail = GpdRefDetailDao.Get(model.DetailId); if (model.NewRow == 1 || gpdrefDetail == null) { gpdrefDetail = new GpdRefDetail { Name = model.DetailName, //ContractorName = model //DTID = model.DTID, INN = model.INN, KPP = model.KPP, Account = model.DetailAccount, BankName = model.BankName, BankBIK = model.BankBIK, CorrAccount = model.CorrAccount, CreatorID = currentUseId.Id, }; } else { gpdrefDetail.Name = model.DetailName; //gpdrefDetail.DTID = model.DTID; gpdrefDetail.INN = model.INN; gpdrefDetail.KPP = model.KPP; gpdrefDetail.Account = model.DetailAccount; gpdrefDetail.BankName = model.BankName; gpdrefDetail.BankBIK = model.BankBIK; gpdrefDetail.CorrAccount = model.CorrAccount; gpdrefDetail.CreatorID = model.DetailCreatorID; gpdrefDetail.EditorID = currentUseId.Id; gpdrefDetail.EditDate = DateTime.Now; } GpdRefDetailDao.SaveAndFlush(gpdrefDetail); model.DetailId = gpdrefDetail.Id; model.StatusID = 2; return true; } catch (Exception ex) { GpdRefDetailDao.RollbackTran(); Log.Error("Error on SaveMissionOrderEditModel:", ex); error = string.Format("Исключение:{0}", ex.GetBaseException().Message); return false; } } }