protected void AddHospitalButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; String btnId = btn.ID; if (btnId.Equals("AddHospitalButton")) { if (IsValid) { System.Threading.Thread.Sleep(3000); var hospitalName = NameTextBox.Text; var hospitalAddress = AddressTextBox.Text; var hospitalLicense = LicenseTextBox.Text; var hospital = new Hospital() { hospitalName = hospitalName, address = hospitalAddress, license = hospitalLicense }; _dataContext.Hospitals.InsertOnSubmit(hospital); _dataContext.SubmitChanges(); HospitalList.DataBind(); ResetInputField(); } } else if (btnId.Equals("ResetHospitalButton")) { ResetInputField(); } }
protected void Get_Hospital(object sender, EventArgs e) { try { DropDownList s = sender as DropDownList; string location = s.SelectedValue; string sqlConnString = ConfigurationManager.ConnectionStrings["ConnString"].ToString(); SqlConnection sqlConn = new SqlConnection(sqlConnString); sqlConn.Open(); String sql = "select * from hospital where hospital_city = '" + location + " 'order by hospital_name"; SqlCommand sqlCmd = new SqlCommand(sql, sqlConn); SqlDataAdapter da = new SqlDataAdapter(sqlCmd); DataSet ds = new DataSet(); da.Fill(ds); HospitalList.DataTextField = ds.Tables[0].Columns["hospital_name"].ToString(); HospitalList.DataValueField = ds.Tables[0].Columns["hospital_id"].ToString(); HospitalList.DataSource = ds.Tables[0]; HospitalList.DataBind(); sqlConn.Close(); } catch (Exception ex) { Response.Write("Error:" + ex.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { string sqlConnString = ConfigurationManager.ConnectionStrings["ConnString"].ToString(); SqlConnection sqlConn = new SqlConnection(sqlConnString); sqlConn.Open(); SqlCommand sqlCmd = new SqlCommand("select * from hospital order by 2", sqlConn); SqlDataAdapter da = new SqlDataAdapter(sqlCmd); DataSet ds = new DataSet(); da.Fill(ds); HospitalList.DataTextField = ds.Tables[0].Columns["hospital_name"].ToString(); HospitalList.DataValueField = ds.Tables[0].Columns["hospital_id"].ToString(); HospitalList.DataSource = ds.Tables[0]; HospitalList.DataBind(); //LocationList.SelectedIndex = 1; } catch (Exception ex) { Response.Write("Error:" + ex.ToString()); } } }
protected void Page_Load(object sender, EventArgs e) { // // if (!IsPostBack) { ListItem emptyItem = new ListItem("----Select----", ""); DoctorList.DataSource = _doctorRepository.GetDoctors(); DoctorList.DataBind(); DoctorList.DataTextField = "DoctorName"; DoctorList.DataValueField = "DoctorName"; DoctorList.DataBind(); DoctorList.Items.Insert(0, emptyItem); HospitalList.DataSource = _hospitalRepository.GetHospitals(); HospitalList.DataBind(); HospitalList.DataTextField = "HospitalName"; HospitalList.DataValueField = "HospitalName"; HospitalList.DataBind(); HospitalList.Items.Insert(0, emptyItem); SpecialityList.DataSource = _specialityRepository.GetSpecialities(); SpecialityList.DataBind(); SpecialityList.DataTextField = "Speciality"; SpecialityList.DataValueField = "Speciality"; SpecialityList.DataBind(); SpecialityList.Items.Insert(0, emptyItem); IDictionary <string, bool?> isActive = new Dictionary <string, bool?>(); isActive.Add("----Select----", null); isActive.Add("Active", true); isActive.Add("Not Active", false); IsActiveList.DataSource = isActive.ToList(); IsActiveList.DataBind(); IsActiveList.DataTextField = "key"; IsActiveList.DataValueField = "value"; IsActiveList.DataBind(); GenerateReport(); } }