public static List <PartSetModel> ConvertTextToPartSet(this List <string> lines) { //Id|^|Name|^|SleeveId|^|BearingId|^|CounterSleeveId; List <PartSetModel> output = new List <PartSetModel>(); PartSetModel curr = new PartSetModel(); List <SleeveModel> sleeves = TextConnector.Sleeve_GetAll(); List <BearingModel> bearings = TextConnector.Bearing_GetAll(); List <CounterSleeveModel> counterSleeves = TextConnector.CounterSleeve_GetAll(); foreach (string line in lines) { string[] cols = line.Split(new string[] { "|^|" }, StringSplitOptions.None); curr.Id = int.Parse(cols[0]); curr.Name = cols[1]; curr.Sleeve = sleeves.Where(x => x.Id == int.Parse(cols[2])).First(); curr.Bearing = bearings.Where(x => x.Id == int.Parse(cols[3])).First(); curr.CounterSleeve = counterSleeves.Where(x => x.Id == int.Parse(cols[4])).First(); output.Add(curr); curr = new PartSetModel(); } return(output); }
public void NewPartSetCreated(PartSetModel model) { partSetOne.Add(model); partSetTwo.Add(model); partSetThree.Add(model); partSetFour.Add(model); UpdateData(); }
public static void CreatePartSet(PartSetModel model) { List <PartSetModel> allPartSets = PartSet_GetAll(); if (allPartSets.Count > 0) { model.Id = allPartSets.OrderByDescending(x => x.Id).First().Id + 1; } else { model.Id = 1; } allPartSets.Add(model); allPartSets.SavePartSetsToFile(); }
private void createNewSetButton_Click(object sender, EventArgs e) { if (!ValidateData()) { return; } PartSetModel model = new PartSetModel() { Name = newSetNameTextBox.Text, Sleeve = (SleeveModel)newSetSleeveComboBox.SelectedItem, CounterSleeve = (CounterSleeveModel)newSetCounterSleeveComboBox.SelectedItem, Bearing = (BearingModel)newSetBearingComboBox.SelectedItem }; TextConnector.CreatePartSet(model); allPartSets.Add(model); UpdatePartSetList(); UpdateNewPartSetGroupBoxes(); callingForm.NewPartSetCreated(model); }
private void selectExistingPartsSetComboBox_SelectionChangeCommitted(object sender, EventArgs e) { selectedPartSet = (PartSetModel)selectExistingPartsSetComboBox.SelectedItem; WireUpLists(); }