public bool Insert(DALDegree degree) { using (var connection = new SQLiteConnection(connectionString)) { SQLiteCommand command = new SQLiteCommand(null, connection); int res = -1; try { connection.Open(); command.CommandText = $"INSERT INTO {DegreeTableName} ({DALDegree.DegreeNameColumn} ,{DALDegree.DegreeCreditColumn},{DALDegree.DegreeAverageColumn},{DALDegree.DegreeExpectedAverageColumn},{DALDegree.DegreeDonePrecentsColumn},{DALDegree.DegreeDifferenceColumn},{DALDegree.DegreeTotalCreditColumn},{DALDegree.DegreeStudentIdColumn},{DALDegree.DegreeYearsNumColumn}) " + $"VALUES (@numVal,@creditVal,@averageVal,@expectedAverageVal,@donePrecentVal,@differenceVal,@totalCreditVal,@studentIdVal,@yearsNumVal);"; SQLiteParameter nameParam = new SQLiteParameter(@"numVal", degree.Name); SQLiteParameter creditParam = new SQLiteParameter(@"creditVal", degree.Credit); SQLiteParameter averageParam = new SQLiteParameter(@"averageVal", degree.Average); SQLiteParameter expectedverageParam = new SQLiteParameter(@"expectedverageVal", degree.ExpectedAverage); SQLiteParameter donePrecentParam = new SQLiteParameter(@"donePrecent", degree.DonePrecent); SQLiteParameter differenceParam = new SQLiteParameter(@"differenceVal", degree.Difference); SQLiteParameter totalCreditParam = new SQLiteParameter(@"totalCreditVal", degree.TotalCredit); SQLiteParameter studentIdParam = new SQLiteParameter(@"studentIdVal", degree.StudentId); SQLiteParameter yearsNumParam = new SQLiteParameter(@"yearsNumVal", degree.StudentId); command.Parameters.Add(nameParam); command.Parameters.Add(creditParam); command.Parameters.Add(averageParam); command.Parameters.Add(expectedverageParam); command.Parameters.Add(donePrecentParam); command.Parameters.Add(differenceParam); command.Parameters.Add(totalCreditParam); command.Parameters.Add(studentIdParam); command.Parameters.Add(yearsNumParam); command.Prepare(); res = command.ExecuteNonQuery(); } catch (Exception e) { if (e.Message != null) { } } finally { command.Dispose(); connection.Close(); } return(res > 0); } }
protected override DALObj ConvertReaderToObject(SQLiteDataReader reader) { DALDegree ret = new DALDegree(reader.GetString(0), reader.GetInt32(1), reader.GetDouble(2), reader.GetDouble(3), reader.GetDouble(4), reader.GetInt32(5), reader.GetDouble(6), reader.GetInt32(7), reader.GetInt32(8)); return(ret); }
public BLLDegree() { dal = new DALDegree(); }