📄 frmconfirmsellbill.pas
字号:
unit FrmConfirmSellBill;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ADODB, StdCtrls, ExtCtrls, DB, Grids, DBGrids;
type
TFormConfirmSellBill = class(TForm)
Shape1: TShape;
DataGrid: TDBGrid;
BtnOK: TButton;
DataSource1: TDataSource;
DataSetSellBill: 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;
EditCustomer: TEdit;
EditDepot: TEdit;
EditPayment: 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
FormConfirmSellBill: TFormConfirmSellBill;
implementation
{$R *.dfm}
function TFormConfirmSellBill.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 TFormConfirmSellBill.RBSeekTodayClick(Sender: TObject);
var
DateTimeStart, DateTimeEnd: string;
DateTime: TDateTime;
begin
DateTime:= Date;
DateTimeStart := DateToStr(DateTime)+ ' 00:00:00';
DateTimeEnd := DateToStr(DateTime)+ ' 23:59:59';
DataSetSellBill.Active := False;
DataSetSellBill.CommandText :=
'SELECT * from SellBill WHERE time > '''
+ DateTimeStart
+ ''' and time < '''
+ DateTimeEnd
+ '''';
DataSetSellBill.Active := True;
end;
procedure TFormConfirmSellBill.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';
DataSetSellBill.Active := False;
DataSetSellBill.CommandText :=
'SELECT * from SellBill WHERE time > '''
+ DateTimeStart
+ ''' and time < '''
+ DateTimeEnd
+ '''';
DataSetSellBill.Active := True;
end;
procedure TFormConfirmSellBill.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';
DataSetSellBill.Active := False;
DataSetSellBill.CommandText :=
'SELECT * from SellBill WHERE time > '''
+ DateTimeStart
+ ''' and time < '''
+ DateTimeEnd
+ '''';
DataSetSellBill.Active := True;
end;
procedure TFormConfirmSellBill.DataGridCellClick(Column: TColumn);
begin
EditTime.Text := DataSetSellBill.FieldByName('time').AsString;
if (EditTime.Text = '') then
exit;
EditAmount.Text := DataSetSellBill.FieldByName('amount').AsString;
EditNote.Text := DataSetSellBill.FieldByName('note').AsString;
if (DataSetSellBill.FieldByName('confirmed').AsBoolean) then
begin
BtnConfirm.Enabled := False;
end
else
begin
BtnConfirm.Enabled := True;
end;
EditCommodity.Text := GetNameByID(DataSetSellBill.FieldByName('commodity').AsString, 'Commodity');
EditSysUser.Text := GetNameByID(DataSetSellBill.FieldByName('sysuser').AsString, 'SysUser');
EditDepot.Text := GetNameByID(DataSetSellBill.FieldByName('depot').AsString, 'Depot');
EditCustomer.Text := GetNameByID(DataSetSellBill.FieldByName('Customer').AsString, 'Customer');
EditPayment.Text := GetNameByID(DataSetSellBill.FieldByName('payment').AsString, 'Payment');
end;
procedure TFormConfirmSellBill.FormShow(Sender: TObject);
begin
if not(DataSetSellBill.CommandText = '') then
DataSetSellBill.Requery;
end;
procedure TFormConfirmSellBill.BtnConfirmClick(Sender: TObject);
begin
CmdConfirm.CommandText :=
'UPDATE SellBill SET confirmed = 1 where time = '''
+ EditTime.Text
+ '''';
try
CmdConfirm.Execute;
except
ShowMessage('确认进货单失败!');
exit;
end;
ShowMessage('确认进货单成功!');
DataSetSellBill.Requery;
BtnConfirm.Enabled := False;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -