Exemplo n.º 1
0
        protected void FilterDept(object sender, EventArgs e) //action fired after selecting facility
        {
            DepartmentDropDownList.DataSource = DepartmentManagementSystem.getDepartmentsFromThisFacility(FacilityDropDownList.SelectedItem.Value);
            DepartmentDropDownList.DataBind();

            DepartmentDropDownList.Items.Insert(0, new ListItem("(Select a Department)", "-1"));
        }
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            String id = lbl_id.Text;

            DepartmentManagementSystem.DeleteDepartments(id); //delete child
            FacilityManagementSystem.DeleteFacility(id);
            Response.Write("<script type=\"text/javascript\">alert('Facility Deleted!');location.href='FacilityListPage.aspx'</script>");
        }
        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;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void HospitalDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            //set opening and closing label to visible
            if (HospitalDropDownList.SelectedItem.ToString() != "-Select a Hospital-")
            {
                lb_openingHrs.Visible = true;
                lb_closingHrs.Visible = true;
                lblHospital.Visible   = false;
            }
            else
            {
                lb_openingHrs.Visible = false;
                lb_closingHrs.Visible = false;
            }
            lblTime.Text = "";

            DepartmentDropDownList.DataSource     = DepartmentManagementSystem.getDepartments(HospitalDropDownList.SelectedValue.ToString());
            DepartmentDropDownList.DataTextField  = "departmentName";
            DepartmentDropDownList.DataValueField = "departmentID";
            DepartmentDropDownList.DataBind();


            DepartmentDropDownList.Items.Insert(0, new ListItem("(Select a Department)", "-1"));

            //get opening hours and set it
            if (HospitalDropDownList.SelectedValue.ToString() != "-1")
            {
                Facility f = FacilityManagementSystem.getOpeningHrs(HospitalDropDownList.SelectedValue.ToString());
                HourChange("AM");

                AMPMDropDownList.ClearSelection();
                AMPMDropDownList.Items.FindByText(f.openingHrs.Substring(4, 2)).Selected = true;

                lb_actualOpening.Text    = f.generalInfo;
                lb_actualClosing.Text    = f.region;
                lb_actualClosing.Visible = true;
                lb_actualOpening.Visible = true;
            }
            else
            {
                HourDropDownList.Items.Clear();
                HourDropDownList.Items.Insert(0, new ListItem("-Hr-", "-1"));
                MinDropDownList.Items.Clear();
                MinDropDownList.Items.Insert(0, new ListItem("-Min-", "-1"));

                AMPMDropDownList.ClearSelection();

                lb_actualClosing.Visible = false;
                lb_actualOpening.Visible = false;
            }
        }
        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();
            }
        }
        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>");
            }
        }
        protected void Create_Click(object sender, EventArgs e)
        {
            bool check = true;

            if (Validation.isEmpty(txtName.Text))
            {
                lblName.Text = "Name cannot be empty";
                check        = false;
            }
            if (Validation.isEmpty(txtInfo.Text))
            {
                lblInfo.Text = "Info cannot be empty";
                check        = false;
            }
            if (Validation.isEmpty(txtPhoneNumber.Text))
            {
                lblPhoneNumber.Text = "PhoneNumber cannot be empty";
                check = false;
            }
            if (Validation.isEmpty(txtOpeninghr.Text))
            {
                lblOpening.Text = "Opening Hours cannot be empty";
                check           = false;
            }
            if (Validation.isEmpty(txtClosinghr.Text))
            {
                lblClosing.Text = "Closing Hours cannot be empty";
                check           = false;
            }
            if (Validation.isEmpty(txtAddress.Text))
            {
                lblAddress.Text = "Address cannot be empty";
                check           = false;
            }
            if (Validation.isEmpty(txtRegion.Text))
            {
                lblRegion.Text = "Region cannot be empty";
                check          = false;
            }
            if (ImageUpload.HasFile)
            {
                string ext   = System.IO.Path.GetExtension(ImageUpload.PostedFile.FileName);
                byte[] bytes = ImageUpload.FileBytes;
                int    width;
                int    height;

                using (Stream memStream = new MemoryStream(bytes))
                {
                    using (System.Drawing.Image img = System.Drawing.Image.FromStream(memStream))
                    {
                        width  = img.Width;
                        height = img.Height;
                    }
                }
                if (!Validation.ImageCheck(ext))
                {
                    check         = false;
                    lblImage.Text = "Invalid image type";
                }
                else if (width > 720 || height > 480)
                {
                    lblImage.Text = "Profile Picture size does not meet specified requirements 720x480 pixels";
                    check         = false;
                }
            }

            if (CreateDepartmentList.Items.Cast <ListItem>().Count(li => li.Selected) == 0)
            {
                check = false;
                lblDepartmentList.Text = "Please select at least 1 department";
            }

            if (check == true)
            {
                Facility f = new Facility();
                f.facilityName = txtName.Text;
                f.facilityType = listFacility.SelectedItem.Text;
                f.generalInfo  = txtInfo.Text;
                f.phoneNumber  = Int32.Parse(txtPhoneNumber.Text);
                f.openingHrs   = txtOpeninghr.SelectedItem.Text + ":" + "00";
                f.closingHrs   = txtClosinghr.SelectedItem.Text + ":" + "00";
                f.address      = txtAddress.Text;
                f.region       = txtRegion.Text;
                f.x            = Decimal.Parse(lblSelectedX.Text);
                f.y            = Decimal.Parse(lblSelectedY.Text);


                if (ImageUpload.HasFile)
                {
                    f.image = Path.GetFileName(ImageUpload.PostedFile.FileName);
                    ImageUpload.PostedFile.SaveAs(Server.MapPath("~/upload/facility/") + f.image);
                }

                if (!FacilityManagementSystem.CheckFacilityName(f.facilityName))
                {
                    FacilityManagementSystem.CreateFacility(f);


                    /////////////////////////To add data department table///////////////////////////
                    int facility_id = FacilityManagementSystem.GetFacilityId(f.facilityName); //only after facility is created will there be facility id

                    Department[] dp    = new Department[12];
                    int          index = 0;
                    foreach (ListItem listItem in CreateDepartmentList.Items)
                    {
                        if (listItem.Selected)
                        {
                            dp[index]                = new Department();
                            dp[index].facilityId     = facility_id;
                            dp[index].departmentName = listItem.Value;

                            index++;
                        }
                    }

                    DepartmentManagementSystem.AddDepartment(dp);


                    txtName.Text = txtInfo.Text = txtPhoneNumber.Text = txtOpeninghr.Text = txtClosinghr.Text = txtAddress.Text = txtRegion.Text = "";
                    lblName.Text = lblInfo.Text = lblPhoneNumber.Text = lblOpening.Text = lblClosing.Text = lblAddress.Text = lblRegion.Text = "";

                    foreach (ListItem listItem in CreateDepartmentList.Items)
                    {
                        if (listItem.Selected)
                        {
                            listItem.Selected = false;
                        }
                    }

                    Response.Write("<script type=\"text/javascript\">alert('Facility Created!');location.href='AdminHomePage.aspx'</script>");

                    //Response.Redirect("AdminHomePage.aspx", false);
                }
                else
                {
                    lblImage.Text = "This hospital already exist in the database";
                }
            }
        }