private void listViewProfile_SelectedIndexChanged(object sender, System.EventArgs e) { try { // get client PLMPackServiceClient client = WCFClientSingleton.Instance.Client; if (listViewProfile.SelectedIndices.Count > 0) { int iSel = listViewProfile.SelectedIndices[0]; ListViewItem item = listViewProfile.Items[iSel]; // check if cardboard profile has some dependancies DCCardboardProfile profile = client.GetCardboardProfileByID((int)item.Tag); this.btDelete.Enabled = !profile.HasMajorationSets; } } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void btDelete_Click(object sender, EventArgs e) { try { // get client PLMPackServiceClient client = WCFClientSingleton.Instance.Client; // retrieve selected carboard profile DCCardboardProfile profile = client.GetCardboardProfileByID(GetSelectedProfileId()); client.RemoveCardboardProfile(profile); // fill list view again FillListView(); // select first item if (listViewProfile.Items.Count > 0) { listViewProfile.Items[0].Selected = true; } } catch (Exception ex) { _log.Debug(ex.ToString()); } }
private void bnModify_Click(object sender, System.EventArgs e) { try { // get client PLMPackServiceClient client = WCFClientSingleton.Instance.Client; if (listViewProfile.SelectedIndices.Count > 0) { // get selected item int iSel = this.listViewProfile.SelectedIndices[0]; ListViewItem item = listViewProfile.Items[iSel]; DCCardboardProfile currentCardboardProfile = client.GetCardboardProfileByID((int)item.Tag); FormCreateCardboardProfile dlg = new FormCreateCardboardProfile(); dlg.ProfileName = currentCardboardProfile.Name; dlg.Code = currentCardboardProfile.Code; dlg.Thickness = currentCardboardProfile.Thickness; if (DialogResult.OK == dlg.ShowDialog()) { // set new values currentCardboardProfile.Name = dlg.ProfileName; currentCardboardProfile.Code = dlg.Code; currentCardboardProfile.Thickness = dlg.Thickness; // update database client.UpdateCardboardProfile(currentCardboardProfile); // refill list view FillListView(); // select current item listViewProfile.Items[iSel].Selected = true; } } } catch (Exception ex) { _log.Error(ex.ToString()); } }