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(); } }
private void bt_ok_Click(object sender, EventArgs e) { string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\Information System For Car Service\\Information System.xls"; if (excel.ExcelIsPresent()) { if (File.Exists(path)) { excel.OpenDocument(path); } else { excel.NewDocument(); } if (excel.ExistAdministration(admin, tb_login.Text, tb_password.Text)) { this.Hide(); excel.CloseDocument(); MainMenuForm menu = new MainMenuForm(admin); menu.ShowDialog(); this.Close(); } else if (excel.ExistClient(client, tb_login.Text, tb_password.Text)) { this.Hide(); excel.CloseDocument(); MainMenuForm menu = new MainMenuForm(client); menu.ShowDialog(); this.Close(); } else { MessageBox.Show("Пользователь с таким логином и паролем не найден!"); } } }