⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.pas

📁 家庭理财系统.rar
💻 PAS
📖 第 1 页 / 共 2 页
字号:
procedure TMain.ToolButton4Click(Sender: TObject);
begin
  hide;
  with TLogout.Create(self) do
    showmodal;
end;

procedure TMain.N10Click(Sender: TObject);
begin
  with TMessage.Create(self) do
    showmodal;
end;

procedure TMain.P1Click(Sender: TObject);
begin
  with TAddMember.Create(self) do
    showmodal;
end;

procedure TMain.N13Click(Sender: TObject);
begin
  with TAddBank.Create(self) do
    showmodal;
end;

procedure TMain.O1Click(Sender: TObject);
begin
  with TOut.Create(self) do
    showmodal;
end;

procedure TMain.N14Click(Sender: TObject);
begin
  with TIncome.Create(self) do
    showmodal;
end;


procedure TMain.Button1Click(Sender: TObject);
var
  num1 : string ;
  num2 : string ;
  tmp : string ;
  i : integer ;
begin
  if ComboBox1.Text = '选择支出者姓名' then
    messagebox(getactivewindow(),'请选择支出者姓名!','错误' ,MB_OK + MB_ICONINFORMATION)
  else if ComboBox2.Text = '选择支出的项目' then
    messagebox(getactivewindow(),'请选择支出的项目!','错误' ,MB_OK + MB_ICONINFORMATION)
  else if edit2.Text = '' then
    messagebox(getactivewindow(),'请选填写支出金额!','错误' ,MB_OK + MB_ICONINFORMATION)
  else
    begin
      DM.User.Close ;
      DM.User.SQL.Clear ;
      DM.User.SQL.Add('select * from sendout ');
      dm.User.Open;
      if edit1.Text = '' then
        tmp := '无'
      else
        tmp :=edit1.Text;
      if dm.User.RecordCount = 0  then
      begin
        num1 := formatdatetime('yy年MM月dd日',now);
        num2 := '01';
        DM.User.Close;
        DM.User.SQL.Clear;
        DM.User.SQL.Add('INSERT INTO sendout (支出编号,支出者姓名,支出项目,项目数量,总支出金额,支出日期,备注) VALUES (:id,:name,:out,:num,:total,:date,:memo)');
        DM.User.Parameters.ParamByName('id').Value := num1 + num2;
        DM.User.Parameters.ParamByName('name').Value := ComboBox1.Text;
        DM.User.Parameters.ParamByName('out').Value := ComboBox2.Text;
        DM.User.Parameters.ParamByName('num').Value := tmp;
        DM.User.Parameters.ParamByName('total').Value := StrToFloat(edit2.Text);
        DM.User.Parameters.ParamByName('date').Value := date();
        DM.User.Parameters.ParamByName('memo').Value := memo1.Lines.Text;
        DM.User.Prepared;
        DM.User.ExecSql;
        messagebox(getactivewindow(),'添加支出成功,单击确定返回!','成功添加' ,MB_OK + MB_ICONINFORMATION);
        edit1.Text := '';
        edit2.Text := '';
        memo1.Lines.Text := '支出备注:';
        ComboBox1.Text := '选择支出者姓名';
        ComboBox2.Text := '选择支出的项目';
        dm.ADOQuery7.Close;
        dm.ADOQuery7.Open;
      end
      else if  dm.User.RecordCount > 0 then
      begin
        DM.User.Close ;
        DM.User.SQL.Clear ;
        DM.User.SQL.Add('select max(支出编号) from sendout ');
        dm.User.Open;
        if edit1.Text = '' then
          tmp := '无'
        else
          tmp :=edit1.Text;
        if dm.User.Fields[0].Value <> '' then
        begin
          num1 := formatdatetime('yy年MM月dd日',now);
          if copy(dm.User.Fields[0].Value,0,6) = formatdatetime('yy年MM月dd日',now) then
          begin
            i := strtoint(copy(dm.User.Fields[0].Value,7,2)) + 1;
            if length(inttostr(i)) = 1 then
              num2 :='0' + inttostr(i)
            else
              num2 := inttostr(i);
          end
          else
            num2 := '01';
          DM.User.Close;
          DM.User.SQL.Clear;
          DM.User.SQL.Add('INSERT INTO sendout (支出编号,支出者姓名,支出项目,项目数量,总支出金额,支出日期,备注) VALUES (:id,:name,:out,:num,:total,:date,:memo)');
          DM.User.Parameters.ParamByName('id').Value := num1 + num2;
          DM.User.Parameters.ParamByName('name').Value := ComboBox1.Text;
          DM.User.Parameters.ParamByName('out').Value := ComboBox2.Text;
          DM.User.Parameters.ParamByName('num').Value := tmp;
          DM.User.Parameters.ParamByName('total').Value := StrToFloat(edit2.Text);
          DM.User.Parameters.ParamByName('date').Value := date();
          DM.User.Parameters.ParamByName('memo').Value := memo1.Lines.Text;
          DM.User.Prepared;
          DM.User.ExecSql;
          messagebox(getactivewindow(),'添加支出成功,单击确定返回!','成功添加' ,MB_OK + MB_ICONINFORMATION);
          edit1.Text := '';
          edit2.Text := '';
          memo1.Lines.Text := '支出备注:' ;
          ComboBox1.Text := '选择支出者姓名';
          ComboBox2.Text := '选择支出的项目';
          dm.ADOQuery7.Close;
          dm.ADOQuery7.Open;
        end;
    end;
    end;
end;

procedure TMain.Button5Click(Sender: TObject);
var
  num1 : string ;
  num2 : string ;
  tmp : string ;
  i : integer ;
begin
  if ComboBox3.Text = '选择收入者姓名' then
    messagebox(getactivewindow(),'请选择收入者姓名!','错误' ,MB_OK + MB_ICONINFORMATION)
  else if ComboBox4.Text = '选择收入的项目' then
    messagebox(getactivewindow(),'请选择收入的项目!','错误' ,MB_OK + MB_ICONINFORMATION)
  else if edit5.Text = '' then
    messagebox(getactivewindow(),'请选填写收入金额!','错误' ,MB_OK + MB_ICONINFORMATION)
  else
    begin
      DM.User.Close ;
      DM.User.SQL.Clear ;
      DM.User.SQL.Add('select * from sendin ');
      dm.User.Open;
      if edit4.Text = '' then
        tmp := '无'
      else
        tmp :=edit4.Text;
      if dm.User.RecordCount = 0  then
      begin
        num1 := formatdatetime('yy年MM月dd日',now);
        num2 := '01';
        DM.User.Close;
        DM.User.SQL.Clear;
        DM.User.SQL.Add('INSERT INTO sendin (收入编号,收入者姓名,收入项目,项目数量,总收入金额,收入日期,备注) VALUES (:id,:name,:out,:num,:total,:date,:memo)');
        DM.User.Parameters.ParamByName('id').Value := num1 + num2;
        DM.User.Parameters.ParamByName('name').Value := ComboBox3.Text;
        DM.User.Parameters.ParamByName('out').Value := ComboBox4.Text;
        DM.User.Parameters.ParamByName('num').Value := tmp;
        DM.User.Parameters.ParamByName('total').Value := StrToFloat(edit5.Text);
        DM.User.Parameters.ParamByName('date').Value := date();
        DM.User.Parameters.ParamByName('memo').Value := memo2.Lines.Text;
        DM.User.Prepared;
        DM.User.ExecSql;
        messagebox(getactivewindow(),'添加收入成功,单击确定返回!','成功添加' ,MB_OK + MB_ICONINFORMATION);
        edit4.Text := '';
        edit5.Text := '';
        memo1.Lines.Text := '收入备注:';
        ComboBox3.Text := '选择收入者姓名';
        ComboBox4.Text := '选择收入的项目';
        dm.ADOQuery8.Close;
        dm.ADOQuery8.Open;
      end
      else if  dm.User.RecordCount > 0 then
      begin
        DM.User.Close ;
        DM.User.SQL.Clear ;
        DM.User.SQL.Add('select max(支出编号) from sendin ');
        dm.User.Open;
        if edit4.Text = '' then
          tmp := '无'
        else
          tmp :=edit4.Text;
        if dm.User.Fields[0].Value <> '' then
        begin
          num1 := formatdatetime('yy年MM月dd日',now);
          if copy(dm.User.Fields[0].Value,0,6) = formatdatetime('yy年MM月dd日',now) then
          begin
            i := strtoint(copy(dm.User.Fields[0].Value,7,2)) + 1;
            if length(inttostr(i)) = 1 then
              num2 :='0' + inttostr(i)
            else
              num2 := inttostr(i);
          end
          else
            num2 := '01';
          DM.User.Close;
          DM.User.SQL.Clear;
          DM.User.SQL.Add('INSERT INTO sendout (收入编号,收入者姓名,收入项目,项目数量,总收入金额,支出日期,备注) VALUES (:id,:name,:out,:num,:total,:date,:memo)');
          DM.User.Parameters.ParamByName('id').Value := num1 + num2;
          DM.User.Parameters.ParamByName('name').Value := ComboBox1.Text;
          DM.User.Parameters.ParamByName('out').Value := ComboBox2.Text;
          DM.User.Parameters.ParamByName('num').Value := tmp;
          DM.User.Parameters.ParamByName('total').Value := StrToFloat(edit2.Text);
          DM.User.Parameters.ParamByName('date').Value := date();
          DM.User.Parameters.ParamByName('memo').Value := memo1.Lines.Text;
          DM.User.Prepared;
          DM.User.ExecSql;
          messagebox(getactivewindow(),'添加收入成功,单击确定返回!','成功添加' ,MB_OK + MB_ICONINFORMATION);
          edit1.Text := '';
          edit2.Text := '';
          memo1.Lines.Text := '收入备注:' ;
          ComboBox1.Text := '选择收入者姓名';
          ComboBox2.Text := '选择收入的项目';
          dm.ADOQuery8.Close;
          dm.ADOQuery8.Open;
        end;
    end;
    end;
