private void OnDelete(object sender, EventArgs e)
        {
            if (bindingSource != null)
            {
                bindingSource.RemoveCurrent();
            }

            OnRefreshItems();
        }
Ejemplo n.º 2
0
 /// <devdoc>
 ///     Deletes current item from BindingSource's list when the DeleteItem is clicked.
 /// </devdoc>
 private void OnDelete(object sender, EventArgs e)
 {
     if (Validate())
     {
         if (bindingSource != null)
         {
             bindingSource.RemoveCurrent();
             RefreshItemsInternal();
         }
     }
 }
Ejemplo n.º 3
0
        private void DeleteEvent(int colIndex, int rowIndex, BindingSource actualEvents)
        {
            //запомнить положение скроллбара
            int saveRow = 0;
            if (dgv1.Rows.Count > 0)
                saveRow = dgv1.FirstDisplayedCell.RowIndex;

            int currEvent = 0;

            string cellTag = Convert.ToString(dgv1[colIndex, rowIndex].Tag);

            if (Int32.TryParse(cellTag, out currEvent))
            {
                if ((dgv1.collapseEvents.Keys.Contains(currEvent)) && (dgv1[colIndex, rowIndex].Style.BackColor == event_error_bg))
                {
                    string filter = String.Format("[{0}] IN ({1}, {2})", currEventField, currEvent, dgv1.collapseEvents[currEvent]);
                    CollapseSelect cs = new CollapseSelect(filter, eCategory);

                    if (cs.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        currEvent = cs.ReturnEventID();
                    }
                    else
                        return;
                }
            }
            else
            {
                ulog.Message("Не удается определить мероприятие.", UserLogMessageLevel.Error);
                return;
            }

            actualEvents.Position = actualEvents.Find(currEventField , currEvent);

            if (ConfirmDeletion("Мероприятие"))
                try
                {
                    actualEvents.RemoveCurrent();
                    ulog.Message("Запись мероприятия удалена.");
                    SaveChanges();

                    PrepareSelected();
                    //восстановить положение скроллбара
                    if (saveRow != 0 && saveRow < dgv1.Rows.Count)
                        dgv1.FirstDisplayedScrollingRowIndex = saveRow;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
        }