public static int insertProject(long id, string name, string addr, double lat, double lng) { using (SQLiteCommand cmd = new SQLiteCommand( "INSERT INTO Project values (@id, @name, @addr, @lat, @lng)")) { cmd.Parameters.Add("@id", DbType.Int64).Value = id; cmd.Parameters.Add("@name", DbType.String).Value = name; cmd.Parameters.Add("@addr", DbType.String).Value = addr; cmd.Parameters.Add("@lat", DbType.Double).Value = lat; cmd.Parameters.Add("@lng", DbType.Double).Value = lng; return(SQLiteDBMS.execInsert(cmd)); } }
public static int insertPLC(string alias, int netid, string ip, int port, int polling_rate, long project_id) { using (SQLiteCommand cmd = new SQLiteCommand( "INSERT INTO PLC (net_id, net_ip, net_port, alias, polling_rate, project_id) " + "values (@net_id, @net_ip, @net_port, @alias, @polling_rate, @project_id)")) { cmd.Parameters.Add("@net_id", DbType.Int32).Value = netid; cmd.Parameters.Add("@net_ip", DbType.String).Value = ip; cmd.Parameters.Add("@net_port", DbType.Int32).Value = port; cmd.Parameters.Add("@alias", DbType.String).Value = alias; cmd.Parameters.Add("@polling_rate", DbType.Int32).Value = polling_rate; cmd.Parameters.Add("@project_id", DbType.Int64).Value = project_id; return(SQLiteDBMS.execInsert(cmd)); } }
public static int insertScaling(string scale_type, double raw_hi, double raw_lo, double scale_hi, double scale_lo, long tag_id) { using (SQLiteCommand cmd = new SQLiteCommand( "INSERT INTO Scaling (scale_type, raw_hi, raw_lo, scale_hi, scale_lo, tag_id) " + "values (@scale_type, @raw_hi, @raw_lo, @scale_hi, @scale_lo, @tag_id)")) { // scale cmd.Parameters.Add("@scale_type", DbType.String).Value = scale_type.ToString(); cmd.Parameters.Add("@raw_hi", DbType.Double).Value = raw_hi; cmd.Parameters.Add("@raw_lo", DbType.Double).Value = raw_lo; cmd.Parameters.Add("@scale_hi", DbType.Double).Value = scale_hi; cmd.Parameters.Add("@scale_lo", DbType.Double).Value = scale_lo; cmd.Parameters.Add("@tag_id", DbType.Int64).Value = tag_id; return(SQLiteDBMS.execInsert(cmd)); } }
public static int insertTag(string alias, int addr, DataType type, string format, string unit, long plc_id) { using (SQLiteCommand cmd = new SQLiteCommand( "INSERT INTO Tag (alias, addr, data_type, format, unit, plc_id) " + "values (@alias, @addr, @data_type, @format, @unit, @plc_id)")) { cmd.Parameters.Add("@alias", DbType.String).Value = alias; cmd.Parameters.Add("@addr", DbType.Int32).Value = addr; cmd.Parameters.Add("@data_type", DbType.String).Value = type.ToString(); cmd.Parameters.Add("@format", DbType.String).Value = format; cmd.Parameters.Add("@unit", DbType.String).Value = unit; // foreigh cmd.Parameters.Add("@plc_id", DbType.Int64).Value = plc_id; return(SQLiteDBMS.execInsert(cmd)); } }