예제 #1
0
        private void DelTransport(object sender, EventArgs e)
        {
            if (this.TransportData.CurrentRow == null)
            {
                return;
            }

            var form = new DelForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var index   = TransportData.CurrentRow.Index;
            var number  = Convert.ToInt32(TransportData[0, index].Value);
            var command = $"DELETE FROM [Transport] WHERE [Transport].[Id] = {number} ";

            SqlHelper.ExecuteQuery(command);
            this.Filter(sender, e);
        }
예제 #2
0
        private void DelFromCommand(object sender, EventArgs e)
        {
            if (this.ViewData.CurrentRow == null)
            {
                return;
            }

            var delForm = new DelForm();

            if (delForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var command = "DELETE FROM ";
            var index   = this.ViewData.CurrentRow.Index;
            var id      = Convert.ToString(this.ViewData[0, index].Value);

            switch (activeTable)
            {
            case ActiveTable.Bus:
                command += $"[Bus] WHERE [Bus].[Id] = {id} ";
                break;

            case ActiveTable.Dispatcher:
                command += $"[Dispatcher] WHERE [Dispatcher].[Id] = {id} ";
                break;

            case ActiveTable.Driver:
                command += $"[Driver] WHERE [Driver].[Id] = {id} ";
                break;

            case ActiveTable.Route:
                command += $"[Route] WHERE [Route].[Id] = {id} ";
                break;

            case ActiveTable.Ticket:
                command += $"[Ticket] WHERE [Ticket].[Id] = {id} ";
                break;

            default:
                return;
            }
            SqlHelper.ExecuteQuery(command);

            switch (activeTable)
            {
            case ActiveTable.Bus:
                this.ViewBuses(sender, e);
                break;

            case ActiveTable.Dispatcher:
                this.ViewDispatchers(sender, e);
                break;

            case ActiveTable.Driver:
                this.ViewDrivers(sender, e);
                break;

            case ActiveTable.Route:
                this.ViewRoutes(sender, e);
                break;

            case ActiveTable.Ticket:
                this.ViewTickets(sender, e);
                break;

            default:
                return;
            }
        }