Example #1
0
        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);
        }