private void btnRandevuOnay_Click(object sender, EventArgs e) { DateTime tarih = dateTimePicker1.Value.Date; string sqlFormattedDate = tarih.Date.ToString("yyyy-MM-dd"); SqlConnection con = new SqlConnection(conString); try { con.Open(); SqlCommand cmd = new SqlCommand("select * from randevular where tarih=@tarih and saat=@saat", con); cmd.Parameters.AddWithValue("@tarih", sqlFormattedDate); cmd.Parameters.AddWithValue("@saat", comboBoxSaat.Text); cmd.ExecuteNonQuery(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds); int count = ds.Tables[0].Rows.Count; if (count == 1) { MessageBox.Show("Seçilen randevu daha önce alınmış. Yeni bir randevu alınız.."); Form f = new hastaPanel(textBoxTCKimlikNo.Text); f.Show(); Close(); } else { randevuKaydi(); } con.Close(); }catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void hastaGirisi() { string girilenTC = textBoxHastaGiris1.Text; string girilensifre = textBoxHastaGiris2.Text; int count = 0; SqlConnection con = new SqlConnection(conString); try { con.Open(); string query = "SELECT * FROM hastaGiris WHERE TCKimlikNo = '" + girilenTC.Trim() + "' AND sifre = '" + girilensifre.Trim() + "'"; SqlDataAdapter sda = new SqlDataAdapter(query, con); DataSet ds = new DataSet(); sda.Fill(ds); count = ds.Tables[0].Rows.Count; con.Close(); if (count == 1) { Form form = new hastaPanel(textBoxHastaGiris1.Text); form.Show(); Hide(); } if (count != 1) { MessageBox.Show("TC kimlik no veya şifre hatalı!!"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }