private void ChangeClinic(string newname, string newaddress) { connect = new DBConnect(); if (connect.OpenConnection()) { try { com = new MySqlCommand("CLINIC", connect.con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@NewName", newname); com.Parameters.AddWithValue("@NewAddress", newaddress); com.Parameters.AddWithValue("@Name", name); com.Parameters.AddWithValue("@Address", address); com.Parameters.AddWithValue("@Id", iIdRecord); com.ExecuteNonQuery(); connect.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void AddToDoctor(string name, string surname, string patro, string clinic, string spec) { connect = new DBConnect(); con = new MySqlConnection(); con = connect.con; if (connect.OpenConnection()) { try { MySqlCommand com = new MySqlCommand("DOCTOR", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@Id", iIdRecord); com.Parameters.AddWithValue("@Id_doctor", id_doctor); com.Parameters.AddWithValue("@newName", name); com.Parameters.AddWithValue("@newSurname", surname); com.Parameters.AddWithValue("@newPatro", patro); com.Parameters.AddWithValue("@newclinic", clinic); com.Parameters.AddWithValue("@newSpec", spec); com.Parameters.AddWithValue("@Id_start", Convert.ToInt32(id_start)); com.Parameters.AddWithValue("@Id_end", Convert.ToInt32(id_end)); com.ExecuteNonQuery(); connect.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void loadSpecHos() { Hospital_cb.Items.Clear(); Specialization_cb.Items.Clear(); connect = new DBConnect(); com = new MySqlCommand(@"select name_clinic from clinic", connect.con); if (connect.OpenConnection()) { using (MySqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { Hospital_cb.Items.Add(dr["name_clinic"].ToString()); } dr.Close(); } connect.CloseConnection(); } com = new MySqlCommand(@"select name_specialization from specialization", connect.con); if (connect.OpenConnection()) { using (MySqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { Specialization_cb.Items.Add(dr["name_specialization"].ToString()); } dr.Close(); } connect.CloseConnection(); } }
private void enter_btn_Click(object sender, EventArgs e) { Data.log = login_tb.Text; Data.pass = Password_tb.Text; DBConnect con = new DBConnect(); if (con.OpenConnection()) { this.Hide(); hospital = new Hospital(); hospital.Show(); con.CloseConnection(); } }
private void DelDubl() { connect = new DBConnect(); if (connect.OpenConnection()) { try { com = new MySqlCommand("DUBLICATE", connect.con); com.CommandType = CommandType.StoredProcedure; com.ExecuteNonQuery(); connect.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void Dubl() { connect = new DBConnect(); if (connect.OpenConnection()) { try { com = new MySqlCommand("CountDubl", connect.con); com.CommandType = CommandType.StoredProcedure; dubl = Convert.ToInt32(com.ExecuteScalar()); connect.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void TimeTable(object sender, DataGridViewCellEventArgs e) { DBProcedure proc = new DBProcedure(); string surname = Convert.ToString(Doctor_dataGrid.CurrentRow.Cells[0].Value); string name = Convert.ToString(Doctor_dataGrid.CurrentRow.Cells[1].Value); string patro = Convert.ToString(Doctor_dataGrid.CurrentRow.Cells[2].Value); string clinic = Convert.ToString(Doctor_dataGrid.CurrentRow.Cells[3].Value); string spec = Convert.ToString(Doctor_dataGrid.CurrentRow.Cells[4].Value); proc.search_id_doctor(name, surname, patro, clinic, spec); id = proc.id_doctor; connect = new DBConnect(); com1 = new MySqlCommand(@"SELECT * FROM doctor, startrecept where doctor.id_startrecept = startrecept.id_startrecept and id_doctor = "+@id, connect.con); com2 = new MySqlCommand(@"SELECT * FROM doctor, endrecept where doctor.id_endrecept=endrecept.id_endrecept and id_doctor = " + @id, connect.con); if (connect.OpenConnection()) { using (MySqlDataReader dr = com1.ExecuteReader()) { while (dr.Read()) { sMon_tb.Text = dr["Monday"].ToString(); sTue_tb.Text = dr["Tuesday"].ToString(); sWed_tb.Text = dr["Wednesday"].ToString(); sThu_tb.Text = dr["thursday"].ToString(); sFri_tb.Text = dr["Friday"].ToString(); sSat_tb.Text = dr["saturday"].ToString(); sSun_tb.Text = dr["sunday"].ToString(); } dr.Close(); } connect.CloseConnection(); } if (connect.OpenConnection()) { using (MySqlDataReader dr = com2.ExecuteReader()) { while (dr.Read()) { eMon_tb.Text = dr["Monday"].ToString(); eTue_tb.Text = dr["Tuesday"].ToString(); eWed_tb.Text = dr["Wednesday"].ToString(); eThu_tb.Text = dr["thursday"].ToString(); eFri_tb.Text = dr["Friday"].ToString(); eSat_tb.Text = dr["saturday"].ToString(); eSun_tb.Text = dr["sunday"].ToString(); } dr.Close(); } connect.CloseConnection(); } }
private void del_spec() { connect = new DBConnect(); if (connect.OpenConnection()) { try { MySqlCommand com = new MySqlCommand("DELSPECIALIZATION", connect.con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@sName",Convert.ToString(Specialization_dataGrid.CurrentRow.Cells[0].Value)); com.ExecuteNonQuery(); connect.CloseConnection(); } catch { MessageBox.Show("Нельзя удалить, существуют связи", "Ошибка", MessageBoxButtons.OK); } } }
private void del_clinic() { connect = new DBConnect(); if (connect.OpenConnection()) { try { MySqlCommand com = new MySqlCommand("DELCLINIC", connect.con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@sname", Convert.ToString(Hospital_dataGrid.CurrentRow.Cells[0].Value)); com.Parameters.AddWithValue("@saddress", Convert.ToString(Hospital_dataGrid.CurrentRow.Cells[1].Value)); com.ExecuteNonQuery(); connect.CloseConnection(); } catch { MessageBox.Show("Нельзя удалить, существуют связи", "Ошибка", MessageBoxButtons.OK); } } }
public DataTable ToDataTable(string QueryString) { DataTable dt = new DataTable(); connect = new DBConnect(); MySqlConnection con = new MySqlConnection(); con = connect.con; string str = QueryString; MySqlCommand com = new MySqlCommand(str, con); if (connect.OpenConnection()) { using (MySqlDataReader dr = com.ExecuteReader()) { dt.Load(dr); } connect.CloseConnection(); } return dt; }
public void StartTime(string mon, string tue, string wed, string thu, string fri, string sat, string sun) { connect = new DBConnect(); con = new MySqlConnection(); con = connect.con; if (connect.OpenConnection()) { try { com = new MySqlCommand("STARTRECEPT", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@id", iIdRecord); com.Parameters.AddWithValue("@id_doctor", id_doctor); com.Parameters.AddWithValue("@smon", mon); com.Parameters.AddWithValue("@stue", tue); com.Parameters.AddWithValue("@swed", wed); com.Parameters.AddWithValue("@sthu", thu); com.Parameters.AddWithValue("@sfri", fri); com.Parameters.AddWithValue("@ssat", sat); com.Parameters.AddWithValue("@ssun", sun); if (iIdRecord) { id_start = Convert.ToInt32(com.ExecuteScalar()); } else com.ExecuteNonQuery(); connect.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void del_doc(DataGridViewRow doc) { connect = new DBConnect(); con = new MySqlConnection(); con = connect.con; if (connect.OpenConnection()) { try { MySqlCommand com = new MySqlCommand("DELDOCTOR", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@Name", Convert.ToString( doc.Cells[1].Value)); com.Parameters.AddWithValue("@Surname", Convert.ToString(doc.Cells[0].Value)); com.Parameters.AddWithValue("@Patro", Convert.ToString(doc.Cells[2].Value)); com.Parameters.AddWithValue("@Spec", Convert.ToString(doc.Cells[4].Value)); com.Parameters.AddWithValue("@Clinic", Convert.ToString(doc.Cells[3].Value)); com.ExecuteNonQuery(); connect.CloseConnection(); } catch { MessageBox.Show("Нельзя удалить, существуют связи", "Ошибка", MessageBoxButtons.OK); } } }
public void search_id_doctor(string name, string surname, string patro, string hospital, string spec) { connect = new DBConnect(); con = new MySqlConnection(); con = connect.con; if (connect.OpenConnection()) { try { MySqlCommand com = new MySqlCommand("ID_DOCTOR", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@Name", name); com.Parameters.AddWithValue("@Surname", surname); com.Parameters.AddWithValue("@Patro", patro); com.Parameters.AddWithValue("@clinic", hospital); com.Parameters.AddWithValue("@Spec", spec); id_doctor = Convert.ToInt32(com.ExecuteScalar()); connect.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void TimeTable() { connect = new DBConnect(); com1 = new MySqlCommand(@"SELECT * FROM doctor, startrecept where doctor.id_startrecept = startrecept.id_startrecept and id_doctor = " + id_doctor, connect.con); com2 = new MySqlCommand(@"SELECT * FROM doctor, endrecept where doctor.id_endrecept=endrecept.id_endrecept and id_doctor = " + id_doctor, connect.con); if (connect.OpenConnection()) { using (MySqlDataReader dr = com1.ExecuteReader()) { while (dr.Read()) { sMon_tb.Text = dr["Monday"].ToString(); sTue_tb.Text = dr["Tuesday"].ToString(); sWed_tb.Text = dr["Wednesday"].ToString(); sThu_tb.Text = dr["thursday"].ToString(); sFri_tb.Text = dr["Friday"].ToString(); sSat_tb.Text = dr["saturday"].ToString(); sSun_tb.Text = dr["sunday"].ToString(); } dr.Close(); } using (MySqlDataReader dr = com2.ExecuteReader()) { while (dr.Read()) { eMon_tb.Text = dr["Monday"].ToString(); eTue_tb.Text = dr["Tuesday"].ToString(); eWed_tb.Text = dr["Wednesday"].ToString(); eThu_tb.Text = dr["thursday"].ToString(); eFri_tb.Text = dr["Friday"].ToString(); eSat_tb.Text = dr["saturday"].ToString(); eSun_tb.Text = dr["sunday"].ToString(); } dr.Close(); } connect.CloseConnection(); } }
private void NewDoctor_Load(object sender, EventArgs e) { TimeTable(); connect = new DBConnect(); con = new MySqlConnection(); con = connect.con; com = new MySqlCommand(@"select name_clinic from clinic", con); if (connect.OpenConnection()) { using (MySqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { Hospital_cb.Items.Add(dr["name_clinic"].ToString()); } dr.Close(); } connect.CloseConnection(); } com = new MySqlCommand(@"select name_specialization from specialization", con); if (connect.OpenConnection()) { using (MySqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { Specialization_cb.Items.Add(dr["name_specialization"].ToString()); } dr.Close(); } connect.CloseConnection(); } }
private void AddSpecialization(string name) { connect = new DBConnect(); if (connect.OpenConnection()) { try { com = new MySqlCommand("SPECIALIZATION", connect.con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@NewName", name); com.Parameters.AddWithValue("@Name", nameString); com.Parameters.AddWithValue("@id", iIdRecord); com.ExecuteNonQuery(); connect.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }