示例#1
0
        //
        //Кнопка, переносит данные в основную таблицу.
        //
        private void Transfer_Button_Click(object sender, EventArgs e)
        {
            var archiveEvent = SearchingObject();
            var addEventForm = new AddEventForm();

            LoadDate_ComboBox(addEventForm);
            addEventForm.comboBox1.Text        = archiveEvent.vCalendar.ToString();
            addEventForm.comboBox2.Text        = archiveEvent.vListofCases.ToString();
            addEventForm.comboBox1.Enabled     = false;
            addEventForm.dateTimePicker1.Value = Convert.ToDateTime(archiveEvent.StartTime);
            addEventForm.dateTimePicker2.Value = Convert.ToDateTime(archiveEvent.EndTime);
            DialogResult result = addEventForm.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                try
                {
                    var eventDate = new EventDate();
                    eventDate.vListofCases = (ListofCases)addEventForm.comboBox1.SelectedItem;
                    eventDate.vCalendar    = (Calendar)addEventForm.comboBox2.SelectedItem;
                    eventDate.StartTime    = addEventForm.dateTimePicker1.Value.ToShortTimeString();
                    eventDate.EndTime      = addEventForm.dateTimePicker2.Value.ToShortTimeString();
                    eventDate.MarkEventSet();
                    db.DBEventDate.Add(eventDate);
                    db.DBArchiveEvents.Remove(archiveEvent);
                    db.SaveChanges();
                    MessageBox.Show("Объект восстановлен!", "Оповещение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); }
            }
            dataGridView1.Refresh();
        }
        //
        //Button, for adding events.
        //
        private void AddEventButton_Click(object sender, EventArgs e)
        {
            var          eventDate    = FindElement();
            var          events       = new Events();
            var          addEventForm = new AddEventForm();
            DialogResult result       = addEventForm.ShowDialog(this);

            try
            {
                if (result == DialogResult.OK)
                {
                    events.TextEvent  = addEventForm.EventTextBox.Text;
                    events.PlaceEvent = addEventForm.PlaceEventTextBox.Text;
                    events.StartDate  = addEventForm.dateTimePicker1.Value.ToShortTimeString();
                    events.EndDate    = addEventForm.dateTimePicker2.Value.ToShortTimeString();
                    events.IsEvent    = true;
                    events.Calendars  = eventDate;
                }
                db.DbEvents.Add(events);
                db.SaveChanges();
                MessageBox.Show("Событие добавлено!", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //
        //To edit the event after a double click.
        //
        private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                var eevent       = FindElement() ?? throw new NullReferenceException("The element wasn't selected. Please, try again.");
                var addEventForm = new AddEventForm();
                addEventForm.comboBox1.Visible = true;
                //To load info to the combo box
                addEventForm.comboBox1.DataSource    = db.Calendars.ToList();
                addEventForm.comboBox1.ValueMember   = "Id";
                addEventForm.comboBox1.DisplayMember = "FullDate";
                addEventForm.comboBox1.Text          = eevent.Calendars.ToString();
                //end load.
                addEventForm.EventTextBox.Text      = eevent.TextEvent;
                addEventForm.PlaceEventTextBox.Text = eevent.PlaceEvent;
                addEventForm.dateTimePicker1.Value  = Convert.ToDateTime(eevent.StartDate);
                addEventForm.dateTimePicker2.Value  = Convert.ToDateTime(eevent.EndDate);

                DialogResult result = addEventForm.ShowDialog(this);
                if (result == DialogResult.OK)
                {
                    eevent.Calendars  = (CLibrary.Calendar)addEventForm.comboBox1.SelectedItem;
                    eevent.TextEvent  = addEventForm.EventTextBox.Text;
                    eevent.PlaceEvent = addEventForm.PlaceEventTextBox.Text;
                    eevent.StartDate  = addEventForm.dateTimePicker1.Value.ToShortTimeString();
                    eevent.EndDate    = addEventForm.dateTimePicker2.Value.ToShortTimeString();
                    db.SaveChanges();
                    dataGridView1.Refresh();
                }
            }
        }
示例#4
0
        //
        //Метод, загружает данные в combo box'ы.
        //
        void LoadDate_ComboBox(AddEventForm addEventForm)
        {
            addEventForm.comboBox2.DataSource    = db.DBCalendars.ToList();
            addEventForm.comboBox2.ValueMember   = "Id";
            addEventForm.comboBox2.DisplayMember = "CalendarFullDate";

            addEventForm.comboBox1.DataSource    = db.DBListofCases.ToList();
            addEventForm.comboBox1.ValueMember   = "Id";
            addEventForm.comboBox1.DisplayMember = "NameEvent";
        }
示例#5
0
        private void buttonTambahEvent_Click(object sender, EventArgs e)
        {
            AddEventForm addEventForm = new AddEventForm();

            // mengambil parent form
            Form form = (this.Parent.Parent.Parent as Form);

            form.Opacity = 0.4; // membuat parent form opacity menjadi 0.4
            addEventForm.ShowDialog(this);
            LoadEventPage();
            form.Opacity = 1; // kembalikan parent form opacity menjadi normal jika form add Event diclose
        }
示例#6
0
        //
        //Кнопка, добавляет новый элемент в бд.
        //
        private void Add_Button_Click(object sender, EventArgs e)
        {
            var eventDate    = new EventDate();
            var addEventForm = new AddEventForm();

            LoadDate_ComboBox(addEventForm);

            DialogResult result = addEventForm.ShowDialog(this);

            SaveData(addEventForm, result, eventDate);
            dataGridView1.Refresh();
        }
        public void AddEvent()
        {
            AddEventForm newEventForm = new AddEventForm(mainForm.Location.X + 250, mainForm.Location.Y);

            newEventForm.formEvent = new Event();
            newEventForm.ShowDialog();

            if (!newEventForm.Canceled)
            {
                eventDB.saveTask(newEventForm.formEvent);
            }

            mainForm.RefreshLVEvents();
        }
示例#8
0
        //
        //Кнопка, редактирования событий.
        //
        private void Edit_Button_Click(object sender, EventArgs e)
        {
            var eventDate    = SearchingObject();
            var addEventForm = new AddEventForm();

            LoadDate_ComboBox(addEventForm);
            addEventForm.comboBox1.Text        = eventDate.vCalendar.ToString();
            addEventForm.comboBox2.Text        = eventDate.vListofCases.ToString();
            addEventForm.dateTimePicker1.Value = Convert.ToDateTime(eventDate.StartTime);
            addEventForm.dateTimePicker2.Value = Convert.ToDateTime(eventDate.EndTime);
            DialogResult result = addEventForm.ShowDialog(this);

            SaveData(addEventForm, result, eventDate);
            dataGridView1.Refresh();
        }
示例#9
0
 private void создатьСобытиеToolStripMenuItem_Click(object sender, EventArgs e)
 {
     client.PingServerAndIndicateHisStateOnControls();
     if (client.isServerOnline)
     {
         var createdEvent = GetNewEventUsingAddEventForm();
         if (createdEvent != null)
         {
             eventManager.AddNewEventAndSerialize(createdEvent);
             if (IsAnyRowSelected() == false)
             {
                 dataGridView1.ClearSelection();
             }
         }
         addEventForm = null;
     }
 }
示例#10
0
 //
 //Метод, сохраняет данные в бд.
 //
 private void SaveData(AddEventForm addEventForm, DialogResult result, EventDate eventDate)
 {
     if (result == DialogResult.OK)
     {
         try
         {
             eventDate.vListofCases = (ListofCases)addEventForm.comboBox1.SelectedItem;
             eventDate.vCalendar    = (Calendar)addEventForm.comboBox2.SelectedItem;
             eventDate.StartTime    = addEventForm.dateTimePicker1.Value.ToShortTimeString();
             eventDate.EndTime      = addEventForm.dateTimePicker2.Value.ToShortTimeString();
             eventDate.MarkEventSet();
             db.DBEventDate.Add(eventDate);
             db.SaveChanges();
             MessageBox.Show("Событие добавлено!", "Оповещение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
         catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); }
     }
 }
        public void EditEvent(int eventId)
        {
            try
            {
                Event        editedEvent = eventDB.getTask(eventId);
                AddEventForm editForm    = new AddEventForm(mainForm.Location.X + 250, mainForm.Location.Y, editedEvent);
                editForm.ShowDialog();

                bool tmp = editForm.Canceled;

                if (!editForm.Canceled)
                {
                    eventDB.editTask(editForm.formEvent);
                    mainForm.RefreshLVEvents();
                }
            }
            catch (Exception e)
            {
                // MessageBox.Show("Nie wybrano ksiazki", "Blad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                string s = e.ToString();
            }
        }
示例#12
0
        private void Append_Click(object sender, EventArgs e)
        {
            AddEventForm appendForm = new AddEventForm();

            appendForm.Show();
        }
示例#13
0
 private BllEvent GetNewEventUsingAddEventForm()
 {
     addEventForm = new AddEventForm(client.GetServerInstance(), client.GetUser());
     addEventForm.ShowDialog();
     return(addEventForm.Event);
 }