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

📄 frmconfirmstorebill.~pas

📁 这是一个商品管理系统
💻 ~PAS
字号:
unit FrmConfirmStoreBill;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, Grids, DBGrids, ExtCtrls, DB, ADODB;

type
  TFormConfirmStoreBill = class(TForm)
    Shape1: TShape;
    DataGrid: TDBGrid;
    BtnOK: TButton;
    DataSourceStoreBill: TDataSource;
    DataSetStoreBill: TADODataSet;
    Label3: TLabel;
    Label4: TLabel;
    EditTime: TEdit;
    EditNote: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    EditSysUser: TEdit;
    Label10: TLabel;
    EditAmount: TEdit;
    Shape2: TShape;
    BtnConfirm: TButton;
    RadioGroup1: TRadioGroup;
    RBSeekToday: TRadioButton;
    RBSeekWeek: TRadioButton;
    RBSeekMonth: TRadioButton;
    EditProvider: TEdit;
    EditDepot: TEdit;
    EditDeliver: TEdit;
    EditCommodity: TEdit;
    DataSet: TADODataSet;
    CmdConfirm: TADOCommand;
    procedure RBSeekTodayClick(Sender: TObject);
    procedure RBSeekWeekClick(Sender: TObject);
    procedure RBSeekMonthClick(Sender: TObject);
    procedure DataGridCellClick(Column: TColumn);
    function GetNameByID(ID: string; table: string) : string;
    procedure FormShow(Sender: TObject);
    procedure BtnConfirmClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormConfirmStoreBill: TFormConfirmStoreBill;

implementation

{$R *.dfm}

function TFormConfirmStoreBill.GetNameByID(ID: string; table: string) : string;
begin
        DataSet.Active := false;
        DataSet.CommandText :=
                'select name from '
                + table
                + ' where id = '''
                + ID
                + '''';
        DataSet.Active := true;
        if not(DataSet.IsEmpty) then
        begin
               GetNameByID := DataSet.FieldByName('name').AsString;
        end
        else
        begin
               Application.MessageBox('无效的商品名称!', '错误', MB_OK);
        end;
end;

procedure TFormConfirmStoreBill.RBSeekTodayClick(Sender: TObject);
var
        DateTimeStart, DateTimeEnd: string;
        DateTime: TDateTime;
begin
        DateTime:= Date;
        DateTimeStart := DateToStr(DateTime)+ ' 00:00:00';
        DateTimeEnd := DateToStr(DateTime)+ ' 23:59:59';

        DataSetStoreBill.Active := False;
        DataSetStoreBill.CommandText :=
                'SELECT * from StoreBill WHERE time > '''
                + DateTimeStart
                + ''' and time < '''
                + DateTimeEnd
                + '''';
        DataSetStoreBill.Active := True;
end;

procedure TFormConfirmStoreBill.RBSeekWeekClick(Sender: TObject);
var
        DateTimeStart, DateTimeEnd: string;
        DateTime: TDateTime;
begin
        DateTime:= Date;
        DateTimeStart := DateToStr(DateTime-7)+ ' 00:00:00';
        DateTimeEnd := DateToStr(DateTime)+ ' 23:59:59';

        DataSetStoreBill.Active := False;
        DataSetStoreBill.CommandText :=
                'SELECT * from StoreBill WHERE time > '''
                + DateTimeStart
                + ''' and time < '''
                + DateTimeEnd
                + '''';
        DataSetStoreBill.Active := True;
end;

procedure TFormConfirmStoreBill.RBSeekMonthClick(Sender: TObject);
var
        DateTimeStart, DateTimeEnd: string;
        DateTime: TDateTime;
begin
        DateTime:= Date;
        DateTimeStart := DateToStr(DateTime-30)+ ' 00:00:00';
        DateTimeEnd := DateToStr(DateTime)+ ' 23:59:59';

        DataSetStoreBill.Active := False;
        DataSetStoreBill.CommandText :=
                'SELECT * from StoreBill WHERE time > '''
                + DateTimeStart
                + ''' and time < '''
                + DateTimeEnd
                + '''';
        DataSetStoreBill.Active := True;
end;

procedure TFormConfirmStoreBill.DataGridCellClick(Column: TColumn);
begin
        EditTime.Text := DataSetStoreBill.FieldByName('time').AsString;
        if (EditTime.Text = '') then
                exit;
        EditAmount.Text := DataSetStoreBill.FieldByName('amount').AsString;
        EditNote.Text := DataSetStoreBill.FieldByName('note').AsString;
        if (DataSetStoreBill.FieldByName('confirmed').AsBoolean) then
        begin
                BtnConfirm.Enabled := False;
        end
        else
        begin
                BtnConfirm.Enabled := True;
        end;

        EditCommodity.Text := GetNameByID(DataSetStoreBill.FieldByName('commodity').AsString, 'Commodity');
        EditSysUser.Text := GetNameByID(DataSetStoreBill.FieldByName('sysuser').AsString, 'SysUser');
        EditDepot.Text := GetNameByID(DataSetStoreBill.FieldByName('depot').AsString, 'Depot');
        EditProvider.Text := GetNameByID(DataSetStoreBill.FieldByName('provider').AsString, 'Provider');
        EditDeliver.Text := GetNameByID(DataSetStoreBill.FieldByName('deliver').AsString, 'Deliver');
end;

procedure TFormConfirmStoreBill.FormShow(Sender: TObject);
begin
        if not(DataSetStoreBill.CommandText = '') then
                DataSetStoreBill.Requery;
end;

procedure TFormConfirmStoreBill.BtnConfirmClick(Sender: TObject);
begin
        CmdConfirm.CommandText :=
                'UPDATE StoreBill SET confirmed = 1 where time = '''
                + EditTime.Text +
                '''';
        try
                CmdConfirm.Execute;
        except
                ShowMessage('确认进货单失败!');
                exit;
        end;
        ShowMessage('确认进货单成功!');
        DataSetStoreBill.Requery;
        BtnConfirm.Enabled := False;
end;


end.

⌨️ 快捷键说明

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