protected void PrescriptionGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { var builder = new MySqlConnectionStringBuilder { Server = "undcsmysql.mysql.database.azure.com", Database = "micah_j_nelson", UserID = "micah.j.nelson@undcsmysql", Password = "******", SslMode = MySqlSslMode.Required, }; using (var connection = new MySqlConnection(builder.ConnectionString)) { connection.Open(); using (var command = connection.CreateCommand()) { GridViewRow row = PrescriptionGridView.Rows[e.RowIndex]; command.CommandText = "UPDATE db455_prescription set prescription = '" + ((TextBox)(row.Cells[1].Controls[0])).Text + "', date = '" + ((TextBox)(row.Cells[2].Controls[0])).Text + "', quantity = " + ((TextBox)(row.Cells[3].Controls[0])).Text + " WHERE id = " + (row.DataItemIndex + 1) + " AND patient_id = 1;"; command.ExecuteNonQuery(); using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter()) { command.CommandText = "SELECT prescription as Prescription, date as Date, quantity as Quantity FROM db455_prescription WHERE patient_id = 1"; dataAdapter.SelectCommand = command; using (DataTable dataTable = new DataTable()) { dataAdapter.Fill(dataTable); PrescriptionGridView.DataSource = dataTable; PrescriptionGridView.DataBind(); Session["PrescriptionTable"] = dataTable; } } } } //Reset the edit index. PrescriptionGridView.EditIndex = -1; //Bind data to the GridView control. PrescriptionBindData(); }
private void PrescriptionBindData() { PrescriptionGridView.DataSource = Session["PrescriptionTable"]; PrescriptionGridView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var builder = new MySqlConnectionStringBuilder { Server = "undcsmysql.mysql.database.azure.com", Database = "micah_j_nelson", UserID = "micah.j.nelson@undcsmysql", Password = "******", SslMode = MySqlSslMode.Required, }; using (var connection = new MySqlConnection(builder.ConnectionString)) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM db455_patients WHERE id = 1"; using (var reader = command.ExecuteReader()) { while (reader.Read()) { FirstNameTxtBox.Text = reader.GetString(1); LastNameTxtBox.Text = reader.GetString(2); SSNTxtBox.Text = reader.GetString(3); AddressTxtBox.Text = reader.GetString(4); HomePhoneTxtBox.Text = reader.GetString(5); CellPhoneTxtBox.Text = reader.GetString(6); DOBTxtBox.Text = reader.GetDateTime(7).ToString(); } } using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter()) { command.CommandText = "SELECT date as Date, mh_type as Type, notes as Notes FROM db455_medical_history WHERE patient_id = 1"; dataAdapter.SelectCommand = command; using (DataTable dataTable = new DataTable()) { dataAdapter.Fill(dataTable); historyGridView.DataSource = dataTable; historyGridView.DataBind(); Session["historyTable"] = dataTable; } } using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter()) { command.CommandText = "SELECT name as Name, phone_number as Phone_Number, is_emergency as Is_Emergency, is_hippa as Is_Hippa FROM db455_contacts WHERE patient_id = 1"; dataAdapter.SelectCommand = command; using (DataTable dataTable = new DataTable()) { dataAdapter.Fill(dataTable); contactsGridView.DataSource = dataTable; contactsGridView.DataBind(); Session["contactsTable"] = dataTable; } } command.CommandText = "SELECT * FROM db455_finances WHERE patient_id = 1"; using (var reader = command.ExecuteReader()) { while (reader.Read()) { InsuranceCoTxtBox.Text = reader.GetString(1); InsuranceIDTxtBox.Text = reader.GetString(2); if (!reader.IsDBNull(3)) { MedicadeIDTxtBox.Text = reader.GetString(3); } if (!reader.IsDBNull(4)) { MedicareIDTxtBox.Text = reader.GetString(4); } BalanceTxtBox.Text = reader.GetString(5); } } using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter()) { command.CommandText = "SELECT prescription as Prescription, date as Date, quantity as Quantity FROM db455_prescription WHERE patient_id = 1"; dataAdapter.SelectCommand = command; using (DataTable dataTable = new DataTable()) { dataAdapter.Fill(dataTable); PrescriptionGridView.DataSource = dataTable; PrescriptionGridView.DataBind(); Session["PrescriptionTable"] = dataTable; } } } } } }