end;

procedure TMain.Button6Click(Sender: TObject);
begin
   DM.User.Close;
   DM.User.SQL.Clear;
   DM.User.SQL.Add('SELECT SUM(总收入金额) as sum_1 FROM sendin where 收入日期=:date');
   DM.User.Parameters.ParamByName('date').Value := date();
   DM.User.Prepared;
   dm.User.Open;
   edit6.text:=dm.User.FieldList.Fields[0].Value;
end;

procedure TMain.Button2Click(Sender: TObject);
begin
   DM.User.Close;
   DM.User.SQL.Clear;
   DM.User.SQL.Add('SELECT SUM(总支出金额) as amount FROM sendout where 支出日期=:date');
   DM.User.Parameters.ParamByName('date').Value := date();
   DM.User.Prepared;
   dm.User.Open;
   edit3.text:=dm.User.FieldList.Fields[0].Value;
end;

procedure TMain.Image1Click(Sender: TObject);
begin
  shellExecute(GetDesktopWindow,'Open','mailto:vfork@163.com',
nil,nil,SW_ShowNormal);
end;

procedure TMain.Label40Click(Sender: TObject);
begin
  shellExecute(GetDesktopWindow,'Open','mailto:vfork@163.com',
nil,nil,SW_ShowNormal);
end;

procedure TMain.ToolButton10Click(Sender: TObject);
begin
  shellExecute(GetDesktopWindow,'Open','mailto:vfork@163.com',
nil,nil,SW_ShowNormal);
end;

procedure TMain.BitBtn1Click(Sender: TObject);
begin
  if (radiobutton1.Checked = false) and (radiobutton2.Checked = false) then
    messagebox(getactivewindow(),'请选择查询的类型!','错误!' ,MB_OK + MB_ICONINFORMATION);
  if radiobutton1.Checked then
    begin
      if ComboBox5.Text = '' then
        begin
          DM.Query.Close;
          DM.Query.SQL.Clear;
          DM.Query.SQL.Add('SELECT * FROM sendin WHERE 收入日期>= :date1 and 收入日期<=:date2');
          DM.Query.Parameters.ParamByName('date1').Value := datetimepicker1.DateTime;
          DM.Query.Parameters.ParamByName('date2').Value := datetimepicker2.DateTime;
          DM.Query.Prepared;
          dm.Query.ExecSQL;
          //edit7.Text := dm.Query.FieldList.Fields[0].Value;
          dm.Query.Open;
        end
      else
        begin
          DM.Query.Close;
          DM.Query.SQL.Clear;
          DM.Query.SQL.Add('SELECT * FROM sendin WHERE 收入日期>= :date1 and 收入日期<=:date2 and 收入者姓名 =:name');
          DM.Query.Parameters.ParamByName('date1').Value := datetimepicker1.DateTime;
          DM.Query.Parameters.ParamByName('date2').Value := datetimepicker2.DateTime;
          DM.Query.Parameters.ParamByName('name').Value := ComboBox5.Text;
          DM.Query.Prepared;
          dm.Query.ExecSQL;
          //edit7.Text := dm.Query.FieldList.Fields[0].Value;
          dm.Query.Open;
        end;
    end;
  if radiobutton2.Checked then
    begin
      if ComboBox5.Text = '' then
        begin
          DM.Query.Close;
          DM.Query.SQL.Clear;
          DM.Query.SQL.Add('SELECT * FROM sendout WHERE 支出日期>= :date1 and 支出日期<=:date2');
          DM.Query.Parameters.ParamByName('date1').Value := datetimepicker1.DateTime;
          DM.Query.Parameters.ParamByName('date2').Value := datetimepicker2.DateTime;
          DM.Query.Prepared;
          dm.Query.ExecSQL;
          //edit7.Text := dm.Query.FieldList.Fields[0].Value;
          dm.Query.Open;
        end
      else
        begin
          DM.Query.Close;
          DM.Query.SQL.Clear;
          DM.Query.SQL.Add('SELECT * FROM sendout WHERE 支出日期>= :date1 and 支出日期<= :date2 and 支出者姓名 = :name');
          DM.Query.Parameters.ParamByName('date1').Value := datetimepicker1.DateTime;
          DM.Query.Parameters.ParamByName('date2').Value := datetimepicker2.DateTime;
          DM.Query.Parameters.ParamByName('name').Value := ComboBox5.Text;
          DM.Query.Prepared;
          dm.Query.ExecSQL;
          //edit7.Text := dm.Query.FieldValues['sum_1'];
          dm.Query.Open;
        end;
    end;
end;

procedure TMain.ToolButton8Click(Sender: TObject);
begin
  with TAbout.Create(self) do
    showmodal;
end;

end.



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -