Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Курсовая работа / Учет материалов на производство (1).docx
Скачиваний:
41
Добавлен:
29.05.2017
Размер:
779.72 Кб
Скачать

Приложение

unit udmMain;

interface

uses

SysUtils, Classes, DB, ADODB;

type

TdmMain = class(TDataModule)

adocDB: TADOConnection;

adotDocPrihod: TADOTable;

dsDocPrihod: TDataSource;

adotDocSpisanie: TADOTable;

dsDocSpisanie: TDataSource;

adotMat: TADOTable;

dsMat: TDataSource;

adotSklad: TADOTable;

dsSklad: TDataSource;

adotDocPrihodAutoIncField: TAutoIncField;

adotDocPrihodDateTimeField: TDateTimeField;

adotDocPrihodIntegerField: TIntegerField;

adotDocPrihodIntegerField2: TWideStringField;

adotTabPrihod: TADOTable;

dsTabPrihod: TDataSource;

adotTabPrihodIntegerField2: TIntegerField;

adotTabPrihodFloatField: TFloatField;

adotTabPrihodFloatField2: TFloatField;

adotTabPrihodIntegerField3: TWideStringField;

adotNSI: TADOTable;

dsNSI: TDataSource;

adotTabSpisanie: TADOTable;

dsTabSpisanie: TDataSource;

adotDocSpisanieAutoIncField: TAutoIncField;

adotDocSpisanieDateTimeField: TDateTimeField;

adotDocSpisanieIntegerField: TIntegerField;

adotDocSpisanieIntegerField2: TIntegerField;

adotDocSpisanieIntegerField3: TIntegerField;

adotDocSpisanieIntegerField4: TIntegerField;

adotDocSpisanieIntegerField5: TWideStringField;

adotPodrazd: TADOTable;

adotNomGrup: TADOTable;

adotStatiya: TADOTable;

dsPodrazd: TDataSource;

dsNomGrup: TDataSource;

dsStatiya: TDataSource;

adotDocSpisanieIntegerField6: TWideStringField;

adotDocSpisanieWideStringField: TWideStringField;

adotDocSpisanieIntegerField7: TWideStringField;

adotTabSpisanieIntegerField: TIntegerField;

adotTabSpisanieIntegerField2: TIntegerField;

adotTabSpisanieFloatField: TFloatField;

adotTabSpisanieIntegerField3: TWideStringField;

adotNSIAutoIncField: TAutoIncField;

adotNSIWideStringField: TWideStringField;

adospMatVed: TADOStoredProc;

dsMatVed: TDataSource;

adotTabPrihodIntegerField: TIntegerField;

adospMatVedWideStringField: TWideStringField;

adospMatVedWideStringField2: TWideStringField;

adospMatVedFloatField: TFloatField;

adospMatVedFloatField2: TFloatField;

adospMatVedField: TWideStringField;

adospMatVedFloatField3: TWideStringField;

procedure adospMatVedCalcFields(DataSet: TDataSet);

procedure DataModuleCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

dmMain: TdmMain;

implementation

{$R *.dfm}

procedure TdmMain.adospMatVedCalcFields(DataSet: TDataSet);

begin

DataSet.FieldByName('ПриходС').AsString := FloatToStr(DataSet.FieldByName('Приход').AsFloat);

DataSet.FieldByName('РасходС').AsString := FloatToStr(DataSet.FieldByName('Расход').AsFloat);

end;

procedure TdmMain.DataModuleCreate(Sender: TObject);

begin

adocDB.Open;

adotDocPrihod.Open;

adotDocSpisanie.Open;

adotMat.Open;

adotSklad.Open;

adotTabPrihod.Open;

adotTabSpisanie.Open;

adotPodrazd.Open;

adotNomGrup.Open;

adotStatiya.Open;

end;

end.

unit ufmMain;

interface

uses

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

Dialogs, Menus, ComCtrls, ToolWin, ActnList, ImgList, ExtCtrls, DBCtrls,

Grids, DBGrids, StdCtrls, StdActns, XPMan;

type

TfmMain = class(TForm)

ActionList1: TActionList;

MainMenu1: TMainMenu;

ImageList1: TImageList;

Splitter1: TSplitter;

Panel1: TPanel;

Panel2: TPanel;

Panel3: TPanel;

Panel4: TPanel;

dbnPrihod: TDBNavigator;

dbnSpisanie: TDBNavigator;

dbgPrihod: TDBGrid;

dbgSpisanie: TDBGrid;

Panel5: TPanel;

Bevel1: TBevel;

Label1: TLabel;

Panel6: TPanel;

Bevel2: TBevel;

Label2: TLabel;

ActionExit: TFileExit;

N1: TMenuItem;

