-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmWorkers.pas
121 lines (103 loc) · 3.65 KB
/
frmWorkers.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
unit frmWorkers;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ClassSprForm, cxGraphics, cxControls,
cxLookAndFeels, cxLookAndFeelPainters, cxStyles, cxCustomData, cxFilter,
cxData, cxDataStorage, cxEdit, cxNavigator, Data.DB, cxDBData, cxGridLevel,
cxClasses, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxGrid, RzButton, Vcl.ExtCtrls, RzPanel, dxGDIPlusClasses,
cxLocalization, cxDBLookupComboBox, dxSkinsCore, dxSkinBlack, dxSkinBlue,
dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringTime, dxSkinStardust,
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinsDefaultPainters,
dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue,
dxSkinscxPCPainter;
type
TfrmWorkers = class(TSprForm)
GridViewColumn1: TcxGridDBColumn;
GridViewColumn2: TcxGridDBColumn;
GridViewColumn3: TcxGridDBColumn;
GridViewColumn4: TcxGridDBColumn;
GridViewColumn5: TcxGridDBColumn;
GridViewColumn6: TcxGridDBColumn;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
StyleHeader: TcxStyle;
procedure Add_btnClick(Sender: TObject);
procedure Edit_btnClick(Sender: TObject);
procedure Del_btnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure FilterRecord(DataSet: TDataSet; var Accept: Boolean);
public
{ Public declarations }
end;
var
formWorkers: TfrmWorkers;
implementation
{$R *.dfm}
uses
DM_Main, CommonVars, CommonTypes, frmWorker;
procedure TfrmWorkers.Add_btnClick(Sender: TObject);
var
prm: TFrmCreateParam;
begin
if not DM.Workers.Active then
DM.Workers.Open;
prm := NewFrmCreateParam(asCreate, DM.Workers);
formWorker := TfrmWorker.Create(self, '', @prm);
formWorker.ShowModal;
FreeAndNil(formWorker);
end;
procedure TfrmWorkers.Del_btnClick(Sender: TObject);
begin
try
// DM.Workers.Edit;
// DM.Workers.FieldByName('IS_DELETED').AsInteger := 1;
// DM.Workers.Post;
if MsgBoxQuestion('Âû äåéñòâèòåëüíî õîòèòå óäàëèòü ñîòðóäíèêà?') = idNo then
Exit;
DM.Workers.Delete;
DM.Workers.ApplyUpdates;
DM.Workers.Transaction.CommitRetaining;
finally
end;
end;
procedure TfrmWorkers.Edit_btnClick(Sender: TObject);
var
prm: TFrmCreateParam;
begin
if not DM.Workers.Active then
DM.Workers.Open;
prm := NewFrmCreateParam(asEdit, DM.Workers);
formWorker := TfrmWorker.Create(self, '', @prm);
formWorker.ShowModal;
FreeAndNil(formWorker);
end;
procedure TfrmWorkers.FilterRecord(DataSet: TDataSet; var Accept: Boolean);
begin
Accept := (DataSet.FieldByName('is_deleted').AsInteger = 0);
end;
procedure TfrmWorkers.FormCreate(Sender: TObject);
begin
inherited;
DM.Workers.OnFilterRecord := FilterRecord;
DM.Workers.Filtered := True;
end;
procedure TfrmWorkers.FormDestroy(Sender: TObject);
begin
DM.Workers.OnFilterRecord := nil;
DM.Workers.Filtered := False;
inherited;
end;
end.