Проектирование информационной системы по работе с клиентами на предприятии

Основная характеристика сроков разработки информационной системы. Главные требования к пользовательскому интерфейсу. Анализ формирования структуры базы данных. Описание созданных запросов и отчетов. Выбор средств решения выполнения технического задания.

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык русский
Дата добавления 10.10.2015
Размер файла 1,4 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

  • 5. К.Дэйт , Введение в системы баз данных: К.: Издательский дом «Вильямс», 2000. - 512 с.
  • Приложения
  • Приложение А
  • ActiveCoupons.dtd:
  • <?xml version="1.0" encoding="Windows-1251" ?>
  • <!-- VPOffice, DTD для печати отчета по активным талонам на указанный момент времени, -->
  • <!-- только итоговые суммы, придеживаемся жесткой структуры документа, -->
  • <!-- при появлении нового вида топлива требуются изменения -->
  • <!-- DTD root element -->
  • <!ELEMENT report (head, clients+) >
  • <!ELEMENT head (startdate, enddate) >
  • <!ELEMENT clients (client+, petrosoftData) >
  • <!ELEMENT client (clientName, gas, pricesSumma ) >
  • <!ELEMENT gas (gas65, gas67, gas69, gas71) >
  • <!ELEMENT gas65 (gas_coupon) >
  • <!ELEMENT gas67 (gas_coupon) >
  • <!ELEMENT gas69 (gas_coupon) >
  • <!ELEMENT gas71 (gas_coupon) >
  • <!ELEMENT petrosoftData (nominal65, nominal 67, nominal 69, nominal 71) >
  • <!ELEMENT gas (gasName, gasLiters, gasPrices) >
  • <!-- client properties -->
  • <!ELEMENT clientName (#PCDATA) ><!-- client title -->
  • <!ELEMENT pricesSumma (#PCDATA) ><!-- Full price summary -->
  • <!-- gas types, summary prices and amounts in liters -->
  • <!ELEMENT gasLiters (#PCDATA) ><!-- Total number of liters -->
  • <!ELEMENT gasPrices (#PCDATA) ><!-- Total price -->
  • <!-- PETROSOFT data -->
  • <!ELEMENT gasLiters65 (#PCDATA) ><!-- Number of liters -->
  • <!ELEMENT gasLiters67 (#PCDATA) ><!-- Number of liters -->
  • <!ELEMENT gasLiters69 (#PCDATA) ><!-- Number of liters -->
  • <!ELEMENT gasLiters71 (#PCDATA) ><!-- Number of liters -->
  • <!-- end of DTD -->
  • ActiveCoupons.xsl:
  • <?xml version="1.0" encoding="Windows-1251"?>
  • <xsl:stylesheet
  • xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  • version="1.0">
  • <xsl:template match="report">
  • <HTML>
  • <style>
  • <!--
  • /* Style Definitions */
  • p.MsoNormal, li.MsoNormal, div.MsoNormal
  • {mso-style-parent:"";
  • margin:0cm;
  • margin-bottom:.0001pt;
  • mso-pagination:widow-orphan;
  • font-size:12.0pt;
  • font-family:"Times New Roman";
  • mso-fareast-font-family:"Times New Roman";}
  • @page Section1
  • {size:841.9pt 595.3pt;
  • mso-page-orientation:landscape;
  • margin:3.0cm 2.0cm 42.55pt 2.0cm;
  • mso-header-margin:35.45pt;
  • mso-footer-margin:35.45pt;
  • mso-paper-source:0;}
  • div.Section1
  • {page:Section1;}
  • -->
  • </style>
  • <HEAD>
  • <TITLE>
  • Активные талоны
  • на <!-- xsl:apply-templates select="head/enddate"/ -->
  • текущий момент времени
  • </TITLE>
  • </HEAD>
  • <BODY>
  • <xsl:apply-templates select="head"/>
  • <BR></BR>
  • <BR></BR>
  • <xsl:apply-templates select="clients"/>
  • <BR></BR>
  • </BODY>
  • </HTML>
  • </xsl:template>
  • <xsl:template match="head">
  • <H2><DIV align="center">
  • ОТЧЕТ
  • <BR/>
  • ПО АКТИВНЫМ ТАЛОНАМ (ИТОГИ)
  • </DIV></H2>
  • <DIV align="center">
  • на <!-- xsl:apply-templates select="enddate"/ -->
  • текущий момент времени
  • <BR></BR>
  • </DIV>
  • </xsl:template>
  • <xsl:template match="clientName">
  • <xsl:value-of select="."/>
  • </xsl:template>
  • <xsl:template match="fuelName">
  • <TD ALIGN="left">
  • <B>
  • <FONT SIZE="-3">
  • <xsl:value-of select="."/>
  • </FONT>
  • </B>
  • </TD>
  • </xsl:template>
  • <xsl:template match="fuelLiters">
  • <TD ALIGN="right">
  • <FONT SIZE="-3" COLOR="BLUE">
  • <xsl:value-of select="format-number(., '#')"/>
  • </FONT>
  • </TD>
  • </xsl:template>
  • <xsl:template match="fuelPrices">
  • <TD ALIGN="right">
  • <FONT SIZE="-3" COLOR="RED">
  • <xsl:value-of select="format-number(., '#')"/>
  • </FONT>
  • </TD>
  • </xsl:template>
  • <xsl:template match="clients">
  • <xsl:variable name="fuelLiters65" select="sum(client/fuels/fuel65/fuel/fuelLiters)"/>
  • <xsl:variable name="fuelPrices65" select="sum(client/fuels/fuel65/fuel/fuelPrices)"/>
  • <xsl:variable name="fuelLiters67" select="sum(client/fuels/fuel67/fuel/fuelLiters)"/>
  • <xsl:variable name="fuelPrices67" select="sum(client/fuels/fuel67/fuel/fuelPrices)"/>
  • <xsl:variable name="fuelLiters69" select="sum(client/fuels/fuel69/fuel/fuelLiters)"/>
  • <xsl:variable name="fuelPrices69" select="sum(client/fuels/fuel69/fuel/fuelPrices)"/>
  • <xsl:variable name="fuelLiters71" select="sum(client/fuels/fuel71/fuel/fuelLiters)"/>
  • <xsl:variable name="fuelPrices71" select="sum(client/fuels/fuel71/fuel/fuelPrices)"/>
  • <xsl:variable name="pricesSumma" select="sum(client/pricesSumma)"/>
  • <TABLE class="MsoTableGrid" border="3" cellspacing="0" cellpadding="2" width="100%"
  • style="border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;
  • mso-yfti-tbllook:480;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-border-insideh:
  • .5pt solid windowtext;mso-border-insidev:.5pt solid windowtext">
  • <TR>
  • <TH ROWSPAN="2" ALIGN="center" WIDTH="3%"><SMALL>№ пп</SMALL></TH>
  • <TH ROWSPAN="2" ALIGN="center" WIDTH="31%"><SMALL>Клиент</SMALL></TH>
  • <TH COLSPAN="2" ALIGN="center" WIDTH="14%"><SMALL>A-76</SMALL></TH>
  • <TH COLSPAN="2" ALIGN="center" WIDTH="14%"><SMALL>AИ-92</SMALL></TH>
  • <TH COLSPAN="2" ALIGN="center" WIDTH="14%"><SMALL>АИ-95</SMALL></TH>
  • <TH COLSPAN="2" ALIGN="center" WIDTH="14%"><SMALL>ДТ</SMALL></TH>
  • <TH ROWSPAN="2" ALIGN="center" WIDTH="10%"><SMALL>Итого р.</SMALL></TH>
  • </TR>
  • <TR>
  • <TH ALIGN="center" WIDTH="7%"><SMALL> Объём, л </SMALL></TH>
  • <TH ALIGN="center" WIDTH="7%"><SMALL> Сумма, р </SMALL></TH>
  • <TH ALIGN="center" WIDTH="7%"><SMALL> Объём, л </SMALL></TH>
  • <TH ALIGN="center" WIDTH="7%"><SMALL> Сумма, р </SMALL></TH>
  • <TH ALIGN="center" WIDTH="7%"><SMALL> Объём, л </SMALL></TH>
  • <TH ALIGN="center" WIDTH="7%"><SMALL> Сумма, р </SMALL></TH>
  • <TH ALIGN="center" WIDTH="7%"><SMALL> Объём, л </SMALL></TH>
  • <TH ALIGN="center" WIDTH="7%"><SMALL> Сумма, р </SMALL></TH>
  • </TR>
  • <xsl:apply-templates select="client"/>
  • <TR>
  • <TD COLSPAN="2" ALIGN="right">
  • <FONT size="-1">
  • <B>
  • ИТОГО по отчету:
  • </B>
  • </FONT>
  • </TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($fuelLiters67, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($fuelPrices67, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($fuelLiters65, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($fuelPrices65, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($fuelLiters69, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($fuelPrices69, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($fuelLiters71, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($fuelPrices71, '#')"/></B></FONT></TD>
  • <TD ALIGN="right">
  • <FONT size="-1">
  • <B>
  • <xsl:value-of select="format-number($pricesSumma, '#')"/>
  • </B>
  • </FONT>
  • </TD>
  • </TR>
  • <xsl:variable name="petrosoftFuelLiters65" select="petrosoftData/fuelLiters65"/>
  • <xsl:variable name="petrosoftFuelLiters67" select="petrosoftData/fuelLiters67"/>
  • <xsl:variable name="petrosoftFuelLiters69" select="petrosoftData/fuelLiters69"/>
  • <xsl:variable name="petrosoftFuelLiters71" select="petrosoftData/fuelLiters71"/>
  • <TR>
  • <TD COLSPAN="2" ALIGN="right">
  • <FONT size="-1">
  • <B>
  • ПЕТРОСОФТ данные:
  • </B>
  • </FONT>
  • </TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($petrosoftFuelLiters67, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($petrosoftFuelLiters65, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($petrosoftFuelLiters69, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B><xsl:value-of select="format-number($petrosoftFuelLiters71, '#')"/></B></FONT></TD>
  • <TD ALIGN="right"><FONT size="-1"><B></B></FONT></TD>
  • <TD ALIGN="right">
  • <FONT size="-1">
  • <B>
  • </B>
  • </FONT>
  • </TD>
  • </TR>
  • </TABLE>
  • </xsl:template>
  • <xsl:template match="client">
  • <TR>
  • <xsl:if test="position() mod 2 = 0">
  • <xsl:attribute name="BGCOLOR">SILVER</xsl:attribute>
  • </xsl:if>
  • <TD ALIGN="center"><SMALL><xsl:value-of select="position()"/></SMALL></TD>
  • <TD ALIGN="left">
  • <FONT SIZE="-1">
  • <B>
  • <xsl:apply-templates select="clientName"/>
  • </B>
  • </FONT>
  • </TD>
  • <xsl:apply-templates select="fuels"/>
  • <TD ALIGN="right">
  • <FONT size="-2">
  • <B>
  • <xsl:apply-templates select="pricesSumma"/>
  • </B>
  • </FONT>
  • </TD>
  • </TR>
  • </xsl:template>
  • <xsl:template match="fuels">
  • <xsl:apply-templates select="fuel67"/>
  • <xsl:apply-templates select="fuel65"/>
  • <xsl:apply-templates select="fuel69"/>
  • <xsl:apply-templates select="fuel71"/>
  • </xsl:template>
  • <xsl:template match="fuel65">
  • <xsl:apply-templates select="fuel"/>
  • </xsl:template>
  • <xsl:template match="fuel67">
  • <xsl:apply-templates select="fuel"/>
  • </xsl:template>
  • <xsl:template match="fuel69">
  • <xsl:apply-templates select="fuel"/>
  • </xsl:template>
  • <xsl:template match="fuel71">
  • <xsl:apply-templates select="fuel"/>
  • </xsl:template>
  • <xsl:template match="fuel">
  • <FONT SIZE="-1">
  • <xsl:apply-templates select="fuelLiters"/>
  • <xsl:apply-templates select="fuelPrices"/>
  • </FONT>
  • </xsl:template>
  • </xsl:stylesheet>
  • ActiveCoupons.sql:
  • USE [VP_OFFICE]
  • GO
  • SET ANSI_NULLS ON
  • GO
  • SET QUOTED_IDENTIFIER ON
  • GO
  • ALTER PROCEDURE [dbo].[docClientActiveCoupons]
  • @DTDvarchar(261),-- DTD file
  • @XSLvarchar(261),-- XSL file
  • @Stationint,-- not used
  • @sDatedatetime,
  • @fDatedatetime
  • AS
  • SET NOCOUNT ON
  • -- Create tempory folder
  • if OBJECT_ID('tempdb..#tmptext') is not null
  • drop table #TmpText
  • CREATE TABLE#TmpText (
  • ID int IDENTITY(1,1),
  • docstr Varchar(5000) COLLATE Cyrillic_General_CI_AS
  • )
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<?xml version="1.0" encoding="Windows-1251"?>' + char(13))
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<?xml-stylesheet type="text/xsl" href="'
  • + @XSL
  • + '"?>' + char(13)
  • )
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<!DOCTYPE clientReport SYSTEM "'
  • + @DTD
  • + '">' + char(13)
  • )
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<report>' + char(13))
  • --- report title
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<head>'
  • + '<startdate>'
  • + CASE
  • WHEN @sDate is not NULL THEN
  • CONVERT(varchar, CAST(@sDate AS datetime), 104)
  • +' '
  • +CONVERT(varchar, CAST(@sDate AS datetime), 108)
  • ELSE
  • 'нет данных'
  • END
  • + '</startdate>'
  • + '<enddate>'
  • + CASE
  • WHEN @fDate is not NULL THEN
  • CONVERT(varchar, CAST(@fDate AS datetime), 104)
  • +' '
  • +CONVERT(varchar, CAST(@fDate AS datetime), 108)
  • ELSE
  • 'нет данных'
  • END
  • + '</enddate>'
  • + '</head>' + char(13)
  • )
  • DECLARE @minDate datetime, @maxDate datetime
  • SET @minDate = DATEADD(dd, -1, @sDate)
  • SET @maxDate = DATEADD(dd, 1, @fDate)
  • -- Open the "clients" tag to declare a start of list of clients.
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<clients>' + char(13))
  • -- Create a table with results
  • CREATE TABLE #TempTable (AUTOID int IDENTITY(1,1) NOT NULL,
  • ID int,-- Coupon database unique id.
  • Date varchar(255),-- Coupon last update.
  • Status int,-- Coupon status.
  • FuelType tinyint,-- Coupon fuel type.
  • Volume int,-- Coupon face-value.
  • Price bigint,-- Coupon liter price.
  • ClientName varchar(255) COLLATE Cyrillic_General_CI_AS ) -- Coupon owner.
  • /*
  • -- Create temporary table to contain coupons issued to the specified moment of time.
  • -- Attention: there is no need to take into account all the coupons that were primarily canceled and issued after that.
  • INSERT INTO #TempTable( ID, Date, Status, FuelType, Volume, Price, ClientName )
  • SELECT DISTINCT couponHistory.couponID, couponHistory.Date, couponHistory.Status,
  • couponHistory.FuelType, couponHistory.Volume, couponHistory.Price * couponHistory.Volume / 10000,
  • (SELECT Name FROM Client WHERE ID1C = (SELECT ClientID1C FROM [dbo].[1CBill] WHERE ID = couponHistory.BillID))
  • FROM [dbo].[CouponHistory] couponHistory
  • /******** select issued to the specified moment of time *******/
  • WHERE Status = 1 AND Date <= @fDate
  • AND couponHistory.couponID in
  • (
  • /******** and select current status == 1 also ********/
  • SELECT DISTINCT ch.CouponID
  • FROM [dbo].[Coupon] c, [dbo].[CouponHistory] ch
  • WHERE c.ID = ch.CouponID AND c.Date = ch.Date AND ch.Status = 1 AND c.Date <= @fDate
  • -- Create temporary table to contain coupons issued inside the specified period and still issued currently.
  • INSERT INTO #TempTable( ID, Date, Status, FuelType, Volume, Price, ClientName )
  • SELECT DISTINCT couponHistory.couponID, couponHistory.Date, couponHistory.Status,
  • couponHistory.FuelType, couponHistory.Volume, couponHistory.Price * couponHistory.Volume / 10000,
  • (SELECT Name FROM Client WHERE ID1C = (SELECT ClientID1C FROM [dbo].[1CBill] WHERE ID = couponHistory.BillID))
  • FROM [dbo].[Coupon] coupon, [dbo].[CouponHistory] couponHistory
  • /******** select issued to the current moment of time *******/
  • WHERE coupon.ID = couponHistory.CouponID AND coupon.Date = couponHistory.Date AND couponHistory.Status = 1
  • DECLARE @CLIENTNAMEvarchar(255) -- Stores a coupon owner.
  • DECLARE @FUELTYPEint -- Stores a coupon fuel type.
  • DECLARE @QUANTITYint -- Stores summary coupons' quantity.
  • DECLARE @TOTALPRICEint -- Stores summary price.
  • DECLARE @TOTALVOLUMEint -- Stores summary liters.
  • DECLARE RecordsForAnalysis CURSOR FOR
  • SELECT ClientName, FuelType, COUNT( FuelType ) Quantity, SUM( Price ) Price, SUM( Volume ) Liters
  • FROM #TempTable
  • GROUP BY ClientName, FuelType
  • ORDER BY ClientName, FuelType
  • DECLARE @CURRENT_CLIENTNAME varchar(255)-- Current owner.
  • SET @CURRENT_CLIENTNAME = ''
  • DECLARE @CURRENT_FUELTYPEvarchar(255)-- Current coupon fuel type.
  • SET @CURRENT_FUELTYPE = ''
  • DECLARE @PRICESSUMMAint-- Stores summary coupons' prices.
  • DECLARE @FUELLITERS65int
  • DECLARE @FUELPRICES65int
  • DECLARE @FUELLITERS67int
  • DECLARE @FUELPRICES67int
  • DECLARE @FUELLITERS69int
  • DECLARE @FUELPRICES69int
  • DECLARE @FUELLITERS71int
  • DECLARE @FUELPRICES71int
  • OPEN RecordsForAnalysis
  • FETCH NEXT FROM RecordsForAnalysis INTO @CLIENTNAME, @FUELTYPE, @QUANTITY, @TOTALPRICE, @TOTALVOLUME
  • -- Analyze the last history record of every coupon.
  • WHILE @@FETCH_STATUS = 0
  • BEGIN
  • -- Check a current client identifier.
  • IF @CURRENT_CLIENTNAME <> @CLIENTNAME
  • BEGIN
  • IF @CURRENT_CLIENTNAME <> ''
  • BEGIN
  • -- Section to fill every record ---------------------------------
  • -- Open tag for a new record.
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel65>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters>' + char(13)+ CONVERT(varchar, CAST(@FUELLITERS65 AS money), 0) + '</fuelLiters>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelPrices>' + char(13)+ CONVERT(varchar, CAST(@FUELPRICES65 AS money), 0)+ '</fuelPrices>' + char(13))
  • -- Close tag for the new record.
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel65>' + char(13))
  • -- Open tag for a new record.
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel67>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters>' + char(13)+ CONVERT(varchar, CAST(@FUELLITERS67 AS money), 0) + '</fuelLiters>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelPrices>' + char(13)+ CONVERT(varchar, CAST(@FUELPRICES67 AS money), 0)+ '</fuelPrices>' + char(13))
  • -- Close tag for the new record.
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel67>' + char(13))
  • -- Open tag for a new record.
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel69>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters>' + char(13)+ CONVERT(varchar, CAST(@FUELLITERS69 AS money), 0) + '</fuelLiters>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelPrices>' + char(13)+ CONVERT(varchar, CAST(@FUELPRICES69 AS money), 0)+ '</fuelPrices>' + char(13))
  • -- Close tag for the new record.
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel69>' + char(13))
  • -- Open tag for a new record.
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel71>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters>' + char(13)+ CONVERT(varchar, CAST(@FUELLITERS71 AS money), 0) + '</fuelLiters>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelPrices>' + char(13)+ CONVERT(varchar, CAST(@FUELPRICES71 AS money), 0)+ '</fuelPrices>' + char(13))
  • -- Close tag for the new record.
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel71>' + char(13))
  • SET @PRICESSUMMA = @FUELPRICES65 + @FUELPRICES67 + @FUELPRICES69 + @FUELPRICES71
  • -- Section to fill every record ---------------------------------
  • -- Close the tag for all records
  • INSERT INTO #TmpText (docstr) (SELECT '</fuels>' + char(13))
  • -- Add a summa title
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<pricesSumma>' + char(13)
  • + CONVERT(varchar, CAST(@PRICESSUMMA AS money), 0)
  • + '</pricesSumma>' + char(13)
  • )
  • -- Close the tag for the client
  • INSERT INTO #TmpText (docstr) (SELECT '</client>' + char(13))
  • END
  • -- Specify the new current client identifier.
  • SET @CURRENT_CLIENTNAME = @CLIENTNAME
  • -- Open a tag for a client
  • INSERT INTO #TmpText (docstr) (SELECT '<client>' + char(13))
  • -- Add a client title
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<clientName>' + char(13)
  • + @CURRENT_CLIENTNAME
  • + '</clientName>' + char(13)
  • )
  • SET @PRICESSUMMA = 0
  • -- Open a tag for all records
  • INSERT INTO #TmpText (docstr) (SELECT '<fuels>' + char(13))
  • SET @FUELLITERS65 = 0
  • SET @FUELPRICES65 = 0
  • SET @FUELLITERS67 = 0
  • SET @FUELPRICES67 = 0
  • SET @FUELLITERS69 = 0
  • SET @FUELPRICES69 = 0
  • SET @FUELLITERS71 = 0
  • SET @FUELPRICES71 = 0
  • END -- END OF IF @CURRENT_CLIENTNAME <> @CLIENTNAME
  • -- Determine correct coupon fuel type and coupon face-value
  • IF @FUELTYPE = 65
  • BEGIN
  • SET @FUELLITERS65 = @TOTALVOLUME
  • SET @FUELPRICES65 = @TOTALPRICE
  • END
  • ELSE IF @FUELTYPE = 67
  • BEGIN
  • SET @FUELLITERS67 = @TOTALVOLUME
  • SET @FUELPRICES67 = @TOTALPRICE
  • END
  • ELSE IF @FUELTYPE = 69
  • BEGIN
  • SET @FUELLITERS69 = @TOTALVOLUME
  • SET @FUELPRICES69 = @TOTALPRICE
  • END
  • ELSE IF @FUELTYPE = 71
  • BEGIN
  • SET @FUELLITERS71 = @TOTALVOLUME
  • SET @FUELPRICES71 = @TOTALPRICE
  • END
  • FETCH NEXT FROM RecordsForAnalysis INTO @CLIENTNAME, @FUELTYPE, @QUANTITY, @TOTALPRICE, @TOTALVOLUME
  • END -- END OF WHILE
  • CLOSE RecordsForAnalysis
  • DEALLOCATE RecordsForAnalysis
  • IF @CURRENT_CLIENTNAME <> ''
  • BEGIN
  • -- Section to fill every record ---------------------------------
  • -- Open tag for a new record.
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel65>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters>' + char(13)+ CONVERT(varchar, CAST(@FUELLITERS65 AS money), 0) + '</fuelLiters>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelPrices>' + char(13)+ CONVERT(varchar, CAST(@FUELPRICES65 AS money), 0)+ '</fuelPrices>' + char(13))
  • -- Close tag for the new record.
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel65>' + char(13))
  • -- Open tag for a new record.
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel67>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters>' + char(13)+ CONVERT(varchar, CAST(@FUELLITERS67 AS money), 0) + '</fuelLiters>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelPrices>' + char(13)+ CONVERT(varchar, CAST(@FUELPRICES67 AS money), 0)+ '</fuelPrices>' + char(13))
  • -- Close tag for the new record.
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel67>' + char(13))
  • -- Open tag for a new record.
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel69>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters>' + char(13)+ CONVERT(varchar, CAST(@FUELLITERS69 AS money), 0) + '</fuelLiters>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelPrices>' + char(13)+ CONVERT(varchar, CAST(@FUELPRICES69 AS money), 0)+ '</fuelPrices>' + char(13))
  • -- Close tag for the new record.
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel69>' + char(13))
  • -- Open tag for a new record.
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel71>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters>' + char(13)+ CONVERT(varchar, CAST(@FUELLITERS71 AS money), 0) + '</fuelLiters>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelPrices>' + char(13)+ CONVERT(varchar, CAST(@FUELPRICES71 AS money), 0)+ '</fuelPrices>' + char(13))
  • -- Close tag for the new record.
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuel71>' + char(13))
  • SET @PRICESSUMMA = @FUELPRICES65 + @FUELPRICES67 + @FUELPRICES69 + @FUELPRICES71
  • -- Section to fill every record ---------------------------------
  • -- Close the tag for all records
  • INSERT INTO #TmpText (docstr) (SELECT '</fuels>' + char(13))
  • -- Add a summa title
  • INSERT INTO #TmpText (docstr)
  • (SELECT '<pricesSumma>' + char(13)
  • + CONVERT(varchar, CAST(@PRICESSUMMA AS money), 0)
  • + '</pricesSumma>' + char(13)
  • )
  • -- Close the tag for the client
  • INSERT INTO #TmpText (docstr) (SELECT '</client>' + char(13))
  • END
  • INSERT INTO #TmpText (docstr) (SELECT '<petrosoftData>' + char(13))
  • DECLARE @COUPONS65int -- Number of coupons 92 type
  • DECLARE @COUPONS67int -- Number of coupons 76 type
  • DECLARE @COUPONS69int -- Number of coupons 95 type
  • DECLARE @COUPONS71int -- Number of coupons DT type
  • -- PETROSOFT DATA: active number of coupons in the previous BDF database.
  • -- (WHERE cac.Number = chc.Number): 803 = 235 + 447 + 82 + 39
  • SET @COUPONS65 = 57799 + 447
  • SET @COUPONS67 = 27453 + 235
  • SET @COUPONS69 = 11465 + 82
  • SET @COUPONS71 = 10668 + 39
  • DECLARE @COUPONFUELTYPEvarchar(255) -- The fuel type of coupons.
  • DECLARE @COUPONNUMBERSint -- The quantity of these coupons.
  • DECLARE NumberOfCoupons CURSOR FOR
  • SELECT SUBSTRING( Number, 3, 1 ), COUNT( SUBSTRING( Number, 3, 1 ) )
  • FROM [dbo].[CouponAbnormalCancellation]
  • WHERE Number NOT IN ( SELECT Number FROM [dbo].[Coupon] )
  • GROUP BY SUBSTRING( Number, 3, 1 )
  • ORDER BY SUBSTRING( Number, 3, 1 )
  • OPEN NumberOfCoupons
  • FETCH NEXT FROM NumberOfCoupons INTO @COUPONFUELTYPE, @COUPONNUMBERS
  • WHILE @@FETCH_STATUS = 0
  • BEGIN
  • IF @COUPONFUELTYPE = 'A'
  • BEGIN
  • SET @COUPONS67 = (@COUPONS67 - @COUPONNUMBERS) * 20
  • END
  • ELSE IF @COUPONFUELTYPE = 'B'
  • BEGIN
  • SET @COUPONS65 = (@COUPONS65 - @COUPONNUMBERS) * 20
  • END
  • ELSE IF @COUPONFUELTYPE = 'C'
  • BEGIN
  • SET @COUPONS69 = (@COUPONS69 - @COUPONNUMBERS) * 20
  • END
  • ELSE IF @COUPONFUELTYPE = 'J'
  • BEGIN
  • SET @COUPONS71 = (@COUPONS71 - @COUPONNUMBERS) * 40
  • END
  • FETCH NEXT FROM NumberOfCoupons INTO @COUPONFUELTYPE, @COUPONNUMBERS
  • END -- END OF WHILE
  • CLOSE NumberOfCoupons
  • DEALLOCATE NumberOfCoupons
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters65>' + char(13) + CONVERT(varchar, CAST(@COUPONS65 AS money), 0))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuelLiters65>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters67>' + char(13) + CONVERT(varchar, CAST(@COUPONS67 AS money), 0))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuelLiters67>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters69>' + char(13) + CONVERT(varchar, CAST(@COUPONS69 AS money), 0))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuelLiters69>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '<fuelLiters71>' + char(13) + CONVERT(varchar, CAST(@COUPONS71 AS money), 0))
  • INSERT INTO #TmpText (docstr) (SELECT '</fuelLiters71>' + char(13))
  • INSERT INTO #TmpText (docstr) (SELECT '</petrosoftData>' + char(13))
  • -- Close the "clients" tag to declare the end of list of clients.
  • INSERT INTO #TmpText (docstr)
  • (SELECT '</clients>' + char(13))
  • INSERT INTO #TmpText (docstr)
  • (SELECT '</report>' + char(13))
  • --------------------------------------------------------------------------------------------------------------------
  • INSERT INTO #TmpText (docstr) VALUES('')
  • SELECT docstr FROM #TmpText ORDER BY ID
  • DROP TABLE #TmpText
  • DROP TABLE #TempTable
  • Размещено на Allbest.ru

    ...

    Подобные документы

    Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
    PPT, PPTX и PDF-файлы представлены только в архивах.
    Рекомендуем скачать работу.