private void Refill_Load(object sender, EventArgs e) { refillRequestList = Refill.indicateNewRefillRequestBrief(); panel5.Visible = true; listBox1.Items.Clear(); if (refillRequestList != null) { Console.WriteLine("Yes " + refillRequestList.Count); for (int i = 0; i < refillRequestList.Count; i++) { Refill thisRefill = (Refill)(refillRequestList[i]); temp = thisRefill.getID(); String s = thisRefill.getfullName().PadRight(30) + thisRefill.getdateFilledIn(); //String s = thisRefill.getlastName().PadRight(10) + thisRefill.getdateFilledIn(); Console.WriteLine(s); listBox1.Items.Add(s); } } else { Console.WriteLine("No"); String s = "There is not any New Refill Request."; listBox1.Items.Add(s); } }
private void button1_Click(object sender, EventArgs e) { selectedIndex = listBox1.SelectedIndex; refillRequestlistdetail = Refill.displayALLRefillRequests(); Console.WriteLine(" Count of DisplayALLRefillRequests " + Refill.displayALLRefillRequests().Count); if (refillRequestlistdetail != null) { Refill thisRefill2 = (Refill)refillRequestlistdetail[selectedIndex]; Console.WriteLine("Index " + selectedIndex); fullName.Text = thisRefill2.getfullName().ToString(); patientID.Text = thisRefill2.getphyId().ToString(); medication.Text = thisRefill2.getMedicine().ToString(); dosage.Text = thisRefill2.getdosage().ToString(); doctor.Text = thisRefill2.getDoctor().ToString(); status.Text = thisRefill2.getrefillStatus().ToString(); } else { Console.WriteLine("There are no new refill requests"); } //to compare with prescription in database string myConnection = "server=localhost;port=3306;database=Pharmacy;username=root;password="******"select * from refills", conn); conn.Open(); try { //MessageBox.Show("Connection open"); MySqlDataAdapter dataAdapter = new MySqlDataAdapter(); dataAdapter.SelectCommand = cmd; DataTable dst1 = new DataTable(); dataAdapter.Fill(dst1); dataGridView1.DataSource = dst1; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } }
public static ArrayList displayALLRefillRequests() { ArrayList refillRequestList = new ArrayList(); DataTable myTable = new DataTable(); string connStr = "server=localhost;user=root;database=pharmacy;port=3306;password=;"; MySqlConnection conn = new MySqlConnection(connStr); try { Console.WriteLine("Connecting to MySQL..."); conn.Open(); string sql = "SELECT * from patients join refills on patients.Patient_ID = refills.Patient_ID where status='New' ORDER BY refill_ID ASC"; MySqlCommand cmd = new MySqlCommand(sql, conn); //cmd.Parameters.AddWithValue("@id", id); MySqlDataAdapter myAdapter = new MySqlDataAdapter(cmd); myAdapter.Fill(myTable); Console.WriteLine("Table is ready."); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } conn.Close(); //convert the retrieved data to events and save them to the list foreach (DataRow row in myTable.Rows) { Refill newRefillRequest = new Refill(); newRefillRequest.fullName = row["FullName"].ToString(); newRefillRequest.phyID = Int32.Parse(row["Patient_ID"].ToString()); newRefillRequest.medicine = row["Medicine"].ToString(); Console.WriteLine("Medicine of this particular thing is " + newRefillRequest.getMedicine()); newRefillRequest.dosage = row["Dosage"].ToString(); newRefillRequest.doctor = row["Doctor"].ToString(); newRefillRequest.refillStatus = row["Status"].ToString(); refillRequestList.Add(newRefillRequest); } return(refillRequestList); }
/* * public void changeStatus(String s) * { * string conn = "server=csdatabase.eku.edu;user=stu_csc340;database=csc340_db;port=3306;password=Colonels18;"; * MySqlConnection myconn = new MySqlConnection(conn); * try * { * Console.Write("Connecting to MySQL..."); * myconn.Open(); * string sql = "UPDATE changprescription SET status=@status WHERE id=@Id"; * MySqlCommand cmd = new MySqlCommand(sql, myconn); * * cmd.Parameters.AddWithValue("@status", s.ToString()); * cmd.Parameters.AddWithValue("@Id", id); * //MySqlDataAdapter myAdapter = new MySqlDataAdapter(cmd); * cmd.ExecuteNonQuery(); * Console.WriteLine("Table has been Updated."); * * } * catch(Exception ex) * { * Console.WriteLine(ex.ToString()); * } * finally * { * myconn.Close(); * } * * * } * * */ public static ArrayList indicateNewRefillRequestBrief() { ArrayList refillRequestList = new ArrayList(); DataTable myTable = new DataTable(); string connStr = "server=localhost;user=root;database=pharmacy;port=3306;password=;"; MySqlConnection conn = new MySqlConnection(connStr); try { Console.WriteLine("Connecting to MySQL..."); conn.Open(); Console.WriteLine("Connection is open"); //string sql = "SELECT Medicine, Doctor from refills where status = 'New'"; string sql = "SELECT patients.FullName, refills.dateFilledIn, refills.refill_ID from patients join refills on patients.Patient_ID = refills.Patient_ID where status='New' "; MySqlCommand cmd = new MySqlCommand(sql, conn); //cmd.Parameters.AddWithValue("@phyId", phyID); MySqlDataAdapter myAdapter = new MySqlDataAdapter(cmd); myAdapter.Fill(myTable); Console.WriteLine("Table is ready."); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } conn.Close(); //convert the retrieved data to events and save them to the list foreach (DataRow row in myTable.Rows) { Refill newRefillRequest = new Refill(); newRefillRequest.id = Int32.Parse(row["refill_ID"].ToString()); newRefillRequest.fullName = row["FullName"].ToString(); newRefillRequest.dateFilledIn = (DateTime)row["dateFilledIn"]; refillRequestList.Add(newRefillRequest); } return(refillRequestList); }