private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     Appointment ap = DataContext as Appointment;
     if (ap == null || ap.Id == 0)
     {
         //NEW DATA
         ap = new Appointment();
         ap.Subject = txtSubject.Text;
         ap.Notes = txtNotes.Text;
         ap.ApDate = dtAppDate.DisplayDate.Date;
         ap.Aptime = txtTime.Text;
         Dentist dent = cbDentist.SelectedItem as Dentist;
         ap.Dentist = dent;
         ap.Patient = App.patient;
         ap.Room = (string)cbRoom.SelectedValue;
         DB.insertAppointment(ap);
     }
     else
     {
         ap.Subject = txtSubject.Text;
         ap.Notes = txtNotes.Text;
         ap.ApDate = dtAppDate.DisplayDate.Date;
         ap.Aptime = txtTime.Text;
         Dentist dent = cbDentist.SelectedItem as Dentist;
         ap.Dentist = dent;
         ap.Patient = App.patient;
         ap.Room = (string)cbRoom.SelectedValue;
         DB.updateAppointment(ap);
     }
     this.Close();
 }
        private void AptCalendar_DayBoxDoubleClicked(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show("AptCalendar_DayBoxDoubleClicked");
            //new appointment
            NewAppointmentEventArgs aea = e as NewAppointmentEventArgs;

            AppointmentEditForm ef = new AppointmentEditForm();
            Appointment ap = new Appointment();
            ap.ApDate = aea.StartDate;
            ef.DataContext = ap;
            ef.ShowDialog();
            Changed();
        }
Ejemplo n.º 3
0
        private Appointment toAppointment(IDataReader dataReader)
        {
            Appointment p = new Appointment();
            
            p.Id = dataReader.GetInt32(dataReader.GetOrdinal("id"));
            p.Subject = GetStringSafe(dataReader, "subject");
            p.Room = GetStringSafe(dataReader, "room");
            p.Notes = GetStringSafe(dataReader, "notes");
            p.Aptime = GetStringSafe(dataReader, "appointment_time");
            p.ApDate = dataReader.GetDateTime(dataReader.GetOrdinal("appointment_date")); ;
            p.Patient = findPatientById(GetStringSafe(dataReader,"patient"));
            p.Dentist = findDentistByUserId(GetStringSafe(dataReader, "dentist"));

            return p;
        }
Ejemplo n.º 4
0
        internal bool updateAppointment(Appointment t)
        {
            string tableName = "Appointments";
            string setColumns = "subject='" + t.Subject + "',patient='" + t.Patient.Id + "', dentist='" + t.Dentist.UserId + "', appointment_date='" + t.ApDate.ToString(Smile.DATE_FORMAT) + "', appointment_time='" + t.Aptime + "', room='" + t.Room + "', notes='" + t.Notes+ "', modified='" + DateTime.Now.ToString(Smile.LONG_DATE_FORMAT) + "', modifiedBy='" + User + "' ";
            string query = "UPDATE " + tableName + " SET " + setColumns + " WHERE id = "+t.Id+"";

            if (this.OpenConnection() == true)
            {
                IDbCommand cmd = getSqlCommand(query, connection);
                cmd.ExecuteNonQuery();
                return true;
            }
            return false;
        }
Ejemplo n.º 5
0
        internal bool insertAppointment(Appointment t)
        {
            string tableName = "Appointments";
            string columns = "(subject, patient, dentist, appointment_date, appointment_time, room, notes, created,createdBy)";
            string values = "('" + t.Subject + "','" + t.Patient.Id + "','" + t.Dentist.UserId + "','" + t.ApDate.ToString(Smile.DATE_FORMAT) + "'," + t.Aptime + ",'" + t.Room + "','" + t.Notes+ "','" + DateTime.Now.ToString(Smile.LONG_DATE_FORMAT) + "','" + User + "')";
            string query = "INSERT INTO " + tableName + " " + columns + " values " + values + " ;";

            if (this.OpenConnection() == true)
            {
                IDbCommand cmd = getSqlCommand(query, connection);
                cmd.ExecuteNonQuery();
                //t.Id = (int)cmd.LastInsertedId;
                t.Id = getLastInsertId(cmd, query, connection);

                this.CloseConnection();

                return true;
            }
            return false;
        }