private void changestatus_doc_Click(object sender, RoutedEventArgs e)
        {
            if (oldPatSelected.indpat_status.ToLower().Equals("admitted"))
            {
                oldPatSelected.indpat_status = "discharged";
                Room r = oldPatSelected.Room;
                if (r == null)
                {
                    return;
                }
                r.availbeds++;
                hmsfac.updateRoom(r);
                MessageBox.Show("Patient status changed to discharged!", "Operation Success!", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            else
            {
                oldPatSelected.indpat_status = "admitted";
                Room r = oldPatSelected.Room;
                if (r.availbeds == 0)
                {
                    MessageBox.Show("No bed available in the current room.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                r.availbeds--;
                hmsfac.updateRoom(r);
                MessageBox.Show("Patient status changed to admitted!", "Operation Success!", MessageBoxButton.OK, MessageBoxImage.Information);
            }


            hmsfac.updateIndoor(oldPatSelected);
            dataGrid_OldPatient.Items.Refresh();
        }
예제 #2
0
        private void assignroom_Btn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(cboselroom_no.Text))
                {
                    MessageBox.Show("Please select a room no.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }


                IndoorPatient indo = (IndoorPatient)dataGrid_IndoorPatients.SelectedItem;


                if (indo.indpat_status == "discharged")
                {
                    MessageBox.Show("Cannot assign room to discharged patient.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }


                if (indo.room_id != null && indo.indpat_status == "admitted")
                {
                    Room currentRoom = hmsfac.getRoomByRid(indo.room_id);
                    currentRoom.availbeds++;
                    hmsfac.updateRoom(currentRoom);
                }


                indo.room_id = int.Parse(cboselroom_no.Text);

                Room newRoom = hmsfac.getRoomByRid(indo.room_id);

                if (newRoom.availbeds == 0)
                {
                    MessageBox.Show("Beds not available in this room. Please select any other room.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                newRoom.availbeds--;

                hmsfac.updateIndoor(indo);
                hmsfac.updateRoom(newRoom);

                MessageBox.Show("Room Assigned successfully!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                dataGrid_IndoorPatients.Items.Refresh();
                roomList = hmsfac.getRoom();
                dataGrid_Room.Items.Refresh();

                this.roombtn_update.IsEnabled = false;
                this.assignroom_btn.IsEnabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please first select the patient from Grid", "Reminder", MessageBoxButton.OKCancel, MessageBoxImage.Information);
                Console.WriteLine(ex.Message);
            }
        }