/*******************************************************************************************************/ #region DATABASE METHODS public static Guid?add(string name, string IPAddress, DefaultForms defaultForm) { Guid Id = Guid.NewGuid(); SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "CounterAddresses_add", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Name, SqlDbType.NVarChar, name), new SqlQueryParameter(COL_DB_IPAddress, SqlDbType.NVarChar, IPAddress), new SqlQueryParameter(COL_DB_DefaultForms_enumid, SqlDbType.TinyInt, defaultForm) ); if (!result.IsSuccessful) { return(null); } else { return(Id); } }
public static void update(Guid Id, string name, string ipAddress, DefaultForms defaultForm) { CounterAddress objOld = new CounterAddress(Id); string log = ""; log = Util.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.IPAddress, ipAddress, "IP Address: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.DefaultForms_description, Util.GetEnumDescription(defaultForm), "Default Form: '{0}' to '{1}'"); if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "CounterAddresses_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Name, SqlDbType.NVarChar, Util.wrapNullable(name)), new SqlQueryParameter(COL_DB_IPAddress, SqlDbType.NVarChar, Util.wrapNullable(ipAddress)), new SqlQueryParameter(COL_DB_DefaultForms_enumid, SqlDbType.TinyInt, defaultForm) ); } }
public CounterAddress(Guid?id, string ipAddress) { DataRow row; if (id != null) { row = get((Guid)id); } else { row = get(ipAddress); } IPAddress = ipAddress; if (row != null) { Id = Util.wrapNullable <Guid>(row, COL_DB_Id); IPAddress = Util.wrapNullable <string>(row, COL_DB_IPAddress); Name = Util.wrapNullable <string>(row, COL_DB_Name); DefaultForms_enum = Util.parseEnum <DefaultForms>(Util.wrapNullable <int>(row, COL_DB_DefaultForms_enumid)); DefaultForms_description = Util.wrapNullable <string>(row, COL_DefaultForms_description); } }