Exemple #1
0
    protected void Add_Click(object sender, EventArgs e)
    {
        using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities())
        {
            Hospital__Bed bed = new Hospital__Bed();
            bed.BedNo    = BedNoA.Text;
            bed.Type     = TypeA.Text;
            bed.H_ID     = hid;
            bed.Occupied = false;

            bed.UpdateDateTime = DateTime.Now;
            bed.UpdatedBy      = Profile.UserName;
            bed.UpdateUserName = Profile.Name;

            myEntities.AddToHospital__Bed(bed);
            myEntities.SaveChanges();
        }

        Response.Redirect("~/Hospital/Management/Beds.aspx");
    }
Exemple #2
0
    protected void Save_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities())
            {
                Patient__Profile profile;
                if (pid != null)
                {
                    profile = (from r in myEntities.Patient__Profile
                               where r.Registration_ID == pid
                               select r).SingleOrDefault();

                    if (profile != null)
                    {
                        // Update profile information
                        profile.Department                 = Department.SelectedValue;
                        profile.CurrentBedNo               = (Bed.SelectedValue == "Unoccupied") ? null : Bed.SelectedValue;
                        profile.PatientName                = Name.Text;
                        profile.PhotoURL                   = Photo.ImageUrl;
                        profile.Sex                        = Sex.SelectedValue;
                        profile.Age                        = Convert.ToInt16(AgeValue.Text);
                        profile.AgeUnit                    = AgeUnit.SelectedValue;
                        profile.BodyWeight                 = Convert.ToInt16(Weight.Text);
                        profile.Height                     = Convert.ToInt16(Height.Text);
                        profile.MaritalStatus              = MaritalStatus.SelectedValue;
                        profile.C_o                        = Co.Text;
                        profile.C_o_Relation               = CoRelation.SelectedValue;
                        profile.MothersName                = MotherName.Text;
                        profile.MLC_No                     = MLC.Text;
                        profile.ReferredBy                 = RName.Text;
                        profile.RefContactNo               = RContact.Text;
                        profile.IfPreviouslyTreated        = PrevTreated.Checked;
                        profile.LastTreatedRegistration_ID = PrevID.Text;
                        profile.Occupation                 = Occupation.Text;
                        profile.Financing                  = Financing.Text;
                        profile.LocalAddress               = LAddress.Text;
                        profile.LState                     = LState.Text;
                        profile.LCountry                   = LCountry.Text;
                        profile.LPincode                   = LPincode.Text;
                        profile.LContactNo1                = LContact1.Text;
                        profile.LContactNo2                = LContact2.Text;
                        profile.Email                      = LEmail.Text;
                        profile.PermanentAddress           = PAddress.Text;
                        profile.PState                     = PState.Text;
                        profile.PCountry                   = PCountry.Text;
                        profile.PPincode                   = PPincode.Text;
                        profile.PContactNo1                = PContact1.Text;
                        profile.PContactNo2                = PContact2.Text;
                        profile.EmergencyContactPerson     = CName.Text;
                        profile.CPRelationship             = CRelation.Text;
                        profile.CPAddress                  = CAddress.Text;
                        profile.CPContactNo1               = CContact1.Text;
                        profile.CPContactNo2               = CContact2.Text;
                        profile.CPEmail                    = CEmail.Text;
                        profile.AdmittingPerson            = AName.Text;
                        profile.APRelationship             = ARelation.Text;
                        profile.APAddress                  = AAddress.Text;
                        profile.APContactNo1               = AContact1.Text;
                        profile.APContactNo2               = AContact2.Text;

                        profile.UpdateDateTime = DateTime.Now;
                        profile.UpdatedBy      = Profile.UserName;
                        profile.UpdateUserName = Profile.Name;

                        // Update bed information
                        Hospital__Bed b = (from r in myEntities.Hospital__Bed
                                           where (r.H_ID == profile.H_ID && r.BedNo == PBed.Text)
                                           select r).SingleOrDefault();
                        if (b != null)
                        {
                            b.Occupied = false;                                 // Previous bed occupied status: false
                        }
                        b = (from r in myEntities.Hospital__Bed
                             where (r.H_ID == profile.H_ID && r.BedNo == Bed.SelectedValue)
                             select r).SingleOrDefault();
                        if (b != null)
                        {
                            b.Occupied = true;                                  // Current Bed occupied status: true if selected value is not "Unoccupied"
                        }

                        myEntities.SaveChanges();

                        //Notification.Text = "Changes saved successfully.";
                        //System.Threading.Thread.Sleep(5000);
                        //Notification.Text = null;
                    }
                    else
                    {
                        MultiView1.ActiveViewIndex = 1;
                    }
                }
                else
                {
                    MultiView1.ActiveViewIndex = 1;
                }
            }
        }

        Response.Redirect(String.Format("~/Hospital/PatientInfo/EditInfo.aspx?PID={0}", RegID.Text));
    }