PageRenderTime 25ms CodeModel.GetById 22ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/HRManager/__history/CONJUCTIONEDITUnit.pas.~10~

https://github.com/oista/NPO
Unknown | 216 lines | 187 code | 29 blank | 0 comment | 0 complexity | 2511da78a90b61cd8b2bba0bd229df90 MD5 | raw file
  1unit CONJUCTIONEDITUnit;
  2
  3interface
  4
  5uses
  6  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7  Dialogs, EditDialogUnit, StdCtrls, ExtCtrls, PKDBDictEdit, PKDBTable, ComCtrls,
  8  PKDBEdit, PKDBBBaseComboBox, dictunit, uADStanIntf, uADStanOption,
  9  uADStanParam, uADStanError, uADDatSManager, uADPhysIntf, uADDAptIntf,
 10  uADStanAsync, uADDAptManager, DB, uADCompDataSet, uADCompClient,reportunit;
 11
 12type
 13  TCONJUCTIONEDIT = class(TEditDialog)
 14    PKDBDictEdit1: TPKDBDictEdit;
 15    PKDBDictEdit2: TPKDBDictEdit;
 16    Label1: TLabel;
 17    Label2: TLabel;
 18    PKDBLabelEdit3: TPKDBLabelEdit;
 19    PKDBLabelEdit4: TPKDBLabelEdit;
 20    PKDBLabelEdit5: TPKDBLabelEdit;
 21    PKDBTable2: TPKDBTable;
 22    ADQuery1: TADQuery;
 23    ADQuery1WORKCONTRACTID: TFMTBCDField;
 24    GroupBox2: TGroupBox;
 25    Label3: TLabel;
 26    PKDBLabelEdit2: TPKDBLabelEdit;
 27    PKDBLabelEdit1: TPKDBLabelEdit;
 28    PKDBLabelEdit6: TPKDBLabelEdit;
 29    PKDBLabelEdit7: TPKDBLabelEdit;
 30    PKDBLabelEdit8: TPKDBLabelEdit;
 31    PKDBBaseEdit1: TPKDBBaseEdit;
 32    PKDBBLabelComboBox1: TPKDBBLabelComboBox;
 33    PKDBLabelEdit10: TPKDBLabelEdit;
 34    PKDBBLabelComboBox2: TPKDBBLabelComboBox;
 35    PKDBBLabelComboBox3: TPKDBBLabelComboBox;
 36    PKDBBLabelComboBox4: TPKDBBLabelComboBox;
 37    CheckBox1: TCheckBox;
 38    PKDBDictEdit4: TPKDBDictEdit;
 39    PKDBDictEdit5: TPKDBDictEdit;
 40    PKDBDictEdit6: TPKDBDictEdit;
 41    PKDBDictEdit7: TPKDBDictEdit;
 42    CheckBox2: TCheckBox;
 43
 44    procedure open; override;
 45    function  finderrors:boolean; override;
 46    procedure runcommand; override;
 47
 48  private
 49    { Private declarations }
 50  public
 51    { Public declarations }
 52  end;
 53
 54var
 55  CONJUCTIONEDIT : TCONJUCTIONEDIT ;
 56  Cform : TWREPORT;
 57
 58  DefAccType: string = '3075940'; // ?????? ?? ????????? - ????
 59  DefEmpType: string = '3009017'; // ??? ???? ?? ????????? - ????????????
 60
 61implementation
 62 uses DM, EMPLOYEEUnit;
 63
 64{$R *.dfm}
 65
 66
 67
 68procedure TCONJUCTIONEDIT.Open;
 69begin
 70
 71  case CommandType of
 72    tcInsert:
 73      begin
 74       Caption := Caption + ': ??????????';
 75       if PKDBTable1.NeedGenPrimaryKey then PKDBTable1.GetTempPrimarykey;
 76       if PKDBTable2.NeedGenPrimaryKey then PKDBTable2.GetTempPrimarykey;
 77
 78       // ????????? ???????? ?? ?????????
 79       begin
 80        // ?????? ?? ?????????? =  TRUE
 81        PKDBBLabelComboBox4.SetValue(DefAccType);
 82        // ???????? ?????????????? = ??????? ????
 83      //  PKDBBLabelComboBox1.SetValue('3081505');
 84        // ??? ????????? ?????????????? = ???????
 85       // PKDBBLabelComboBox3.SetValue('3075942');
 86       end;
 87
 88      end;
 89    tcUpdate:
 90      Begin
 91        Caption := Caption + ': ?????????';
 92        PKDBTable1.Fields.PrimaryKey.FieldVal := PrimaryKey;
 93
 94        // ?????? ????? ?????????
 95        ADQuery1.Params[0].Value:= PKDBTable1.Fields.PrimaryKey.FieldVal;
 96        ADQuery1.Open;
 97        PKDBTable2.Fields.PrimaryKey.FieldVal:= ADQuery1WORKCONTRACTID.AsString;
 98        ADQuery1.Close;
 99      End;
