Пример #1
0
        // metoda pobierająca aktualne leki wraz z dawkami na recepcie
        private List <string> GetPrescriptions()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>()
            {
                { "@appointment", AppointmentID.ToString() }
            };

            if (connection.Open())
            {
                return(connection.GetPrescription($"SELECT dawki_i_leki.iddl, leki.nazwa, dawki.ile FROM dawki_i_leki JOIN leki ON leki.idl=dawki_i_leki.idl JOIN dawki ON dawki.idd=dawki_i_leki.idd WHERE iddl NOT IN (SELECT iddl FROM wiz_i_dawki_i_leki WHERE idw=@appointment) ORDER BY 2", parameters));
            }
            else
            {
                throw new CustomExceptions.DatabaseConnectionFailedException();
            }
        }
        public void Save(SQLiteDatabase sqLiteDatabase)
        {
            if (sqLiteDatabase.IsOpen)
            {
                if (IsNew)
                {
                    try
                    {
                        ContentValues values = new ContentValues();
                        values.Put("AppointmentID", AppointmentID.ToString());
                        values.Put("Question", Question.Trim());
                        values.Put("Answer", Answer.Trim());
                        QuestionsID = (int)sqLiteDatabase.Insert("AppointmentQuestions", null, values);

                        IsNew   = false;
                        IsDirty = false;
                    }
                    catch (Exception newE)
                    {
                        throw new Exception("Unable to Save Appointment Question - " + newE.Message);
                    }
                }

                if (IsDirty)
                {
                    try
                    {
                        string        whereClause = "QuestionsID = " + QuestionsID;
                        ContentValues values      = new ContentValues();

                        values.Put("AppointmentID", AppointmentID);
                        values.Put("Question", Question.Trim());
                        values.Put("Answer", Answer.Trim());
                        sqLiteDatabase.Update("AppointmentQuestions", values, whereClause, null);

                        IsDirty = false;
                    }
                    catch (SQLException dirtyE)
                    {
                        throw new Exception("Unable to Update Appointment Question - " + dirtyE.Message);
                    }
                }
            }
        }
Пример #3
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (connection.Open())
            {
                bool status = true;
                if (RowsID.Count > 0)
                {
                    foreach (var id in RowsID)
                    {
                        Dictionary <string, string> parameters = new Dictionary <string, string>()
                        {
                            { "@appointment", AppointmentID.ToString() },
                            { "@id", id.ToString() }
                        };

                        if (!connection.InsertInfo($"INSERT INTO wiz_i_dawki_i_leki(idw, iddl) VALUES(@appointment, @id)", parameters))
                        {
                            status = false;
                        }
                    }
                }
                else
                {
                    status = false;
                }

                if (status)
                {
                    MessageBox.Show("Leki zostały poprawnie dodane do recepty!", "Pozytywnie dodano!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Błąd podpisania leku do recepty! Upewnij się, że cokolwiek zostało wybrane." +
                                    "Możliwe jest, że próbujesz dodać duplikat. Uruchom te okno ponownie.", "Błąd!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Błąd z połaczeniem!");
            }
        }
Пример #4
0
        public void LoadAppointmentQuestions(SQLiteDatabase sqLiteDatabase)
        {
            if (sqLiteDatabase.IsOpen && !IsNew)
            {
                if (_questions == null)
                {
                    _questions = new List <AppointmentQuestion>();
                }

                _questions.Clear();

                string[] arrColumns = new string[3];
                arrColumns[0] = "QuestionsID";
                arrColumns[1] = "Question";
                arrColumns[2] = "Answer";

                try
                {
                    var questionData = sqLiteDatabase.Query("AppointmentQuestions", arrColumns, "AppointmentID = " + AppointmentID.ToString(), null, null, null, null);
                    if (questionData != null)
                    {
                        var count = questionData.Count;
                        if (count > 0)
                        {
                            questionData.MoveToFirst();
                            for (var loop = 0; loop < count; loop++)
                            {
                                var question = new AppointmentQuestion();
                                question.AppointmentID = AppointmentID;
                                question.QuestionsID   = questionData.GetInt(questionData.GetColumnIndex("QuestionsID"));
                                question.Question      = questionData.GetString(questionData.GetColumnIndex("Question"));
                                question.Answer        = questionData.GetString(questionData.GetColumnIndex("Answer"));
                                question.IsNew         = false;
                                _questions.Add(question);
                                questionData.MoveToNext();
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error(TAG, "LoadAppointmentQuestions: Exception - " + e.Message);
                    _questions = new List <AppointmentQuestion>();
                }
            }
        }
Пример #5
0
 /**
  * \brief <b>Brief Description</b> - Program <b><i>class method</i></b> - Gets the string array representation
  * \details <b>Details</b>
  *
  * Gets the string array representation of the Appointment object for saving to the database.
  *
  * \return <b>string[]</b> - the string array
  */
 public string[] ToStringArray()
 {
     return(new string[] { AppointmentID.ToString(), PatientID.ToString(), DependantID.ToString(), RecallFlag.ToString() });
 }