예제 #1
0
        public Patient GetPatientId(AppointmentVm appointment)
        {
            Query = "SELECT Id FROM Patient WHERE PatientCode = @patientCode";

            Command = new SqlCommand(Query, Connection);
            Patient aPatient = null;


            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("patientCode", SqlDbType.VarChar);
            Command.Parameters["patientCode"].Value = appointment.PatientCode;


            Reader = Command.ExecuteReader();
            bool a = Reader.HasRows;

            while (Reader.Read())
            {
                aPatient = new Patient();

                aPatient.Id = (int)Reader["Id"];
            }

            Reader.Close();
            Connection.Close();
            return(aPatient);
        }
예제 #2
0
        public List <AppointmentVm> GetAllAppointment()
        {
            Query   = "SELECT p.PatientCode,p.ContactNo,d.Name,a.time FROM Appointment a JOIN Doctor d ON a.DoctorId = d.Id JOIN Patient p ON p.Id = a.PatientId";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();

            Reader = Command.ExecuteReader();
            List <AppointmentVm> appointmentVms = new List <AppointmentVm>();

            while (Reader.Read())
            {
                AppointmentVm appointmentVm = new AppointmentVm();
                appointmentVm.PatientCode      = Reader["PatientCode"].ToString();
                appointmentVm.DoctorName       = Reader["Name"].ToString();
                appointmentVm.PatientContactNo = Reader["ContactNo"].ToString();

                int    Time = Convert.ToInt32(Reader["Time"].ToString());
                string ampm = null;

                int Hr;


                if (Time > 719)
                {
                    ampm = "PM";
                }
                else
                {
                    ampm = "AM";
                }


                string Min = Convert.ToString(Time % 60);
                if (Min.Length == 1)
                {
                    Min = Min + "0";
                }
                int Hr2 = Time / 60;
                if (Hr2 > 12)
                {
                    Hr = Hr2 - 12;
                }
                else
                {
                    Hr = Hr2;
                }

                appointmentVm.Time = Hr + ":" + Min + "" + ampm;
                appointmentVms.Add(appointmentVm);
            }
            Reader.Close();
            Connection.Close();
            return(appointmentVms);
        }
예제 #3
0
        public string Save(AppointmentVm appointment)
        {
            Patient patient = appointmentGateway.GetPatientId(appointment);
            int     pId     = patient.Id;

            appointment.PatientId = pId;
            int rowAffected = appointmentGateway.Save(appointment);

            if (rowAffected > 0)
            {
                return("1");
            }
            return("2");
        }
예제 #4
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            string time = timeTextBox.Value;



            string timeHr = time.Substring(0, 2);


            string timeMin = time.Substring(3, 2);


            int timeHr2 = Convert.ToInt32(timeHr);

            int timeMin2 = Convert.ToInt32(timeMin);


            string timeAMPM = time.Substring(6, 2);

            if (timeAMPM == "PM")
            {
                timeHr2 = timeHr2 + 12;
            }

            int time2 = timeHr2 * 60 + timeMin2;

            AppointmentVm appointment = new AppointmentVm();

            appointment.PatientCode = patientCodeTextBox.Value;

            appointment.DoctorId = Convert.ToInt32(selectDoctorDropDownList.SelectedValue);

            appointment.Time = Convert.ToString(time2);

            string msg = appointmentManager.Save(appointment);

            if (msg == "1")
            {
                messageLabel.InnerText = "Appointment saved";
            }
            else if (msg == "2")
            {
                messageLabel2.InnerText = "Saving failed";
            }

            PopulateGridView();
            patientCodeTextBox.Value = String.Empty;
            timeTextBox.Value        = String.Empty;
        }
예제 #5
0
        public int Save(AppointmentVm appointment)
        {
            Query = "INSERT INTO Appointment VALUES(@patientid, @doctorId, @time)";

            Command = new SqlCommand(Query, Connection);
            Command.Parameters.Clear();
            Command.Parameters.Add("patientid", SqlDbType.Int);
            Command.Parameters["patientid"].Value = appointment.PatientId;

            Command.Parameters.Add("doctorId", SqlDbType.Int);
            Command.Parameters["doctorId"].Value = appointment.DoctorId;

            Command.Parameters.Add("time", SqlDbType.VarChar);
            Command.Parameters["time"].Value = appointment.Time;

            Connection.Open();

            int rowAffected = Command.ExecuteNonQuery();

            Connection.Close();
            return(rowAffected);
        }