private void bt_register_Click(object sender, EventArgs e) { if (allFieldsFull() && excel.ExcelIsPresent()) { client.Login = tb_login.Text; client.Password = tb_password.Text; client.FullName = tb_fullName.Text; client.YearOfBirth = tb_year.Text; client.CarModel = tb_modelCar.Text; client.LicensePlate = tb_licensePlate.Text; client.YearOfCarManufacture = tb_yearOfCar.Text; client.VIP = false; string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\Information System For Car Service\\Information System.xls"; if (File.Exists(path)) { excel.OpenDocument(path); } else { excel.NewDocument(); } if (!excel.ExistClient(client, tb_login.Text, tb_password.Text)) { excel.WriteDataUser(client); } else { MessageBox.Show("Пользователь с таким логином уже существует!"); this.Close(); } if (!File.Exists(path)) { excel.SaveAsDocument(path); } else { excel.SaveDocument(); } excel.CloseDocument(); } }