100    tcCopy:
101      Begin
102        Caption := Caption + ': ???????????';
103        self.Button1.Enabled:=false;
104        showmessage('??????? ??????????? ?? ?????????????? ? ?????? ?????????.');
105      End;
106    tcView:
107      Begin
108        Caption := Caption + ': ????????';
109        PKDBTable1.Fields.PrimaryKey.FieldVal:= PrimaryKey;
110        PKDBTable2.Fields.PrimaryKey.FieldVal:= PrimaryKey;
111      end;
112  end;
113
114  if CommandType <> tcInsert then
115   begin
116    // ???????? ??????????? ?????????? ? ??
117    PKDBTable1.ReadFromDB(PrimaryKey);
118    PKDBTable2.ReadFromDB(PKDBTable2.Fields.PrimaryKey.FieldVal);
119   end;
120  if PKDBTable1.Fields.ParentKey <> nil then
121    begin
122     PKDBTable1.Fields.ParentKey.FieldVal := ParentKey;
123    end;
124
125
126  if CommandType = tcView then
127    Begin
128      Button1.Enabled := false;
129    End;
130end;
131
132function TCONJUCTIONEDIT.FindErrors: Boolean;
133Var
134  i: integer;
135begin
136  // ???????? ???????? ID ??????????
137  PKDBDictEdit4.DictionaryValue:= PKDBDictEdit1.DictionaryValue;
138
139  // ???????? ???????? ID ???????????? ??????????
140  PKDBDictEdit5.DictionaryValue:= PKDBTable1.Fields.PrimaryKey.FieldVal;
141
142  // ????????????
143  PKDBDictEdit7.DictionaryValue:= DefEmpType;
144
145
146  Result := False;
147  for i := 0 to PKDBTable1.Fields.Count - 1 do
148    Begin
149      if (PKDBTable1.Fields.Items[i].Nullable = false) and
150         (PKDBTable1.Fields.Items[i].IsEmpty) then
151        Begin
152          if (PKDBTable1.Fields.Items[i].IsPrimaryKey = false) then
153               Result := True;
154        End;
155    End;
156  for i := 0 to PKDBTable2.Fields.Count - 1 do
157    Begin
158      if (PKDBTable2.Fields.Items[i].Nullable = false) and
159         (PKDBTable2.Fields.Items[i].IsEmpty) then
160        Begin
161          if (PKDBTable2.Fields.Items[i].IsPrimaryKey = false) then
162               Result := True;
163        End;
164    End;
165  if Result then
166    ShowMessage('?? ????????? ???????????? ????')
167  else
168     // ????????? ???????? ??????
169   begin
170     // ?????? ?????????????? ?????
171     if PKDBBaseEdit1.Text<>'0' then
172      PKDBDictEdit6.DictionaryValue:=
173        ''''+datetostr(strtodate(PKDBLabelEdit4.Text)+strtoint(PKDBBaseEdit1.Text))+''''
174     else
175      PKDBDictEdit6.DictionaryValue:='';
176   end;
177end;
178
179procedure TCONJUCTIONEDIT.RunCommand;
180begin
181  case CommandType of
182    tcInsert:
183     begin
184      begin  // ?????????? ??????
185       // ???? ?????? ???????? ????? ?? ???? ??????? ?? ?????????
186       if (PKDBLabelEdit6.Text='') then
187          (PKDBLabelEdit6.Text:=PKDBLabelEdit4.Text);
188
189      end;
190      PrimaryKey := PKDBTable1.Insert;
191      PKDBTable2.Fields.PrimaryKey.FieldVal:=PrimaryKey;
192      PKDBTable2.Insert;
193     end;
194    tcCopy:
195     begin
196      PrimaryKey := PKDBTable1.Insert;
197      PKDBTable2.Fields.PrimaryKey.FieldVal:=PrimaryKey;
198     end;
199    tcUpdate:
200     begin
201      PKDBTable1.Update;
202      PKDBTable2.Update;
203     end;
204  end;
205  
206  if CheckBox1.Checked then    // ???? ???? ??????? ????? ????? "??"
207     begin
208      Cform := TWREPORT.Create(EMPLOYEE);
209      Cform.madeWorkContract(strtofloat(PKDBTable2.Fields.PrimaryKey.FieldVal));
210     end;
211end;
212
213initialization
214
215RegisterClasses([TCONJUCTIONEDIT]);
216end.