/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

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