public List <ViewOrderWithPatient> GetPatientByBill(string billNo) { List <ViewOrderWithPatient> patientWithBillList = new List <ViewOrderWithPatient>(); string query = String.Format("SELECT * FROM ViewOrderWithPatient WHERE BillNo='{0}'", billNo); command = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ViewOrderWithPatient orderWithPatient = new ViewOrderWithPatient(); orderWithPatient.OrderId = Convert.ToInt32(reader["OrderId"]); orderWithPatient.BillNo = reader["BillNo"].ToString(); orderWithPatient.TotalFee = Convert.ToSingle(reader["TotalFee"]); orderWithPatient.EntryDate = Convert.ToDateTime(reader["EntryDate"]); orderWithPatient.PatientId = Convert.ToInt32(reader["PatientId"]); orderWithPatient.PatientName = reader["PatientName"].ToString(); orderWithPatient.Mobile = reader["Mobile"].ToString(); orderWithPatient.DOB = Convert.ToDateTime(reader["DOB"]); patientWithBillList.Add(orderWithPatient); } } reader.Close(); conn.Close(); return(patientWithBillList); }
public List <ViewOrderWithPatient> GetUnpaidBillWithPatient(DateTime fromDate, DateTime toDate) { List <ViewOrderWithPatient> orderWithPatientList = new List <ViewOrderWithPatient>(); string query = String.Format("SELECT * FROM ViewOrderWithPatient WHERE TotalFee > 0 AND EntryDate BETWEEN '{0}' AND '{1}' ORDER BY PatientName", fromDate, toDate); command = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ViewOrderWithPatient orderWithPatient = new ViewOrderWithPatient(); orderWithPatient.OrderId = Convert.ToInt32(reader["OrderId"]); orderWithPatient.BillNo = reader["BillNo"].ToString(); orderWithPatient.TotalFee = Convert.ToSingle(reader["TotalFee"]); orderWithPatient.EntryDate = Convert.ToDateTime(reader["EntryDate"]); orderWithPatient.PatientId = Convert.ToInt32(reader["PatientId"]); orderWithPatient.PatientName = reader["PatientName"].ToString(); orderWithPatient.Mobile = reader["Mobile"].ToString(); orderWithPatientList.Add(orderWithPatient); } } reader.Close(); conn.Close(); return(orderWithPatientList); }