NewProjectFrm.pas 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. unit NewProjectFrm;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants,
  5. Classes, Graphics, Controls, Forms,
  6. Dialogs, StdCtrls, ExtCtrls,
  7. ConstMethodUnit, ConstVarUnit,
  8. ConstTypeUnit;
  9. type
  10. TNewProjectForm = class(TForm)
  11. ldeProjectName: TLabeledEdit;
  12. GroupBox1: TGroupBox;
  13. btnCreate: TButton;
  14. btnClose: TButton;
  15. cbGatherProject: TCheckBox;
  16. cbBidLotProject: TCheckBox;
  17. GroupBox2: TGroupBox;
  18. cbEstimate: TCheckBox;
  19. cbBillsBudget: TCheckBox;
  20. Label1: TLabel;
  21. cbbProjList: TComboBox;
  22. procedure btnCloseClick(Sender: TObject);
  23. procedure cbBillsBudgetClick(Sender: TObject);
  24. procedure cbEstimateClick(Sender: TObject);
  25. procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  26. procedure cbGatherProjectClick(Sender: TObject);
  27. procedure cbBidLotProjectClick(Sender: TObject);
  28. procedure ldeProjectNameChange(Sender: TObject);
  29. private
  30. FProjectName: string;
  31. function GetProjectName: string;
  32. function GetProjectType: Integer;
  33. function GetProjectKind: Integer;
  34. function GetProjectGatherID: Integer;
  35. procedure SetProjectType(const Value: Integer);
  36. procedure SetProjectName(const Value: string);
  37. {}
  38. procedure InitProjList(aProjList: TStrings; aCurIdx: Integer);
  39. procedure DisabledBuildProject;
  40. { FX lib }
  41. procedure InputLibView(aFormType: TFormType);
  42. function GetFileFlag: Integer;
  43. property FileFlag: Integer read GetFileFlag;
  44. property ProjectName: string read GetProjectName write SetProjectName;
  45. property ProjectType: Integer read GetProjectType write SetProjectType;
  46. property ProjectKind: Integer read GetProjectKind;
  47. property ProjectGatherID: Integer read GetProjectGatherID;
  48. public
  49. end;
  50. function NewProjectInfo(aProjList: TStrings; var aProjName: string;
  51. var aProjType, aProjKind, aGatherID: Integer; aCurIdx: Integer = -1): Boolean;
  52. { TODO : Import FXQD }
  53. function InputStdLibName(var aLibName: string; var aFileFlag: Integer;
  54. aFormType: TFormType = ftImportStdLib): Boolean;
  55. implementation
  56. {$R *.dfm}
  57. function NewProjectInfo(aProjList: TStrings;
  58. var aProjName: string;
  59. var aProjType, aProjKind, aGatherID: Integer;
  60. aCurIdx: Integer): Boolean;
  61. var
  62. NewProjectForm: TNewProjectForm;
  63. begin
  64. NewProjectForm := TNewProjectForm.Create(nil);
  65. try
  66. if Assigned(aProjList) then
  67. if aProjList.Count = 0 then
  68. begin
  69. Result := False;
  70. ShowMessage('项目文件不存在, 请先创建项目文件!');
  71. Exit;
  72. end
  73. else
  74. NewProjectForm.InitProjList(aProjList, aCurIdx)
  75. else
  76. begin
  77. // 以前处理方法,如不存在项目文件,则创建
  78. NewProjectForm.DisabledBuildProject;
  79. end;
  80. NewProjectForm.ProjectName := aProjName;
  81. NewProjectForm.ProjectType := aProjType;
  82. Result := NewProjectForm.ShowModal = mrYes;
  83. if Result then
  84. begin
  85. aProjName := NewProjectForm.ProjectName;
  86. aProjType := NewProjectForm.ProjectType;
  87. aProjKind := NewProjectForm.ProjectKind;
  88. if Assigned(aProjList) then
  89. aGatherID := NewProjectForm.ProjectGatherID;
  90. end;
  91. finally
  92. NewProjectForm.Free;
  93. end;
  94. end;
  95. function InputStdLibName(var aLibName: string; var aFileFlag: Integer; aFormType: TFormType): Boolean;
  96. var
  97. NewProjectForm: TNewProjectForm;
  98. begin
  99. NewProjectForm := TNewProjectForm.Create(nil);
  100. try
  101. NewProjectForm.ldeProjectName.Text := aLibName;
  102. NewProjectForm.InputLibView(aFormType);
  103. Result := NewProjectForm.ShowModal = mrYes;
  104. if Result then
  105. begin
  106. aLibName := NewProjectForm.ldeProjectName.Text;
  107. aFileFlag := NewProjectForm.FileFlag;
  108. end;
  109. finally
  110. NewProjectForm.Free;
  111. end;
  112. end;
  113. procedure TNewProjectForm.btnCloseClick(Sender: TObject);
  114. begin
  115. Close;
  116. end;
  117. procedure TNewProjectForm.cbBillsBudgetClick(Sender: TObject);
  118. begin
  119. cbEstimate.Checked := not cbBillsBudget.Checked;
  120. end;
  121. procedure TNewProjectForm.cbEstimateClick(Sender: TObject);
  122. begin
  123. cbBillsBudget.Checked := not cbEstimate.Checked;
  124. end;
  125. function TNewProjectForm.GetProjectName: string;
  126. begin
  127. Result := ldeProjectName.Text;
  128. end;
  129. function TNewProjectForm.GetProjectType: Integer;
  130. begin
  131. if cbBillsBudget.Checked then
  132. Result := 5
  133. else
  134. Result := 6;
  135. end;
  136. procedure TNewProjectForm.SetProjectType(const Value: Integer);
  137. begin
  138. cbBillsBudget.Checked := Value = 5;
  139. end;
  140. procedure TNewProjectForm.FormCloseQuery(Sender: TObject;
  141. var CanClose: Boolean);
  142. begin
  143. if ModalResult <> mrYes then Exit;
  144. if ProjectName = '' then
  145. begin
  146. MessageWarning(0, sNameNotNull);
  147. CanClose := False;
  148. Exit;
  149. end;
  150. if CheckFileExists(ProjectName) then
  151. begin
  152. MessageWarning(0, sSameFileName);
  153. CanClose := False;
  154. Exit;
  155. end;
  156. end;
  157. procedure TNewProjectForm.SetProjectName(const Value: string);
  158. begin
  159. ldeProjectName.Text := Value;
  160. end;
  161. procedure TNewProjectForm.cbGatherProjectClick(Sender: TObject);
  162. begin
  163. cbBidLotProject.Checked := not cbGatherProject.Checked;
  164. Label1.Enabled := False;
  165. cbbProjList.Enabled := False;
  166. end;
  167. procedure TNewProjectForm.cbBidLotProjectClick(Sender: TObject);
  168. begin
  169. cbGatherProject.Checked := not cbBidLotProject.Checked;
  170. Label1.Enabled := True;
  171. cbbProjList.Enabled := True;
  172. end;
  173. function TNewProjectForm.GetProjectKind: Integer;
  174. begin
  175. if cbGatherProject.Checked then
  176. Result := 1
  177. else
  178. Result := 2;
  179. end;
  180. procedure TNewProjectForm.InitProjList(aProjList: TStrings; aCurIdx: Integer);
  181. var
  182. I: Integer;
  183. begin
  184. if aProjList.Count = 0 then
  185. begin
  186. { TODO : 如果建设项目没有,则只能创建新建设项目,不可以创建标段 [litao 2011.7.4] }
  187. cbGatherProject.Checked := True;
  188. DisabledBuildProject;
  189. Exit;
  190. end;
  191. for I := 0 to aProjList.Count - 1 do
  192. begin
  193. cbbProjList.Items.AddObject(aProjList[I], aProjList.Objects[I]);
  194. end;
  195. cbbProjList.ItemIndex := aCurIdx;
  196. end;
  197. function TNewProjectForm.GetProjectGatherID: Integer;
  198. begin
  199. Result := 0;
  200. if cbbProjList.ItemIndex = -1 then Exit;
  201. Result := Integer(cbbProjList.Items.Objects[cbbProjList.ItemIndex]);
  202. end;
  203. procedure TNewProjectForm.DisabledBuildProject;
  204. begin
  205. Label1.Enabled := False;
  206. cbbProjList.Enabled := False;
  207. cbGatherProject.Enabled := False;
  208. cbBidLotProject.Enabled := False;
  209. end;
  210. procedure TNewProjectForm.ldeProjectNameChange(Sender: TObject);
  211. begin
  212. if CheckSpecialChar(TLabeledEdit(Sender).Text) then
  213. begin
  214. MessageWarning(0, sSpecialChar);
  215. TLabeledEdit(Sender).Text := FProjectName;
  216. TLabeledEdit(Sender).SelStart := Length(FProjectName);
  217. end
  218. else
  219. FProjectName := TLabeledEdit(Sender).Text;
  220. end;
  221. procedure TNewProjectForm.InputLibView(aFormType: TFormType);
  222. begin
  223. Caption := '导入';
  224. Label1.Visible := False;
  225. cbbProjList.Visible := False;
  226. GroupBox2.Visible := False;
  227. GroupBox1.Width := ldeProjectName.Width;
  228. GroupBox1.Top := 60;
  229. // Maixinrong 2012-03-26 类型框错位了
  230. GroupBox1.Left := ldeProjectName.Left;
  231. if aFormType = ftImportStdLib then
  232. begin
  233. cbGatherProject.Checked := True;
  234. ldeProjectName.EditLabel.Caption := '名称:';
  235. cbBidLotProject.Visible := False;
  236. cbGatherProject.Caption := '分项清单';
  237. cbBidLotProject.Caption := '工程量清单';
  238. end;
  239. btnCreate.Caption := '确定';
  240. Height := 210;
  241. OnCloseQuery := nil;
  242. end;
  243. function TNewProjectForm.GetFileFlag: Integer;
  244. begin
  245. if cbGatherProject.Checked then
  246. Result := 1
  247. else
  248. Result := 2;
  249. end;
  250. end.