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

910 lines
26 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_CKProductBCPInList;
interface
uses
Windows, Messages, strutils,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, cxCheckBox, RM_Common,
RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, Menus,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;
type
TfrmCKProductBCPInList = 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;
Label5: TLabel;
conNo: TEdit;
Label6: TLabel;
MJID: TEdit;
Label8: TLabel;
KZ: TEdit;
Label9: TLabel;
MF: TEdit;
Label7: TLabel;
CPType: TComboBox;
cxGrid2: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column1: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
Label10: TLabel;
BCGangNo: TEdit;
RM1: TRMGridReport;
RMDBMain: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
RMDBHZ: TRMDBDataSet;
CDS_HZ: TClientDataSet;
CDS_PRT: TClientDataSet;
TBRKCX: TToolButton;
v1Column4: TcxGridDBColumn;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
v1RollNum: TcxGridDBColumn;
TBADD: TToolButton;
v1C_Color: TcxGridDBColumn;
v1gangNO: TcxGridDBColumn;
v1kcKw: TcxGridDBColumn;
v1CRType: TcxGridDBColumn;
TBEdit: TToolButton;
CRTYPE: TComboBox;
Label12: TLabel;
v1ThCust: TcxGridDBColumn;
v1Note: TcxGridDBColumn;
v1factoryNoName: TcxGridDBColumn;
Label11: TLabel;
factoryNoName: TEdit;
Label13: TLabel;
ThCust: TEdit;
CheckBox1: TCheckBox;
ADOPrint1: TADOQuery;
ADOPrint: TADOQuery;
RMDB_MD: TRMDBDataSet;
RMDB_Sub: TRMDBDataSet;
v1Column11: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
v1Column13: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
v1Column15: TcxGridDBColumn;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton1: TToolButton;
ToolButton6: TToolButton;
RMGridReport1: TRMGridReport;
ADOQueryPrint: TADOQuery;
RMDB_Main: TRMDBDataSet;
v1Column16: TcxGridDBColumn;
TBprint2: TToolButton;
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 C_CodeNameChange(Sender: TObject);
procedure TBPrintClick(Sender: TObject);
procedure conNoChange(Sender: TObject);
procedure conNoKeyPress(Sender: TObject; var Key: Char);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure TBRKCXClick(Sender: TObject);
procedure TBADDClick(Sender: TObject);
procedure TBEditClick(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure TBprint2Click(Sender: TObject);
private
TblCprk:string;
procedure InitGrid();
procedure DropTable();
procedure CreateTable();
{ Private declarations }
public
fDParameters2:string;
{ Public declarations }
end;
var
frmCKProductBCPInList: TfrmCKProductBCPInList;
implementation
uses
U_DataLink,U_Fun, U_Printckmd, U_CPRK,U_CKProductBCPOutth, U_NoteList,
U_YGList, U_RKSMEdit;
{$R *.dfm}
procedure TfrmCKProductBCPInList.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 TfrmCKProductBCPInList.CreateTable();
var
strSQL:string;
begin
TblCprk := '[##CP_RK10' + 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 TfrmCKProductBCPInList.FormDestroy(Sender: TObject);
begin
frmCKProductBCPInList:=nil;
end;
procedure TfrmCKProductBCPInList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
writeCxGrid(self.Caption,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
Action:=caFree;
end;
procedure TfrmCKProductBCPInList.FormCreate(Sender: TObject);
begin
//cxGrid1.Align:=alClient;
BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp)
end;
procedure TfrmCKProductBCPInList.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
sql.Clear;
Filtered:=False;
SQL.Add('select A.defstr1,A.defstr2,A.defstr3,A.Filler,A.FillTime,A.note,A.ThCust,A.mainID,A.subID,A.MJID,A.BCID,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('conNo=(select top 1 ConNo from WFB_MJJY X where X.MJID=A.MJID),');
sql.Add('factoryNoName=(select X.Aorddefstr4 from JYOrder_Sub_AnPai X where X.APID=A.APID), ');
sql.Add('C_CodeNameZw=(select MAX(defnote3) from KH_Zdy_Attachment X where X.ZdyName=A.C_CodeName) ');
sql.add('from CK_BanCP_CR 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 A.C_CodeName like '+quotedstr('%'+trim(C_CodeName.Text)+'%'));
sql.add('and A.C_Color like '+quotedstr('%'+trim(C_Color.Text)+'%'));
sql.add('and A.BCGangNo like '+quotedstr('%'+trim(BCGangNo.Text)+'%'));
SQL.Add('and A.CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
finally
ADOQueryMain.EnableControls;
end;
TBFind.Click;
end;
procedure TfrmCKProductBCPInList.TBRafreshClick(Sender: TObject);
begin
// BegDate.SetFocus;
InitGrid();
end;
procedure TfrmCKProductBCPInList.ConNoMChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
end;
end;
procedure TfrmCKProductBCPInList.TBCloseClick(Sender: TObject);
begin
//ReadCxGrid(self.Caption,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
Close;
end;
procedure TfrmCKProductBCPInList.FormShow(Sender: TObject);
begin
ReadCxGrid(self.Caption,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
if Trim(fDParameters2)='<27><><EFBFBD><EFBFBD>' then
begin
TBRKCX.Visible:=True;
end;
if Trim(fDParameters2)='<27><>ѯ' then
begin
TBADD.Visible:=false;
TBEdit.Visible:=false;
TBRKCX.Visible:=false;
ToolButton3.Visible:=false;
ToolButton4.Visible:=false;
ToolButton5.Visible:=false;
end;
//InitGrid();
end;
procedure TfrmCKProductBCPInList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then exit;
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid2);
end;
procedure TfrmCKProductBCPInList.TBFindClick(Sender: TObject);
var
strwhere:string;
begin
if ADOQueryMain.Active then
begin
strwhere:= SGetFilters(Panel1,1,2);
SDofilter(ADOQueryMain,strwhere);
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
end;
end;
procedure TfrmCKProductBCPInList.C_CodeNameChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmCKProductBCPInList.TBPrintClick(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_CprkList ');
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_CprkList ');
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);
RM1.LoadFromFile(filepath);
RM1.ShowReport;
finally
end;
DropTable();
end;
procedure TfrmCKProductBCPInList.conNoChange(Sender: TObject);
begin
// if Length(Trim(conNo.Text))<4 then Exit;
TBFind.Click;
end;
procedure TfrmCKProductBCPInList.conNoKeyPress(Sender: TObject;
var Key: Char);
begin
{ if Key=#13 then
begin
if Length(Trim(conNo.Text))<4 then Exit;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
SQL.Add('select A.*,B.ConNo,C.C_Color,C.MF,C.KZ,D.MJXH');
sql.Add(',isnull(factoryNoName,B.ConNo) KHName');
sql.Add(',E.AOrdDefStr1');
sql.add('from CK_BanCP_CR A ');
Sql.add(' left join Contract_Main B on A.MainId=B.MainId');
Sql.add(' left join Contract_sub C on A.SubId=C.SubId');
Sql.add(' left join WFB_MJJY D on A.MJId=D.MJId');
sql.Add(' left join JYOrder_Sub_AnPai E on A.APID=E.APID');
sql.add('where A.orderNo
SQL.Add(' and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
Parameters.ParamByName('orderNo').Value:='%'+Trim(conNo.Text)+'%';
Open;
//ShowMessage(SQL.Text);
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
finally
ADOQueryMain.EnableControls;
end;
end; }
end;
procedure TfrmCKProductBCPInList.N1Click(Sender: TObject);
begin
SelOKNo(CDS_Main,True);
end;
procedure TfrmCKProductBCPInList.N2Click(Sender: TObject);
begin
SelOKNo(CDS_Main,False);
end;
procedure TfrmCKProductBCPInList.TBRKCXClick(Sender: TObject);
var
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>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
BegDate.SetFocus;
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_Main do
begin
while Locate('SSel',True,[]) do
begin
IF trim(CDS_Main.fieldbyname('CRType').AsString)='<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR ');
sql.Add(' where MainID='''+Trim(CDS_Main.fieldbyname('ckordNo').AsString)+'''');
sql.Add(' and P_COdeName='''+Trim(CDS_Main.fieldbyname('C_COdeName').AsString)+'''');
sql.Add(' and P_Color='''+Trim(CDS_Main.fieldbyname('C_COlor').AsString)+'''');
sql.Add(' and YFName=''<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(' and status>=''1'' ');
Open;
if not IsEmpty then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<>տ<EFBFBD>û<EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
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('ckordNo').AsString)+'''');
sql.Add(' and P_COdeName='''+Trim(CDS_Main.fieldbyname('C_COdeName').AsString)+'''');
sql.Add(' and P_Color='''+Trim(CDS_Main.fieldbyname('C_COlor').AsString)+'''');
sql.Add(' and YFName=''<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>'' ');
Open;
if not IsEmpty then
begin
YFID:=Fieldbyname('YFID').AsString;
CRID:=Fieldbyname('CRID').AsString;
end;
end;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select CRID from CK_BanCP_PH where CRID='+Trim(CDS_Main.fieldbyname('CRID').AsString));
Open;
end;
if not ADOQueryTemp.IsEmpty then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select CRID from CK_BanCP_CR where CRID='+Trim(CDS_Main.fieldbyname('CRID').AsString));
Open;
end;
if ADOQueryTemp.RecordCount>1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27>ѳ<EFBFBD><D1B3><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete CK_BanCP_CR where BCID='''+Trim(CDS_Main.fieldbyname('BCID').AsString)+'''');
sql.Add('delete CK_BanCP_KC where CRID='+Trim(CDS_Main.fieldbyname('CRID').AsString));
sql.Add('Update WFB_MJJY Set MJStr2='<><CEB4><EFBFBD><EFBFBD>'' where MJID='''+Trim(CDS_Main.fieldbyname('MJID').AsString)+'''');
sql.Add('update YF_Money_CR Set Qty=(select -1*isnull(Sum(Qty),0) from CK_BanCP_CR A ');
sql.Add('where A.ckordNo=YF_Money_CR.mainID and A.C_COdeName=YF_Money_CR.P_CodeName and A.C_Color=YF_Money_CR.P_Color and A.CRType=''<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>'' )');
sql.Add(',PS=(select -1* isnull(count(*),0) from CK_BanCP_CR A ');
sql.Add(' where A.ckordNo=YF_Money_CR.mainID and A.C_COdeName=YF_Money_CR.P_CodeName and A.C_Color=YF_Money_CR.P_Color and A.CRType=''<27>˻<EFBFBD><CBBB><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)+'''');
ExecSQL;
end;
CDS_Main.Delete;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
end;
end;
procedure TfrmCKProductBCPInList.TBADDClick(Sender: TObject);
begin
frmCPRK:=TfrmCPRK.create(self);
with frmCPRK do
begin
if Trim(DParameters2)<>'<27><><EFBFBD><EFBFBD>' then
begin
CRType.Items.Clear;
CRType.Items.Add('<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>');
CRType.ItemIndex:=0;
end;
fFlag:=0;
fkeyNo:='';
fBCID:='';
if showmodal=1 then
begin
TBRafresh.Click;
end;
free;
end;
end;
procedure TfrmCKProductBCPInList.TBEditClick(Sender: TObject);
begin
if CDS_Main.IsEmpty then exit;
if (trim(CDS_Main.fieldbyname('CRType').AsString)<>'<27>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD>') and
(trim(CDS_Main.fieldbyname('CRType').AsString)<>'<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>') then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select A.* from CK_BanCP_KC A ');
sql.Add('inner join CK_BanCP_CR B on B.crid=A.crid and B.MJID=A.MJID ');
sql.Add('where (A.KCQty<>B.Qty or A.kcRollNum <> B.RollNum or isnull(A.KCStatus,''0'')>''0'') ');
sql.Add('and B.CKOrdNo='+quotedstr(trim(CDS_Main.fieldbyname('ckordNo').AsString)));
sql.Add('and B.BCID='+quotedstr(trim(CDS_Main.fieldbyname('BCID').AsString)));
open;
end;
if not ADOQueryCmd.IsEmpty then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
frmCPRK:=TfrmCPRK.create(self);
with frmCPRK do
begin
fFlag:=1;
fkeyNo:=self.CDS_Main.fieldbyname('ckordNo').AsString;
fBCID:=self.CDS_Main.fieldbyname('BCID').AsString;
if showmodal=1 then
begin
self.InitGrid();
end;
free;
end;
end;
procedure TfrmCKProductBCPInList.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 TfrmCKProductBCPInList.ToolButton3Click(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
frmYGlist:=TfrmYGlist.create(self);
with frmYGlist do
begin
frmYGlist.Caption:='<27><><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD>';
frmYGlist.Label1.Caption:='<27><><EFBFBD><EFBFBD><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 defstr1='+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 TfrmCKProductBCPInList.ToolButton4Click(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
frmYGlist:=TfrmYGlist.create(self);
with frmYGlist do
begin
frmYGlist.Caption:='<27><><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD>';
frmYGlist.Label1.Caption:='<27><><EFBFBD><EFBFBD><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 defstr2='+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 TfrmCKProductBCPInList.ToolButton5Click(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
frmYGlist:=TfrmYGlist.create(self);
with frmYGlist do
begin
frmYGlist.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD><CFBC><EFBFBD>';
frmYGlist.Label1.Caption:='<27>ϼ<EFBFBD><CFBC><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 defstr3='+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 TfrmCKProductBCPInList.ToolButton1Click(Sender: TObject);
begin
try
frmRKSMEdit:=TfrmRKSMEdit.Create(Application);
with frmRKSMEdit do
begin
if ShowModal=1 then
begin
end;
end;
finally
frmRKSMEdit.Free;
end;
end;
procedure TfrmCKProductBCPInList.ToolButton6Click(Sender: TObject);
var
fPrintFile:string;
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;
CDS_Main.DisableControls;
with CDS_Main do
begin
First;
while not Eof do
begin
if CDS_Main.FieldByName('SSel').AsBoolean=True then
begin
try
Moudle:=LoadLibrary('MakeQRBarcode.dll');
@Makebar:=GetProcAddress(Moudle,'Make');
@Mixtext:=GetProcAddress(Moudle,'MixText');
Txt:=Trim(CDS_Main.fieldbyname('MJID').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);
CDS_Main.EnableControls;
exit;
end;
with ADOQueryPrint do //Ӣ<><D3A2><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>ж<EFBFBD>ȡ<EFBFBD><C8A1>Ҫ<EFBFBD>ڿͻ<DABF><CDBB>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ȡ<EFBFBD><C8A1>note<74>ֶΡ<D6B6>
begin
Close;
SQL.Clear;
sql.Add('select A.*,Qty as mjlen,QtyUnit as MJTypeother,A.CPType as MJType,C_CodeNameZW=(select Top 1 defnote3 from KH_Zdy_Attachment X where X.ZdyName=A.C_CodeName and Type=''CP'') ');
sql.Add(',C_colorName=(select Top 1 DEFstr6 from KH_Zdy_Attachment X where X.ZdyName=A.C_CodeName and X.DEFstr3=A.C_Color and Type=''CP'') ');
sql.Add(' from CK_BanCP_CR A') ;
SQL.Add(' where A.MJID='''+Trim(CDS_Main.fieldbyname('MJID').AsString)+'''');
SQL.Add(' and Qty>0 and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
Open;
end;
fPrintFile:=ExtractFilePath(Application.ExeName)+'Report\ͨ<>ñ<EFBFBD>ǩ.rmf' ;
if FileExists(fPrintFile) then
begin
RMVariables['QRBARCODE']:=fImagePath;
RMGridReport1.LoadFromFile(fPrintFile);
// RMGridReport1.ShowReport;
RMGridReport1.PrintReport;
end else
begin
CDS_Main.EnableControls;
Application.MessageBox(PChar(<><C3BB><EFBFBD>ҵ<EFBFBD>'+trim(fPrintFile)),'<27><>ʾ',0);
Exit;
end;
end;
Next;
end;
end;
CDS_Main.EnableControls;
end;
procedure TfrmCKProductBCPInList.TBprint2Click(Sender: TObject);
var
fPrintFile:string;
Txt,fImagePath:string;
Moudle: THandle;
Makebar:TMakebar;
Mixtext:TMixtext;
begin
if CDS_Main.IsEmpty then Exit;
IF trim(CDS_Main.FieldByName('CRType').AsString)<>'<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>' then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>ӡ<EFBFBD><D3A1>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
with AdoPrint do
begin
close;
sql.Clear;
sql.Add('select A.*, ');
SQL.Add('zroll=(select sum(RollNum) from CK_BanCp_CR X where X.CKordNo=A.CKordNo),');
SQL.Add('zQty=(select sum(Qty) from CK_BanCp_CR X where X.CKordNo=A.CKordNo)');
sql.Add('from CK_BanCp_CR A ');
sql.Add('where CKordNo='+quotedstr(trim(CDS_Main.fieldbyname('CKordNo').AsString)));
sql.Add('order by A.MJID ');
open;
end;
try
Moudle:=LoadLibrary('MakeQRBarcode.dll');
@Makebar:=GetProcAddress(Moudle,'Make');
@Mixtext:=GetProcAddress(Moudle,'MixText');
Txt:=Trim(AdoPrint.fieldbyname('CKordNo').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);
CDS_Main.EnableControls;
exit;
end;
try
fPrintFile:=ExtractFilePath(Application.ExeName) + 'report\<5C><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><CBBB><EFBFBD>.rmf';
if not FileExists(Pchar(fPrintFile)) then
begin
application.MessageBox(pchar('<27>ļ<EFBFBD>['+fPrintFile+']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'),'<27><>ʾ<EFBFBD><CABE>Ϣ',MB_IConError);
exit;
end;
RMVariables['QRBARCODE']:=fImagePath;
// 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);
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
finally
end;
end;
end.