Esempio n. 1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int terminalID = GetSelectedTerminalID();

            if (Util.Confirm("Are you sure you want to delete this Terminal? This cannot be undone."))
            {
                _dtCtrl.BeginTransaction();

                try
                {
                    bool brs1 = _dtCtrl.DeleteTerminal(terminalID);
                    bool brs2 = _dtCtrl.DeleteEmployeeTerminal(terminalID);

                    if (brs1 && brs2)
                    {
                        _dtCtrl.CommitTransaction();
                        LoadData();
                        MessageBox.Show("Terminal deleted.");
                    }
                    else
                    {
                        throw new Exception("Terminal could not be deleted.");
                    }
                }
                catch (Exception ex)
                {
                    _dtCtrl.RollbackTransaction();
                    Util.ShowErrorMessage(ex);
                }
            }
        }