/HRManager/__history/APPOINTMENTEDITUnit.pas.~22~

https://github.com/oista/NPO · Unknown · 266 lines · 240 code · 26 blank · 0 comment · 0 complexity · f07946904076012ab4c02c39cf97d316 MD5 · raw file

  1. unit APPOINTMENTEDITUnit;
  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, DB, uADStanIntf, uADStanOption,
  7. uADStanParam, uADStanError, uADDatSManager, uADPhysIntf, uADDAptIntf,
  8. uADStanAsync, uADDAptManager, uADCompClient, uADCompDataSet, reportunit;
  9. type
  10. TAPPOINTMENTEDIT = class(TEditDialog)
  11. PKDBDictEdit2: TPKDBDictEdit;
  12. Label2: TLabel;
  13. PKDBLabelEdit3: TPKDBLabelEdit;
  14. PKDBLabelEdit4: TPKDBLabelEdit;
  15. PKDBLabelEdit5: TPKDBLabelEdit;
  16. PKDBDictEdit3: TPKDBDictEdit;
  17. ADStoredProc2: TADStoredProc;
  18. PKDBDictLabelEdit1: TPKDBDictLabelEdit;
  19. ADQuery1: TADQuery;
  20. PKDBTable2: TPKDBTable;
  21. PKDBDictEdit1: TPKDBDictEdit;
  22. ADQuery1ID: TFMTBCDField;
  23. Label1: TLabel;
  24. PKDBDictEdit4: TPKDBDictEdit;
  25. PKDBDictEdit5: TPKDBDictEdit;
  26. PKDBDictEdit6: TPKDBDictEdit;
  27. ADQuery1WORKCONTRACTID: TFMTBCDField;
  28. PKDBTable3: TPKDBTable;
  29. GroupBox1: TGroupBox;
  30. PKDBLabelEdit2: TPKDBLabelEdit;
  31. PKDBLabelEdit1: TPKDBLabelEdit;
  32. PKDBLabelEdit6: TPKDBLabelEdit;
  33. CheckBox1: TCheckBox;
  34. PKDBDictEdit7: TPKDBDictEdit;
  35. PKDBDictEdit8: TPKDBDictEdit;
  36. PKDBDictEdit9: TPKDBDictEdit;
  37. PKDBLabelEdit7: TPKDBLabelEdit;
  38. PKDBLabelEdit8: TPKDBLabelEdit;
  39. PKDBLabelEdit9: TPKDBLabelEdit;
  40. CheckBox2: TCheckBox;
  41. PKDBTable4: TPKDBTable;
  42. GroupBox2: TGroupBox;
  43. PKDBLabelEdit10: TPKDBLabelEdit;
  44. PKDBLabelEdit11: TPKDBLabelEdit;
  45. PKDBDictEdit10: TPKDBDictEdit;
  46. PKDBDictEdit11: TPKDBDictEdit;
  47. PKDBDictEdit12: TPKDBDictEdit;
  48. procedure PKDBDictEdit1BeforeOpenButtonClick(Sender: TObject;
  49. Form: TDictForm);
  50. procedure Button1Click(Sender: TObject);
  51. procedure FormShow(Sender: TObject);
  52. procedure open; override;
  53. procedure runcommand; override;
  54. function finderrors:boolean; override;
  55. private
  56. { Private declarations }
  57. public
  58. { Public declarations }
  59. end;
  60. var
  61. APPOINTMENTEDIT : TAPPOINTMENTEDIT ;
  62. Cform : TWREPORT;
  63. implementation
  64. uses DM, EMPLOYEEUnit;
  65. {$R *.dfm}
  66. procedure TAPPOINTMENTEDIT.Button1Click(Sender: TObject);
  67. begin
  68. inherited;
  69. // ????????(???? ??????? < ???? ??????????)
  70. if (PKDBLabelEdit5.text<>'') and (strtodate(PKDBLabelEdit4.text) > strtodate(PKDBLabelEdit5.text)) then
  71. begin
  72. showmessage('???? ??????? ?? ????????? ?????? ???? ?????? ???? ?????(???????? ???????? ??? ????? ?????????).');
  73. exit;
  74. end
  75. else
  76. begin
  77. ADStoredProc2.Params[0].Value:= PKDBTable2.Fields.PrimaryKey.FieldVal; // ?????????
  78. ADStoredProc2.Params[1].Value:= strtodate(PKDBLabelEdit4.Text); // ???? ??????/??????????
  79. ADStoredProc2.ExecProc;
  80. end;
  81. end;
  82. procedure TAPPOINTMENTEDIT.FormShow(Sender: TObject);
  83. begin
  84. inherited; // ???????? ???????? ?????????? ??????????
  85. PKDBDictLabelEdit1.SetValue(PKDBTable1.Fields.ParentKey.FieldVal);
  86. // ????? ?????? ?????????.
  87. // ???? ? ????. ?????? 2? ???????? (??????)
  88. ADQuery1.Params[0].Value:=PKDBTable1.Fields.ParentKey.FieldVal;
  89. ADQuery1.Open;
  90. // ???????? ?????? ?????????? ?????? ???????
  91. PKDBDictEdit6.DictionaryValue:= ADQuery1WORKCONTRACTID.asstring;
  92. if (ADQuery1.RecordCount>1) then
  93. begin
  94. showmessage('? ?????????? ?????? 1 ??????????? ????? ??????. ??????? ?????? ??????.');
  95. // exit;
  96. end
  97. else
  98. begin
  99. // ???????? ???????? ?????? ????????? ?? ?????????
  100. PKDBTable2.Fields.PrimaryKey.FieldVal:= ADQuery1ID.asstring;
  101. PKDBTable2.ReadFromDB(PKDBTable2.Fields.PrimaryKey.FieldVal);
  102. // ?????? ? ????? ?????? ???????? ? id ?????? ?????????
  103. // 25.05 ???? ???????? ?????? ??? ?????? ????????
  104. // PKDBDictEdit4.DictionaryValue:= ADQuery1ID.asstring;
  105. PKDBDictEdit5.DictionaryValue:= '''???????''';
  106. // ????????? ?????????? ? ??????
  107. PKDBTable4.Fields.ParentKey.FieldVal:= ADQuery1ID.asstring;;
  108. end;
  109. ADQuery1.Close;
  110. end;
  111. procedure TAPPOINTMENTEDIT.PKDBDictEdit1BeforeOpenButtonClick(Sender: TObject;
  112. Form: TDictForm);
  113. begin
  114. inherited;
  115. // ?? ???? ????? ????? ??????? ?????? ?????????? ?? ?????? ??????
  116. PKDBDictEdit3.DictionaryValue:= '3009016';
  117. end;
  118. procedure TAPPOINTMENTEDIT.Open;
  119. begin
  120. case CommandType of
  121. tcInsert:
  122. begin
  123. Caption := Caption + ': ??????????';
  124. if PKDBTable1.NeedGenPrimaryKey then PKDBTable1.GetTempPrimarykey;
  125. if PKDBTable3.NeedGenPrimaryKey then PKDBTable3.GetTempPrimarykey;
  126. if PKDBTable4.NeedGenPrimaryKey then PKDBTable4.GetTempPrimarykey;
  127. // ??????????? ?????????? ? ??????????
  128. PKDBTable3.Fields.ParentKey.FieldVal:= PKDBTable1.Fields.PrimaryKey.FieldVal;
  129. // ??????????? ?????? ?????????? ? ???????
  130. PKDBDictEdit12.DictionaryValue:= PKDBTable1.Fields.PrimaryKey.FieldVal;
  131. // ??????????? ?????????? ? ???????
  132. PKDBDictEdit11.DictionaryValue:= PKDBTable3.Fields.PrimaryKey.FieldVal;
  133. end;
  134. tcUpdate:
  135. Begin
  136. Caption := Caption + ': ?????????';
  137. self.Button1.Enabled:=false;
  138. // ?????????????? ????? ??????????,?? ??????????? ???????
  139. End;
  140. tcCopy:
  141. Begin
  142. Caption := Caption + ': ???????????';
  143. self.Button1.Enabled:=false;
  144. // ??????????? ????? ??????????,?? ??????????? ???????
  145. End;
  146. tcView:
  147. Begin
  148. Caption := Caption + ': ????????';
  149. self.Button1.Enabled:=false;
  150. end;
  151. end;
  152. if CommandType <> tcInsert then
  153. begin
  154. // ???????? ??????????? ?????????? ? ??
  155. PKDBTable1.ReadFromDB(PrimaryKey);
  156. end;
  157. if PKDBTable1.Fields.ParentKey <> nil then
  158. begin
  159. PKDBTable1.Fields.ParentKey.FieldVal := ParentKey;
  160. end;
  161. if CommandType = tcView then
  162. Begin
  163. Button1.Enabled := false;
  164. End;
  165. end;
  166. procedure TAPPOINTMENTEDIT.RunCommand;
  167. begin
  168. case CommandType of
  169. tcInsert:
  170. begin
  171. PrimaryKey := PKDBTable1.Insert;
  172. PKDBTable3.Insert;
  173. PKDBTable4.Insert;
  174. end;
  175. tcCopy:
  176. begin
  177. // ??????????? ?? ?????????????? ? ?????? ?????????
  178. end;
  179. tcUpdate:
  180. begin
  181. // ?????????????? ?? ?????????????? ? ?????? ?????????
  182. end;
  183. end;
  184. if CheckBox1.Checked then // ???? ???? ??????? ????? ?????????? ????? "??"
  185. begin
  186. Cform := TWREPORT.Create(EMPLOYEE);
  187. Cform.madeExtAgreement(strtofloat(PKDBTable3.Fields.PrimaryKey.FieldVal));
  188. end;
  189. if CheckBox2.Checked then // ???? ???? ??????? ????? ??????? ????? "??"
  190. begin
  191. Cform := TWREPORT.Create(EMPLOYEE);
  192. Cform.madeOrderAppoint(strtofloat(PKDBTable4.Fields.PrimaryKey.FieldVal));
  193. end;
  194. end;
  195. function TAPPOINTMENTEDIT.FindErrors: Boolean;
  196. Var
  197. i: integer;
  198. begin
  199. // ?????? ????????? ? ??????????
  200. PKDBDictEdit7.DictionaryValue:= PKDBDictEdit1.DictionaryValue;
  201. // ????? ????????? ? ??????????
  202. PKDBDictEdit8.DictionaryValue:= PKDBDictEdit2.DictionaryValue;
  203. // ??? ??????????=? ????????
  204. PKDBDictEdit9.DictionaryValue:='4136894';
  205. // ??? ???????=? ????????
  206. PKDBDictEdit10.DictionaryValue:='4180888';
  207. Result := False;
  208. for i := 0 to PKDBTable1.Fields.Count - 1 do
  209. Begin
  210. if (PKDBTable1.Fields.Items[i].Nullable = false) and
  211. (PKDBTable1.Fields.Items[i].IsEmpty) then
  212. Begin
  213. if (PKDBTable1.Fields.Items[i].IsPrimaryKey = false) then
  214. Result := True;
  215. End;
  216. End;
  217. for i := 0 to PKDBTable3.Fields.Count - 1 do
  218. Begin
  219. if (PKDBTable3.Fields.Items[i].Nullable = false) and
  220. (PKDBTable3.Fields.Items[i].IsEmpty) then
  221. Begin
  222. if (PKDBTable3.Fields.Items[i].IsPrimaryKey = false) then
  223. Result := True;
  224. End;
  225. End;
  226. for i := 0 to PKDBTable4.Fields.Count - 1 do
  227. Begin
  228. if (PKDBTable4.Fields.Items[i].Nullable = false) and
  229. (PKDBTable4.Fields.Items[i].IsEmpty) then
  230. Begin
  231. if (PKDBTable4.Fields.Items[i].IsPrimaryKey = false) then
  232. Result := True;
  233. End;
  234. End;
  235. if Result then
  236. ShowMessage('?? ????????? ???????????? ????');
  237. end;
  238. initialization
  239. RegisterClasses([TAPPOINTMENTEDIT]);
  240. end.