public bool DoctorRegistration(string medicalRegistrationNo, string firstName, string lastName, int phoneNumber, string healthProfession, string email) { Doctor d = new Doctor() { MedicalRegistrationNo = medicalRegistrationNo, FirstName = firstName, LastName = lastName, HealthProfession = healthProfession, PhoneNumber = phoneNumber, Email = email }; string sql = String.Format("INSERT INTO Doctors VALUES('{0}', '{1}', '{2}', '{3}', {4}, '{5}')", d.MedicalRegistrationNo, d.FirstName, d.LastName, d.HealthProfession, d.PhoneNumber, d.Email); SqlCommand command = new SqlCommand(sql, conn); conn.Open(); int num; try { num = command.ExecuteNonQuery(); conn.Close(); } catch (Exception e) { conn.Close(); throw new FaultException(e.Message); } if (num > 0) return true; else return false; }
public Models.Doctor GetDoctorInfo(string firstName, string lastName) { string sql = String.Format("SELECT * FROM Doctors WHERE FirstName = '{0}' AND LastName = '{1}'", firstName, lastName); SqlCommand command = new SqlCommand(sql, conn); conn.Open(); SqlDataReader reader; try { reader = command.ExecuteReader(); } catch (Exception e) { conn.Close(); throw new FaultException(e.Message); } if (reader.HasRows) { reader.Read(); Doctor result = new Doctor() { MedicalRegistrationNo = reader.GetString(0), FirstName = reader.GetString(1), LastName = reader.GetString(2), HealthProfession = reader.GetString(3), PhoneNumber = reader.GetInt32(4), Email = reader.GetString(5) }; reader.Close(); conn.Close(); return result; } else conn.Close(); reader.Close(); return null; }
public Models.Doctor GetDoctorInfo(string firstName, string lastName) { DoctorData dData = (from d in db.DoctorDatas where d.FirstName == firstName && d.LastName == lastName select d).FirstOrDefault(); if (dData == null) { return null; } Doctor dModel = new Doctor() { MedicalRegistrationNo = dData.MedicalRegistrationNo, FirstName = dData.FirstName, LastName = dData.LastName, PhoneNumber = dData.PhoneNumber, HealthProfession = dData.HealthProfession, Email = dData.Email }; return dModel; }