public int SaveDoctor(Doctor aDoctor) { string query = string.Format("INSERT INTO Doctor VALUES('{0}','{1}','{2}','{3}')", aDoctor.DoctorName, aDoctor.Degree, aDoctor.Specialization,aDoctor.CenterId); SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return rowAffected; }
public List<Doctor> PopulateDoctorDropDownList(int centerId) { List<Doctor> doctorList = new List<Doctor>(); SqlConnection connection = new SqlConnection(connectionString); string query = string.Format("SELECT * FROM Doctor Where CenterId='{0}'", centerId); connection.Open(); SqlCommand command = new SqlCommand(query, connection); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Doctor aDoctor = new Doctor(); aDoctor.Id = Convert.ToInt32(reader["Id"]); aDoctor.DoctorName = reader["DoctorName"].ToString(); doctorList.Add(aDoctor); } reader.Close(); connection.Close(); return doctorList; }
public string SaveDoctor(Doctor aDoctor) { if (gateway.SaveDoctor(aDoctor)>0) { return "Saved successfully"; } else { return "Save failed"; } }