📄 selsettleqry.~pas
字号:
unit selSettleQry;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGridEh, xEhLibCtl, RzButton, RzRadChk, ComCtrls, RzDTP,
RzBtnEdt, StdCtrls, Mask, RzEdit, RzCmboBx, RzLabel, RzPanel, RzSplit,
TFlatSpeedButtonUnit, ExtCtrls, RzStatus, TFlatPanelUnit, Menus, ImgList,
ActnList, ModuleAction, DB, DBClient, MConnect, ckDBClient, StrUtils,
xBaseFrm, IMainFrm, uGlobal, uDataTypes;
type
TFmSelSettleQry = class(TxBaseForm)
dsCheckSurplus: TDataSource;
cdsSelSettle: TckClientDataSet;
DCOMConnection1: TDCOMConnection;
ActionList1: TActionList;
ActQuery: TModlAction;
ActReport: TModlAction;
ActFieldsLayout: TModlAction;
ActDataExport: TModlAction;
ActDesignReport: TModlAction;
ActViewBill: TModlAction;
ImageList1: TImageList;
TopPopMenu: TPopupMenu;
SetFields1: TMenuItem;
refresh1: TMenuItem;
ptBkPanel: TFlatPanel;
FlatPanel2: TPanel;
BtnWhatIs: TFlatSpeedButton;
BtnHelp: TFlatSpeedButton;
FlatPanel3: TPanel;
BtnPopMenu: TFlatSpeedButton;
RzSizePanel1: TRzSizePanel;
RzGroupBox1: TRzGroupBox;
RzLabel1: TRzLabel;
Label7: TLabel;
RzLabel18: TRzLabel;
RzLabel4: TRzLabel;
RzLabel5: TRzLabel;
RzLabel19: TRzLabel;
RzLabel25: TRzLabel;
RzLabel26: TRzLabel;
RzLabel17: TRzLabel;
RzLabel3: TRzLabel;
RzLabel6: TRzLabel;
RzLabel20: TRzLabel;
RzLabel2: TRzLabel;
RzLabel8: TRzLabel;
RzLabel23: TRzLabel;
RzLabel24: TRzLabel;
Label1: TLabel;
cbPayModeNo: TRzComboBox;
cbInOutKind: TRzComboBox;
edBillNo1: TRzEdit;
edAccountNo: TRzEdit;
edTaxNo: TRzEdit;
edDepartID: TRzEdit;
edTelephone: TRzEdit;
cbAccountBank: TRzComboBox;
cbCompanyName: TRzComboBox;
edLinkman: TRzButtonEdit;
edPayDate1: TRzDateTimePicker;
edInvoiceDate1: TRzDateTimePicker;
edDate1: TRzDateTimePicker;
ckMultiSelect: TRzCheckBox;
edCustNo: TRzButtonEdit;
edEmpNo: TRzButtonEdit;
edAudit: TRzButtonEdit;
edGoodsID: TRzButtonEdit;
RzBitBtn1: TRzBitBtn;
RzBitBtn2: TRzBitBtn;
RzBitBtn3: TRzBitBtn;
dbgSelSettle: TxDBGridEh;
Label2: TLabel;
edBillNo2: TRzEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
edDate2: TRzDateTimePicker;
Label6: TLabel;
Label8: TLabel;
Label9: TLabel;
edInvoiceDate2: TRzDateTimePicker;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
edPayDate2: TRzDateTimePicker;
Label13: TLabel;
procedure ActQueryExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ActReportExecute(Sender: TObject);
procedure ActViewBillExecute(Sender: TObject);
procedure edCustNoButtonClick(Sender: TObject);
procedure edLinkmanButtonClick(Sender: TObject);
procedure edEmpNoButtonClick(Sender: TObject);
procedure edAuditButtonClick(Sender: TObject);
procedure edGoodsIDButtonClick(Sender: TObject);
procedure edBillNo2KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
IFmMain: IMainForm;
LocSetting: PLocSetting;
iClientID: Integer;
SvrSelSettle,SvrCommon: TDispatchConnection;
CdsFieldProperty :TckClientDataSet;
procedure GetPayModes;
function InitialDate: TDate;
public
{ Public declarations }
end;
var
FmSelSettleQry: TFmSelSettleQry;
implementation
uses SelectGoodsFrm,ceGlobal, ShowProGress, FieldsLayoutFrm, RepSelectFrm, DataExportFrm,
SelectCustFrm,SelectEmpFrm,SelectDepartFrm,SelectPayMode,DBFuncs,SelectProvLinkManFrm;
Const
sFieldProPerty='Select * From SysFieldProperty '+' Where TableName=''SelSettle''';
sPayModes='Select PayModeNo,PayModename,TimeLimit From PayModes order By PayModeNO';
{$R *.dfm}
procedure TFmSelSettleQry.FormCreate(Sender: TObject);
begin
CdsFieldProperty := TckClientDataSet.Create(Self);
edDate1.Date := InitialDate;
edDate2.Date := Date;
edinvoiceDate1.Date := InitialDate;
edinvoiceDate2.Date := Date;
edPayDate1.Date := InitialDate;
edPayDate2.Date := Date;
IFmMain := Application.MainForm as IMainForm;
LocSetting := IFmMain.IFmMainEx.GetLocSetting;
iClientID := IFmMain.IFmMainEx.ClientID;
SetGressHint('正在连接到公用信息服务器...');
SvrCommon := IFmMain.GetConnection(Handle, '', 'CommonSvr.CommonRDM');
SvrSelSettle:=iFmMain.GetConnection(Handle,'','CKSalesBase.SalesBase');
cdsSelSettle.RemoteServer := SvrCommon;
CdsFieldProPerty.ProviderName:='DspTemp';
CdsFieldProPerty.RemoteServer:=SvrCommon;
end;
procedure TFmSelSettleQry.FormShow(Sender: TObject);
var sTableNames: string;
begin
SetGressHint('初始化本地环境...');
IFmMain.SetActionStatus(ActionList1, hInstance, self.ClassName);
SysFieldXml(CdsFieldProPerty,sFieldProPerty,'TFmSelSettleQry.Xml');
sTableNames:='SelSettle';
SetFieldProperty(CdsFieldProPerty,CdsSelSettle,sTableNames);
SetGridEhColor([dbgSelSettle]);
ptBkPanel.Color := TitlePanelColor;
GetPayModes;
FreeGressForm;
end;
procedure TFmSelSettleQry.ActQueryExecute(Sender: TObject);
var
sTableNames,s,swMst,swDtl:string;
i:integer;
begin
swMst:=swMst+' and FDate>='''+FormatDateTime('yyyy-mm-dd',edDate1.Date)
+''' and FDate<='''+FormatDateTime('yyyy-mm-dd',edDate2.Date)+'''';
swMst:=swMst+' and InvoiceDate>='''+FormatDateTime('yyyy-mm-dd',edInvoicedate1.Date)
+''' and InvoiceDate<='''+FormatDateTime('yyyy-mm-dd',edInvoicedate2.Date)+'''';
swMst:=swMst+' and PayDate>='''+FormatDateTime('yyyy-mm-dd',edPayDate1.Date)
+''' and PayDate<='''+FormatDateTime('yyyy-mm-dd',edPayDate2.Date)+'''';
s:=edBillNo1.Text;
if s<>'' then
begin
if edBillNo2.Text<>'' then
swMst:=swMst+' and BillNo>='''+s+''' and BillNo<=''' + edBillNo2.Text + ''''
else
swMst:=swMst+' BillNo='''+s+'''';
end;
s:=cbInOutKind.Text;
if s<>'' then
begin
s:=copy(s,1,1);
swMst:=swMst+' and InOutKind='+s;
end;
s:=cbAccountBank.Text;
if s<>'' then
swMst:=swMst+' and AccountBank='''+s+'''';
s:=edLinkman.Text;
if s<>'' then
swMst:=swMst+' and Linkman='''+s+'''';
s:=edDepartID.Text;
if s<>'' then
swMst:=swMst+' and DepartID='+s;
s:=edTelephone.Text;
if s<>'' then
swMst:=swMst+' and Telephone='''+s+'''';
s:=edAccountNo.Text;
if s<>'' then
swMst:=swMst+' and AccountNo='''+s+'''';
s:=edTaxNo.Text;
if s<>'' then
swMst:=swMst+' and TaxNo='''+s+'''';
s:=cbPayModeNo.Text;
if s<>'' then
swMst:=swMst+' and PayModeNo='''+s+'''';
s:=edEmpNo.Text;
if s<>'' then
swMst:=swMst+' and EmpNo='''+s+'''';
s:=edAudit.Text;
if s<>'' then
swMst:=swMst+' and Audit='''+s+'''';
s:=edCustNo.Text;
if s<>'' then
swMst:=swMst+' and CustNo='''+s+'''';
s:=edGoodsID.Text;
if s<>'' then
begin
if AnsiPos(',', s)>0 then
swDtl := swDtl + ' and GoodsID in(''' + AnsiReplaceText(swDtl, ',', ''',''') + ''')'
else
swDtl := ' AND GoodsID Like '''+edGoodsID.Text+'''';
end;
cdsSelSettle.Close;
cdsSelSettle.Data := SvrCommon.AppServer.QueryBill(iClientID, 'SelSettle', swMst, swDtl);
sTableNames := 'PchSettle';
SetFieldProperty(CdsFieldProPerty,cdsSelSettle,sTableNames);
end;
procedure TFmSelSettleQry.GetPayModes;
Var
A:Variant;
iClientID, i, k:Integer;
begin
iClientID := IFmMain.IFmMainEx.ClientID;
A:=SvrSelSettle.AppServer.GetNeedValue(iClientID,3,sPayModes);
If (Not VarIsNull(A)) And (VarIsArray(A)) Then
Begin
cbPayModeNo.Items.Clear;
k := VarArrayHighBound(A,2);
for i:=VarArrayLowBound(A,2) to k do
cbPayModeNo.Items.Add(A[0,i]+':'+A[1,i]+'('+A[2,i]+')');
End;
end;
procedure TFmSelSettleQry.ActReportExecute(Sender: TObject);
begin
SelRepPrint(self.Name, [cdsSelSettle], '采购结算单查询', ActDesignReport.Enabled);
end;
procedure TFmSelSettleQry.ActViewBillExecute(Sender: TObject);
var Values: Variant;
sBillNo, sBills: String;
mark: TBookmark;
begin
if cdsSelSettle.IsEmpty then Exit;
with cdsSelSettle do begin
sBillNo := FieldByName('BillNo').AsString;
mark := GetBookmark;
DisableControls;
try
First;
while not Eof do begin
sBills := sBills+FieldByName('BillNo').AsString+#13;
Next;
end;
finally
GotoBookmark(mark);
FreeBookmark(mark);
EnableControls;
end;
end;
Values := VarArrayCreate([0,1], varOleStr);
Values[0] := sBillNo;
Values[1] := sBills;
IFmMain.DoSome(ActViewBill.ModuleFile, 'ViewBill', Values);
Values := NULL;
end;
procedure TFmSelSettleQry.edCustNoButtonClick(Sender: TObject);
Var
CustNo :String;
CustName :String;
begin
CustNo := '';
CustName := '';
if SelectCust(CustNo,CustName) then
edCustNo.Text := CustNo;
end;
procedure TFmSelSettleQry.edLinkmanButtonClick(Sender: TObject);
var sCustNo,sLinkMan:string;
begin
sCustNo:=edCustNo.Text;
If SelectProvLinkMan(sCustNo,sLinkMan) Then
edLinkman.Text:=sLinkman;
end;
procedure TFmSelSettleQry.edEmpNoButtonClick(Sender: TObject);
Var
EmpNo :String;
EmpName :String;
begin
EmpNo := '';
EmpName := '';
if SelectEmp(EmpNo,EmpName) then
edEmpNo.Text := EmpNo;
end;
procedure TFmSelSettleQry.edAuditButtonClick(Sender: TObject);
Var
EmpNo :String;
EmpName :String;
begin
EmpNo := '';
EmpName := '';
if SelectEmp(EmpNo,EmpName) then
edAudit.Text := EmpNo;
end;
procedure TFmSelSettleQry.edGoodsIDButtonClick(Sender: TObject);
var
sGoodsId :String;
begin
sGoodsID := '';
if ckMultiSelect.Checked then
begin
if SelectGoodsID(sGoodsID, true) then
If edGoodsID.Text<>'' Then
edGoodsId.Text := edGoodsId.Text+','+sGoodsId
else
edGoodsId.Text := sGoodsID;
End
else if SelectGoodsID(sGoodsID, false) then
edGoodsID.text := sGoodsID;
end;
procedure TFmSelSettleQry.edBillNo2KeyPress(Sender: TObject;
var Key: Char);
begin
if Key=#13 then
actQuery.Execute;
end;
function TFmSelSettleQry.InitialDate: TDate;
begin
result := StrToDateTime(FormatDateTime('yyyy-mm-01', Date));
end;
initialization
RegisterClass(TFmSelSettleQry);
finalization
UnRegisterClass(TFmSelSettleQry);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -