//---------------------------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------

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

            sSQLStatement =
                $@"
        insert into CodeGen_Automobile
        (
          AutomobileMake, 
          AutomobileModel, 
          AutomobileYear, 
          AutomobileGUID
        )
        values
        (
          @AutomobileMake, 
          @AutomobileModel, 
          @AutomobileYear, 
          @AutomobileGUID
        )
      ";
            if (@AutomobileGUID == null)
            {
                AutomobileGUID = new GUID();
            }

            SqlCommand xSQLCommand = new SqlCommand(sSQLStatement, a_xSQLConnection);

            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileMake", AutomobileMake.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileModel", AutomobileModel.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileYear", AutomobileYear.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileGUID", AutomobileGUID.ToString()));

            return(xSQLCommand);
        }
Example #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);
        }
        //---------------------------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------

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

            sSQLStatement =
                $@"
        update CodeGen_Automobile
          set 
            AutomobileMake                           = @AutomobileMake,
            AutomobileModel                          = @AutomobileModel,
            AutomobileYear                           = @AutomobileYear
          where
            AutomobileGUID = @AutomobileGUID
      ";

            SqlCommand xSQLCommand = new SqlCommand(sSQLStatement, a_xSQLConnection);

            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileMake", AutomobileMake.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileModel", AutomobileModel.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileYear", AutomobileYear.ToDBNull()));
            xSQLCommand.Parameters.Add(new SqlParameter("@AutomobileGUID", AutomobileGUID.ToString()));

            return(xSQLCommand);
        }
Example #4
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);
        }