public int SaveDoctor(DoctorEntry aDoctorEntry) { SqlConnection connection = new SqlConnection(connectionstring); string query = "insert into tbl_DoctorEntry values ('"+aDoctorEntry.Name+"','"+aDoctorEntry.Degeree+"','"+aDoctorEntry.Specialization+"','"+aDoctorEntry.CenterID+"','"+aDoctorEntry.ThanaID+"','"+aDoctorEntry.DistrictID+"')"; SqlCommand command = new SqlCommand(query,connection); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return rowAffected; }
public string SaveDoctor(DoctorEntry aDoctorEntry) { if (aDoctorEntryGateway.SaveDoctor(aDoctorEntry) > 0) { return "Doctor saved successfully."; } else { return "Doctor not saved."; } }
public List<DoctorEntry> LoadDoctor(string center, string thana, string district) { int centerID = aMedicineGateway.GetIDByCenterName(center); int thanaID = aMedicineGateway.GetIDByThanaName(thana); int districtID = aMedicineGateway.GetIDByDistrictName(district); SqlConnection connection = new SqlConnection(connectionString); string query = "select * from tbl_DoctorEntry where CenterID = '" + centerID + "' and ThanaID = '" + thanaID +"' and DistrictID = '" + districtID + "'"; SqlCommand command = new SqlCommand(query,connection); connection.Open(); List<DoctorEntry> doctorList = new List<DoctorEntry>(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { DoctorEntry aDoctorEntry = new DoctorEntry(); aDoctorEntry.ID = int.Parse(reader["ID"].ToString()); aDoctorEntry.Name = reader["Name"].ToString(); doctorList.Add(aDoctorEntry); } reader.Close(); connection.Close(); return doctorList; }