📄 inv_checkinvandbill.pas
字号:
unit Inv_CheckInvAndBill;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin;
Type
TFrm_Inv_CheckInvAndBill = Class(TFrm_Base_Qry)
CheckBox1: TCheckBox;
Label1: TLabel;
lbl_RecordCount: TLabel;
Label2: TLabel;
AdODataSet_Main: TAdODataSet;
procedure FormCreate(Sender: TObject);
procedure Act_nextExecute(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
procedure InitForm(Adoconnect:TAdoConnection);
{ Public declarations }
end;
var
Frm_Inv_CheckInvAndBill: TFrm_Inv_CheckInvAndBill;
implementation
uses Inv_Querystatus;
{$R *.DFM}
{ TFrm_Inv_CheckInvAndBill }
procedure TFrm_Inv_CheckInvAndBill.InitForm(Adoconnect: TAdoConnection);
begin
AdODataSet_Main.Connection:=Adoconnect;
AdoQry_Main.Connection:=Adoconnect;
AdoQry_Tmp.Connection:=Adoconnect;
Frm_Inv_QueryStatus.SetFocus;
act_next.Execute;
end;
procedure TFrm_Inv_CheckInvAndBill.FormCreate(Sender: TObject);
begin
inherited;
TlBtn_Look.Action:=act_next;
act_next.Visible:=False;
Frm_Inv_QueryStatus:=TFrm_Inv_QueryStatus.Create(Application);
Frm_Inv_QueryStatus.Show;
Frm_Inv_QueryStatus.refresh;
end;
procedure TFrm_Inv_CheckInvAndBill.Act_nextExecute(Sender: TObject);
var
sql_txt:string;
begin
inherited;
Sql_Txt:='create table #table'+
' (ItemCode varchAr(16),'+
' whCode varchAr(4),'+
' onCheckInv decimal(20,8) default 0,'+
' oncheckqty decimal(20,8) default 0,'+
' DifferentQty decimal(20,8) default 0)'+
' insert into #table'+
' select ItemCode,whCode,'+
' case when onCheckInv is Null then 0 else onCheckInv end onCheckInv,0,0'+
' from CurrentInv'+
' where onCheckInv<>0'+
' insert into #table(ItemCode,whCode)'+
' select c.ItemCode,c.whCode'+
' from (select distinct ItemCode,whCode,rTrim(ItemCode)+rTrim(whCode) flag'+
' from oncheckBillline bl,oncheckBill b'+
' where bl.oncheckBillid=b.oncheckBillid and'+
' bl.oncheckstatus=0 )c'+
' where c.flag not in'+
' (select distinct rTrim(ItemCode)+rTrim(whCode)'+
' from #table)'+
' update #table'+
' set oncheckqty=c.oncheckqty'+
' from (select distinct ItemCode,whCode,oncheckqty'+
' from oncheckBillline bl,oncheckBill b'+
' where bl.oncheckBillid=b.oncheckBillid and'+
' bl.oncheckstatus=0 )c'+
' where c.ItemCode=#table.ItemCode and c.whCode=#table.whCode'+
' update #table'+
' set DifferentQty=onCheckInv-oncheckqty'+
' select d.ItemCode+'' ''+I.ItemName 物料标识,'+
' d.whCode+'' ''+W.whName 仓库标识,'+
' d.onCheckInv 待检库存,'+
' d.oncheckqty 单据数量,'+
' d.DifferentQty 差异 '+
' from #table d,Item I,Warehouse W'+
' where d.DifferentQty<>0 and '+
' I.ItemCode=d.ItemCode and '+
' W.whCode=d.whCode '+
' drop table #table';
with AdODataSet_Main do
begin
CommandTimeout:=0;
Close;
CommandText:=sql_txt;
Open;
lbl_RecordCount.Caption:=inttostr(RecordCount);
end;
with DBGridEh do
begin
TFloatField(AdODataSet_Main.Fields[2]).displayFormat:='0.##';
TFloatField(AdODataSet_Main.Fields[3]).displayFormat:='0.##';
TFloatField(AdODataSet_Main.Fields[4]).displayFormat:='0.##';
Columns[0].Width:=250;
Columns[1].Width:=200;
Columns[2].Width:=100;
Columns[3].Width:=100;
Columns[4].Width:=100;
Frm_Inv_QueryStatus.Close;
Frozencols:=2;
ReFresh;
end;
end;
procedure TFrm_Inv_CheckInvAndBill.CheckBox1Click(Sender: TObject);
begin
inherited;
DBGridEh.AutoFitColWidths:=CheckBox1.Checked;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -