Смекни!
smekni.com

Информационная система Data-центр (стр. 3 из 4)

Left = 38

Bottom = 123

Right = 207

End

DisplayFlags = 280

TopColumn = 3

End

End

End

Begin SQLPane =

End

Begin DataPane =

Begin ParameterDefaults = ""

End

End

Begin CriteriaPane =

Begin ColumnWidths = 11

Column = 1440

Alias = 900

Table = 1170

Output = 720

Append = 1400

NewValue = 1170

SortType = 1350

SortOrder = 1410

GroupBy = 1350

Filter = 1350

Or = 1350

Or = 1350

Or = 135',@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'VIEW', @level1name=N'PR_MASHIN'

GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane2', @value=N'0

End

End

End

',@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'VIEW', @level1name=N'PR_MASHIN'

GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=2,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'VIEW', @level1name=N'PR_MASHIN'

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[PR_DOGOVOR]'))

EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[PR_DOGOVOR]

AS

SELECT dbo.TB_KLIENTS.NAIM AS NAIM_KLIENT, dbo.TB_MASHIN.NAIM AS NAIM_MASH, dbo.TB_MASHIN.CENA, dbo.TB_DOGOVOR.Date_zakl,

dbo.TB_DOGOVOR.Date_okonch, dbo.TB_DOGOVOR.Stoimost

FROM dbo.TB_DOGOVOR INNER JOIN

dbo.TB_KLIENTS ON dbo.TB_DOGOVOR.ID_KLIENT = dbo.TB_KLIENTS.ID_KLIENT INNER JOIN

dbo.TB_MASHIN ON dbo.TB_DOGOVOR.ID_MASHIN = dbo.TB_MASHIN.ID_MASHIN

'

GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]

Begin DesignProperties =

Begin PaneConfigurations =

Begin PaneConfiguration = 0

NumPanes = 4

Configuration = "(H (1[40] 4[20] 2[20] 3))"

End

Begin PaneConfiguration = 1

NumPanes = 3

Configuration = "(H (1 [50] 4 [25] 3))"

End

Begin PaneConfiguration = 2

NumPanes = 3

Configuration = "(H (1 [50] 2 [25] 3))"

End

Begin PaneConfiguration = 3

NumPanes = 3

Configuration = "(H (4 [30] 2 [40] 3))"

End

Begin PaneConfiguration = 4

NumPanes = 2

Configuration = "(H (1 [56] 3))"

End

Begin PaneConfiguration = 5

NumPanes = 2

Configuration = "(H (2 [66] 3))"

End

Begin PaneConfiguration = 6

NumPanes = 2

Configuration = "(H (4 [50] 3))"

End

Begin PaneConfiguration = 7

NumPanes = 1

Configuration = "(V (3))"

End

Begin PaneConfiguration = 8

NumPanes = 3

Configuration = "(H (1[56] 4[18] 2))"

End

Begin PaneConfiguration = 9

NumPanes = 2

Configuration = "(H (1 [75] 4))"

End

Begin PaneConfiguration = 10

NumPanes = 2

Configuration = "(H (1[66] 2))"

End

Begin PaneConfiguration = 11

NumPanes = 2

Configuration = "(H (4 [60] 2))"

End

Begin PaneConfiguration = 12

NumPanes = 1

Configuration = "(H (1))"

End

Begin PaneConfiguration = 13

NumPanes = 1

Configuration = "(V (4))"

End

Begin PaneConfiguration = 14

NumPanes = 1

Configuration = "(V (2))"

End

ActivePaneConfig = 0

End

Begin DiagramPane =

Begin Origin =

Top = 0

Left = 0

End

Begin Tables =

Begin Table = "TB_MASHIN"

Begin Extent =

Top = 6

Left = 38

Bottom = 123

Right = 207

End

DisplayFlags = 280

TopColumn = 3

End

Begin Table = "TB_KLIENTS"

Begin Extent =

Top = 6

Left = 245

Bottom = 108

Right = 414

End

DisplayFlags = 280

TopColumn = 0

End

Begin Table = "TB_DOGOVOR"

Begin Extent =

Top = 6

Left = 452

Bottom = 123

Right = 621

End

DisplayFlags = 280

TopColumn = 0

End

End

End

Begin SQLPane =

End

Begin DataPane =

Begin ParameterDefaults = ""

End

End

Begin CriteriaPane =

Begin ColumnWidths = 11

Column = 1440

Alias = 900

Table = 1170

Output = 720

Append = 1400

NewValue = 1170

SortType = 1350

SortOrder = 1410

GroupBy = 1350

Filter = 1350

Or = 1350

Or = 1350

Or = 1350

End

End

End

',@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'VIEW', @level1name=N'PR_DOGOVOR'

GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'VIEW', @level1name=N'PR_DOGOVOR'

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PPoisk]') AND type in (N'P', N'PC'))

BEGIN

EXEC dbo.sp_executesql @statement = N'-- -- Author:<Author,,Name>

-- Create date: <Create Date,,>

-- Description:<Description,,>

CREATE PROCEDURE [dbo].[PPoisk]

@p CHAR(10)

AS

BEGIN

SELECT NAIM_MASH, NAIM_MEM, NAIM_SPEED, NAIM_PROC, NAIM_HDD, CENA

FROM PR_MASHIN

WHERE (NAIM_SPEED = @p)

END

'

END

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TB_MASHIN_TB_HDD]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_MASHIN]'))

ALTER TABLE [dbo].[TB_MASHIN] WITH CHECK ADD CONSTRAINT [FK_TB_MASHIN_TB_HDD] FOREIGN KEY([ID_HDD])

REFERENCES [dbo].[TB_HDD] ([ID_HDD])

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TB_MASHIN_TB_MEM]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_MASHIN]'))

ALTER TABLE [dbo].[TB_MASHIN] WITH CHECK ADD CONSTRAINT [FK_TB_MASHIN_TB_MEM] FOREIGN KEY([ID_MEM])

REFERENCES [dbo].[TB_MEM] ([ID_MEM])

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TB_MASHIN_TB_PROC]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_MASHIN]'))

ALTER TABLE [dbo].[TB_MASHIN] WITH CHECK ADD CONSTRAINT [FK_TB_MASHIN_TB_PROC] FOREIGN KEY([ID_PROC])

REFERENCES [dbo].[TB_PROC] ([ID_PROC])

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TB_MASHIN_TB_SPEED]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_MASHIN]'))

ALTER TABLE [dbo].[TB_MASHIN] WITH CHECK ADD CONSTRAINT [FK_TB_MASHIN_TB_SPEED] FOREIGN KEY([ID_SPEED])

REFERENCES [dbo].[TB_SPEED] ([ID_SPEED])

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TB_DOGOVOR_TB_KLIENTS]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_DOGOVOR]'))

ALTER TABLE [dbo].[TB_DOGOVOR] WITH CHECK ADD CONSTRAINT [FK_TB_DOGOVOR_TB_KLIENTS] FOREIGN KEY([ID_KLIENT])

REFERENCES [dbo].[TB_KLIENTS] ([ID_KLIENT])

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TB_DOGOVOR_TB_MASHIN]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_DOGOVOR]'))

ALTER TABLE [dbo].[TB_DOGOVOR] WITH CHECK ADD CONSTRAINT [FK_TB_DOGOVOR_TB_MASHIN] FOREIGN KEY([ID_MASHIN])

REFERENCES [dbo].[TB_MASHIN] ([ID_MASHIN])

3.1.2 Клиентское приложение

unit UnitMain;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, DBGrids, Menus, ExtCtrls, DBCtrls, StdCtrls;

type

TFRMMain = class(TForm)

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N11: TMenuItem;

N21: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

N9: TMenuItem;

N10: TMenuItem;

N12: TMenuItem;

N13: TMenuItem;

N14: TMenuItem;

N15: TMenuItem;

N16: TMenuItem;

DBGrid1: TDBGrid;

procedure N10Click(Sender: TObject);

procedure N9Click(Sender: TObject);

procedure N7Click(Sender: TObject);

procedure N8Click(Sender: TObject);

procedure N12Click(Sender: TObject);

procedure N6Click(Sender: TObject);

procedure N15Click(Sender: TObject);

procedure N16Click(Sender: TObject);

procedure N5Click(Sender: TObject);

procedure N13Click(Sender: TObject);

procedure N14Click(Sender: TObject);

procedure N11Click(Sender: TObject);

procedure N21Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

FRMMain: TFRMMain;

implementation

uses UnitDM, UnitSprav, UnitTable;

{$R *.dfm}

procedure TFRMMain.N7Click(Sender: TObject);

begin

FRMSPRAV.DBGrid1.DataSource:=DM.DS_KLIENT;

FRMSPRAV.DBNavigator1.DataSource:=DM.DS_KLIENT;

FRMSPRAV.Caption:='Клиенты';

FRMSPRAV.Show;

end;

procedure TFRMMain.N8Click(Sender: TObject);

begin

FRMSPRAV.DBGrid1.DataSource:=DM.DS_PROC;

