Beispiel #1
0
        private void AppointmentsDeletedExecute2(DevExpress.XtraScheduler.PersistentObjectCancelEventArgs e)
        {
            string LastMessage;

            Appointment             deletedAppt = e.Object as Appointment;
            IHP_HARMONOGRAM_DZIENNY item        = context.IHP_HARMONOGRAM_DZIENNY.Local.FirstOrDefault(x => x.ID_IHP_HARMONOGRAM_DZIENNY == Convert.ToInt32(deletedAppt.Id));


            if (item != null)
            {
                if (item.IHP_NAGLDOK > 0)
                {
                    MessageBoxService.ShowMessage("WYSTAWIONO ZAMÓWIENIE - NIE MOŻNA USUNĄĆ");
                    e.Cancel = true;
                    return;
                }
                try
                {
                    context.IHP_HARMONOGRAM_DZIENNY.Remove(item);
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    LastMessage = ex.ToString();
                    LogManager.WriteLogMessage(LogManager.LogType.Error, LastMessage);
                }
            }
        }
Beispiel #2
0
        private void AddTestData()
        {
            //         planowanieEntity.ARIT_HARMONOGRAM_DZIENNY.Local.Clear();
            int     godzstart = 6;
            int     godzstop  = godzstart + 5; // przeliczCzasStop(_arItharmonogramSel.ID_KONTRAH ?? 0);
            string  LastMessage;
            decimal _waga = WyliczWage();

            try
            {
                IHP_HARMONOGRAM_DZIENNY apt = new IHP_HARMONOGRAM_DZIENNY()
                {
                    ID_IHP_HARMONOGRAM_DZIENNY = GetNextNumer(1),
                    DATA = _submissiondate,
                    //  TEMAT = _arItharmonogramSel.HODOWCA,
                    TEMAT     = "MASZYNA1",
                    CZASSTART = _submissiondate.AddHours(godzstart),
                    CZASSTOP  = _submissiondate.AddHours(godzstop),
                    //   ID_ARIT_HARMONOGRAM = _arItharmonogramSel.ID_HARMONOGRAM,
                    ID_IHP_MASZYNA = _machine.ID_IHP_MASZYNA,
                    LABELID        = 2,
                    ILOSC          = 3,
                    WAGA           = _waga,
                    ID_KARTOTEKA   = 1,
                    ID_KONTRAH     = 1
                };

                Appointments.Add(apt);
                context.IHP_HARMONOGRAM_DZIENNY.Add(apt);
                context.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    foreach (var ve in eve.ValidationErrors)
                    {
                        LastMessage = ve.PropertyName + ": " + ve.ErrorMessage;
                        LogManager.WriteLogMessage(LogManager.LogType.Error, LastMessage);

                        //       Console.WriteLine("- 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);
             * }
             */
        }