Exit1: TMenuItem;

ActionSclad: TAction;

ActionPodrazd: TAction;

ActionNomGrup: TAction;

ActionMat: TAction;

ActionStatiya: TAction;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

ActionMatVed: TAction;

N9: TMenuItem;

XPManifest1: TXPManifest;

procedure dbgPrihodDblClick(Sender: TObject);

procedure dbnPrihodClick(Sender: TObject; Button: TNavigateBtn);

procedure dbgSpisanieDblClick(Sender: TObject);

procedure dbnSpisanieClick(Sender: TObject; Button: TNavigateBtn);

procedure ActionMatExecute(Sender: TObject);

procedure ActionScladExecute(Sender: TObject);

procedure ActionPodrazdExecute(Sender: TObject);

procedure ActionNomGrupExecute(Sender: TObject);

procedure ActionStatiyaExecute(Sender: TObject);

procedure ActionMatVedExecute(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

fmMain: TfmMain;

implementation

uses

udmMain, ufmPrihod, ufmSpisanie, ufmNSI, ufmMatVed;

{$R *.dfm}

procedure TfmMain.ActionMatExecute(Sender: TObject);

begin

ShowNSIForm('Материалы', 'Материалы');

end;

procedure TfmMain.ActionMatVedExecute(Sender: TObject);

begin

fmMatVed := TfmMatVed.Create(Application);

fmMatVed.ShowModal;

fmMatVed.Free;

end;

procedure TfmMain.ActionNomGrupExecute(Sender: TObject);

begin

ShowNSIForm('НоменклатурныеГруппы', 'Номенклатурные группы');

end;

procedure TfmMain.ActionPodrazdExecute(Sender: TObject);

begin

ShowNSIForm('Подразделения', 'Подразделения');

end;

procedure TfmMain.ActionScladExecute(Sender: TObject);

begin

ShowNSIForm('Склады', 'Склады');

end;

procedure TfmMain.ActionStatiyaExecute(Sender: TObject);

begin

ShowNSIForm('СтатьиЗатрат', 'Статьи затрат');

end;

procedure TfmMain.dbgPrihodDblClick(Sender: TObject);

begin

fmPrihod := TfmPrihod.Create(Application);

fmPrihod.ShowModal;

fmPrihod.Free;

end;

procedure TfmMain.dbgSpisanieDblClick(Sender: TObject);

begin

fmSpisanie := TfmSpisanie.Create(Application);

fmSpisanie.ShowModal;

fmSpisanie.Free;

end;

procedure TfmMain.dbnSpisanieClick(Sender: TObject; Button: TNavigateBtn);

begin

if Button in [nbEdit, nbInsert] then

dbgSpisanieDblClick(Sender);

end;

procedure TfmMain.dbnPrihodClick(Sender: TObject; Button: TNavigateBtn);

begin

if Button in [nbEdit, nbInsert] then

dbgPrihodDblClick(Sender);

end;

end.

unit ufmNSI;

interface

uses

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

Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, Buttons, ActnList;

type

TfmNSI = class(TForm)

DBGrid1: TDBGrid;

DBNavigator1: TDBNavigator;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

BitBtn3: TBitBtn;

ActionList1: TActionList;

ActionOK: TAction;

ActionSave: TAction;

ActionClose: TAction;

procedure ActionOKExecute(Sender: TObject);

procedure ActionSaveExecute(Sender: TObject);

procedure ActionCloseExecute(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

procedure ShowNSIForm(TableName, FormName: string);

var

fmNSI: TfmNSI;

implementation

uses

DB, udmMain;

{$R *.dfm}

procedure ShowNSIForm(TableName, FormName: string);

begin

with dmMain do

begin

adotNSI.TableName := TableName;

adotNSI.Open;

fmNSI := TfmNSI.Create(Application);

fmNSI.Caption := FormName;

fmNSI.ShowModal;

fmNSI.Free;

adotNSI.Close;

end;

end;

procedure TfmNSI.ActionCloseExecute(Sender: TObject);

begin

with dmMain do

if adotNSI.State in [dsInsert, dsEdit] then

if MessageDlg('Справочник изменен. Записать?',

mtConfirmation, mbYesNoCancel, -1) = mrYes then

adotNSI.Post

else

adotNSI.Cancel;

Close;

end;

procedure TfmNSI.ActionOKExecute(Sender: TObject);

begin

ActionSaveExecute(Sender);

Close;

end;

procedure TfmNSI.ActionSaveExecute(Sender: TObject);

begin

with dmMain do

begin

if adotNSI.State in [dsInsert, dsEdit] then

adotNSI.Post;

end;

end;

end.

unit ufmPrihod;

interface

uses

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

Dialogs, StdCtrls, Mask, DBCtrls, Buttons, Grids, DBGrids, ExtCtrls, ActnList,

ComCtrls;

type

TfmPrihod = class(TForm)

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

DBEdit1: TDBEdit;

DBLookupComboBox1: TDBLookupComboBox;

BitBtn1: TBitBtn;

DBGrid1: TDBGrid;

DBNavigator1: TDBNavigator;

BitBtn3: TBitBtn;

ActionList1: TActionList;

ActionOK: TAction;

ActionSave: TAction;

ActionClose: TAction;

dtpDate: TDateTimePicker;

BitBtn2: TBitBtn;

procedure ActionSaveExecute(Sender: TObject);

procedure ActionCloseExecute(Sender: TObject);

procedure ActionOKExecute(Sender: TObject);

procedure dtpDateChange(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

private

{ Private declarations }

public

{ Public declarations }

end;

var

fmPrihod: TfmPrihod;

implementation

uses

DB, udmMain;

{$R *.dfm}

procedure TfmPrihod.ActionCloseExecute(Sender: TObject);

begin

Close;

end;

procedure TfmPrihod.ActionOKExecute(Sender: TObject);

begin

ActionSaveExecute(Sender);

Close;

end;

procedure TfmPrihod.ActionSaveExecute(Sender: TObject);

begin

with dmMain do

begin

if adotDocPrihod.State in [dsInsert, dsEdit] then

adotDocPrihod.Post;

if adotTabPrihod.State in [dsInsert, dsEdit] then

adotTabPrihod.Post;

end;

end;

procedure TfmPrihod.dtpDateChange(Sender: TObject);

begin

with dmMain do

begin

if not (adotDocPrihod.State in [dsInsert, dsEdit]) then

adotDocPrihod.Edit;

adotDocPrihod.FieldByName('Äàòà').AsDateTime := dtpDate.DateTime;

end;

end;

procedure TfmPrihod.FormClose(Sender: TObject; var Action: TCloseAction);

var

SaveDoc, SaveTab: Boolean;

begin

with dmMain do

begin

SaveDoc := adotDocPrihod.State in [dsInsert, dsEdit];

SaveTab := adotTabPrihod.State in [dsInsert, dsEdit];

if SaveDoc or SaveTab then

if MessageDlg('Документ изменен. Записать?',mtConfirmation, mbYesNoCancel, -1) = mrYes then

begin

if SaveDoc then

adotDocPrihod.Post;

if SaveTab then

adotTabPrihod.Post;

end else begin

if SaveDoc then

adotDocPrihod.Cancel;

if SaveTab then

adotTabPrihod.Cancel;

end;

end;

end;

procedure TfmPrihod.FormCreate(Sender: TObject);

begin

with dmMain do

case adotDocPrihod.State of

dsInsert:

begin

dtpDate.DateTime := Now;

adotDocPrihod.FieldByName('Äàòà').AsDateTime := dtpDate.DateTime;

adotDocPrihod.Post;

end;

dsEdit:

dtpDate.DateTime := adotDocPrihod.FieldByName('Äàòà').AsDateTime;

else

if adotDocPrihod.FieldByName('Номер').AsInteger = 0 then

begin

dtpDate.DateTime := Now;

adotDocPrihod.Insert;

adotDocPrihod.FieldByName('Äàòà').AsDateTime := dtpDate.DateTime;

adotDocPrihod.Post;

end else

dtpDate.DateTime := adotDocPrihod.FieldByName('Äàòà').AsDateTime;

end;

end;

end.

unit ufmSpisanie;

interface

uses

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

Dialogs, StdCtrls, Mask, DBCtrls, ComCtrls, Grids, DBGrids, ActnList, Buttons,

ExtCtrls;

type

TfmSpisanie = class(TForm)

Label1: TLabel;

DBEdit1: TDBEdit;

Label2: TLabel;

dtpDate: TDateTimePicker;

DBLookupComboBox1: TDBLookupComboBox;

Label3: TLabel;

DBLookupComboBox2: TDBLookupComboBox;

Label4: TLabel;

DBLookupComboBox3: TDBLookupComboBox;

DBLookupComboBox4: TDBLookupComboBox;

Label5: TLabel;

Label6: TLabel;

DBGrid1: TDBGrid;

ActionList1: TActionList;

ActionOK: TAction;

ActionSave: TAction;

ActionClose: TAction;

DBNavigator1: TDBNavigator;

BitBtn1: TBitBtn;

BitBtn3: TBitBtn;

BitBtn2: TBitBtn;

procedure ActionOKExecute(Sender: TObject);

procedure ActionSaveExecute(Sender: TObject);

procedure ActionCloseExecute(Sender: TObject);

procedure dtpDateChange(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

private

{ Private declarations }

public

{ Public declarations }

end;

var

fmSpisanie: TfmSpisanie;

implementation

uses

DB, udmMain;

{$R *.dfm}

procedure TfmSpisanie.ActionCloseExecute(Sender: TObject);

begin

Close;

end;

procedure TfmSpisanie.ActionOKExecute(Sender: TObject);

begin

ActionSaveExecute(Sender);

Close;

end;

procedure TfmSpisanie.ActionSaveExecute(Sender: TObject);

begin

with dmMain do

begin

if adotDocSpisanie.State in [dsInsert, dsEdit] then

adotDocSpisanie.Post;

if adotTabSpisanie.State in [dsInsert, dsEdit] then

adotTabSpisanie.Post;

end;

end;

procedure TfmSpisanie.dtpDateChange(Sender: TObject);

begin

with dmMain do

begin

if not (adotDocSpisanie.State in [dsInsert, dsEdit]) then

adotDocSpisanie.Edit;

adotDocSpisanie.FieldByName('Äàòà').AsDateTime := dtpDate.DateTime;

end;

end;

procedure TfmSpisanie.FormClose(Sender: TObject; var Action: TCloseAction);

var

SaveDoc, SaveTab: Boolean;

begin

with dmMain do

begin

SaveDoc := adotDocSpisanie.State in [dsInsert, dsEdit];

SaveTab := adotTabSpisanie.State in [dsInsert, dsEdit];

if SaveDoc or SaveTab then

if MessageDlg('Документ изменен. Записать?',

mtConfirmation, mbYesNoCancel, -1) = mrYes then

begin

if SaveDoc then

adotDocSpisanie.Post;

if SaveTab then

adotTabSpisanie.Post;

end else begin

if SaveDoc then

adotDocSpisanie.Cancel;

if SaveTab then

adotTabSpisanie.Cancel;

end;

end;

end;

procedure TfmSpisanie.FormCreate(Sender: TObject);

begin

with dmMain do

case adotDocSpisanie.State of

dsInsert:

begin

dtpDate.DateTime := Now;

adotDocSpisanie.FieldByName('Äàòà').AsDateTime := dtpDate.DateTime;

adotDocSpisanie.Post;

end;

dsEdit:

dtpDate.DateTime := adotDocSpisanie.FieldByName('Äàòà').AsDateTime;

else

if adotDocSpisanie.FieldByName('Номер').AsInteger = 0 then

begin

dtpDate.DateTime := Now;

adotDocSpisanie.Insert;

adotDocSpisanie.FieldByName('Äàòà').AsDateTime := dtpDate.DateTime;

adotDocSpisanie.Post;

end else

dtpDate.DateTime := adotDocSpisanie.FieldByName('Äàòà').AsDateTime;

end;

end;

end.

unit ufmMatVed;

interface

uses

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

Dialogs, RpBase, RpSystem, RpDefine, RpRave, StdCtrls, Buttons, ComCtrls,

RpCon, RpConDS;

type

TfmMatVed = class(TForm)

RvProject: TRvProject;

RvSystem: TRvSystem;

bbtnStart: TBitBtn;

dtpBegin: TDateTimePicker;

dtpEnd: TDateTimePicker;

Label1: TLabel;

Label2: TLabel;

RvDataSetConnection: TRvDataSetConnection;

procedure bbtnStartClick(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

fmMatVed: TfmMatVed;

implementation

uses

udmMain;

{$R *.dfm}

procedure TfmMatVed.bbtnStartClick(Sender: TObject);

var

DBegin, DEnd : TDateTime;

Year, Month, Day: Word;

begin

with dmMain do

begin

DecodeDate(dtpBegin.DateTime, Year, Month, Day);

DBegin := EncodeDate(Year, Month, Day);

DecodeDate(dtpEnd.DateTime, Year, Month, Day);

DEnd := EncodeDate(Year, Month, Day) + EncodeTime(23, 59, 59, 999);

adospMatVed.Parameters.FindParam('ПериодС').Value := DBegin;

adospMatVed.Parameters.FindParam('ПериодПо').Value := DEnd;

adospMatVed.Open;

RvProject.Open;

RvProject.SelectReport('RaveProject', False);

RvProject.Execute;

RvProject.Close;

adospMatVed.Close;

end;

end;

procedure TfmMatVed.FormCreate(Sender: TObject);

begin

RvProject.ProjectFile := ChangeFileExt(ParamStr(0), '.rav');

dtpBegin.DateTime := Now;

dtpEnd.DateTime := dtpBegin.DateTime;

end;

end.

Соседние файлы в папке Курсовая работа