private void Double_Att_Graph_FormClosing(object sender, FormClosingEventArgs e) { Double_Session_List jo = new Double_Session_List(id, patnamo, med, fillo, begindate, enddate, firamo, secoamo, medgg1, medgg2); this.Hide(); jo.Show(); }
private void Med_History_Grid_CellContentClick(object sender, DataGridViewCellEventArgs e) { selectint = e.RowIndex; DataGridViewRow row = new DataGridViewRow(); row = Med_History_Grid.Rows[selectint]; if (!(row.Cells[2].Value == DBNull.Value || row.Cells[2].Value == null || String.IsNullOrWhiteSpace(row.Cells[2].Value.ToString()))) { End_Medication_But.Enabled = true; if (e.ColumnIndex == 0) { go = row.Cells[1].Value; getid = Convert.ToInt32(go); goget = row.Cells[3].Value; gogetprox = Convert.ToString(goget); Boolean ended2; if (row.Cells[6].Value == null || row.Cells[6].Value == DBNull.Value || String.IsNullOrWhiteSpace(row.Cells[6].Value.ToString())) { ended2 = false; //enddate = DateTime.Now.ToString(); enddate = ""; } else { ended2 = true; go4 = row.Cells[6].Value;//end date enddate = Convert.ToString(go4); } object go6 = row.Cells[4].Value; ended = ended2; go = row.Cells[3].Value; go2 = row.Cells[8].Value; gu = row.Cells[7].Value; go3 = row.Cells[5].Value;//begin date go5 = row.Cells[6].Value; begindate = Convert.ToString(go3); string kek = go5.ToString(); //enddate string med2 = go6.ToString(); //medname 2 meme3 = Convert.ToString(gu); //first amount meme = Convert.ToString(go); //medname 1 meme2 = Convert.ToString(go2); //secondamount Double_Session_List joto = new Double_Session_List(Patient_ID_Lab.Text, Patient_Name_Lab.Text, meme + "-" + med2, ended2, begindate, kek, meme3, meme2, meme, med2); this.Hide(); joto.Show(); } } }
private void Register_Session_Button_Click(object sender, EventArgs e) { sesnum(); 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)); scor = Convert.ToInt32(Score_Box.Text); 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); // START LOOKING FROM HERE //firstbox if (!(string.IsNullOrWhiteSpace(Change_First_Amount_Box.Text))) { if (int.TryParse(Change_First_Amount_Box.Text, out filler) == false) { MessageBox.Show("Enter a proper amount"); } else { firstamount = Change_First_Amount_Box.Text; firstnumber = Convert.ToDouble(firstamount); //if (Endexists < 0) //{ string update = "UPDATE Double_Medication_Historty SET First_Used_Amount=" + firstnumber + " WHERE (ID=@ID AND End_Date IS NULL)"; adsescon.Open(); SqlCommand adeseso = new SqlCommand(update, adsescon); adeseso.Parameters.AddWithValue("ID", id); adeseso.ExecuteNonQuery(); adsescon.Close(); //} //else //{ //} } } if (!(string.IsNullOrWhiteSpace(Change_Second_Amount_Box.Text))) { if (int.TryParse(Change_Second_Amount_Box.Text, out filler) == false) { MessageBox.Show("Enter a proper amount"); } else { secondamount = Change_Second_Amount_Box.Text; secondnumber = Convert.ToDouble(secondamount); string update = "UPDATE Double_Medication_Historty SET Second_Used_Amount=" + secondnumber + " WHERE (ID=@ID AND End_Date IS NULL)"; adsescon.Open(); SqlCommand adeseso = new SqlCommand(update, adsescon); adeseso.Parameters.AddWithValue("ID", id); adeseso.ExecuteNonQuery(); adsescon.Close(); } } string adse = "INSERT INTO Double_Session_Table (First_Medication, Second_Medication, Date, Quality_of_Sleep, Appetite, Eye_Contact, Voice_Tone, Attention_Span, ID, Score, Notes, Session_Number, First_Used_Amount, Full_Combination, Second_Used_Amount ) "; adse += "VALUES (@First_Medication, @Second_Medication, @Date, @Quality_of_Sleep, @Appetite, @Eye_Contact, @Voice_Tone, @Attention_Span, @ID, @Score, @Notes, @Session_Number, @First_Used_Amount, @Full_Combination, @Second_Used_Amount )"; adsescon.Open(); SqlCommand adsescomm = new SqlCommand(adse, adsescon); adsescomm.Parameters.AddWithValue("First_Medication", firstmedname); adsescomm.Parameters.AddWithValue("Second_Medication", secondmedname); adsescomm.Parameters.AddWithValue("Date", actd); //adsescomm.Parameters.AddWithValue("First_Medication", firstmedname); adsescomm.Parameters.AddWithValue("Quality_of_Sleep", sleep); adsescomm.Parameters.AddWithValue("Appetite", appet); adsescomm.Parameters.AddWithValue("Eye_Contact", eyecont); adsescomm.Parameters.AddWithValue("Voice_Tone", voice); adsescomm.Parameters.AddWithValue("Attention_Span", attent); adsescomm.Parameters.AddWithValue("ID", id); adsescomm.Parameters.AddWithValue("Score", scor); adsescomm.Parameters.AddWithValue("Notes", Testr.Text); if (Endexists < 0) { adsescomm.Parameters.AddWithValue("Session_Number", 0); } else { adsescomm.Parameters.AddWithValue("Session_Number", Endexists + 1); } adsescomm.Parameters.AddWithValue("First_Used_Amount", firstnumber); adsescomm.Parameters.AddWithValue("Full_Combination", SessAdd_Medication.Text); adsescomm.Parameters.AddWithValue("Second_Used_Amount", secondnumber); adsescomm.ExecuteNonQuery(); adsescon.Close(); MessageBox.Show("Session Added"); Double_Session_List jog = new Double_Session_List(SesAdd_Patient_ID.Text, SesAdd_Patient_Name.Text, SessAdd_Medication.Text, fillertempvalue, b, fillerendtemp, firstnumber.ToString(), secondnumber.ToString(), firstmedname, secondmedname); this.Hide(); jog.Show(); }