예제 #1
0
        private void RemoveTicketButton_Click(object sender, EventArgs e)
        {
            // Opening a connection to the database
            SqlConnection connection = new SqlConnection(connectionString);

            connection.Open();
            SqlCommand command = connection.CreateCommand();

            // Searching the table and deleting an entry
            command.Parameters.AddWithValue("@Ticket_Name", EditComboBox.SelectedItem);
            command.CommandText = "DELETE FROM TicketData WHERE Ticket_Name = @Ticket_Name";

            if (command.ExecuteNonQuery() > 0)
            {
                MessageBox.Show("Ticket was deleted.");
            }

            else
            {
                MessageBox.Show("Failed to delete ticket.");
            }

            // Clearing the form
            EditComboBox.ResetText();
            EditDateOfRequestTextBox.Clear();
            EditDescriptionOfRequestTextBox.Clear();
            EditTechnicianAssignedTextBox.Clear();
            EditDateOfCompletionTextBox.Clear();
            EditNotesTextBox.Clear();
            EditTicketStatusTextBox.Clear();
            EditTicketStatusComboBox.ResetText();

            connection.Close();
            updateView();
        }
예제 #2
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            // Opening a connection to the database
            SqlConnection connection = new SqlConnection(connectionString);

            connection.Open();
            SqlCommand command = connection.CreateCommand();

            // Grabbing user input
            command.Parameters.AddWithValue("@Ticket_Name", EditComboBox.Text);
            command.Parameters.AddWithValue("@Date_of_Request", EditDateOfRequestTextBox.Text);
            command.Parameters.AddWithValue("@Description_of_Request", EditDescriptionOfRequestTextBox.Text);
            command.Parameters.AddWithValue("@Technician_Assigned", EditTechnicianAssignedTextBox.Text);
            command.Parameters.AddWithValue("@Date_of_Completion", EditDateOfCompletionTextBox.Text);
            command.Parameters.AddWithValue("@Notes", EditNotesTextBox.Text);
            command.Parameters.AddWithValue("@Status", EditTicketStatusComboBox.Text);

            // Updating the table with the user input and prompting the user
            command.CommandText = "UPDATE TicketData SET Date_of_Request = @Date_of_Request, Description_of_Request = @Description_of_Request, Technician_Assigned = @Technician_Assigned, Date_of_Completion = @Date_of_Completion, Notes = @Notes, Status = @Status WHERE Ticket_Name = @Ticket_Name";

            if (command.ExecuteNonQuery() > 0)
            {
                MessageBox.Show("Ticket was edited.");
            }
            else
            {
                MessageBox.Show("Failed to edit ticket.");
            }

            // Clearing the form
            EditComboBox.ResetText();
            EditDateOfRequestTextBox.Clear();
            EditDescriptionOfRequestTextBox.Clear();
            EditTechnicianAssignedTextBox.Clear();
            EditDateOfCompletionTextBox.Clear();
            EditNotesTextBox.Clear();
            EditTicketStatusTextBox.Clear();
            EditTicketStatusComboBox.ResetText();

            connection.Close();
            updateView();
        }