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";
                }
            }
        }