private void SaveWystTrasa()
        {
            string LastMessage;

            try
            {
                if (Kontrah != null && TrasaUpdate != null)
                {
                    IHP_WYSTTRASAKONTRAH wtk = new IHP_WYSTTRASAKONTRAH();
                    wtk.ID_IHP_WYSTTRASAKONTRAH = GetNextNumer(19);
                    wtk.ID_IHP_KONTRAHENT       = Kontrah.ID_IHP_KONTRAHENT;
                    wtk.ID_IHP_TRASY            = TrasaUpdate.ID_IHP_TRASY;
                    context.IHP_WYSTTRASAKONTRAH.Add(wtk);
                    context.SaveChanges();
                    LoadWystColection();
                    TrasaUpdate = null;
                }
            }
            catch (Exception ex)
            {
                LastMessage = ex.ToString();
                if (LastMessage == String.Empty)
                {
                    LastMessage = ex.InnerException.ToString();
                }
                LogManager.WriteLogMessage(LogManager.LogType.Error, LastMessage);
                throw ex;
            }
        }
        private void DeleteWysTrasaKart()
        {
            string LastMessage;

            try
            {
                if (TrasaSelect != null)
                {
                    //    IHP_WYSTTRASAKART wtk = context.IHP_WYSTTRASAKART?.FirstOrDefault(x => x.ID_IHP_KONTRAHENT.Equals(TrasaSelect.ID_IHP_KONTRAHENT) &&  x.ID_IHP_TRASY.Equals(TrasaSelect.ID_IHP_TRASY));
                    //if(wtk!=null)
                    //    {
                    //       context.IHP_WYSTTRASAKART.Remove(wtk);
                    //       context.SaveChanges();
                    //        Clear();
                    //        LoadWystColection();
                    //        TrasaUpdate = null;
                    //    }
                    IHP_WYSTTRASAKONTRAH wtk = context.IHP_WYSTTRASAKONTRAH.Find(TrasaSelect.ID_IHP_WYSTTRASAKONTRAH);
                    context.Entry(wtk).State = EntityState.Deleted;
                    context.IHP_WYSTTRASAKONTRAH.Remove(wtk);
                    context.SaveChanges();
                    LoadWystColection();
                    TrasaUpdate = null;
                }
            }
            catch (DbUpdateException Ex)
            {
                LogManager.WriteLogMessage(LogManager.LogType.Error, String.Format("DbUpdateException \"{0}\"  :", Ex.InnerException.Message));
                throw Ex;
            }
            catch (SqlException exc)
            {
                //here you might still get some exceptions but not about validation.

                LogManager.WriteLogMessage(LogManager.LogType.Error, String.Format("SqlException \"{0}\"  :", exc.Message));


                //sometimes you may want to throw the exception to upper layers for handle it better over there!
                throw;
            }

            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    LogManager.WriteLogMessage(LogManager.LogType.Error, String.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State));
                    foreach (var ve in eve.ValidationErrors)
                    {
                        LogManager.WriteLogMessage(LogManager.LogType.Error, String.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage));
                    }
                }
                throw;
            }
            catch (Exception ex)
            {
                LastMessage = ex.ToString();
                if (LastMessage == String.Empty)
                {
                    LastMessage = ex.InnerException.ToString();
                }
                LogManager.WriteLogMessage(LogManager.LogType.Error, LastMessage);
                throw ex;
            }
        }