Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Hide database error on page load
            DataBaseError.Visible = false;

            // Hide gridview on page load
            BedGridView.Enabled = false;

            // Redirect to login page if not logged in
            if (Session[Global.user] == null)
            {
                Response.Redirect("Login.aspx");
            }

            // If logged in attempt to pull data from database
            try
            {
                // Bind bed data to gridview
                List <Bed> beds = BedUtility.GetBeds();
                BedGridView.Enabled    = true;
                BedGridView.DataSource = beds;
                BedGridView.DataBind();
            }
            // If exception caught show database error
            // and hide gridview
            catch (Exception)
            {
                DataBaseError.Visible = true;
                BedGridView.Enabled   = false;
            }
        }
Beispiel #2
0
        // Validate Bed Id exists in Database
        protected void BedIdValidate(object sender, ServerValidateEventArgs e)
        {
            try
            {
                int id;
                // Try parse input to int
                if (int.TryParse(e.Value, out id))
                {
                    // Get bed from database with provided id
                    // using stored procedure
                    Bed bed = BedUtility.GetBed(id);

                    // Valid if found
                    if (bed != null)
                    {
                        e.IsValid = true;
                        return;
                    }
                }

                // Throw exception if no valid bed found
                // or input not parsable to int
                throw new Exception();
            }
            // Invalid if any exception caught
            catch (Exception)
            {
                e.IsValid = false;
            }
        }
Beispiel #3
0
 // Get bed ID if exists or convert DBNull to Null string
 // for gridview
 protected string GetBedId(object bed)
 {
     if (object.ReferenceEquals(bed, DBNull.Value))
     {
         return("Null");
     }
     else
     {
         return(BedUtility.GetBed(Convert.ToInt32(
                                      bed.ToString())).name);
     }
 }
Beispiel #4
0
 // Get price of visit for GridView
 protected string GetPrice(object bed)
 {
     if (object.ReferenceEquals(bed, DBNull.Value))
     {
         return("Null");
     }
     else
     {
         int price = BedUtility.GetBed(Convert.ToInt32(
                                           bed.ToString())).rate;
         return(String.Format("${0}", price));
     }
 }
Beispiel #5
0
 // Return bed name from id for gridview
 protected string GetBedId(object bed)
 {
     // If database has null bed return
     // empty string
     if (bed.ToString() == "Null")
     {
         return("");
     }
     // Else return bed name as string
     else
     {
         return(BedUtility.GetBed(Convert.ToInt32(
                                      bed.ToString())).name);
     }
 }
Beispiel #6
0
 // Added
 private static bool AddedBedIsOwned(Pawn pawn, Building_Bed building_Bed)
 {
     return(pawn.IsArrivedGuest()
         ? BedUtility.GetGuestBed(pawn) == building_Bed
         : building_Bed == pawn.ownership.OwnedBed);
 }
        public static IntVec3 GetSleepingPosForChargeStation(Pawn takee, Thing station)
        {
            var pos = BedUtility.GetSleepingSlotPos(0, station.Position, station.Rotation, station.def.size);

            return(pos);
        }
Beispiel #8
0
        // Add new visit submit
        protected void AssignClick(object sender, EventArgs e)
        {
            try
            {
                // Hide error messages when assign button is clicked
                DatabaseError.Visible = false;
                AssignSuccess.Visible = false;
                AssignFail.Visible    = false;

                // Get patient and doctor
                Patient patient = PatientUtility.GetPatient(
                    int.Parse(PatientId.Text));
                Doctor doctor = DoctorUtility.GetDoctor(
                    int.Parse(DoctorId.Text));

                // Break if either not found, error messages will
                // be given by validators
                if (patient == null || doctor == null)
                {
                    return;
                }

                // Generate pseudo id for object creation
                // (real id assigned by database)
                int visitId = VisitUtility.GetNewId();
                // Get system date
                string fullDate = DateTime.Now.ToString();
                // Split date from time
                string[] fullDateSplit = fullDate.Split(' ');
                // Split date into 3 parts (D,M,Y)
                string[] dateArray = fullDateSplit[0].Split('/');
                // Recreate date in MM/DD/YYYY format for storing
                string date = String.Format("{0}/{1}/{2} {3}", dateArray[1],
                                            dateArray[0], dateArray[2], fullDateSplit[1]);

                // Set type to outpatient
                int visitType = 1;

                // If inpatient
                if (PatientTypeRadioButtonList.SelectedItem.ToString() ==
                    "Inpatient")
                {
                    // Change type
                    visitType = 0;
                    // Get Bed
                    Bed bed = BedUtility.GetBed(int.Parse(Bed.Text));
                    // Create new invisit
                    InVisit inVisit = new InVisit(visitId, patient.id, visitType,
                                                  doctor.id, date, "", bed.id);

                    // Attempt to add object to database throw exception
                    // on failure
                    if (!VisitUtility.AddVisit(inVisit))
                    {
                        throw new Exception();
                    }
                }
                // If outpatient
                else
                {
                    // Set discharge date to visit date
                    string discharge = date;
                    // Create new outvisit object
                    OutVisit outVisit = new OutVisit(visitId, patient.id,
                                                     visitType, doctor.id, date, discharge);

                    // Attempt to add object to database throw exception
                    // on failure
                    if (!VisitUtility.AddVisit(outVisit))
                    {
                        throw new Exception();
                    }
                }

                // If no exception thrown operation was a success, show
                // confirmation message and hide errors
                AssignFail.Visible    = false;
                AssignSuccess.Visible = true;
                AssignSubmit.Enabled  = false;
            }
            // If exception is caught there is an issue with database connection
            // show appropriate error messages
            catch (Exception)
            {
                AssignSuccess.Visible = false;
                AssignFail.Visible    = true;
                DatabaseError.Visible = true;
            }
        }