public void AddNew() { String name = txtName.Text; String pilseta = txtPilseta.Text; String iela = txtIela.Text; String indeks = txtIndeks.Text; String ePasts = txt_ePasts.Text; int number; int.TryParse(txtTelefons.Text, out number); int telefons = number; Stends jauns = new Stends(name, pilseta, iela, indeks, ePasts, telefons); String json = JsonConvert.SerializeObject(jauns); try { StreamWriter write = new StreamWriter("C:\\Users\\ronis\\OneDrive\\Documents\\StendiPTP.txt"); write.WriteLine(json); write.Close(); } catch (Exception e) { } }
private void btnSave_Click(object sender, EventArgs e) { String name = txtName.Text; String pilseta = txtPilseta.Text; String iela = txtIela.Text; String indeks = txtIndeks.Text; String ePasts = txt_ePasts.Text; int number; int.TryParse(txtTelefons.Text, out number); int telefons = number; jauns = new Stends(name, pilseta, iela, indeks, ePasts, telefons); this.Close(); }