public void UpdateGridview() { SqlConnection conn = new SqlConnection(@"data source = .\sqlexpress; integrated security = true; database = Dentist"); SqlCommand cmd = null; SqlDataReader rdr = null; try { conn.Open(); cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SelectAllRes"; SqlParameter in1 = cmd.Parameters.Add("@P_id", SqlDbType.Int); in1.Direction = ParameterDirection.Input; in1.Value = Convert.ToInt32(Session["PatientId"].ToString()); rdr = cmd.ExecuteReader(); GridViewRes.DataSource = rdr; GridViewRes.DataBind(); DropDownListPatients.Visible = false; DropDownListDays.Visible = false; } catch (Exception ex) { LabelMessage.Text = ex.Message; } finally { conn.Close(); } }
public void UpdateGridviewDentist() { SqlConnection conn = new SqlConnection(@"data source = .\sqlexpress; integrated security = true; database = Dentist"); SqlCommand cmd = null; SqlDataReader rdr = null; try { conn.Open(); cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "ShowDentistAll"; rdr = cmd.ExecuteReader(); GridViewRes.DataSource = rdr; GridViewRes.DataBind(); } catch (Exception ex) { LabelMessage.Text = ex.Message; } finally { conn.Close(); } SqlDataAdapter da = null; DataSet ds = null; DataTable dt = null; string sqlsel = "select * from Patient"; try { da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(sqlsel, conn); ds = new DataSet(); da.Fill(ds, "MyTreatments"); dt = ds.Tables["MyTreatments"]; DropDownListPatients.DataSource = dt; DropDownListPatients.DataTextField = "P_Id"; DropDownListPatients.DataValueField = "P_Id"; DropDownListPatients.DataBind(); DropDownListPatients.Items.Insert(0, "Select a Patient"); } catch (Exception ex) { LabelMessage.Text = ex.Message; } finally { conn.Close(); } string sqlselday = "select * from Reservations"; try { da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(sqlselday, conn); ds = new DataSet(); da.Fill(ds, "MyRes"); dt = ds.Tables["MyRes"]; DropDownListDays.DataSource = dt; DropDownListDays.DataTextField = "R_Date"; DropDownListDays.DataValueField = "R_Date"; DropDownListDays.DataBind(); DropDownListDays.Items.Insert(0, "Select a Day"); } catch (Exception ex) { LabelMessage.Text = ex.Message; } finally { conn.Close(); } }