Exemple #1
0
        void CreateNewEntry()
        {
            Pages.Appointment appointment = new Pages.Appointment();

            appointment.Title    = titleTextBox.Text;
            appointment.Category = appointmentCategoryComboBox.SelectedValue.ToString();
            appointment.FromDate = (DateTime)appointmentFromDatePicker.SelectedDate;
            appointment.ToDate   = (DateTime)appointmentToDatePicker.SelectedDate;
            appointment.Priority = (int)appointmentPriorityComboBox.SelectedIndex;
            appointment.State    = (int)appointmentStatusComboBox.SelectedIndex;


            ConnectionClass connection = new ConnectionClass();

            connection.InsertAppointment(appointment);
        }
        public void InsertAppointment(Pages.Appointment appointment)
        {
            OpenConnection();
            MySqlCommand command = new MySqlCommand();

            command.CommandText = "INSERT INTO appointments VALUES(?id, ?title,?state,?priority,?category,?fromDate,?toDate)";
            command.Parameters.AddWithValue("?id", command.LastInsertedId);
            command.Parameters.AddWithValue("?title", appointment.Title);
            command.Parameters.AddWithValue("?state", appointment.State);
            command.Parameters.AddWithValue("?priority", appointment.Priority);
            command.Parameters.AddWithValue("?category", appointment.Category);
            command.Parameters.AddWithValue("?fromDate", appointment.FromDate);
            command.Parameters.AddWithValue("?toDate", appointment.ToDate);
            command.Connection = GetConnection();

            command.ExecuteNonQuery();
        }