private void btnSave_Click(object sender, EventArgs e)
 {
     SportFacility s = new SportFacility();
     s.SportTypeID = (int)cboSportsType.SelectedValue;
     s.SportFacilityName = txtSportsFacilityName.Text;
     s.Picture = myCaller.ImageToByte((btnUpload.BackgroundImage));
     s.FacilityStatus = "1";
     s.Remarks = txtRemarks.Text;
     myCaller.SelectSave(s);
 }
        public void AcceptSpecFacilityInfo(SportFacility s,List<SportType> sl)
        {
            txtSportsFacilityID.Text = s.SportFacilityID.ToString();

            cboSportsType.DataSource = sl;
            cboSportsType.DisplayMember = "SportTypeName";
            cboSportsType.ValueMember = "SportTypeID";
            cboSportsType.SelectedValue = s.SportTypeID;

            txtSportsFacilityName.Text = s.SportFacilityName;
            try {
                btnUpload.BackgroundImage = myCaller.ByteToImage(s.Picture);
                txtRemarks.Text = s.Remarks;
            }
            catch(SystemException se)
            {

            }

            cboFacilityStatus.Items.Add("Broken");
            cboFacilityStatus.Items.Add("Normal");
            cboFacilityStatus.Items.Add("UnderMaintain");
            cboFacilityStatus.SelectedIndex = Convert.ToInt32(s.FacilityStatus);
            switch (cboFacilityStatus.SelectedText)
            {
                case "Broken":
                    cboFacilityStatus.SelectedValue = '0';
                    break;
                case "Normal":
                    cboFacilityStatus.SelectedValue = '1';
                    break;
                case "UnderMaintain":
                    cboFacilityStatus.SelectedValue = '2';
                    break;
            }
            cboFacilityStatus.SelectedValue = s.FacilityStatus;
        }
 public void SelectSave(SportFacility s)
 {
     SportsFacilityBookingEntities1 ent = new SportsFacilityBookingEntities1();
     ent.SportFacilities.Add(s);
     ent.SaveChanges();
 }