private void SearchList_SelectionChanged(object sender, SelectionChangedEventArgs e) { // 특정 상벌점 항목 선택 시 유형, 이름, 최소, 최대 점수 출력 if (e.AddedItems.Count != 0) { var target = (PunishmentListViewModel)e.AddedItems[0]; if (punishmentGoodList.Contains(target)) { GoodPoint.IsChecked = true; } else if (punishmentBadList.Contains(target)) { BadPoint.IsChecked = true; } PunishmentName.Text = target.Name; MinimumPoint.SliderValue = target.MinPoint; MaximumPoint.SliderValue = target.MaxPoint; selectedItem = target; } }
private void EditPunishmentListButton_Click(object sender, EventArgs e) { if (selectedItem != null) { if (!(CheckNameValue() && CheckSliderValue())) { return; } var requestDict = new Dictionary <string, object> { { "rule_id", selectedItem.ID }, { "name", PunishmentName.Text }, { "min_point", (bool)GoodPoint.IsChecked ? MinimumPoint.SliderValue : -1 * MinimumPoint.SliderValue }, { "max_point", (bool)GoodPoint.IsChecked ? MaximumPoint.SliderValue : -1 * MaximumPoint.SliderValue } }; var responseDict = Info.GenerateRequest("PATCH", Info.Server.MANAGING_RULE, Info.mainPage.AccessToken, requestDict); if ((HttpStatusCode)responseDict["status"] == HttpStatusCode.OK) { MessageBox.Show("항목 수정 완료"); } else { MessageBox.Show("항목 수정 실패"); } selectedItem = null; UpdatePunishmentList(); } }
private void DelPunishmentListButton_Click(object sender, EventArgs e) { if (selectedItem != null) { var requestDict = new Dictionary <string, object> { { "rule_id", selectedItem.ID } }; var responseDict = Info.GenerateRequest("DELETE", Info.Server.MANAGING_RULE, Info.mainPage.AccessToken, requestDict); if ((HttpStatusCode)responseDict["status"] == HttpStatusCode.OK) { MessageBox.Show("항목 삭제 완료"); } else { MessageBox.Show("항목 삭제 실패"); } selectedItem = null; UpdatePunishmentList(); } }