private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            End_Medication_Button.Enabled = true;
            selectint = e.RowIndex;
            DataGridViewRow row = new DataGridViewRow();

            row = Med_History_Grid.Rows[selectint];
            if (e.ColumnIndex == 0)
            {
                Boolean ended2;
                if (row.Cells[5].Value == null || row.Cells[5].Value == DBNull.Value || String.IsNullOrWhiteSpace(row.Cells[5].Value.ToString()))
                {
                    ended2 = false;

                    //enddate = DateTime.Now.ToString();
                    enddate = "";
                }
                else
                {
                    ended2  = true;
                    go4     = row.Cells[5].Value;//end date
                    enddate = Convert.ToString(go4);
                }
                if (row.Cells[1].Value == DBNull.Value || row.Cells[1].Value == null || String.IsNullOrWhiteSpace(row.Cells[1].Value.ToString()))
                {
                    MessageBox.Show("HERE");
                }
                else
                {
                    ended = ended2;
                    go    = row.Cells[1].Value;
                    go2   = row.Cells[2].Value;
                    gu    = row.Cells[3].Value;
                    go3   = row.Cells[4].Value;//begin date
                    go5   = row.Cells[6].Value;

                    begindate = Convert.ToString(go3);
                    string kek = go5.ToString();
                    meme3 = Convert.ToString(gu);
                    meme  = Convert.ToString(go);
                    meme2 = Convert.ToString(go2);
                    this.Hide();
                    Session_List l = new Session_List(PatName.Text, Patient_Name_Lab.Text, meme3, ended, begindate, enddate, kek);
                    l.Show();



                    go        = row.Cells[1].Value;
                    getid     = Convert.ToInt32(go);
                    goget     = row.Cells[3].Value;
                    gogetprox = Convert.ToString(goget);
                }
            }
        }
