public void Save(ChosenName ChosenName) { try { if (ChosenName == null) { throw new ArgumentException("ChosenName is empty"); } if (String.IsNullOrEmpty(ChosenName.Name)) { throw new ArgumentException("ChosenName name is empty"); } if (ChosenName.UnId <= 0) { throw new ArgumentException("user id is empty"); } if (ChosenName.NumerlogyNumber <= 0) { throw new ArgumentException("NumerlogyNumber is empty"); } ChosenNameDAL = new ChosenNameDAL(); ChosenNameDAL.Insert(ChosenName); } catch (Exception) { throw; } }
public void Insert(ChosenName chosenName) { try { string sql = "insert into chosenname (unId,Name,NumerlogyNumber) values (" + chosenName.UnId + ",'" + chosenName.Name + "'," + chosenName.NumerlogyNumber + ")"; connectToDatabase(); SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); m_dbConnection.Close(); } catch (SQLiteException ex) { throw; } }