FRMSPRAV.DBNavigator1.DataSource:=DM.DS_PROC;

FRMSPRAV.Caption:='Процессоры';

FRMSPRAV.Show;

end;

procedure TFRMMain.N9Click(Sender: TObject);

begin

FRMSPRAV.DBGrid1.DataSource:=DM.DS_HDD;

FRMSPRAV.DBNavigator1.DataSource:=DM.DS_HDD;

FRMSPRAV.Caption:='Жесткие диски';

FRMSPRAV.Show;

end;

procedure TFRMMain.N10Click(Sender: TObject);

begin

FRMSPRAV.DBGrid1.DataSource:=DM.DS_MEM;

FRMSPRAV.DBNavigator1.DataSource:=DM.DS_MEM;

FRMSPRAV.Show;

FRMSPRAV.Caption:='Память';

end;

procedure TFRMMain.N11Click(Sender: TObject);

begin

FRMTable.Label1.Caption:=('Введите название машины');

FRMTable.DBGrid1.DataSource:=DM.DSQ_Dogovor;

FRMTable.ClientHeight:=211;

FRMTable.Show;

FRMTable.Panel1.Visible:=false;

FRMTable.Panel2.Visible:=true;

FRMTable.Caption:='Поиск арендаторов';

end;

procedure TFRMMain.N12Click(Sender: TObject);

begin

FRMSPRAV.DBGrid1.DataSource:=DM.DS_SPEED;

FRMSPRAV.DBNavigator1.DataSource:=DM.DS_SPEED;

FRMSPRAV.Show;

FRMSPRAV.Caption:='Скорость';

end;

procedure TFRMMain.N13Click(Sender: TObject);

begin

FRMTable.DBGrid1.DataSource:=DM.DSv_DOGOVOR;

FRMTable.Show;

FRMTable.ClientHeight:=169;

FRMTable.Caption:='Договора';

end;

procedure TFRMMain.N14Click(Sender: TObject);

begin

FRMTable.DBGrid1.DataSource:=DM.DSV_MASHINS;

FRMTable.Show;

FRMTable.ClientHeight:=169;

FRMTable.Caption:='Прайс-лист';

end;

procedure TFRMMain.N15Click(Sender: TObject);

begin

FRMTable.DBGrid1.DataSource:=DM.DS_DOGOVOR;

FRMTable.ClientHeight:=211;

FRMTable.Show;

FRMTable.Panel1.Visible:=true;

FRMTable.Panel2.Visible:=false;

FRMTable.Caption:='Договора';

end;

procedure TFRMMain.N16Click(Sender: TObject);

begin

FRMTable.DBGrid1.DataSource:=DM.DS_MASHIN;

FRMTable.ClientHeight:=211;

FRMTable.Show;

FRMTable.Panel1.Visible:=true;

FRMTable.Panel2.Visible:=false;

FRMTable.Caption:='Прайс-лист';

end;

procedure TFRMMain.N21Click(Sender: TObject);

begin

FRMTable.Label1.Caption:=('Введите требуемый объем памяти');

FRMTable.DBGrid1.DataSource:=DM.DSP_Poisk;

FRMTable.ClientHeight:=211;

FRMTable.Show;

FRMTable.Panel1.Visible:=false;

FRMTable.Panel2.Visible:=true;

FRMTable.Caption:='Поиск машины';

end;

procedure TFRMMain.N5Click(Sender: TObject);

begin

DM.RvDogovora.Execute;

end;

procedure TFRMMain.N6Click(Sender: TObject);

begin

close;

end;

end.

unit UnitDM;

interface

uses

SysUtils, Classes, DB, ADODB, RpCon, RpConDS, RpDefine, RpRave, RpRender,

RpRenderCanvas, RpRenderPreview, DBClient;

type

TDM = class(TDataModule)

T_KLIENTS: TADOTable;

T_DOGOVOR: TADOTable;

T_MASHIN: TADOTable;

T_SPEED: TADOTable;

T_MEM: TADOTable;

T_HDD: TADOTable;

T_PROC: TADOTable;

DS_DOGOVOR: TDataSource;

DS_MASHIN: TDataSource;

DS_SPEED: TDataSource;

DS_MEM: TDataSource;

DS_HDD: TDataSource;

DS_PROC: TDataSource;

DS_KLIENT: TDataSource;

ADOConnection1: TADOConnection;

T_HDDID_HDD: TAutoIncField;

T_HDDNAIM: TWideStringField;

T_HDDHARACT: TWideStringField;

T_PROCID_PROC: TAutoIncField;

