📄 iorder.pas
字号:
unit IOrder;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Unitmb, StdCtrls, Grids, DBGridEh, Buttons, ComCtrls, ExtCtrls, ToolWin,
Mask, DBCtrlsEh, DBLookupEh, Menus, ImgList,adodb, FR_Ctrls,db, DBCtrls,
dbcgrids, DBGrids, Variants;
type
TIOrderForm = class(TmbForm)
DeliveryDate: TDateTimePicker;
chkCancel: TCheckBox;
procedure FormShow(Sender: TObject);
procedure printClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure cmdEditClick(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
private
{ Private declarations }
dDeliveryDate,dOldDeliveryDate:TDatetime;
bEnd,bOldEnd:boolean;
procedure InsertMaster(sInvono:string);override;
procedure UpdateMaster;override;
procedure ShowMasterSpecial(bAdd:boolean);override;
public
{ Public declarations }
end;
var
IOrderForm: TIOrderForm;
implementation
uses datamodule1, report2, SelectGoods;
{$R *.DFM}
procedure TIOrderForm.InsertMaster(sInvoNo:string);
begin
with dataE2 do
InsertIOrder(nBillid,nCusId,nEmployid,edtBillDate.date,sInvoNo,edtMemo.text,myTable);
end;
procedure TIOrderForm.UpdateMaster;
var
sSql:string;
i:integer;
begin
bEnd:=chkCancel.checked;
sMasterMemo:=trim(edtMemo.text);
dDeliverydate:=DeliveryDate.Date;
//dynamic sql sentence
i:=0;
with dataE2 do
begin
adoCmd.CommandText:='update '+mytable+' set ';
if nEmployId <> nOldEmployId then
begin
adoCmd.CommandText :=adoCmd.CommandText +' Employid= :employid ';
adoCmd.Parameters[i].value:=nEmployId;
inc(i);
end;
if nCusId <> nOldCusId then
begin
if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';
if nTableid=0 then
adoCmd.CommandText :=adoCmd.CommandText +' vendorId= :cusid '
else
adoCmd.CommandText :=adoCmd.CommandText +' ClientId= :cusid ';
adoCmd.Parameters[i].value:=nCusId;
inc(i);
end;
if dDeliveryDate <> dOldDeliveryDate then
begin
if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';
adoCmd.CommandText :=adoCmd.CommandText +' Deliverydate= :deliverydate ';
adoCmd.Parameters[i].value:=dDeliverydate;
inc(i);
end;
if bEnd <> bOldEnd then
begin
if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';
adoCmd.CommandText :=adoCmd.CommandText +' isEnd= :IsEnd ';
adoCmd.Parameters[i].value:=bEnd;
inc(i);
end;
if sMasterMemo <> sOldMasterMemo then
begin
if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';
adoCmd.CommandText :=adoCmd.CommandText +' Memo= :Memo ';
adoCmd.Parameters[i].value:=sMastermemo;
inc(i);
end;
if i>0 then
begin
adoCmd.CommandText :=adoCmd.CommandText +' where BillId= :Billid ';
adoCmd.parameters[i].value:=nBillid;
adoCmd.Execute ;
end;
end; //dataE2
end;
procedure TIOrderForm.ShowMasterSpecial(bAdd:boolean);
var
s,sSql:string;
begin
with DataE2 do
if not bAdd then
begin
nEmployId:=adoquery1.fieldbyname('EmployId').asinteger;
bEnd:=adoquery1.fieldbyname('IsEnd').asboolean;
dDeliveryDate:=adoquery1.fieldbyname('DeliveryDate').asdatetime;
sMasterMemo:=trim(adoquery1.fieldbyname('Memo').asstring);
DeliveryDate.Date:=dDeliveryDate;
chkCancel.Checked :=bEnd;
edtMemo.text:=sMastermemo;
if nTableid=0 then
begin
nCusId:=adoquery1.fieldbyname('VendorId').asinteger;
sSql:= 'select * from vendor where vendorId= :vendorid'; end
else begin
nCusId:=adoquery1.fieldbyname('ClientId').asinteger;
sSql:= 'select * from client where clientId= :clientd';
end;
s:='';
if OpenTable('select * from employ where EmployId= :employid',nEmployid) then
s:=adoquery1.fieldbyname('name').asstring;
edtEmp.text:=s;
adoQuery1.close;
s:='';
if OpenTable(sSql,nCusid) then
s:=adoquery1.fieldbyname('ShortName').asstring;
edtName.text:=s;
adoQuery1.close;
end
else begin //add emptye record,so clear last infomation
chkCancel.checked:=false;
edtStore.Text:='';
edtEmp.Text:='';
deliveryDate.date:=date;
s:='';
nEmployId:=1;
if OpenTable('select * from employ where EmployId= :employid',nEmployid) then
s:=adoquery1.fieldbyname('name').asstring;
edtEmp.text:=s;
adoQuery1.close;
end;
end;
procedure TIOrderForm.FormShow(Sender: TObject);
begin
inherited;
DeliveryDate.Date :=date();
end;
procedure TIOrderForm.printClick(Sender: TObject);
begin
inherited;
formrpt1.frReport1.PrintPreparedReportDlg;
end;
procedure TIOrderForm.FormCreate(Sender: TObject);
begin
inherited;
if nTableid=10 then
begin
LblFormName.Caption :='销售订单';
caption:=lblFormName.caption;
lblName.caption:='客 户'
end;
end;
procedure TIOrderForm.cmdEditClick(Sender: TObject);
begin
inherited;
bOldEnd:=bEnd;
dOldDeliveryDate:=dDeliveryDate;
end;
procedure TIOrderForm.DBGrid1DblClick(Sender: TObject);
begin
inherited;
if cmdSave.Enabled then
begin
if SelectGoodsForm.NewStatus='O' then
if nCusid=-1 then
begin
Application.MessageBox('请选择客户!','提示',64);
exit;
end
else SelectGoodsForm.NewCusId:=nCusId;
if (dbGrid1.selectedindex = 0) and (dbGrid1.columns[0].FieldName='code') then
SelectGoodsForm.ShowModal;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -