private void CancelBtn_Click(object sender, EventArgs e) { RouteTextBox.Clear(); ToTextBox.Clear(); FromTextBox.Clear(); TypeComboBox.SelectedIndex = -1; }
private void addSchedule() { if (RouteTextBox.Text == "" || ToTextBox.Text == "" || FromTextBox.Text == "" || TimePicker.Text == "" || TypeComboBox.Text == "") { MessageBox.Show("Please enter all the details.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (TimePicker.Text == DateTime.Now.ToString("HH:mm:ss")) { MessageBox.Show("Please enter a valid time.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { try { con.Open(); // adding new schedule string sql = "INSERT INTO schedules (route, start_from, ends_at, departure_time, type) VALUES('" + RouteTextBox.Text + "', '" + FromTextBox.Text + "', '" + ToTextBox.Text + "', '" + TimePicker.Text + "', '" + TypeComboBox.Text + "')"; SqlCommand cmd = new SqlCommand(sql, con); cmd.ExecuteNonQuery(); MessageBox.Show("Schedule created successfully!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); con.Close(); refreshData(); RouteTextBox.Clear(); ToTextBox.Clear(); FromTextBox.Clear(); TypeComboBox.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { con.Close(); } } }
private void btnSelectFromTextBox_Click(object sender, EventArgs e) { FromTextBox?.Invoke(this, new WinFormsTestControlEventArgs(contentBox.Text)); }