private void btnCreateRecordCreate_Click(object sender, RoutedEventArgs e) { if (tbAdress.Text.Length != 0 && tbCost.Text.Length != 0 && tbSquare.Text.Length != 0 && tbRoomCount.Text.Length != 0) { try { PremisesType typeOfPremisses = cbPlacementType.Text == "Помещение" ? PremisesType.Apartment : PremisesType.Room; string address = tbAdress.Text; int square = int.Parse(tbSquare.Text); int numberOfRooms = int.Parse(tbRoomCount.Text); double price = double.Parse(tbCost.Text); Record record = new Record( typeOfPremisses, address, square, numberOfRooms, price, CurrentUser.Name, CurrentUser.PhoneNumber); RecordList.AddRecord(record); grdCreateRecord.Visibility = Visibility.Hidden; grdMenu.Visibility = Visibility.Visible; tbAdress.Text = ""; tbCost.Text = ""; tbSquare.Text = ""; tbRoomCount.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("error: empty fields"); } }
public Record( PremisesType typeOfPremises, string address, int square, int numberOfRooms, double price, string landLordName, string landLordPhoneNumber) { ID = CurrentID; CurrentID++; using (StreamWriter file = new StreamWriter(@".\Resources\ID.txt")) { file.Write(CurrentID); } TypeOfPremises = typeOfPremises; Address = address; Square = square; NumberOfRooms = numberOfRooms; Price = price; LandLordName = landLordName; LandLordPhoneNumber = landLordPhoneNumber; }