public List<DoctorDetails> GetDoctorDetails(string consentName) { var output = new List<DoctorDetails>(); using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ToString())) { using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("select Physician.Fname as FName, Physician.Lname as LName,Physician.ConsentTypeID as ID from Physician,ConsentType where Physician.ConsentTypeID=ConsentType.ID AND ConsentType.Name ='" + consentName + "' ", sqlConnection)) { DataSet dataset = new DataSet(); sqlDataAdapter.Fill(dataset); if (dataset.Tables.Count > 0) { foreach (DataRow row in dataset.Tables[0].Rows) { var doctorDetail = new DoctorDetails(); doctorDetail.ID = Convert.ToInt32(row["ID"].ToString()); doctorDetail.Fname = row["FName"].ToString(); doctorDetail.Lname = row["LName"].ToString(); output.Add(doctorDetail); } } } } return output; }
public DoctorDetails GetDoctorDetail(int id) { var output = new DoctorDetails(); System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath); var conStr = config.AppSettings.Settings["DBConnection"].Value; using (var sqlConnection = new SqlConnection(conStr)) { sqlConnection.Open(); using (var sqlDataAdapter = new SqlDataAdapter("GetDoctorDetail", sqlConnection)) { sqlDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; sqlDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = id; var dataset = new DataSet(); sqlDataAdapter.Fill(dataset); if (dataset.Tables.Count > 0) { if (dataset.Tables[0].Rows.Count > 0) { DataRow row = dataset.Tables[0].Rows[0]; output.Fname = row["FName"].ToString(); output.Lname = row["LName"].ToString(); output.ID = id; } } } } return output; }
public DoctorDetails GetDoctorDetail(int ID) { var output = new DoctorDetails(); using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ToString())) { sqlConnection.Open(); using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("select Physician.Fname as FName, Physician.Lname as LName from Physician where Physician.ID ='" + ID + "' ", sqlConnection)) { DataSet dataset = new DataSet(); sqlDataAdapter.Fill(dataset); if (dataset.Tables.Count > 0) { if (dataset.Tables[0].Rows.Count > 0) { DataRow row = dataset.Tables[0].Rows[0]; output.Fname = row["FName"].ToString(); output.Lname = row["LName"].ToString(); output.ID = ID; } } } } return output; }