D7wmguihua/桂华管理系统/U_CKProductBCPOutList_other.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

1110 lines
32 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_CKProductBCPOutList_other;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView,
cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView,
cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu,
cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, RM_Common, RM_Class,
RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, cxCheckBox, Menus,
MovePanel;
type
TfrmCKProductBCPOutList_other = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBExport: TToolButton;
TBPrint: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
cxGridPopupMenu1: TcxGridPopupMenu;
Label3: TLabel;
Label4: TLabel;
C_CodeName: TEdit;
C_Color: TEdit;
Label1: TLabel;
Label2: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
CDS_Main: TClientDataSet;
Tv1: TcxGridDBTableView;
cxGrid2Level1: TcxGridLevel;
cxGrid2: TcxGrid;
v2Column1: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
Label5: TLabel;
orderNo: TEdit;
Label6: TLabel;
BCGangNO: TEdit;
v1Column7: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
Label8: TLabel;
MPRTKZ: TEdit;
Label9: TLabel;
MPRTMF: TEdit;
Label7: TLabel;
CPType: TComboBox;
v1Column3: TcxGridDBColumn;
CDS_PRT: TClientDataSet;
RM1: TRMGridReport;
RMDBMain: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
v1Column4: TcxGridDBColumn;
Label10: TLabel;
CkOrdNo: TEdit;
v1Column5: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
RMDB_Sub: TRMDBDataSet;
TBCKCX: TToolButton;
v1Column11: TcxGridDBColumn;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
MovePanel2: TMovePanel;
CDS_CX: TClientDataSet;
v1CRTYPE: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
v1gangNo: TcxGridDBColumn;
v1customerNoname: TcxGridDBColumn;
TBOtCk: TToolButton;
ADOPrint: TADOQuery;
RMDB_MD: TRMDBDataSet;
RMGridReport1: TRMGridReport;
v1note: TcxGridDBColumn;
customerNoname: TEdit;
Label11: TLabel;
TbNote: TToolButton;
v1defNote1: TcxGridDBColumn;
Label12: TLabel;
CRTYPE: TComboBox;
v1defstr1: TcxGridDBColumn;
v1Column13: TcxGridDBColumn;
Label13: TLabel;
packNo: TEdit;
ba: TLabel;
Label15: TLabel;
defNote1: TEdit;
CheckBox1: TCheckBox;
ToolButton3: TToolButton;
ADOPrint1: TADOQuery;
tbpackNo: TToolButton;
RMXLSExport2: TRMXLSExport;
v1Column14: TcxGridDBColumn;
v1Column15: TcxGridDBColumn;
v1Column16: TcxGridDBColumn;
Label14: TLabel;
PHYG: TEdit;
Label16: TLabel;
defstr2: TComboBox;
v1defstr2: TcxGridDBColumn;
ToolButton1: TToolButton;
CheckBox2: TCheckBox;
v1Column17: TcxGridDBColumn;
v1FHADDress: TcxGridDBColumn;
v1Column19: TcxGridDBColumn;
Label17: TLabel;
ToolButton2: TToolButton;
Panetime: TPanel;
MJID: TEdit;
Label18: TLabel;
Filler: TEdit;
Label19: TLabel;
v1Column18: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ConNoMChange(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBFindClick(Sender: TObject);
procedure PRTCodeNameChange(Sender: TObject);
procedure TBPrintClick(Sender: TObject);
procedure orderNoChange(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure TBCKCXClick(Sender: TObject);
procedure orderNoKeyPress(Sender: TObject; var Key: Char);
procedure TBOtCkClick(Sender: TObject);
procedure TbNoteClick(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure tbpackNoClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
private
TblCprk :string;
procedure InitGrid();
function YSData(Order_Main10:TClientDataSet):Boolean;
procedure CreateTable();
procedure DropTable();
{ Private declarations }
public
{ Public declarations }
end;
var
frmCKProductBCPOutList_other: TfrmCKProductBCPOutList_other;
implementation
uses
U_DataLink,U_Fun, U_Printckmd, U_CKProductCK, U_NoteList1,U_phYGList,U_NoteList,
U_CKProductCK_Other;
{$R *.dfm}
procedure TfrmCKProductBCPOutList_other.DropTable();
var
strSQL:string;
begin
// TblCprk := '[##CP_INOut123' + trim(DCode) + IntToStr(Handle)+formatdatetime('hhnnsszzz',time) + ']';
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
strSQL := 'IF OBJECT_ID(''tempdb..' + TblCprk + ''') IS NOT NULL DROP TABLE ' + TblCprk;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(strSQL);
ExecSQL;
end;
end;
procedure TfrmCKProductBCPOutList_other.CreateTable();
var
strSQL:string;
begin
TblCprk := '[##CP_PPack' + trim(DCode) + IntToStr(Handle)+formatdatetime('hhnnsszzz',time) + ']';
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
strSQL := 'IF OBJECT_ID(''tempdb..' + TblCprk + ''') IS NOT NULL DROP TABLE ' + TblCprk + #13
+ 'CREATE TABLE ' + TblCprk + ' ('
+ 'MainID VARCHAR(20),'
+ 'subID VARCHAR(20),'
+ 'BCID Varchar(20))'#13;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(strSQL);
ExecSQL;
end;
end;
procedure TfrmCKProductBCPOutList_other.FormDestroy(Sender: TObject);
begin
frmCKProductBCPOutList_other:=nil;
end;
procedure TfrmCKProductBCPOutList_other.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmCKProductBCPOutList_other.FormCreate(Sender: TObject);
begin
cxGrid2.Align:=alClient;
BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp)
end;
procedure TfrmCKProductBCPOutList_other.InitGrid();
begin
screen.Cursor:=crsqlwait;
Panetime.Visible:=true;
Panetime.Left:=(Width-Panetime.Width) div 2;
Panetime.top:=(Height-Panetime.Height-200) div 2;
application.ProcessMessages;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
sql.Clear;
Filtered:=False;
SQL.Add('select A.PHID,A.packNo,A.defNote1,A.defstr1,A.defstr2,A.defstr3,A.Filler,A.FillTime,A.note,A.ThCust,A.mainID,A.subID,A.MJID,A.BCID,');
SQL.Add('A.CRTime,A.CRType,A.CRID,A.Qty,A.RollNum,A.QtyUnit,A.CPType,A.CKOrdNo,A.C_CodeName,A.C_Color,A.RCgangNo,A.BCgangNO,a.kcKw,');
SQL.Add('B.OrderNo,B.customerNoname ');
sql.Add(',MF.defstr7 as PrtMF,MF.defstr8 as Prtkz,kgQty=A.Qty*isnull(MF.defstr8,0) ');
sql.Add(',isnull(customerNoName,B.OrderNo) KHName,B.FHADDress,B.lxfs');
sql.Add(',PHYG=(select Top 1 PHYG from CK_BanCP_PH X where X.phID=A.phID )');
sql.Add(',AOrddefstr4=(select AOrddefstr4 from JYOrder_Sub_AnPai X where X.apid=A.apid )');
sql.add('from CK_BanCP_CR1 A ');
Sql.add(' LEFT join JYOrder_Main B on A.MainId=B.MainId');
// Sql.add(' LEFT join JYOrder_Sub C on A.SubId=C.SubId');
Sql.add(' LEFT join KH_Zdy_Attachment MF on MF.zdyName=A.C_CodeName and MF.defstr3=A.C_Color');
sql.add('where A.CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''' ');
sql.add('and A.CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.DateTime+1))+''' ');
SQL.Add(' and CRflag =''<27><><EFBFBD><EFBFBD>'' ');
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
with ADOQueryTemp do
begin
Close;
sql.Clear;
Filtered:=False;
SQL.Add('select count(distinct ckOrdNO) as cnt ');
sql.add('from CK_BanCP_CR1 A ');
sql.add('where A.CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''' ');
sql.add('and A.CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.DateTime+1))+''' ');
SQL.Add(' and CRflag =''<27><><EFBFBD><EFBFBD>'' ');
Open;
Label17.Caption:='<27><><EFBFBD><EFBFBD><E2B5A5><EFBFBD><EFBFBD>0';
if not IsEmpty then
begin
Label17.Caption:='<27><><EFBFBD><EFBFBD><E2B5A5><EFBFBD><EFBFBD>'+Fieldbyname('cnt').AsString;
end;
end;
finally
ADOQueryMain.EnableControls;
tbfind.Click;
Panetime.Visible:=false;
screen.Cursor:=crdefault;
end;
end;
procedure TfrmCKProductBCPOutList_other.TBRafreshClick(Sender: TObject);
begin
BegDate.SetFocus;
InitGrid();
end;
procedure TfrmCKProductBCPOutList_other.ConNoMChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
end;
end;
procedure TfrmCKProductBCPOutList_other.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('<27>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
Close;
end;
procedure TfrmCKProductBCPOutList_other.FormShow(Sender: TObject);
begin
ReadCxGrid('<27>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Cast('''' as varchar(20)) MainId,Cast('''' as varchar(80)) KHName,Cast(0 as decimal(18,4)) PRTPrice ');
Open;
end;
SCreateCDS20(ADOQueryTemp,CDS_CX);
SInitCDSData20(ADOQueryTemp,CDS_CX);
CDS_CX.Delete;
//InitGrid();
if Trim(DParameters2)='<27><><EFBFBD><EFBFBD>' then
begin
TBCKCX.Visible:=True;
// TBOtCk.Visible:=true;
// TbNote.Visible:=true;
//TBPrint.Visible:=true;
// tbpackNo.Visible:=true;
end;
end;
procedure TfrmCKProductBCPOutList_other.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then exit;
SelExportData(Tv1,ADOQueryMain,'');
end;
procedure TfrmCKProductBCPOutList_other.TBFindClick(Sender: TObject);
var
strwhere:string;
begin
if ADOQueryMain.Active then
begin
strwhere:=SGetFilters(Panel1,1,2);
IF CheckBox2.Checked then
begin
IF trim(strwhere)='' then
strwhere:=strwhere+' customerNoname<>''<27><EFBFBD><E3B6AB><EFBFBD>в<EFBFBD>'' '
else
strwhere:=strwhere+' and customerNoname<>''<27><EFBFBD><E3B6AB><EFBFBD>в<EFBFBD>'' ';
end;
SDofilter(ADOQueryMain,strwhere);
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
end;
end;
procedure TfrmCKProductBCPOutList_other.PRTCodeNameChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmCKProductBCPOutList_other.TBPrintClick(Sender: TObject);
var
filepath,fOrderNo:string;
i:integer;
Txt,fImagePath:string;
Moudle: THandle;
Makebar:TMakebar;
Mixtext:TMixtext;
begin
if CDS_Main.IsEmpty then Exit;
if CDS_Main.Locate('ssel',true,[])=false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
CreateTable();
i:=0;
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
IF trim(Fieldbyname('customerNoname').AsString)<>'<27><EFBFBD><E3B6AB><EFBFBD>в<EFBFBD>'then
begin
IF i=0 then fOrderNo:=trim(fieldbyname('OrderNo').AsString);
IF (i>0) and (trim(fieldbyname('OrderNo').AsString)<> fOrderNo) then
begin
application.MessageBox('ѡ<><D1A1><EFBFBD>˲<EFBFBD>ͬ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>ӡ<EFBFBD><D3A1>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
EnableControls;
exit;
end;
end;
with adoqueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(' insert into '+TblCprk+'(BCID) values( ');
SQL.Add(' '+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
sql.add(')');
execsql;
end;
i:=i+1;
end;
next;
end;
First;
EnableControls;
end;
with AdoPrint do
begin
close;
sql.Clear;
sql.Add('exec P_Do_PrintMd10 ');
sql.Add('@mainID='+quotedstr(trim(CDS_Main.fieldbyname('MainID').AsString)));
sql.Add(',@TblCprk='+quotedstr(trim(TblCprk)));
sql.Add(',@flag='+quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')));
open;
end;
try
filepath:=ExtractFilePath(Application.ExeName) + 'report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>.rmf';
if not FileExists(Pchar(filepath)) then
begin
application.MessageBox(pchar('<27>ļ<EFBFBD>['+filepath+']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'),'<27><>ʾ<EFBFBD><CABE>Ϣ',MB_IConError);
exit;
end;
try
Moudle:=LoadLibrary('MakeQRBarcode.dll');
@Makebar:=GetProcAddress(Moudle,'Make');
@Mixtext:=GetProcAddress(Moudle,'MixText');
Txt:=Trim(AdoPrint.fieldbyname('orderNo').AsString);
fImagePath:=ExtractFilePath(Application.ExeName)+'image\temp.bmp';
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName)+'image')) then
CreateDirectory(pchar(ExtractFilePath(Application.ExeName)+'image'),nil);
if FileExists(fImagePath) then DeleteFile(fImagePath);
Makebar(pchar(Txt),Length(Txt),3,3,0,PChar(fImagePath),3);
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
exit;
end;
RMVariables['QRBARCODE']:=fImagePath;
RMVariables['dtxz'] :=FormatDateTime('yyyy-mm-dd',date());
RMVariables['zdr'] :=trim(DName);
RMVariables['Filler'] :=trim(CDS_Main.fieldbyname('Filler').AsString);
RMGridReport1.LoadFromFile(filepath);
RMGridReport1.ShowReport;
finally
DropTable();
end;
end;
procedure TfrmCKProductBCPOutList_other.orderNoChange(Sender: TObject);
begin
if Length(orderNo.Text)<4 then Exit;
end;
procedure TfrmCKProductBCPOutList_other.N1Click(Sender: TObject);
begin
SelOKNo(CDS_Main,True);
end;
procedure TfrmCKProductBCPOutList_other.N2Click(Sender: TObject);
begin
SelOKNo(CDS_Main,False);
end;
procedure TfrmCKProductBCPOutList_other.TBCKCXClick(Sender: TObject);
var
FFMainId,FPrice:String;
YFID,CRID:string;
begin
if CDS_Main.IsEmpty then Exit;
if CDS_Main.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
MovePanel2.Visible:=True;
MovePanel2.Refresh;
try
ADOQueryCmd.Connection.BeginTrans;
CDS_Main.DisableControls;
with CDS_Main do
begin
while CDS_Main.Locate('SSel',True,[])=True do
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR ');
sql.Add(' where MainID='''+Trim(CDS_Main.fieldbyname('MainID').AsString)+'''');
sql.Add(' and subID='''+Trim(CDS_Main.fieldbyname('subID').AsString)+'''');
sql.Add(' and YFName=''<27><><EFBFBD>۽<EFBFBD><DBBD><EFBFBD>'' ');
sql.Add(' and status>=''1'' ');
Open;
if not IsEmpty then
begin
CDS_Main.EnableControls;
MovePanel2.Visible:=False;
Application.MessageBox(<>տ<EFBFBD>û<EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
ADOQueryCmd.Connection.RollbackTrans;
exit;
end;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR ');
sql.Add(' where MainID='''+Trim(CDS_Main.fieldbyname('MainID').AsString)+'''');
sql.Add(' and subID='''+Trim(CDS_Main.fieldbyname('subID').AsString)+'''');
sql.Add(' and YFName=''<27><><EFBFBD>۽<EFBFBD><DBBD><EFBFBD>'' ');
Open;
if not IsEmpty then
begin
YFID:=Fieldbyname('YFID').AsString;
CRID:=Fieldbyname('CRID').AsString;
end;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPDATE CK_BanCp_KC1 SET kcstatus=''1'',KCKgQty =A.KCKgQty + B.KgQty,KCQty =A.KCQty + B.Qty,KCRollNum =1 ');
sql.Add('FROM CK_BanCp_KC1 A ');
sql.Add('INNER JOIN CK_BanCP_CR1 B on B.CRID=A.CRID and B.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add('WHERE B.BCID ='+Quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
sql.Add('UPDATE CK_BanCp_KC1 SET KCKgQty =A.KCKgQty + B.KgQty,KCQty =A.KCQty + B.Qty,KCRollNum =1 ');
sql.Add('FROM CK_BanCp_KC1 A ');
sql.Add('INNER JOIN CK_BanCP_CR1 B on B.CRID=A.CRID and B.CRType<>''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add('WHERE B.BCID ='+Quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
sql.Add('update JYOrder_sub SET substatus=''2'' ');
sql.Add('where mainID='+quotedstr(trim(CDS_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID='+quotedstr(trim(CDS_Main.fieldbyname('subID').AsString)));
sql.Add('and isnull(substatus,''0'')>''0'' ');
sql.Add('delete CK_BanCP_CR1 where BCID='''+Trim(CDS_Main.fieldbyname('BCID').AsString)+'''');
sql.Add('update CK_BanCP_PH1 SET P_status=''0'' where PHID='''+Trim(CDS_Main.fieldbyname('PHID').AsString)+'''');
sql.Add('update YF_Money_CR Set Qty=(select isnull(Sum(Qty),0) from CK_BanCP_CR1 A ');
sql.Add(' where A.mainID=YF_Money_CR.mainID and A.subiD=YF_Money_CR.subiD and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' )');
sql.Add(',PS=(select isnull(count(*),0) from CK_BanCP_CR1 A ');
sql.Add(' where A.mainID=YF_Money_CR.mainID and A.subiD=YF_Money_CR.subiD and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' )');
sql.Add(' where YFID='''+Trim(YFID)+'''');
sql.Add('delete from YF_Money_CR ');
sql.Add('where YFID='''+Trim(YFID)+''' and Qty=0 ');
sql.Add('Update YF_Money_CR Set Money=Price*Qty,BBMoney=Price*Qty*HuiLv');
sql.Add(' where YFID='''+Trim(YFID)+'''');
sql.Add('Update YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
sql.Add(' where CRID='''+Trim(CRID)+'''');
ExecSQL;
end;
CDS_Main.Delete;
end;
end;
CDS_Main.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
MovePanel2.Visible:=False;
Exit;
except
MovePanel2.Visible:=False;
CDS_Main.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
function TfrmCKProductBCPOutList_other.YSData(Order_Main10:TClientDataSet):Boolean;
var
CRID,YFID,Price,PriceUnit,OrderUnit:String;
begin
Result:=False;
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select Top 1 * from JYOrder_Sub Where Mainid='''+Trim(Order_Main10.fieldbyname('MainId').AsString)+'''');
//sql.Add(' and PRTPrice>0');
Open;
end;
{Price:=ADOQueryTemp.fieldbyname('PRTPrice').AsString;
if Trim(Price)='' then
begin
Price:='0';
end; }
PriceUnit:=Trim(ADOQueryTemp.fieldbyname('PriceUnit').AsString);
OrderUnit:=Trim(ADOQueryTemp.fieldbyname('OrderUnit').AsString);
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_KC where FactoryName='''+Trim(Order_Main10.fieldbyname('KHName').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
CRID:=ADOQueryTemp.fieldbyname('CRID').AsString;
end else
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_CRID set CRID=CRID+1');
sql.Add('select * from YF_Money_CRID ');
Open;
end;
CRID:=ADOQueryCmd.fieldbyname('CRID').AsString;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_KC where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('CRID').Value:=StrToInt(CRID);
FieldByName('FactoryName').Value:=Trim(Order_Main10.fieldbyname('KHName').AsString);
FieldByName('ZdyStr1').Value:=<><D3A6><EFBFBD><EFBFBD>';
Post;
end;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR where FactoryName='''+Trim(Order_Main10.fieldbyname('KHName').AsString)+'''');
sql.Add(' and YFTypeId='''+Trim(Order_Main10.fieldbyname('Mainid').AsString)+'''');
sql.Add(' and Price='''+Trim(Order_Main10.fieldbyname('PRTPrice').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty then
begin
if GetLSNo(ADOQueryCmd,YFID,'CS','YF_Money_CR',3,1)=False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
{with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('YFID').Value:=Trim(YFID);
FieldByName('YFTypeId').Value:=Trim(Order_Main10.fieldbyname('MainId').AsString);
FieldByName('CRID').Value:=StrToInt(CRID);
FieldByName('Filler').Value:=Trim(DName);
FieldByName('CRType').Value:='Ӧ<>տ<EFBFBD><D5BF>Ǽ<EFBFBD>';
FieldByName('CRFlag').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
FieldByName('QtyFlag').Value:=1;
FieldByName('FactoryName').Value:=Trim(Order_Main10.fieldbyname('KHName').AsString);
FieldByName('CRTime').Value:=SGetServerDateTime(ADOQueryTemp);
FieldByName('YFType').Value:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('Price').Value:=Price;
//FieldByName('HuiLv').Value:=1;
FieldByName('BZType').Value:=Trim(PriceUnit);
FieldByName('QtyUnit').Value:=Trim(OrderUnit);
FieldByName('YFName').Value:='<27><><EFBFBD>۽<EFBFBD><DBBD><EFBFBD>';
FieldByName('MainId').Value:=Trim(Order_Main10.fieldbyname('Mainid').AsString);
Post;
end; }
end else
begin
YFID:=Trim(ADOQueryTemp.fieldbyname('YFID').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('update YF_Money_CR Set Qty=(select isnull(Sum(Qty),0) from CK_BanCP_CR A ');
sql.Add(' inner join JYOrder_Sub B on A.SubId=B.SubId where');
SQL.Add(' A.MainId=YF_Money_CR.YFTypeId and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' and CPType=''<27><>Ʒ'' ');
SQL.Add(' and B.PRTPrice=YF_Money_CR.Price)');
sql.Add(',PS=(select isnull(count(*),0) from CK_BanCP_CR A ');
sql.Add(' inner join JYOrder_Sub B on A.SubId=B.SubId where');
SQL.Add(' A.MainId=YF_Money_CR.YFTypeId and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' and CPType=''<27><>Ʒ'' ');
SQL.Add(' and B.PRTPrice=YF_Money_CR.Price )');
sql.Add(' where YFTypeId='''+Trim(Order_Main10.fieldbyname('Mainid').AsString)+'''');
sql.Add(' and Price='+Order_Main10.fieldbyname('PRTPrice').AsString);
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_CR Set Money=Price*Qty,BBMoney=Price*Qty*HuiLv');
sql.Add(' where YFID='''+Trim(YFID)+'''');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
sql.Add(' where CRID='+CRID);
ExecSQL;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR where YFId='''+Trim(YFID)+'''');
Open;
end;
if ADOQueryTemp.FieldByName('Qty').Value=0 then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete from YF_Money_CR where YFID='''+Trim(YFID)+'''');
ExecSQL;
end;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR where CRId='+CRID);
Open;
end;
if ADOQueryTemp.IsEmpty then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete from YF_Money_KC where CRId='+CRID);
ExecSQL;
end;
end;
Result:=True;
end;
procedure TfrmCKProductBCPOutList_other.orderNoKeyPress(Sender: TObject;
var Key: Char);
begin
if Key=#13 then
begin
if Length(Trim(orderNo.Text))<4 then Exit;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
sql.Clear;
Filtered:=False;
SQL.Add('select A.*,B.OrderNo,ISNULL(C.PRTCode,A.C_Code) as PRTCode,ISNULL(C.PRTCodeName,A.C_COdeName) as PRTCodeName,C.PRTSpec,isnull(C.prtColor,A.C_Color) as prtColor,B.MPRTMF,B.MPRTKZ,B.customerNoname,C.PRTPrice ');
sql.Add(',isnull(customerNoName,B.OrderNo) KHName,B.FHADDress,B.lxfs');
sql.Add(',PHYG=(select Top 1 PHYG from CK_BanCP_PH X where X.phID=A.phID )');
sql.Add(',AOrddefstr4=(select AOrddefstr4 from JYOrder_Sub_AnPai X where X.apid=A.apid )');
sql.add('from CK_BanCP_CR A ');
Sql.add(' LEFT join JYOrder_Main B on A.MainId=B.MainId');
Sql.add(' LEFT join JYOrder_Sub C on A.SubId=C.SubId');
sql.add('where B.OrderNo='+quotedstr(trim(OrderNo.Text)));
SQL.Add(' and CRflag =''<27><><EFBFBD><EFBFBD>'' ');
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
with ADOQueryTemp do
begin
Close;
sql.Clear;
Filtered:=False;
SQL.Add('select count(distinct ckOrdNO) as cnt ');
sql.add('from CK_BanCP_CR A ');
Sql.add(' LEFT join JYOrder_Main B on A.MainId=B.MainId');
Sql.add(' LEFT join JYOrder_Sub C on A.SubId=C.SubId');
sql.add('where B.OrderNo='+quotedstr(trim(OrderNo.Text)));
SQL.Add(' and CRflag =''<27><><EFBFBD><EFBFBD>'' ');
Open;
Label17.Caption:='<27><><EFBFBD><EFBFBD><E2B5A5><EFBFBD><EFBFBD>0';
if not IsEmpty then
begin
Label17.Caption:='<27><><EFBFBD><EFBFBD><E2B5A5><EFBFBD><EFBFBD>'+Fieldbyname('cnt').AsString;
end;
end;
finally
ADOQueryMain.EnableControls;
end;
end;
end;
procedure TfrmCKProductBCPOutList_other.TBOtCkClick(Sender: TObject);
begin
frmCKProductCK_other:=TfrmCKProductCK_other.create(self);
with frmCKProductCK_other do
begin
if Trim(DParameters2)<>'<27><><EFBFBD><EFBFBD>' then
begin
CRType.Items.Clear;
// CRType.Items.Add('<27>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>');
CRType.Items.Add('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>');
// CRType.Items.Add('<27><><EFBFBD>޳<EFBFBD><DEB3><EFBFBD>');
CRType.Items.Add('<27><><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>');
// CRType.Items.Add('<27><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>');
CRType.ItemIndex:=0;
end;
if showmodal=1 then
begin
self.TBRafresh.Click;
end;
free;
end;
end;
procedure TfrmCKProductBCPOutList_other.TbNoteClick(Sender: TObject);
var
Fnote:string;
begin
IF CDS_Main.IsEmpty then exit;
frmwlnote1:=Tfrmwlnote1.create(self);
with frmwlnote1 do
begin
if showmodal=1 then
begin
Fnote:=trim(Memo1.Text);
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update CK_Bancp_CR1 SET defNote1='+quotedstr(trim(Memo1.Text)));
sql.Add('where BCID='+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
{ sql.Add('update BP_InOut SET defNote1='+quotedstr(trim(Memo1.Text)));
sql.Add('where FromSubID='+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString))); }
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
TBRafresh.Click;
end;
close;
end;
end;
procedure TfrmCKProductBCPOutList_other.CheckBox1Click(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value:=checkbox1.Checked;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmCKProductBCPOutList_other.ToolButton3Click(Sender: TObject);
var
filepath:string;
begin
if CDS_Main.IsEmpty then exit;
if CDS_Main.Locate('ssel',true,[])=false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
CreateTable();
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
with adoqueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(' insert into '+TblCprk+'(BCID) values( ');
SQL.Add(' '+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
sql.add(')');
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
with AdoPrint do
begin
close;
sql.Clear;
sql.Add('exec P_Get_CpCkpackList ');
sql.Add('@mainID='+quotedstr(trim('')));
sql.Add(',@TblCprk='+quotedstr(trim(TblCprk)));
sql.Add(',@flag='+quotedstr(trim('1')));
open;
end;
with AdoPrint1 do
begin
close;
sql.Clear;
sql.Add('exec P_Get_CpCkpackList ');
sql.Add('@mainID='+quotedstr(trim('')));
sql.Add(',@TblCprk='+quotedstr(trim(TblCprk)));
sql.Add(',@flag='+quotedstr(trim('10')));
open;
end;
try
filepath:=ExtractFilePath(Application.ExeName) + 'report\<5C><>Ʒ<EFBFBD><C6B7><EFBFBD>ⵥ.rmf';
if not FileExists(Pchar(filepath)) then
begin
application.MessageBox(pchar('<27>ļ<EFBFBD>['+filepath+']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'),'<27><>ʾ<EFBFBD><CABE>Ϣ',MB_IConError);
exit;
end;
RMVariables['begdate'] :=FormatDateTime('yyyy-MM-dd',BegDate.DateTime)+' - '+FormatDateTime('yyyy-MM-dd',enddate.DateTime);
RMVariables['dtxz'] :=FormatDateTime('yyyy-mm-dd',date());
RMVariables['zdr'] :=trim(DName);
RMVariables['Filler'] :=trim(CDS_Main.fieldbyname('Filler').AsString);
RMGridReport1.LoadFromFile(filepath);
RMGridReport1.ShowReport;
finally
end;
DropTable();
end;
procedure TfrmCKProductBCPOutList_other.tbpackNoClick(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
frmwlnote:=Tfrmwlnote.create(self);
with frmwlnote do
begin
frmwlnote.Caption:='<27><><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>';
frmwlnote.Label1.Caption:='<27><><EFBFBD><EFBFBD>';
if showmodal=1 then
begin
// Fnote:=trim(Memo1.Text);
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update CK_Bancp_CR SET packNo='+quotedstr(trim(Memo1.Text)));
sql.Add('where BCID='+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
TBRafresh.Click;
end;
close;
end;
end;
procedure TfrmCKProductBCPOutList_other.ToolButton1Click(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
frmwlnote:=Tfrmwlnote.create(self);
with frmwlnote do
begin
frmwlnote.Caption:='<27>޸Ļ<DEB8><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
frmwlnote.Label1.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if showmodal=1 then
begin
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update CK_Bancp_CR SET defstr2='+quotedstr(trim(Memo1.Text)));
sql.Add('where BCID='+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
sql.Add('update BP_InOut SET defstr2='+quotedstr(trim(Memo1.Text)));
sql.Add('where FromSubID='+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
TBRafresh.Click;
end;
close;
end;
end;
procedure TfrmCKProductBCPOutList_other.CheckBox2Click(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmCKProductBCPOutList_other.ToolButton2Click(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
frmphYGList:=TfrmphYGList.create(self);
with frmphYGList do
begin
if showmodal=1 then
begin
// Fnote:=trim(Memo1.Text);
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update CK_Bancp_PH SET PHYG='+quotedstr(trim(PHYG.Text)));
sql.Add('from CK_Bancp_PH A');
sql.Add('inner JOIN CK_Bancp_CR B on B.PHID=A.PHID ');
sql.Add('where B.BCID='+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
TBRafresh.Click;
end;
close;
end;
end;
end.