T_PROCNAIM: TWideStringField;

T_PROCHARACT: TWideStringField;

T_MEMID_MEM: TAutoIncField;

T_MEMNAIM: TWideStringField;

T_MEMHARACT: TWideStringField;

T_KLIENTSID_KLIENT: TAutoIncField;

T_KLIENTSNAIM: TWideStringField;

T_SPEEDID_SPEED: TAutoIncField;

T_SPEEDNAIM: TWideStringField;

T_SPEEDHARACT: TWideStringField;

RvDogovora: TRvProject;

RvDogovor: TRvDataSetConnection;

TV_DOGOVOR: TADOTable;

DSV_DOGOVOR: TDataSource;

TV_MASHINS: TADOTable;

DSV_MASHINS: TDataSource;

TV_MASHINSNAIM_MASH: TWideStringField;

TV_MASHINSNAIM_MEM: TWideStringField;

TV_MASHINSNAIM_SPEED: TWideStringField;

TV_MASHINSNAIM_PROC: TWideStringField;

TV_MASHINSNAIM_HDD: TWideStringField;

TV_MASHINSCENA: TFloatField;

TV_DOGOVORNAIM_MASH: TWideStringField;

TV_DOGOVORCENA: TFloatField;

TV_DOGOVORDate_zakl: TDateTimeField;

TV_DOGOVORDate_okonch: TDateTimeField;

TV_DOGOVORStoimost: TFloatField;

TV_DOGOVORNAIM_KLIENT: TWideStringField;

QP_Dogovor: TADOQuery;

DSQ_Dogovor: TDataSource;

P_Poisk: TADOStoredProc;

DSP_Poisk: TDataSource;

T_KLIENTSHARACT: TWideStringField;

T_DOGOVORID_DOGOVOR: TAutoIncField;

T_DOGOVORID_KLIENT: TIntegerField;

T_DOGOVORID_MASHIN: TIntegerField;

T_DOGOVORDate_zakl: TDateTimeField;

T_DOGOVORDate_okonch: TDateTimeField;

T_DOGOVORStoimost: TFloatField;

T_MASHINID_MASHIN: TAutoIncField;

T_MASHINID_PROC: TIntegerField;

T_MASHINID_HDD: TIntegerField;

T_MASHINID_MEM: TIntegerField;

T_MASHINID_SPEED: TIntegerField;

T_MASHINNAIM: TWideStringField;

T_MASHINCENA: TFloatField;

QP_DogovorNAIM_KLIENT: TWideStringField;

QP_DogovorNAIM_MASH: TWideStringField;

QP_DogovorCENA: TFloatField;

QP_DogovorDate_zakl: TDateTimeField;

QP_DogovorDate_okonch: TDateTimeField;

QP_DogovorStoimost: TFloatField;

P_PoiskNAIM_MASH: TWideStringField;

P_PoiskNAIM_MEM: TWideStringField;

P_PoiskNAIM_SPEED: TWideStringField;

P_PoiskNAIM_PROC: TWideStringField;

P_PoiskNAIM_HDD: TWideStringField;

P_PoiskCENA: TFloatField;

procedure T_DOGOVORCalcFields(DataSet: TDataSet);

private

{ Private declarations }

public

{ Public declarations }

end;

var

DM: TDM;

implementation

uses UnitMain;

{$R *.dfm}

procedure TDM.T_DOGOVORCalcFields(DataSet: TDataSet);

begin

T_Dogovor.Fields[5].AsFloat:=round(T_Dogovor.Fields[4].AsDateTime-T_Dogovor.Fields[3].AsDateTime)*(T_Mashin.Fields[6].AsInteger/30);

end;

end.

unit UnitTable;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, DBGrids, StdCtrls, ExtCtrls;

type

TFRMTable = class(TForm)

DBGrid1: TDBGrid;

Panel1: TPanel;

Button3: TButton;

Button2: TButton;

Button1: TButton;

Panel2: TPanel;

Edit1: TEdit;

Button4: TButton;

Label1: TLabel;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

FRMTable: TFRMTable;

implementation

uses UnitDM, UnitAdd;

{$R *.dfm}

procedure set_add_form_dogovor;

begin

FRMAdd.DBLookupComboBoxD1.Visible:=true;

FRMAdd.DBLookupComboBoxD2.Visible:=true;

FRMAdd.DBEditD1.Visible:=true;

FRMAdd.DBEditD2.Visible:=true;

FRMAdd.DBLookupComboBoxM1.Visible:=false;

FRMAdd.DBLookupComboBoxM2.Visible:=false;