Exemple #2
0
        private void Register_Session_Button_Click(object sender, EventArgs e)
        {
            sesnum();
            if (int.TryParse(Score_Box.Text, out filler) == false)
            {
                MessageBox.Show("Please enter a valid number");
            }
            else
            {
                scor = Convert.ToInt32(Score_Box.Text);
                if (scor < 0 || scor > 100)
                {
                    MessageBox.Show("Please enter a number between 0 and 100");
                }
                else
                {
                    picko   = Convert.ToDateTime(ok.ToString());
                    yearstr = picko.Year.ToString();
                    if (Specific_Date_Check.Checked == true)
                    {
                        actualdate = yearstr + "-" + Session_Month.Text + "-" + Session_Day.Text;
                        actd       = Convert.ToDateTime(actualdate);
                    }
                    if (TodayCheck.Checked == true)
                    {
                        actd = DateTime.Now;
                    }
                    sleep = Convert.ToInt32(Sleep_Combo.Text.Substring(0, 2));
                    appet = Convert.ToInt32(Appetite_Combo.Text.Substring(0, 2));

                    eyecont = Convert.ToInt32(Eye_Contact_Combo.Text.Substring(0, 2));
                    voice   = Convert.ToInt32(Voice_Tone_Combo.Text.Substring(0, 2));
                    attent  = Convert.ToInt32(Attention_Combo.Text.Substring(0, 2));
                    id      = Convert.ToInt32(SesAdd_Patient_ID.Text);
                    if (!(string.IsNullOrWhiteSpace(Change_Amount_Box.Text)))
                    {
                        if (int.TryParse(Change_Amount_Box.Text, out filler) == false)
                        {
                            MessageBox.Show("Enter a proper amount");
                        }
                        else
                        {
                            amount       = Change_Amount_Box.Text;
                            numberamount = Convert.ToDouble(amount);
                            if (Endexists < 0)
                            {
                                string update = "UPDATE Patient_Medication_Historty SET Amount_Used=" + numberamount + " WHERE (ID=@ID AND Medication=@Medication AND Starting_Date=@Starting_Date AND End_Date IS NULL)";
                                adsescon.Open();
                                string adse = "INSERT INTO Session_Table (Medication, Date, Quality_of_Sleep, Appetite, Eye_Contact, Voice_Tone_Consistency, Attention_Span, ID, Score, Notes, Session_Number ) ";
                                adse += "VALUES (@Medication, @Date, @Quality_of_Sleep, @Appetite, @Eye_Contact, @Voice_Tone_Consistency, @Attention_Span, @ID, @Score, @Notes, @Session_Number)";
                                SqlCommand adsescomm = new SqlCommand(adse, adsescon);
                                SqlCommand adeseso   = new SqlCommand(update, adsescon);
                                adeseso.Parameters.AddWithValue("ID", id);
                                adeseso.Parameters.AddWithValue("Medication", SessAdd_Medication.Text);
                                adeseso.Parameters.AddWithValue("Starting_Date", Convert.ToDateTime(b));
                                adsescomm.Parameters.AddWithValue("Medication", SessAdd_Medication.Text);
                                adsescomm.Parameters.AddWithValue("Date", actd);
                                adsescomm.Parameters.AddWithValue("Quality_of_Sleep", sleep);
                                adsescomm.Parameters.AddWithValue("Appetite", appet);
                                adsescomm.Parameters.AddWithValue("Eye_Contact", eyecont);
                                adsescomm.Parameters.AddWithValue("Voice_Tone_Consistency", voice);
                                adsescomm.Parameters.AddWithValue("Attention_Span", attent);
                                adsescomm.Parameters.AddWithValue("ID", id);
                                adsescomm.Parameters.AddWithValue("Score", scor);
                                adsescomm.Parameters.AddWithValue("Notes", Testr.Text);
                                adsescomm.Parameters.AddWithValue("Session_Number", 0);
                                adsescomm.Parameters.AddWithValue("Used_Amount", numberamount);
                                adeseso.ExecuteNonQuery();
                                adsescomm.ExecuteNonQuery();
                                adsescon.Close();

                                MessageBox.Show("Session Added");
                                this.Hide();
                                Session_List hj = new Session_List(SesAdd_Patient_ID.Text, SesAdd_Patient_Name.Text, SessAdd_Medication.Text, idga, b, d, amount);
                                hj.Show();
                            }
                            else
                            {
                                int sesnumber;
                                adsescon3.Open();
                                string getsesnum = "SELECT *  FROM Session_Table WHERE (Medication='" + SessAdd_Medication.Text + "' AND ID=" + SesAdd_Patient_ID.Text + " AND End_Status IS NULL)";
                                string update    = "UPDATE Patient_Medication_Historty SET Amount_Used=" + numberamount + " WHERE (ID=@ID AND Medication=@Medication AND Starting_Date=@Starting_Date AND End_Date IS NULL)";
                                sesnumber = Convert.ToInt32(nums);
                                string kek = Convert.ToString(sesnumber);
                                adsescon.Open();
                                string adse = "INSERT INTO Session_Table (Medication, Date, Quality_of_Sleep, Appetite, Eye_Contact, Voice_Tone_Consistency, Attention_Span, ID, Score, Notes, Session_Number, Used_Amount ) ";
                                adse += "VALUES (@Medication, @Date, @Quality_of_Sleep, @Appetite, @Eye_Contact, @Voice_Tone_Consistency, @Attention_Span, @ID, @Score, @Notes, @Session_Number, @Used_Amount)";
                                SqlCommand adsescomm = new SqlCommand(adse, adsescon);
                                adsescomm.Parameters.AddWithValue("Medication", SessAdd_Medication.Text);
                                SqlCommand adeseso = new SqlCommand(update, adsescon);
                                adeseso.Parameters.AddWithValue("ID", id);
                                adeseso.Parameters.AddWithValue("Medication", SessAdd_Medication.Text);
                                adeseso.Parameters.AddWithValue("Starting_Date", Convert.ToDateTime(b));
                                adsescomm.Parameters.AddWithValue("Date", actd);
                                adsescomm.Parameters.AddWithValue("Quality_of_Sleep", sleep);
                                adsescomm.Parameters.AddWithValue("Appetite", appet);
                                adsescomm.Parameters.AddWithValue("Eye_Contact", eyecont);
                                adsescomm.Parameters.AddWithValue("Voice_Tone_Consistency", voice);
                                adsescomm.Parameters.AddWithValue("Attention_Span", attent);
                                adsescomm.Parameters.AddWithValue("ID", id);
                                adsescomm.Parameters.AddWithValue("Score", scor);
                                adsescomm.Parameters.AddWithValue("Notes", Testr.Text);
                                adsescomm.Parameters.AddWithValue("Session_Number", Endexists + 1);
                                adsescomm.Parameters.AddWithValue("Used_Amount", numberamount);
                                adeseso.ExecuteNonQuery();
                                adsescomm.ExecuteNonQuery();
                                adsescon.Close();
                                adsescon3.Close();
                                this.Hide();
                                Session_List hj = new Session_List(SesAdd_Patient_ID.Text, SesAdd_Patient_Name.Text, SessAdd_Medication.Text, idga, b, d, amount);
                                hj.Show();
                            }
                        }
                    }
                    else
                    {
                        numberamount = Convert.ToDouble(amount);
                        if (Endexists < 0)
                        {
                            adsescon.Open();
                            string adse = "INSERT INTO Session_Table (Medication, Date, Quality_of_Sleep, Appetite, Eye_Contact, Voice_Tone_Consistency, Attention_Span, ID, Score, Notes, Session_Number ) ";
                            adse += "VALUES (@Medication, @Date, @Quality_of_Sleep, @Appetite, @Eye_Contact, @Voice_Tone_Consistency, @Attention_Span, @ID, @Score, @Notes, @Session_Number)";
                            SqlCommand adsescomm = new SqlCommand(adse, adsescon);
                            adsescomm.Parameters.AddWithValue("Medication", SessAdd_Medication.Text);
                            adsescomm.Parameters.AddWithValue("Date", actd);
                            adsescomm.Parameters.AddWithValue("Quality_of_Sleep", sleep);
                            adsescomm.Parameters.AddWithValue("Appetite", appet);
                            adsescomm.Parameters.AddWithValue("Eye_Contact", eyecont);
                            adsescomm.Parameters.AddWithValue("Voice_Tone_Consistency", voice);
                            adsescomm.Parameters.AddWithValue("Attention_Span", attent);
                            adsescomm.Parameters.AddWithValue("ID", id);
                            adsescomm.Parameters.AddWithValue("Score", scor);
                            adsescomm.Parameters.AddWithValue("Notes", Testr.Text);
                            adsescomm.Parameters.AddWithValue("Session_Number", 0);
                            adsescomm.Parameters.AddWithValue("Used_Amount", numberamount);
                            adsescomm.ExecuteNonQuery();
                            adsescon.Close();

                            MessageBox.Show("Session Added");
                            this.Hide();
                            Session_List hj = new Session_List(SesAdd_Patient_ID.Text, SesAdd_Patient_Name.Text, SessAdd_Medication.Text, idga, b, d, amount);
                            hj.Show();
                        }
                        else
                        {
                            int sesnumber;
                            adsescon3.Open();
                            string getsesnum = "SELECT *  FROM Session_Table WHERE (Medication='" + SessAdd_Medication.Text + "' AND ID=" + SesAdd_Patient_ID.Text + " AND End_Status IS NULL)";

                            sesnumber = Convert.ToInt32(nums);
                            string kek = Convert.ToString(sesnumber);
                            adsescon.Open();
                            string adse = "INSERT INTO Session_Table (Medication, Date, Quality_of_Sleep, Appetite, Eye_Contact, Voice_Tone_Consistency, Attention_Span, ID, Score, Notes, Session_Number, Used_Amount ) ";
                            adse += "VALUES (@Medication, @Date, @Quality_of_Sleep, @Appetite, @Eye_Contact, @Voice_Tone_Consistency, @Attention_Span, @ID, @Score, @Notes, @Session_Number, @Used_Amount)";
                            SqlCommand adsescomm = new SqlCommand(adse, adsescon);
                            adsescomm.Parameters.AddWithValue("Medication", SessAdd_Medication.Text);
                            adsescomm.Parameters.AddWithValue("Date", actd);
                            adsescomm.Parameters.AddWithValue("Quality_of_Sleep", sleep);
                            adsescomm.Parameters.AddWithValue("Appetite", appet);
                            adsescomm.Parameters.AddWithValue("Eye_Contact", eyecont);
                            adsescomm.Parameters.AddWithValue("Voice_Tone_Consistency", voice);
                            adsescomm.Parameters.AddWithValue("Attention_Span", attent);
                            adsescomm.Parameters.AddWithValue("ID", id);
                            adsescomm.Parameters.AddWithValue("Score", scor);
                            adsescomm.Parameters.AddWithValue("Notes", Testr.Text);
                            adsescomm.Parameters.AddWithValue("Session_Number", Endexists + 1);
                            adsescomm.Parameters.AddWithValue("Used_Amount", numberamount);
                            adsescomm.ExecuteNonQuery();
                            adsescon.Close();
                            adsescon3.Close();
                            this.Hide();
                            Session_List hj = new Session_List(SesAdd_Patient_ID.Text, SesAdd_Patient_Name.Text, SessAdd_Medication.Text, idga, b, d, amount);
                            hj.Show();
                        }
                    }
                }
            }
        }