コード例 #1
0
ファイル: EditInfo.aspx.cs プロジェクト: asmitde/nmhc
    protected void Page_Load(object sender, EventArgs e)
    {
        pid = Request.QueryString.Get("PID");
        if (!Page.IsPostBack && pid != null)
        {
            using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities())
            {
                // Select patient based on registration id
                var p = (from r in myEntities.Patient__Profile
                         where r.Registration_ID == pid
                         select r).SingleOrDefault();

                string hid = (from r in myEntities.Hospital__Staff
                              where r.Staff_ID == Profile.UserName
                              select r.H_ID).SingleOrDefault();

                if (p != null && p.H_ID == hid)
                {
                    RegID.Text = pid;
                    PName.Text = p.PatientName;
                    PBed.Text  = (p.CurrentBedNo == null) ? "Unoccupied" : p.CurrentBedNo;

                    MultiView1.ActiveViewIndex = 0;

                    // Select department ids having selected patient's hospital id
                    var dids = from r in myEntities.Hospital__Department
                               where r.H_ID == p.H_ID
                               select r.D_ID;

                    // Select department names corresponding to selected department ids
                    Department.DataSource = from d in myEntities.Module__Department
                                            join i in dids on d.Department_ID equals i
                                            orderby d.Name ascending
                                            select d.Name;
                    Department.DataBind();

                    // Selext beds correspinding to selected patient's hospital id
                    var beds = (from r in myEntities.Hospital__Bed
                                where (r.H_ID == hid && (r.Occupied == false || r.BedNo == p.CurrentBedNo))
                                orderby r.BedNo ascending
                                select r.BedNo).ToList();

                    beds.Add("Unoccupied");
                    Bed.DataSource = beds;
                    Bed.DataBind();

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