📄 unit_gl.pas
字号:
unit Unit_GL;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, Inifiles, Grids, Aligrid;
type
TForm_GL = class(TForm)
BitBtn1: TBitBtn;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Bevel1: TBevel;
TreeView1: TTreeView;
GroupBox1: TGroupBox;
StaticText1: TStaticText;
ProgressBar1: TProgressBar;
SpeedButton_huifuY: TSpeedButton;
GroupBox2: TGroupBox;
ListBox_name: TListBox;
GroupBox3: TGroupBox;
ListBox_spot: TListBox;
Edit_spot: TEdit;
SpeedButton_spotGengGai: TSpeedButton;
GroupBox4: TGroupBox;
Edit_type1Show: TEdit;
SpeedButton_typeG: TSpeedButton;
Edit_type2Show: TEdit;
Label1: TLabel;
StaticText3: TStaticText;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit_type3Show: TEdit;
ComboBox_type1: TComboBox;
ComboBox_type2: TComboBox;
ComboBox_type3: TComboBox;
Label2: TLabel;
Label3: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Bevel2: TBevel;
GroupBox6: TGroupBox;
Label14: TLabel;
Edit_name: TEdit;
Edit_namep: TEdit;
Label15: TLabel;
Edit_namepp: TEdit;
Label16: TLabel;
BitBtn_name: TBitBtn;
GroupBox5: TGroupBox;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Edit_oldp: TEdit;
Edit_newp: TEdit;
Edit_newpp: TEdit;
BitBtn_p: TBitBtn;
RadioButton_GLY: TRadioButton;
RadioButton_PT: TRadioButton;
RadioButton_YL: TRadioButton;
TabSheet3: TTabSheet;
Bevel4: TBevel;
GroupBox8: TGroupBox;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Edit_j11: TEdit;
Edit_j22: TEdit;
Edit_J33: TEdit;
BitBtn_jok: TBitBtn;
Edit_j3: TEdit;
Edit_j2: TEdit;
Edit_j1: TEdit;
OpenDialog1: TOpenDialog;
SpeedButton_j1x: TSpeedButton;
SpeedButton_j1m: TSpeedButton;
SpeedButton_j3x: TSpeedButton;
SpeedButton_j3m: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton_j2x: TSpeedButton;
SpeedButton_j2m: TSpeedButton;
GroupBox9: TGroupBox;
StringGrid1: TStringGrid;
BitBtn_JH: TBitBtn;
ComboBox_name: TComboBox;
Label10: TLabel;
RadioButton_GLY1: TRadioButton;
RadioButton_PT1: TRadioButton;
RadioButton_YL1: TRadioButton;
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ListBox_spotClick(Sender: TObject);
procedure Edit_spotKeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton_spotGengGaiClick(Sender: TObject);
procedure SpeedButton_huifuYClick(Sender: TObject);
procedure ComboBox_type1Click(Sender: TObject);
procedure ComboBox_type2Click(Sender: TObject);
procedure TreeView1Click(Sender: TObject);
procedure SpeedButton_typeGClick(Sender: TObject);
procedure TreeView1KeyPress(Sender: TObject; var Key: Char);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure PageControl1Change(Sender: TObject);
procedure BitBtn_pClick(Sender: TObject);
procedure ComboBox_nameChange(Sender: TObject);
procedure BitBtn_nameClick(Sender: TObject);
procedure SpeedButton_j1xClick(Sender: TObject);
procedure SpeedButton_j2xClick(Sender: TObject);
procedure SpeedButton_j3xClick(Sender: TObject);
procedure SpeedButton_j1mClick(Sender: TObject);
procedure SpeedButton_j2mClick(Sender: TObject);
procedure SpeedButton_j3mClick(Sender: TObject);
procedure BitBtn_jokClick(Sender: TObject);
procedure BitBtn_JHClick(Sender: TObject);
private
filepath,TreeS1,TreeS2 : String;
procedure TongYiGengGaiJiLu(s1,s2,ST: String;level:Integer);
function MyTreeNode(Node1,Node2,Node3:String; level:Integer): TTreeNode;
{ Private declarations }
public
{ Public declarations }
end;
var
Form_GL: TForm_GL;
implementation
uses jia;
{$R *.dfm}
function TForm_GL.MyTreeNode(Node1,Node2,Node3:String; Level:Integer): TTreeNode;
var
I: Integer;
begin
for i:=0 to TreeView1.Items.Count -1 do
begin
Result := TreeView1.Items[i];
if Result.Level = Level then
case Result.Level of
0: if (Result.Text = Node1) then
Exit;
1: if (Result.Text = Node2) and (Result.Parent.Text = Node1) then
Exit;
2: if (Result.Text = Node3) and (Result.Parent.Text = Node2) and (Result.Parent.Parent.Text = Node1) then
Exit;
end;
end;
Result := nil;
end;
procedure TForm_GL.TongYiGengGaiJiLu(s1,S2,ST:String;level:integer);
begin
Form1.DBGrid1.DataSource.Enabled := False;
Form1.all_cx;
case level of
1: Form1.Table1.Filter := '('+ST+'='+#39+s1+#39+')and(type1='+#39+TreeS1
+#39+')';
2: Form1.Table1.Filter := '('+ST+'='+#39+s1+#39+')and(type2='+#39+TreeS2
+#39+')and(type1='+#39+TreeS1+#39+')';
else
Form1.Table1.Filter :=ST+'='+#39+s1+#39;
end;
Form1.Table1.Filtered := True;
Form1.Table1.First;
while not Form1.Table1.Eof do
begin
Form1.Table1.Edit;
Form1.Table1.FieldValues[ST] := s2;
Form1.Table1.Post;
end;
Form1.DBGrid1.DataSource.Enabled := True;
end;
procedure TForm_GL.BitBtn1Click(Sender: TObject);
begin
Close;
end;
procedure TForm_GL.FormShow(Sender: TObject);
var
i: Integer;
MyNode : TTreeNode;
myinifile : TInifile;
begin
filepath :=ExtractFilePath(Paramstr(0));
TreeView1.Items :=Form1.TreeView1.Items;
Edit_type1Show.Clear;
Edit_type2Show.Clear;
Edit_type3Show.Clear;
ComboBox_type1.Clear;
ComboBox_type2.Clear;
ComboBox_type3.Clear;
Edit_spot.Clear;
StringGrid1.ColCount :=1;
StringGrid1.RowCount :=2;
for i:=0 to TreeView1.Items.Count -1 do
begin
MyNode := TreeView1.Items[i];
if MyNode.Level = 0 then
ComboBox_type1.Items.Add(MyNode.Text);
if (MyNode.Level = 1) and (MyNode.Parent.Text = '开支') then
begin
StringGrid1.ColCount := StringGrid1.ColCount +1;
StringGrid1.ColWidths[StringGrid1.ColCount-1] := 50;
StringGrid1.Cols[StringGrid1.ColCount-1].Strings[0] := MyNode.Text;
end;
end;
SpeedButton_spotGengGai.Enabled := False;
PageControl1.ActivePageIndex := 0;
StringGrid1.Rows[0].Strings[0] := '项目';
StringGrid1.Rows[1].Strings[0] := '计划消费额';
myinifile :=Tinifile.Create(filepath+'data\Home.dft');
try
for i:=1 to StringGrid1.ColCount -1 do
StringGrid1.Rows[1].Strings[i] := FloatToStr(myinifile.ReadFloat('计划',StringGrid1.Rows[0].Strings[i],0));
finally
myinifile.Destroy;
end;
StringGrid1.FixedRows :=1;
if StringGrid1.ColCount > 1 then
StringGrid1.FixedCols :=1;
PageControl1Change(Sender);
ComboBox_name.OnChange(Sender);
RadioButton_YL.Checked := True;
end;
procedure TForm_GL.ListBox_spotClick(Sender: TObject);
begin
Edit_spot.Text := ListBox_spot.Items[ListBox_spot.ItemIndex];
Edit_spot.SelectAll;
end;
procedure TForm_GL.Edit_spotKeyPress(Sender: TObject; var Key: Char);
begin
SpeedButton_spotGengGai.Enabled := True;
end;
procedure TForm_GL.SpeedButton_spotGengGaiClick(Sender: TObject);
var
I : Integer;
T : Boolean;
begin
T := True;
for i:=0 to ListBox_spot.Count -1 do
if ListBox_spot.Items[i] = Edit_spot.Text then T := False;
if T then
if MessageBox(Application.Handle,'这将使数据库全部更新!是否确定这样操作?','系统',MB_YESNO)=6 then
begin
TongYiGengGaiJiLu(ListBox_spot.Items[ListBox_spot.ItemIndex],Edit_spot.Text,'spot',0);
ListBox_spot.Items[ListBox_spot.ItemIndex] := Edit_spot.Text;
Edit_spot.Clear;
end;
SpeedButton_spotGengGai.Enabled := False;
end;
procedure TForm_GL.SpeedButton_huifuYClick(Sender: TObject);
var
S1,S2,S3: String;
I: Integer;
T: Boolean;
MyNode, TSNode: TTreeNode;
myinifile : TIniFile;
begin
if MessageBox(Application.Handle,'这将使数据库全部更新!分类、地址、用户名都会根据数据库记录更新!'+#13
+'而且这是不可逆转的!仅在数据记录比较全面时作为恢复系统数据用!请慎重使用'+#13+'是否确定这样操作?','系统',MB_YESNO)=6 then
begin
ListBox_name.Clear;
ListBox_spot.Clear;
TreeView1.Items.Clear;
TreeView1.Items.Add(TreeView1.Selected,'开支');
TreeView1.Items.Add(TreeView1.Selected,'收入');
Edit_type1Show.Clear;
Edit_type2Show.Clear;
Edit_type3Show.Clear;
ComboBox_type1.ItemIndex := -1;
ComboBox_type2.ItemIndex := -1;
ComboBox_type3.ItemIndex := -1;
StaticText1.Visible := True;
StaticText1.Update;
Form1.DBGrid1.DataSource.Enabled := False;
Form1.all_cx;
Form1.Table1.Filtered := False;
Form1.Table1.First;
ProgressBar1.Max := Form1.Table1.RecordCount;
while not Form1.Table1.Eof do
begin
S1:= Form1.Table1.FieldValues['name'];
T:= False;
myinifile :=Tinifile.Create(ExtractFilePath(Paramstr(0))+'data\Home.dft');
try
for i:=0 to ListBox_name.Items.Count -1 do
if S1=ListBox_name.Items[i] then T:= True;
if (Not T) and (S1 <> '管理员') then
begin
if myinifile.ReadString('Name',S1,'') <> '' then
ListBox_name.Items.Add(S1);
end;
finally
myinifile.Destroy;
end;
S1:= Form1.Table1.FieldValues['spot'];
T := False;
For i:=0 to ListBox_spot.Items.Count -1 do
if S1=ListBox_spot.Items[i] then T:= True;
if not T then
ListBox_spot.Items.Add(S1);
if Form1.Table1.FieldValues['type1'] <> Null then
begin
S1:= Form1.Table1.FieldValues['type1'];
MyNode := MyTreeNode(S1,'','',0);
if MyNode = nil then
begin
MyNode := TreeView1.Items.Add(nil,S1);
Mynode.ImageIndex := 0;
end;
if Form1.Table1.FieldValues['type2'] <> Null then
begin
S2:= Form1.Table1.FieldValues['type2'];
TSNode := MyTreeNode(S1,S2,'',1);
if TSNode = nil then
begin
MyNode := TreeView1.Items.AddChild(MyNode,S2);
MyNode.ImageIndex := 1;
end
else
MyNode := TSNode;
if Form1.Table1.FieldValues['type3'] <> Null then
begin
S3:= Form1.Table1.FieldValues['type3'];
if MyTreeNode(S1,S2,S3,2) = nil then
begin
MyNode := TreeView1.Items.AddChild(MyNode,S3);
MyNode.ImageIndex := 2;
end;
end;
end;
end;
Form1.Table1.Next;
ProgressBar1.Position := Form1.Table1.RecNo;
end;
ShowMessage('完成统计!');
Form1.DBGrid1.DataSource.Enabled := True;
StaticText1.Visible := False;
ProgressBar1.Position := 0;
// for I:= 0 to TreeView1.
end;
end;
procedure TForm_GL.ComboBox_type1Click(Sender: TObject);
var
mynode: TTreeNode;
i,j: Integer;
begin
ComboBox_type2.Clear;
ComboBox_type3.Clear;
for i:=0 to TreeView1.Items.Count -1 do
begin
mynode := TreeView1.Items[i];
if (mynode.Text = ComboBox_type1.Text) and (mynode.Level = 0) then
begin
for j:=0 to mynode.Count -1 do
ComboBox_type2.Items.Add(mynode.item[j].Text);
Break;
end;
end;
end;
procedure TForm_GL.ComboBox_type2Click(Sender: TObject);
var
mynode: TTreeNode;
i,j: Integer;
begin
ComboBox_type3.Clear;
for i:=0 to TreeView1.Items.Count -1 do
begin
mynode := TreeView1.Items[i];
if mynode.Level = 1 then
if (mynode.Text = ComboBox_type2.Text)
and (mynode.Parent.Text = ComboBox_type1.Text) then
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -