private void buttonUpdate_Click(object sender, EventArgs e) { CoreWebService.ArrCodeResponse arrCode = client.getArrCode((int)comboBoxArrCode.SelectedValue); string displayText = arrCode.Data.Abbr + " " + textBoxRoadNumber.Text.Trim(); CoreWebService.RollingStockResponse response = client.updateRollingstock((int)listBoxCars.SelectedValue, textBoxRoadNumber.Text, (int)comboBoxArrCode.SelectedValue, (int)numericUpDownLength.Value, (int)numericUpDownCapacityTons.Value, (int)comboBoxCarType.SelectedValue, textBoxRFID.Text, displayText); if (response.Status == 0) { CoreWebService.RollingStockAttributeListResponse rsDeleteResponse = client.deleteAllRollingStockAttribute(response.Data.ID); foreach (var i in listBoxCarTypeAttributes.SelectedIndices) { CoreWebService.CarTypeAttribute item = (CoreWebService.CarTypeAttribute)listBoxCarTypeAttributes.Items[(int)i]; CoreWebService.RollingStockAttributeResponse rsResponse = client.addRollingStockAttribute(response.Data.ID, item.ID); } CoreWebService.RollingStockListResponse rollingStock = client.listAllRollingStock(""); listBoxCars.DisplayMember = "displayText"; listBoxCars.ValueMember = "ID"; listBoxCars.DataSource = rollingStock.Data; listBoxCars.SelectedValue = response.Data.ID; } else { MessageBox.Show(response.Message); } }
private void comboBoxCarType_SelectedIndexChanged(object sender, EventArgs e) { CoreWebService.CarTypeAttributeListResponse carTypeAttributes = client.listCarTypeAttributes((int)comboBoxCarType.SelectedValue); listBoxCarTypeAttributes.DisplayMember = "attribute"; listBoxCarTypeAttributes.ValueMember = "ID"; listBoxCarTypeAttributes.DataSource = carTypeAttributes.Data; listBoxCarTypeAttributes.ClearSelected(); try { CoreWebService.RollingStockAttributeListResponse rollingStockAttribute = client.listRollingStockAttribute((int)listBoxCars.SelectedValue); for (int i = 0; i < rollingStockAttribute.Data.Count; i++) { listBoxCarTypeAttributes.SelectedValue = rollingStockAttribute.Data[i].carTypeAttrID; int r = listBoxCarTypeAttributes.SelectedIndex; listBoxCarTypeAttributes.SetSelected(r, true); } } catch (NullReferenceException) { } }