private void detach_ContractMoneys(ContractMoney entity)
		{
			this.SendPropertyChanging();
			entity.Month = null;
		}
        private void SavePaymentPlan(Budget2DataContext context, Guid budgetVersionId, IEnumerable<PaymentPlanItem> paymentPlanItems, Guid contractId)
        {
            foreach (var paymentPlanItem in paymentPlanItems)
            {

                var currPaymentPlanItem = new ContractMoney()
                                              {
                                                  Id = Guid.NewGuid(),
                                                  Number = paymentPlanItem.Prefix,
                                                  NumberId = paymentPlanItem.Number,
                                                  ContractId = contractId,
                                                  ExternalId = paymentPlanItem.Id
                                              };

                context.ContractMoneys.InsertOnSubmit(currPaymentPlanItem);



                if (paymentPlanItem.Date == DateTime.MinValue)
                    throw new Exception(string.Format("Значение поля PaymentPlanItem.Date ({0}) некорректно.", paymentPlanItem.Date));

                currPaymentPlanItem.Date = paymentPlanItem.Date;
                currPaymentPlanItem.MonthId = (byte)paymentPlanItem.Date.Month;
                currPaymentPlanItem.Year = paymentPlanItem.Date.Year;
                currPaymentPlanItem.DateFrom = paymentPlanItem.DateFrom;
                currPaymentPlanItem.DateTo = paymentPlanItem.DateTo;
                currPaymentPlanItem.Comment = paymentPlanItem.Comment;
                currPaymentPlanItem.ConditionPayment = paymentPlanItem.PaymentTerms;
                currPaymentPlanItem.Sum = paymentPlanItem.Amount;
                currPaymentPlanItem.ExternalFromEmployeeId = paymentPlanItem.FromEmployee;
                currPaymentPlanItem.ExternaToEmployeeId = paymentPlanItem.ToEmployee;
                currPaymentPlanItem.PaidState = paymentPlanItem.FactPay;

                currPaymentPlanItem.FromCounteragentId =
                        (from c in context.Counteragents
                         where c.Number == paymentPlanItem.FromEmployee && c.BudgetVersionId == budgetVersionId && !c.IsDeleted && !c.IsPotential
                         select new Nullable<Guid>(c.Id)).FirstOrDefault();

                currPaymentPlanItem.ToCounteragentId =
                       (from c in context.Counteragents
                        where c.Number == paymentPlanItem.ToEmployee && c.BudgetVersionId == budgetVersionId && !c.IsDeleted && !c.IsPotential
                        select new Nullable<Guid>(c.Id)).FirstOrDefault();

                Logger.Log.DebugFormat("План платежей {0} обновлен (Id={1}).", currPaymentPlanItem.NumberId, currPaymentPlanItem.Id);
            }
        }
		private void detach_ContractMoneys1(ContractMoney entity)
		{
			this.SendPropertyChanging();
			entity.Counteragent1 = null;
		}
		private void attach_ContractMoneys(ContractMoney entity)
		{
			this.SendPropertyChanging();
			entity.Counteragent = this;
		}
 partial void DeleteContractMoney(ContractMoney instance);
 partial void UpdateContractMoney(ContractMoney instance);
 partial void InsertContractMoney(ContractMoney instance);