Exemple #1
0
        //---------------------------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------

        public SqlCommand SQLCommand_Create(SqlConnection a_xSQLConnection)
        {
            string sSQLStatement = "";

            sSQLStatement =
                $@"
        insert into CodeGen_AutomobilePart
        (
          AutomobileGUID, 
          AutomobilePartDescription, 
          AutomobilePartName, 
          AutomobilePartNumber, 
          AutomobilePartPrice, 
          AutomobilePartGUID
        )
        values
        (
          @AutomobileGUID, 
          @AutomobilePartDescription, 
          @AutomobilePartName, 
          @AutomobilePartNumber, 
          @AutomobilePartPrice, 
          @AutomobilePartGUID
        )
      ";
            if (@AutomobilePartGUID == null)
            {
                AutomobilePartGUID = new GUID();
            }

            SqlCommand xSQLCommand = new SqlCommand(sSQLStatement, a_xSQLConnection);

            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileGUID", AutomobileGUID == null ? System.DBNull.Value : AutomobileGUID.ToString().ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartDescription", AutomobilePartDescription.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartName", AutomobilePartName.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartNumber", AutomobilePartNumber.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartPrice", AutomobilePartPrice.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartGUID", AutomobilePartGUID.ToString()));

            return(xSQLCommand);
        }
Exemple #2
0
        //---------------------------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------

        public SqlCommand SQLCommand_Update(SqlConnection a_xSQLConnection)
        {
            string sSQLStatement = "";

            sSQLStatement =
                $@"
        update CodeGen_AutomobilePart
          set 
            AutomobileGUID                           = @AutomobileGUID,
            AutomobilePartDescription                = @AutomobilePartDescription,
            AutomobilePartName                       = @AutomobilePartName,
            AutomobilePartNumber                     = @AutomobilePartNumber,
            AutomobilePartPrice                      = @AutomobilePartPrice
          where
            AutomobilePartGUID = @AutomobilePartGUID
      ";

            SqlCommand xSQLCommand = new SqlCommand(sSQLStatement, a_xSQLConnection);

            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileGUID", AutomobileGUID.ToString().ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartDescription", AutomobilePartDescription.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartName", AutomobilePartName.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartNumber", AutomobilePartNumber.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartPrice", AutomobilePartPrice.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobilePartGUID", AutomobilePartGUID.ToString()));

            return(xSQLCommand);
        }