private void frmHobbies_Load_1(object sender, EventArgs e) { dgvHobby.AutoGenerateColumns = false; el = new HobbyList(); el.Savable += El_Savable; el = el.GetAll(); dgvHobby.DataSource = el.List; }
private void LoadHobbies(HobbyList Hobbies) { foreach (Hobby hobby in Hobbies.List) { CheckBox cb = new CheckBox(); cb.CheckStateChanged += Cb_CheckStateChanged; cb.Text = hobby.HobbyName; cb.Tag = hobby.Id; cb.AutoSize = true; this.flpHobby.Controls.Add(cb); } }
public IHttpActionResult PostHobby(HobbyList hobby)//Hobby hobby) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } CookieHeaderValue cookie = Request.Headers.GetCookies("UserSession").FirstOrDefault(); if (!CheckAccess.IsAccess(cookie, 0, "Admin")) { return(ResponseMessage(new HttpResponseMessage(HttpStatusCode.Forbidden))); } db.HobbiesList.Add(hobby); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = hobby.id }, hobby)); }
public IHttpActionResult DeleteHobby([FromBody] int id)//Hobby hobby) { if (id == 0) { return(BadRequest()); } CookieHeaderValue cookie = Request.Headers.GetCookies("UserSession").FirstOrDefault(); if (!CheckAccess.IsAccess(cookie, 0, "Admin")) { return(ResponseMessage(new HttpResponseMessage(HttpStatusCode.Forbidden))); } HobbyList hobby = db.HobbiesList.FirstOrDefault(x => x.id == id); db.HobbiesList.Remove(hobby); db.SaveChanges(); return(Ok()); }
private void Form1_Load(object sender, EventArgs e) { el = new EmployeeList(); departments = new DepartmentList(); departments = departments.GetAll(); phoneTypes = new PhoneTypeList(); phoneTypes = phoneTypes.GetAll(); emailTypes = new EmailTypeList(); emailTypes = emailTypes.GetAll(); HobbyList hobbyList; hobbyList = new HobbyList(); hobbyList.GetAll(); LoadHobbies(hobbyList); dgvFamily.DataError += DgvFamily_DataError; dgvFamily.CellFormatting += DgvFamily_CellFormatting; dgvEmployee.CellFormatting += DgvEmployee_CellFormatting; dgvEmployeePhones.CellFormatting += DgvEmployeePhones_CellFormatting; dgvEmployeeEmail.CellFormatting += DgvEmployeeEmail_CellFormatting; dgvEmployeePhones.DataError += DgvEmployeePhones_DataError; dgvEmployeeEmail.DataError += DgvEmployeeEmail_DataError; dgvEmployee.DataError += DgvEmployee_DataError; dgvEmployee.AutoGenerateColumns = false; dgvSubordinate.AutoGenerateColumns = false; dgvSubordinate.CellFormatting += DgvSubordinate_CellFormatting; dgvSubordinate.DataError += DgvSubordinate_DataError; dgvFamily.AutoGenerateColumns = false; dgvEmployeePhones.AutoGenerateColumns = false; dgvEmployeeEmail.AutoGenerateColumns = false; el.Savable += El_Savable; mnuSave.Enabled = false; dgvEmployee.RowHeaderMouseDoubleClick += DgvEmployee_RowHeaderMouseDoubleClick; dgvSubordinate.RowHeaderMouseDoubleClick += DgvSubordinate_RowHeaderMouseDoubleClick; }