public HourlyAppointment GetContactIdByCarDeliveryOrderId(string carDeliveryOrderId) { // var contactId = CRMAccessDB.ExecuteScalar(@"select new_Contact from new_hourlyappointmentBase //inner join ContactBase on ContactBase.ContactId = new_hourlyappointmentBase.new_Contact //where new_hourlyappointmentId = N'" + shiftId + @"'"); // return contactId != null ? Convert.ToString(contactId) : string.Empty; var reader = CRMAccessDB.ExecuteReader(@"select new_hourlyappointmentId, new_servicecontractperhour, new_contractnumber, new_Contact, new_employee, new_status, dateadd(hh,3,new_shiftend) as new_shiftend , dateadd(hh,3,new_shiftstart) as new_shiftstart , dateadd(hh,3,new_actualshiftstart) new_actualshiftstart, dateadd(hh,3,new_actualshiftend) new_actualshiftend, Isnull( new_rate,0) as new_rate, new_carid from new_hourlyappointmentBase inner join new_hindvcontract on new_hindvcontract.new_HIndvContractId = new_hourlyappointmentBase.new_servicecontractperhour inner join new_cardeliveryorder on new_cardeliveryorder.new_cardeliveryorderid = new_hourlyappointmentBase.new_cardeliveryorderhourlyappointmeId where new_cardeliveryorder.new_cardeliveryorderId = N'" + carDeliveryOrderId + @"' order by new_shiftstart "); HourlyAppointment hourlyAppointment = new HourlyAppointment(); while (reader.Read()) { hourlyAppointment.new_Contact = reader["new_Contact"].ToString(); hourlyAppointment.ShiftStart = Convert.ToDateTime(reader["new_shiftstart"]); hourlyAppointment.ShiftEnd = Convert.ToDateTime(reader["new_shiftend"]); hourlyAppointment.new_contractnumber = Convert.ToString(reader["new_contractnumber"]); } return(hourlyAppointment); }