public static ColumnStruct getColumn(int id) { SQLiteCommand command = new SQLiteCommand(); ColumnStruct ans = new ColumnStruct(); try { DAL.OpenConnect(); command = new SQLiteCommand(null, DAL.connection); command.CommandText = "SELECT * FROM Column WHERE Cid = " + id; command.Prepare(); SQLiteDataReader reader = command.ExecuteReader(); //string ans = ""; while (reader.Read()) { int limit = int.Parse("" + reader["CLimit"]); ans = new ColumnStruct(id, "" + reader["Name"], limit); } command.Dispose(); reader.Close(); DAL.CloseConnect(); return(ans); } catch (SQLiteException e) { Logger.Log.Fatal("faild to retrive column with id: " + id + "\n eror: " + e.Message); command.Dispose(); DAL.CloseConnect(); return(ans); } }
public static void saveColumn(ColumnStruct column, int BoradLocation, int BoardID) { SQLiteCommand command = new SQLiteCommand(); try { DAL.OpenConnect(); command = new SQLiteCommand(null, DAL.connection); command.CommandText = "INSERT INTO Columns(Cid, Name, CLimit, Bid, BLocation) " + " VALUES (@Column_id, @Column_Name, @Column_Limit, @Board_id, @Board_Location )"; SQLiteParameter ColumnId = new SQLiteParameter("@Column_id", column.Id); SQLiteParameter ColumnName = new SQLiteParameter("@Column_Name", column.Name); SQLiteParameter ColumnLimit = new SQLiteParameter("@Column_Limit", column.Limit); SQLiteParameter boardID = new SQLiteParameter("@Board_id", BoardID); SQLiteParameter boardLoc = new SQLiteParameter("@Board_Location", BoradLocation); command.Parameters.Add(ColumnId); command.Parameters.Add(ColumnName); command.Parameters.Add(ColumnLimit); command.Parameters.Add(boardID); command.Parameters.Add(boardLoc); command.Prepare(); int changes = command.ExecuteNonQuery(); command.Dispose(); DAL.CloseConnect(); Logger.Log.Info("saved new column; id: " + column.Id + "; name: '" + column.Name + "'; limit: " + column.Limit + "; to board with id: " + BoardID + "; location: " + BoradLocation); } catch (SQLiteException e) { Logger.Log.Fatal("faild to save column with id: " + column.Id + "\n eror: " + e.Message); command.Dispose(); DAL.CloseConnect(); } }