public NewDoctor(DataGridViewRow clinic,ToolStripStatusLabel lbl ) { InitializeComponent(); Hospital_cb.Text = Convert.ToString(clinic.Cells[3].Value); Name_tb.Text = Convert.ToString(clinic.Cells[1].Value); Surname_tb.Text = Convert.ToString(clinic.Cells[0].Value); Patro_tb.Text = Convert.ToString(clinic.Cells[2].Value); Specialization_cb.Text = Convert.ToString(clinic.Cells[4].Value); hospital = Convert.ToString(clinic.Cells[3].Value); name = Convert.ToString(clinic.Cells[1].Value); surname = Convert.ToString(clinic.Cells[0].Value); patro = Convert.ToString(clinic.Cells[2].Value); spec = Convert.ToString(clinic.Cells[4].Value); DBProcedure proc = new DBProcedure(); proc.search_id_doctor(name, surname, patro, hospital, spec); id_doctor = proc.id_doctor; status = lbl; if (!iIdRecord) { SaveDoctor_btn.Visible = false; } }
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 DelDoctor_btn_Click(object sender, EventArgs e) { DataGridViewRow hclinic = new DataGridViewRow(); hclinic = Doctor_dataGrid.CurrentRow; DialogResult res = MessageBox.Show("Удалить: " + hclinic.Cells[0].Value.ToString() + hclinic.Cells[1].Value.ToString() +hclinic.Cells[2].Value.ToString()+"?", "Удаление", MessageBoxButtons.OKCancel); if (res == DialogResult.OK) { DBProcedure proc = new DBProcedure(); proc.del_doc(hclinic); StatusLbl.Text = "Доктор удален: " + hclinic.Cells[0].Value.ToString() + " " + hclinic.Cells[1].Value.ToString() + " " + hclinic.Cells[2].Value.ToString(); string sql = GetSQLStringDoctor(); Doctor_dataGrid.DataSource = ToDataTable(sql); } }
private bool SaveDoc () { proc = new DBProcedure(); proc.iIdRecord = iIdRecord; if (Name_tb.Text != "" && Surname_tb.Text != "" && Patro_tb.Text != "" && Hospital_cb.Text != "" && Specialization_cb.Text != "") { if (!iIdRecord) proc.search_id_doctor(name, surname, patro, hospital, spec); proc.StartTime(sMon_tb.Text, sTue_tb.Text, sWed_tb.Text, sThu_tb.Text, sFri_tb.Text, sSat_tb.Text, sSun_tb.Text); proc.endTime(eMon_tb.Text, eTue_tb.Text, eWed_tb.Text, eThu_tb.Text, eFri_tb.Text, sSat_tb.Text, sSun_tb.Text); proc.AddToDoctor(Name_tb.Text, Surname_tb.Text, Patro_tb.Text, Hospital_cb.Text, Specialization_cb.Text); if (iIdRecord) { status.Text = "Добавлено: " + Surname_tb.Text + " " + Name_tb.Text + " " + Patro_tb.Text; } else status.Text = "Отредактировано: " + Surname_tb.Text + " " + Name_tb.Text + " " + Patro_tb.Text; return true; } else { MessageBox.Show("Заполните все поля", "Пустые поля", MessageBoxButtons.OK); return false; } }