コード例 #1
0
        private void bindFacility()
        {
            Facility f = new Facility();

            grdFacility.DataSource = FacilityManagementSystem.GetFacility();
            grdFacility.DataBind();
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Account a = new Account();

            a = (Account)Session["Account"];

            if (a == null)
            {
                Response.Redirect("LoginPage.aspx");
            }
            if (!a.accountType.Equals("admin"))
            {
                Response.Redirect("LoginPage.aspx");
            }
            if (!IsPostBack)
            {
                String id = (String)Session["fac_id"];

                Facility f = new Facility();
                f = FacilityManagementSystem.GetFacility(id);
                txtName.Attributes.Add("placeholder", f.facilityName);
                txtInfo.Attributes.Add("placeholder", f.generalInfo);
                txtPhoneNumber.Attributes.Add("placeholder", f.phoneNumber.ToString());

                string[] OpeningTimeArray = f.openingHrs.Split(':');
                UpdateOpeninghr.SelectedValue = OpeningTimeArray[0] + ":" + OpeningTimeArray[1];


                string[] ClosingTimeArray = f.closingHrs.Split(':');
                UpdateClosinghr.SelectedValue = ClosingTimeArray[0] + ":" + ClosingTimeArray[1];


                txtAddress.Attributes.Add("placeholder", f.address);
                txtRegion.Attributes.Add("placeholder", f.region);


                listFacility.SelectedValue = f.facilityType;

                List <Department> Deptlist = DepartmentManagementSystem.getDepartments(id);

                //////////////////////////////////////Department can't be deleted because doctor is tied to the department
                for (int i = 0; i < Deptlist.Count; i++)
                {
                    foreach (ListItem listItem in UpdateDepartmentList.Items)
                    {
                        if (listItem.Value.Equals(Deptlist.ElementAt(i).departmentName))
                        {
                            listItem.Selected = true;
                        }
                    }
                }
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Account a = new Account();

            a = (Account)Session["Account"];

            if (a == null)
            {
                Response.Redirect("LoginPage.aspx");
            }
            if (!a.accountType.Equals("admin"))
            {
                Response.Redirect("LoginPage.aspx");
            }
            if (!IsPostBack)
            {
                int id = Int32.Parse((string)Session["doc_id"]);

                a = AccountManagementSystem.GetAccount(id);
                txtNric.Attributes.Add("placeholder", a.nric);
                txtName.Attributes.Add("placeholder", a.name);
                txtPassword.Attributes.Add("placeholder", a.password);
                txtEmail.Attributes.Add("placeholder", a.email);
                txtAddress.Attributes.Add("placeholder", a.address);

                Department D = new Department();
                D = DepartmentManagementSystem.GetDepartmentByUserID(id);


                Facility F = new Facility();
                F = FacilityManagementSystem.GetFacility(D.facilityId);

                FacilityDropDownList.DataSource = FacilityManagementSystem.GetAllfacility();
                FacilityDropDownList.DataBind();

                FacilityDropDownList.SelectedValue = F.facilityID.ToString();


                DepartmentDropDownList.DataSource = DepartmentManagementSystem.getDepartmentsFromThisFacility(FacilityDropDownList.SelectedItem.Value);
                DepartmentDropDownList.DataBind();


                DepartmentDropDownList.SelectedValue = D.departmentID.ToString();
            }
        }
コード例 #4
0
        protected void UpDate_Click(object sender, EventArgs e)
        {
            String id = (String)Session["fac_id"];

            Facility f = new Facility();

            f = FacilityManagementSystem.GetFacility(id);

            if (string.IsNullOrEmpty(txtName.Text))
            {
                txtName.Text = f.facilityName;
            }

            if (string.IsNullOrEmpty(txtInfo.Text))
            {
                txtInfo.Text = f.generalInfo;
            }

            if (string.IsNullOrEmpty(txtPhoneNumber.Text))
            {
                txtPhoneNumber.Text = f.phoneNumber.ToString();
            }


            if (string.IsNullOrEmpty(txtAddress.Text))
            {
                txtAddress.Text = f.address;
            }

            if (string.IsNullOrEmpty(txtRegion.Text))
            {
                txtRegion.Text = f.region;
            }

            String image = f.image;

            if (ImageUpload.HasFile)
            {
                string ext = System.IO.Path.GetExtension(ImageUpload.PostedFile.FileName);
                if (!Validation.ImageCheck(ext))
                {
                    lblImage.Text = "Invalid image type";
                }
                else
                {
                    image = Path.GetFileName(ImageUpload.PostedFile.FileName);
                    ImageUpload.PostedFile.SaveAs(Server.MapPath("~/upload/facility/") + image);
                }
            }

            FacilityManagementSystem.UpdateFacility(txtName.Text, listFacility.SelectedItem.Text, txtInfo.Text, Convert.ToInt32(txtPhoneNumber.Text), UpdateOpeninghr.SelectedItem.Text + ":" + "00", UpdateClosinghr.SelectedItem.Text + ":" + "00", txtAddress.Text, txtRegion.Text, image, f.facilityID);

            //need to check whether there's any doctor with these department
            Department[] dp     = new Department[12]; //selected
            Department[] ndp    = new Department[12]; //not selected
            int          index  = 0;
            int          nindex = 0;

            foreach (ListItem listItem in UpdateDepartmentList.Items)
            {
                if (listItem.Selected)
                {
                    dp[index]                = new Department();
                    dp[index].facilityId     = f.facilityID;
                    dp[index].departmentName = listItem.Value;

                    index++;
                }
                else
                {
                    ndp[nindex]                = new Department();
                    ndp[nindex].facilityId     = f.facilityID;
                    ndp[nindex].departmentName = listItem.Value;

                    nindex++;
                }
            }


            bool   DepartmentCheckexist = false; //this is to check whether there's child dependency for facility_staff before deleting the uncheck facility to prevent database error
            String tempDeptName;

            foreach (Department d in ndp)
            {
                if (d != null)
                {
                    tempDeptName = DepartmentManagementSystem.CheckDepartmentForStaff(d);
                    if (tempDeptName != null)
                    {
                        lblImage.Text        = "unable to remove department: " + tempDeptName + ", there are doctors working in that department";
                        DepartmentCheckexist = true;//don't allow the update
                    }
                }
            }
            if (DepartmentCheckexist == false)
            {
                DepartmentManagementSystem.DeleteDepartment(ndp);
                DepartmentManagementSystem.AddDepartment(dp);
                Response.Write("<script type=\"text/javascript\">alert('Facility Updated!');location.href='AdminHomePage.aspx'</script>");
            }
        }