📄 inv_dailypurchin_c.pas
字号:
unit Inv_DailyPurchIn_C;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Condition, StdCtrls, Db, AdODB, CheckLst, ExtEdit, Mask, linkedit;
Type
TFrm_Inv_DailyPurchIn_C = Class(TFrm_Base_Condition)
ChLstBx_WhSelect: TCheckListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label6: TLabel;
Label7: TLabel;
MEdt_StArtDate: TMaskEdit;
MEdt_EndDate: TMaskEdit;
ExtEdt_VendorCode1: TExtEdit;
Lbl_VendorName1: TLabel;
ChBx_SelectAll: TCheckBox;
Lbl_VendorName: TExtEdit;
ExtEdt_VendorCode: TLinkEdit;
procedure btn_okClick(Sender: TObject);
procedure ChLstBx_WhSelectClickCheck(Sender: TObject);
procedure MEdt_EndDateExit(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ChBx_SelectAllClick(Sender: TObject);
procedure FindVendorCode(Sender: TObject);
procedure ExtEdt_VendorCodeKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ExtEdt_VendorCodeButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure SetDBConnect(AdOConnection:TAdOConnection); Override;
end;
var
Frm_Inv_DailyPurchIn_C: TFrm_Inv_DailyPurchIn_C;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Inv_DailyPurchIn_C.btn_okClick(Sender: TObject);
var
i:integer;
StrTemp1,StrTemp2:String;
begin
inherited;
Condition:='';
for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
begin
if ChLstBx_WhSelect.Checked[i] then
begin
if Condition='' then
begin
Condition:='('''+GetCode(ChLstBx_WhSelect.Items.Strings[i])+'''';
ConditionHint:='仓库:'+GetName(ChLstBx_WhSelect.Items.Strings[i]);
end
else
begin
Condition:=Condition+','''+GetCode(ChLstBx_WhSelect.Items.Strings[i])+'''';
ConditionHint:=ConditionHint+'.'+GetName(ChLstBx_WhSelect.Items.Strings[i]);
end;
end;
end;
if pos('(',condition)<>0 then
Condition:=Condition+')';
ConditionHint:=ConditionHint+' 日期:从 '+MEdt_StArtDate.Text+' 到 '+MEdt_EndDate.Text;
if(ExtEdt_VendorCode.Text<>'')then
begin
StrTemp1:=' And InvInBill.VendorCode='''+ExtEdt_VendorCode.Text+'''';
StrTemp2:=' And OnCheckBill.VendorCode='''+ExtEdt_VendorCode.Text+'''';
ConditionHint:=ConditionHint+' 供应商: '+ExtEdt_VendorCode.Text+' '+Lbl_VendorName.text;
end
else
begin
StrTemp1:='';
StrTemp2:='';
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Delete #DailyPurchIn';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert #DailyPurchIn'
+' Select InvInBillLine.ItemCode As ItemCode'
+',Item.ItemName As ItemName'
+',InvInBillLine.ItemCode+'' ''+Item.ItemName As ItemCodeName'
+',Uom.UomName As UomName'
+',InvInBillLine.InvBillQty As InvBillQty'
+',Null As OnCheckQty'
+' From InvInBillLine'
+' join InvInBill on InvInBillLine.InvBillId=InvInBill.InvBillId'
+' join Item on InvInBillLine.ItemCode=Item.ItemCode'
+' join Uom on Item.UomCode=Uom.UomCode '
+IIFValue(Condition='',' where ',' Where (InvInBill.WHCode In '+Condition+') And ')
+' InvInBill.InvBillDate>='''+MEdt_StArtDate.Text+''''
+' And InvInBill.InvBillDate<='''+MEdt_EndDate.Text+''''
+' And ((InvInBill.BillTypeCode In (''0101'',''0102''))'
+' Or ((InvInBill.BillTypeCode In (''0103'')) And (InvInBill.InvBillWHChck=1)))'
+StrTemp1;
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert #DailyPurchIn'
+' Select OnCheckBillLine.ItemCode As ItemCode'
+',Item.ItemName As ItemName'
+',OnCheckBillLine.ItemCode+'' ''+Item.ItemName As ItemCodeName'
+',Uom.UomName As UomName'
+',Null As InvBillQty'
+',OnCheckBillLine.OnCheckQty As OnCheckQty'
+' From OnCheckBillLine'
+' join OnCheckBill on OnCheckBillLine.OnCheckBillId=OnCheckBill.OnCheckBillId'
+' join Item on OnCheckBillLine.ItemCode=Item.ItemCode'
+' join Uom on Item.UomCode=Uom.UomCode'
+IIFValue(Condition='',' where ',' Where OnCheckBill.WHCode In '+Condition+' and ')
+' OnCheckStatus=0 '
+' And OnCheckBill.OnCheckDate>='''+MEdt_StArtDate.Text+''''
+' And OnCheckBill.OnCheckDate<='''+MEdt_EndDate.Text+''''
+StrTemp2;
AdoQry_Tmp.ExecSQL;
Condition:='';
ModalResult:=mrOk;
end;
procedure TFrm_Inv_DailyPurchIn_C.ChLstBx_WhSelectClickCheck(
Sender: TObject);
var
i:Integer;
begin
inherited;
btn_ok.Enabled:=False;
for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
begin
if ChLstBx_WhSelect.Checked[i] then
btn_ok.Enabled:=True;
end;
end;
procedure TFrm_Inv_DailyPurchIn_C.MEdt_EndDateExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
Exit;
DateCheck(Sender);
if StrToDateTime(MEdt_EndDate.Text)<StrToDateTime(MEdt_StArtDate.Text) then
begin
DispInfo('结束时间不能小于开始时间',3);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Inv_DailyPurchIn_C.FormCreate(Sender: TObject);
begin
inherited;
MEdt_StArtDate.Text:=FormatDateTime('yyyy.mm.dd',IncMonth(Now,-1));
MEdt_EndDate.Text:=FormatDateTime('yyyy.mm.dd',Now);
end;
procedure TFrm_Inv_DailyPurchIn_C.ChBx_SelectAllClick(Sender: TObject);
var
i:integer;
begin
inherited;
if ChBx_SelectAll.Checked then
begin
for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
begin
ChLstBx_WhSelect.Checked[i]:=True;
end;
btn_ok.Enabled:=True;
end
else
begin
for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
begin
ChLstBx_WhSelect.Checked[i]:=False;
end;
btn_ok.Enabled:=False;
end;
end;
procedure TFrm_Inv_DailyPurchIn_C.SetDBConnect(
AdOConnection: TAdOConnection);
begin
if Self.DBConnect=nil then
begin
inherited;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select Warehouse.WHCode+'' ''+Warehouse.WHName As CodeName'
+' From Warehouse'
+' Join WHAccessCtrl On Warehouse.WHCode=WHAccessCtrl.WHCode'
+' Where WHAccessCtrl.EmployeeCode='''+UserCode+'''';
AdoQry_Tmp.Open;
ChLstBx_WhSelect.clear;
AdoQry_Tmp.First;
while not AdoQry_Tmp.Eof do
begin
ChLstBx_WhSelect.Items.Add(AdoQry_Tmp.fieldbyname('CodeName').AsString);
AdoQry_Tmp.Next;
end;
end;
end;
procedure TFrm_Inv_DailyPurchIn_C.FindVendorCode(Sender: TObject);
begin
inherited;
with AdoQry_tmp do
begin
Close;
Sql.text:='select VendorName from Vendor where VendorCode='''+Trim(ExtEdt_VendorCode.Text )+''''
+' and VendorUsable=1 ' ;
open;
if not eof then
Lbl_VendorName.text:=fieldbyname('VendorName').asstring;
end;
end;
procedure TFrm_Inv_DailyPurchIn_C.ExtEdt_VendorCodeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if(Key=120)then
CommonHint(Sender,AdoQry_Tmp,'VendorName','供应商名称','VendorCode',
'供应商代码','Vendor','VendorUsable=1');
end;
procedure TFrm_Inv_DailyPurchIn_C.ExtEdt_VendorCodeButtonClick(
Sender: TObject);
begin
inherited;
CommonHint(Sender,AdoQry_Tmp,'VendorName','供应商名称','VendorCode',
'供应商代码','Vendor','VendorUsable=1');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -