📄 unit_tu.pas
字号:
begin
mydate := MySeries.XLabel[j];
if S <> '' then
S1 := S + 'and(TYPE2='+#39+mydate+#39+')'
else
S1 := '(TYPE2='+#39+mydate+#39+')';
Form1.Table1.Filter := S1;
Form1.Table1.Filtered := True;
MySeries.YValue[j] := Abs(Form1.TableMoneyJS);
end;
Form1.DBGrid1.DataSource.Enabled := True;
end;
if RadioButton_xiangmu.Checked then //项目的选择 888888888888888888888888888
begin
while not Form1.Table1.Eof do
begin
mydate := Form1.Table1.FieldValues['TYPE3'];
Form1.Table1.Next;
T := False;
for j:=0 to MySeries.Count -1 do
if mydate = MySeries.XLabel[j] then
begin
T := True;
Break;
end;
if (Not T)or(MySeries.Count = 0) then
MySeries.Add(0,mydate);
end;
for j:=0 to MySeries.Count -1 do
begin
mydate := MySeries.XLabel[j];
if S <> '' then
S1 := S + 'and(TYPE3='+#39+mydate+#39+')'
else
S1 := '(TYPE3='+#39+mydate+#39+')';
Form1.Table1.Filter := S1;
Form1.Table1.Filtered := True;
MySeries.YValue[j] := Abs(Form1.TableMoneyJS);
end;
Form1.DBGrid1.DataSource.Enabled := True;
end;
Chart1.AddSeries(MySeries);
Panel_TU.Visible := False;
end;
procedure TForm_TU.CheckBox_3DClick(Sender: TObject);
begin
Chart1.View3D := CheckBox_3D.Checked;
end;
procedure TForm_TU.CheckBox_xxClick(Sender: TObject);
begin
Chart1.Legend.Visible := CheckBox_xx.Checked;
end;
procedure TForm_TU.BitBtn_tjbClick(Sender: TObject);
begin
MonthCalendar_S.Date := DateTimePicker_S.Date;
MonthCalendar_Z.Date := DateTimePicker_Z.Date;
Panel2.Top := 0;
Panel2.Left := 0;
Panel2.Show;
end;
procedure TForm_TU.BitBtn_XMMClick(Sender: TObject);
var
myinifile : Tinifile;
ET,S,a,b,c,d : String;
i : Integer;
T : Boolean;
begin
ET := InputBox('添加','输入成组名:','');
T := True;
for i:= 0 to ComboBox_XMM.Items.Count-1 do
if ComboBox_XMM.Items[i] = '*'+ET then
T := False;
if (ET <> '')and(T) then
begin
if RadioButton_nian.Checked then a:='1';
if RadioButton_yue.Checked then a:='2';
if RadioButton_ri.Checked then a:='3';
if RadioButton_dizi.Checked then a:='4';
if RadioButton_fenqu.Checked then a:='5';
if RadioButton_fenlei.Checked then a:='6';
if RadioButton_xiangmu.Checked then a:='7';
if RadioButton_juxing.Checked then b:='1';
if RadioButton_xianxing.Checked then b:='2';
if CheckBox_xx.Checked then c:='1' else c:='0';
if CheckBox_3D.Checked then d:='1' else d:='0';
S := DateToStr(DateTimePicker_S.Date)+','+DateToStr(DateTimePicker_Z.Date);
if ComboBox_spot.Text = '' then
S := S+',0'
else
S := S+','+ComboBox_spot.Text;
if ComboBox_type1.Text = '' then
S := S+',0'
else
S := S+','+ComboBox_type1.Text;
if ComboBox_type2.Text = '' then
S := S+',0'
else
S := S+','+ComboBox_type2.Text;
if ComboBox_type3.Text = '' then
S := S+',0'
else
S := S+','+ComboBox_type3.Text;
S := S+','+a+','+b+','+c+','+d;
myinifile :=Tinifile.Create(ExtractFilePath(Paramstr(0))+'data\Home.dft');
try
ComboBox_XMM.Items.Add('*'+ET);
myinifile.WriteInteger('序列','n',ComboBox_XMM.Items.Count);
myinifile.WriteString('序列',IntToStr(ComboBox_XMM.Items.Count-1),'*'+ET);
myinifile.WriteString('序列','*'+ET,S);
finally
myinifile.Destroy;
end;
end;
end;
procedure TForm_TU.BitBtn_DelClick(Sender: TObject);
var
myinifile : TIniFile;
i : Integer;
begin
myinifile :=Tinifile.Create(ExtractFilePath(Paramstr(0))+'data\Home.dft');
try
for i:=0 to ComboBox_XMM.Items.Count -1 do
if ComboBox_XMM.Text = ComboBox_XMM.Items[i] then
begin
myinifile.DeleteKey('序列',ComboBox_XMM.Text);
ComboBox_XMM.Items.Delete(i);
Break;
end;
myinifile.writeInteger('序列','n',ComboBox_XMM.Items.Count);
for i:=0 to ComboBox_XMM.Items.Count-1 do
myinifile.WriteString('序列',IntToStr(i),ComboBox_XMM.Items[i]);
finally
myinifile.Destroy;
end;
end;
procedure TForm_TU.FormShow(Sender: TObject);
var
myinifile : TIniFile;
i,n : integer;
begin
myinifile :=Tinifile.Create(ExtractFilePath(Paramstr(0))+'data\Home.dft');
try
n := myinifile.ReadInteger('序列','n',0);
for i:=0 to n-1 do
ComboBox_XMM.Items.Add(myinifile.ReadString('序列',IntToStr(i),''));
finally
myinifile.Destroy;
end;
end;
procedure TForm_TU.ComboBox_XMMChange(Sender: TObject);
var
myinifile : TIniFile;
i : Integer;
P,S,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10 : String;
begin
myinifile :=Tinifile.Create(ExtractFilePath(Paramstr(0))+'data\Home.dft');
try
S1:='';
S2:='';
S3:='';
S4:='';
S5:='';
S6:='';
S7:='';
S8:='';
S9:='';
S10:='';
S := myinifile.ReadString('序列',ComboBox_XMM.Text,'');
for i:=1 to Length(S) do
begin
P := Copy(S,i,1);
if p<>',' then
S10 := S10 + P
else
begin
if S1 = '' then S1 := S10 else
if S2 = '' then S2 := S10 else
if S3 = '' then S3 := S10 else
if S4 = '' then S4 := S10 else
if S5 = '' then S5 := S10 else
if S6 = '' then S6 := S10 else
if S7 = '' then S7 := S10 else
if S8 = '' then S8 := S10 else
if S9 = '' then S9 := S10;
S10 := '';
end;
end;
DateTimePicker_S.Date := StrToDate(S1);
DateTimePicker_SChange(Sender);
DateTimePicker_Z.Date := StrToDate(S2);
DateTimePicker_ZChange(Sender);
if S3 = '0' then ComboBox_spot.ItemIndex := 0
else
for i:= 0 to ComboBox_spot.Items.Count-1 do
if ComboBox_spot.Items[i] = S3 then
begin
ComboBox_spot.ItemIndex := i;
Break;
end;
if S4 = '0' then ComboBox_type1.ItemIndex := 0
else
for i:= 0 to ComboBox_type1.Items.Count-1 do
if ComboBox_type1.Items[i] = S4 then
begin
ComboBox_type1.ItemIndex := i;
ComboBox_type1Click(Sender);
Break;
end;
if S5 = '0' then ComboBox_type2.ItemIndex := 0
else
for i:= 0 to ComboBox_type2.Items.Count-1 do
if ComboBox_type2.Items[i] = S5 then
begin
ComboBox_type2.ItemIndex := i;
ComboBox_type2Click(Sender);
Break;
end;
if S6 = '0' then ComboBox_type3.ItemIndex := 0
else
for i:= 0 to ComboBox_type3.Items.Count-1 do
if ComboBox_type3.Items[i] = S6 then
begin
ComboBox_type3.ItemIndex :=i;
Break;
end;
Case StrToInt(S7) of
1 : RadioButton_nian.Checked := True;
2 : RadioButton_yue.Checked := True;
3 : RadioButton_ri.Checked := True;
4 : RadioButton_dizi.Checked := True;
5 : RadioButton_fenqu.Checked := True;
6 : RadioButton_fenlei.Checked := True;
7 : RadioButton_xiangmu.Checked := True;
end;
Case StrToInt(S8) of
1 : RadioButton_juxing.Checked := True;
2 : RadioButton_xianxing.Checked := True;
end;
if S9 = '0' then CheckBox_xx.Checked := False else CheckBox_xx.Checked := True;
if S10 = '0' then CheckBox_3D.Checked := False else CheckBox_3D.Checked := True;
finally
myinifile.Destroy;
end;
end;
procedure TForm_TU.MonthCalendar_SClick(Sender: TObject);
begin
MonthCalendar_Z.Date :=MonthCalendar_S.Date;
Form1.SDate := MonthCalendar_Z.Date;
Form1.EDate := MonthCalendar_Z.Date;
end;
procedure TForm_TU.BitBtn_tjbiaoClick(Sender: TObject);
var
T : Boolean;
mydate : String;
myD,myT : Single;
j,d : Integer;
myinifile : TIniFile;
begin
StringAlignGrid1.ColCount :=5;
StringAlignGrid1.RowCount :=1;
{ StringAlignGrid1.ColWidths[0] :=70;
StringAlignGrid1.Rows[0].Strings[0]:='项目名';
StringAlignGrid1.ColWidths[1] :=100;
StringAlignGrid1.Rows[0].Strings[1]:='计划月消费';
StringAlignGrid1.ColWidths[2] :=100;
StringAlignGrid1.Rows[0].Strings[2]:='应消费额';
StringAlignGrid1.ColWidths[3] :=100;
StringAlignGrid1.Rows[0].Strings[3]:='实际消费额';
StringAlignGrid1.ColWidths[4] :=100;
StringAlignGrid1.Rows[0].Strings[4]:='剩余消费额';
}
//确定项目名
Form1.DBGrid1.DataSource.Enabled := False;
D:= Form1.chaxun;
Form1.Table1.Filter := 'type1='+#39+'开支'+#39;
Form1.Table1.Filtered := True;
Form1.Table1.First;
while not Form1.Table1.Eof do
begin
mydate := Form1.Table1.FieldValues['TYPE2'];
Form1.Table1.Next;
T := False;
for j:=0 to StringAlignGrid1.RowCount -1 do
if mydate = StringAlignGrid1.Rows[j].Strings[0] then
begin
T := True;
Break;
end;
if (Not T)or(StringAlignGrid1.RowCount = 0) then
begin
StringAlignGrid1.RowCount := StringAlignGrid1.RowCount +1;
StringAlignGrid1.Rows[StringAlignGrid1.RowCount-1].Strings[0] :=mydate;
end;
end;
//付值
myinifile :=Tinifile.Create(ExtractFilePath(Paramstr(0))+'data\Home.dft');
try
for j:=1 to StringAlignGrid1.RowCount -1 do
begin
//计划本月消费
myT := myinifile.ReadFloat('计划',StringAlignGrid1.Rows[j].Strings[0],0);
StringAlignGrid1.Rows[j].Strings[1] := FloatToStr(myT);
//按计划应消费
StringAlignGrid1.Rows[j].Strings[2] := FloatToStr(Round(Abs(StrToFloat(StringAlignGrid1.Rows[j].Strings[1])/30)*D*100)/100);
//实际消费
mydate := StringAlignGrid1.Rows[j].Strings[0];
Form1.Table1.Filter :='(type1='+#39+'开支'+#39+')and(type2='+#39+mydate+#39+')' ;
Form1.Table1.Filtered := True;
StringAlignGrid1.Rows[j].Strings[3] := FloatToStr(Abs(Form1.TableMoneyJS));
//剩余金额
MyD := StrToFloat(StringAlignGrid1.Rows[j].Strings[2])-StrToFloat(StringAlignGrid1.Rows[j].Strings[3]);
if MyD < 0 then
StringAlignGrid1.CellFont[4,j].Color := clred
else
StringAlignGrid1.CellFont[4,j].Color := clBackground;
StringAlignGrid1.Rows[j].Strings[4] := FloatToStr(Round(MyD*100)/100);
end;
finally
myinifile.Destroy;
end;
Form1.DBGrid1.DataSource.Enabled := True;
StringAlignGrid1.RowCount := StringAlignGrid1.RowCount +1;
StringAlignGrid1.Rows[StringAlignGrid1.RowCount-1].Strings[0] := '总计:';
myD :=0;
for j:=1 to StringAlignGrid1.RowCount-2 do
myD := myD + StrToFloat(StringAlignGrid1.Rows[j].Strings[1]);
StringAlignGrid1.Rows[StringAlignGrid1.RowCount-1].Strings[1] := FloatToStr(Round(myD*100)/100);
myD :=0;
for j:=1 to StringAlignGrid1.RowCount-2 do
myD := myD + StrToFloat(StringAlignGrid1.Rows[j].Strings[2]);
StringAlignGrid1.Rows[StringAlignGrid1.RowCount-1].Strings[2] := FloatToStr(Round(myD*100)/100);
myD :=0;
for j:=1 to StringAlignGrid1.RowCount-2 do
myD := myD + StrToFloat(StringAlignGrid1.Rows[j].Strings[3]);
StringAlignGrid1.Rows[StringAlignGrid1.RowCount-1].Strings[3] := FloatToStr(Round(myD*100)/100);
MyD :=0;
for j:=1 to StringAlignGrid1.RowCount-2 do
myD := myD + StrToFloat(StringAlignGrid1.Rows[j].Strings[4]);
if MyD < 0 then
StringAlignGrid1.CellFont[4,StringAlignGrid1.RowCount-1].Color := clred
else
StringAlignGrid1.CellFont[4,StringAlignGrid1.RowCount-1].Color := clBackground;
StringAlignGrid1.Rows[StringAlignGrid1.RowCount-1].Strings[4] := FloatToStr(Round(myD*100)/100);
StringAlignGrid1.FixedRows :=1;
Label_rcS.Caption :='开始日期: '+DateToStr(MonthCalendar_S.Date);
Label_rcZ.Caption :='结束日期: '+DateToStr(MonthCalendar_Z.Date);
Label_rcD.Caption :='共统计 '+IntToStr(D)+' 天的数据';
end;
procedure TForm_TU.BitBtn_tjtuClick(Sender: TObject);
begin
Panel2.Hide;
DateTimePicker_S.Date := MonthCalendar_S.Date;
DateTimePicker_Z.Date := MonthCalendar_Z.Date;
end;
procedure TForm_TU.MonthCalendar_ZClick(Sender: TObject);
begin
Form1.EDate := MonthCalendar_Z.Date;
end;
procedure TForm_TU.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form1.TreeView1.SetFocus;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -