public static int UpdateAttribute(PLDbConnection dbConn, int shapeID, string shapeTypeAttributeName, string attributeValue) { PLDbCommand dbCmd; int shapeTypeAttributeID; // TODO: Get the attributeID for the passed in attributeName if ((shapeTypeAttributeID = DataAccess.GetShapeTypeAttributeID(shapeTypeAttributeName)) > 0) { dbCmd = new PLDbCommand("SetAttributeValue", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; dbCmd.AddParameter("@Table", SqlDbType.Int, 0).Value = Globals.TABLE_SHAPE; dbCmd.AddParameter("@ID", SqlDbType.Int, 0).Value = shapeID; dbCmd.AddParameter("@STA_ID", SqlDbType.Int, 0).Value = shapeTypeAttributeID; dbCmd.AddParameter("@Function", SqlDbType.Int, 0).Value = Globals.LOGFUNCTION_SET_ATTRIBUTEVALUE; dbCmd.AddParameter("@Contact", SqlDbType.VarChar, 100).Value = global::System.Security.Principal.WindowsIdentity.GetCurrent().Name; dbCmd.AddParameter("@Value", SqlDbType.VarChar, 100).Value = attributeValue; dbCmd.ExecuteNonQuery(); return(Globals.SUCCESS); } else { return(Globals.FAILURE); } }
public static int CreateShape(PLDbConnection dbConn, string shapeType, string shapeName, string shapeDescription, out int shapeID) { // TODO : Update with using and handle errors. // TODO : Can we pass in a dbCmd and have the common stuff already populated? PLDbCommand dbCmd; // Create the Shape dbCmd = new PLDbCommand("SetShape", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; dbCmd.AddParameter("@Table", SqlDbType.Int, 0).Value = Globals.TABLE_SHAPE; dbCmd.AddParameter("@ShapeType", SqlDbType.Int, 0).Value = Globals.ShapeTypes[shapeType]; dbCmd.AddParameter("@Lifecycle", SqlDbType.Int, 0).Value = Globals.LIFECYCLE_CURRENT; dbCmd.AddParameter("@Function", SqlDbType.Int, 0).Value = Globals.LOGFUNCTION_SET_SHAPE; dbCmd.AddParameter("@Contact", SqlDbType.VarChar, 100).Value = global::System.Security.Principal.WindowsIdentity.GetCurrent().Name; dbCmd.AddParameter("@Value", SqlDbType.VarChar, 100).Value = shapeName; dbCmd.AddParameter("@NewID", SqlDbType.Int, 0).Direction = ParameterDirection.Output; dbCmd.ExecuteNonQuery(); shapeID = (int)dbCmd.GetParameter("@NewID").Value; dbCmd.Dispose(); dbCmd = new PLDbCommand("SetItem_Desc", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; dbCmd.AddParameter("@Table", SqlDbType.Int, 0).Value = Globals.TABLE_SHAPE; dbCmd.AddParameter("@ID", SqlDbType.Int, 0).Value = shapeID; dbCmd.AddParameter("@Value", SqlDbType.VarChar, 1000).Value = shapeDescription; dbCmd.AddParameter("@Function", SqlDbType.Int, 0).Value = Globals.LOGFUNCTION_SET_SHAPE; dbCmd.AddParameter("@Contact", SqlDbType.VarChar, 100).Value = global::System.Security.Principal.WindowsIdentity.GetCurrent().Name; dbCmd.ExecuteNonQuery(); dbCmd.Dispose(); return(Globals.SUCCESS); }