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

📄 udailycost.pas

📁 是个办公系统,可以实现财务上的管理和人员的流动
💻 PAS
字号:
unit UdailyCost;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Grids, DBGrids, Buttons, ExtCtrls, DBCtrls,
  Mask,StrUtils;

type
  TfrmDailyCost = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    ComboBox1: TComboBox;
    DateTimePicker1: TDateTimePicker;
    bbtnSelect: TBitBtn;
    Panel1: TPanel;
    DBGrid1: TDBGrid;
    GroupBox2: TGroupBox;
    bbtnNew: TBitBtn;
    bbtnModify: TBitBtn;
    bbtnDel: TBitBtn;
    bbtnSave: TBitBtn;
    bbtnCancel: TBitBtn;
    GroupBox3: TGroupBox;
    Label3: TLabel;
    Label5: TLabel;
    Label7: TLabel;
    Label4: TLabel;
    Label6: TLabel;
    Label8: TLabel;
    DateTimePicker2: TDateTimePicker;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBComboBox1: TDBComboBox;
    DBComboBox2: TDBComboBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bbtnSelectClick(Sender: TObject);
    procedure bbtnNewClick(Sender: TObject);
    procedure bbtnModifyClick(Sender: TObject);
    procedure bbtnDelClick(Sender: TObject);
    procedure bbtnSaveClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure DBComboBox2DropDown(Sender: TObject);
    procedure bbtnCancelClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
   Function AutoNum:string;
  end;

var
  frmDailyCost: TfrmDailyCost;
implementation

uses MyData;

{$R *.dfm}

procedure TfrmDailyCost.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
   Action:=caFree;
end;

procedure TfrmDailyCost.bbtnSelectClick(Sender: TObject);
var
 DCObject,DCDate:string;
 sqlstr:string;
begin
 DCObject:=Trim(ComboBox1.Text);
 DCDate:=FormatDateTime('YYYY-MM-DD',DateTimePicker1.Date);
 sqlstr:='';
 if DCDate<>'' then
    sqlstr:=' where DCDate= '''+DCDate+'''';
 if ComboBox1.Text<>'' then
    sqlstr:=sqlstr+' and DCObject='''+DCObject+'''';

  with dm.AQDailyCost do
    begin
      close;
      sql.Clear;
      sql.Add('select * from DailyCost');
      sql.Add(sqlstr);
      open;
    end;
end;

procedure TfrmDailyCost.bbtnNewClick(Sender: TObject);
begin
   dm.AQDailyCost.Append;
   DBEdit1.Text:=self.AutoNum;
end;

procedure TfrmDailyCost.bbtnModifyClick(Sender: TObject);
begin
 dm.AQDailyCost.Edit;
end;

procedure TfrmDailyCost.bbtnDelClick(Sender: TObject);
begin
  if application.messagebox('这是日常开销的原始信息,真的要删除吗','提示',MB_YESNO+MB_ICONINFORMATION)=IDYES then
    begin
     dm.AQDailyCost.Delete;
    end

end;

procedure TfrmDailyCost.bbtnSaveClick(Sender: TObject);
begin
  if (DBEdit2.Text='') or (DBEdit3.Text='') or (DBComboBox1.Text='') or (DBComboBox2.Text='') then
   begin
     ShowMessage('日常开销信息不完整!');
     Exit;
   end;
    with dm.AQDailyCost do
      begin
        Edit;
        fieldbyname('DCDate').AsString:=formatdatetime('yyyy-mm-dd',DateTimePicker2.Date);
        Post;
        DBEdit1.Text:='';
        DBEdit2.Text:='';
        DBEdit3.Text:='';
        DBComboBox1.Text:='';
        DBComboBox2.Text:='';
        showmessage('已存盘!');
      end;

end;

procedure TfrmDailyCost.FormShow(Sender: TObject);
begin
  Datetimepicker1.Date:=Date;
  Datetimepicker2.Date:=Date;
end;

procedure TfrmDailyCost.DBComboBox2DropDown(Sender: TObject);
begin
 DBComboBox2.Items.Clear;
  with dm.AQEmpname do
   begin
     close;
     sql.Clear;
     sql.Add('select * from Employees where Department='''+'财务部'+'''');
     open;
     while not dm.AQEmpname.Eof do
      begin
        DBComboBox2.Items.Add(dm.AQEmpname.FieldValues['EmpName']);
        dm.AQEmpname.Next;
      end;
   end;
end;

procedure TfrmDailyCost.bbtnCancelClick(Sender: TObject);
begin
  close;
end;

function TfrmDailyCost.AutoNum:string;
var
 Year,Month,Day:Word;
 today:string;
 MaxStr,MaxValue:String;
 MaxInt:Integer;
begin
  DecodeDate(Date,Year,Month,Day);
   if Month<10 then
    begin
      today :=floatToStr(Year)+'0'+floatToStr(Month);
      if Day<10 then
        today :=today+'0'+floatToStr(Day)
      else
        today :=today+floatToStr(Day);
    end
    else
    begin
      today :=floatToStr(Year)+floatToStr(Month);
      if Day<10 then
        today :=today+'0'+floatToStr(Day)
      else
        today :=today+floatToStr(Day);
    end;
  with dm.AQPublic do
   begin
    close;
    sql.Clear;
    sql.Add('select max(DCNO) as MaxDailyCostNO from DailyCost where DCNO like '''+today+'%'+'''');
    open;
    if FieldByName('MaxDailyCostNO').IsNull then
       MaxStr:=today+'01'
    else
     begin
       MaxValue:=RightStr(Fieldbyname('MaxDailyCostNO').AsString,2);
       MaxInt:=StrToInt(MaxValue);
       if MaxInt <10 then
         MaxValue:='0'+IntToStr(MaxInt+1)
       else
         MaxValue:=IntToStr(MaxInt+1);
       MaxStr:=today+MaxValue;
     end;
    Result:=Maxstr;
   end;
end;

end.

⌨️ 快捷键说明

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