396 lines
10 KiB
ObjectPascal
396 lines
10 KiB
ObjectPascal
![]() |
unit U_CPZDDB;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
|||
|
cxEdit, DB, cxDBData, StdCtrls, ExtCtrls, ADODB, DBClient,
|
|||
|
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxGridCustomTableView,
|
|||
|
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
|
|||
|
cxGrid, MovePanel, cxCheckBox, Menus, ComCtrls, BtnEdit, RM_System, RM_Common,
|
|||
|
RM_Class, RM_GridReport, RM_Dataset, cxCalendar, MMSystem, U_BaseList,
|
|||
|
cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters,
|
|||
|
cxNavigator, dxDateRanges, dxBarBuiltInMenu, dxScrollbarAnnotations;
|
|||
|
|
|||
|
type
|
|||
|
TfrmCPZDDB = class(TfrmBaseList)
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
Panel1: TPanel;
|
|||
|
Button2: TButton;
|
|||
|
DS_RKJL: TDataSource;
|
|||
|
CDS_RKJL: TClientDataSet;
|
|||
|
PM_RKJL: TPopupMenu;
|
|||
|
MenuItem1: TMenuItem;
|
|||
|
MenuItem2: TMenuItem;
|
|||
|
RM1: TRMGridReport;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
RMDB_Main: TRMDBDataSet;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1Column4: TcxGridDBColumn;
|
|||
|
v1Column1: TcxGridDBColumn;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
v2Column3: TcxGridDBColumn;
|
|||
|
v1Column8: TcxGridDBColumn;
|
|||
|
v1Column9: TcxGridDBColumn;
|
|||
|
v1Column6: TcxGridDBColumn;
|
|||
|
v1Column13: TcxGridDBColumn;
|
|||
|
v1Column21: TcxGridDBColumn;
|
|||
|
v1Column5: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
v1Column16: TcxGridDBColumn;
|
|||
|
v2Column5: TcxGridDBColumn;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v1Column19: TcxGridDBColumn;
|
|||
|
v1Column22: TcxGridDBColumn;
|
|||
|
v1Column11: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
Timer1: TTimer;
|
|||
|
Button1: TButton;
|
|||
|
ComboBox1: TComboBox;
|
|||
|
chkBBQ: TCheckBox;
|
|||
|
CDS_DDB: TClientDataSet;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
Button3: TButton;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
PopupMenu1: TPopupMenu;
|
|||
|
N1: TMenuItem;
|
|||
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
Button4: TButton;
|
|||
|
lbldb: TLabel;
|
|||
|
Edit1: TEdit;
|
|||
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
Tv1Column6: TcxGridDBColumn;
|
|||
|
Tv1Column7: TcxGridDBColumn;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
Label1: TLabel;
|
|||
|
Label2: TLabel;
|
|||
|
Packer: TComboBox;
|
|||
|
Tv1Column8: TcxGridDBColumn;
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure Button2Click(Sender: TObject);
|
|||
|
procedure MenuItem1Click(Sender: TObject);
|
|||
|
procedure MenuItem2Click(Sender: TObject);
|
|||
|
procedure Button1Click(Sender: TObject);
|
|||
|
procedure Timer1Timer(Sender: TObject);
|
|||
|
procedure Button3Click(Sender: TObject);
|
|||
|
procedure N1Click(Sender: TObject);
|
|||
|
procedure Button4Click(Sender: TObject);
|
|||
|
procedure Tv1DblClick(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure PackerChange(Sender: TObject);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
FBaoId: string;
|
|||
|
procedure InitGrid();
|
|||
|
procedure PrintBao(PBaoId: string);
|
|||
|
procedure InitDBJD();
|
|||
|
public
|
|||
|
canshu2: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmCPZDDB: TfrmCPZDDB;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmCPZDDB.PackerChange(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
initgrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.PrintBao(PBaoId: string);
|
|||
|
var
|
|||
|
fPrintFile, NLBName: string;
|
|||
|
begin
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
SQL.Add('update CK_Cloth_CR set PrtBaoInt=isnull(PrtBaoInt,0)+1 where BaoId=' + quotedstr(PBaoId));
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
SQL.Add('exec P_DB_Print_Lab ' + quotedstr(PBaoId));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
NLBName := Trim(ADOQueryPrint.FieldByName('NLBName').AsString);
|
|||
|
|
|||
|
ExportFtErpFile(Trim(NLBName) + '.rmf', ADOQueryTemp);
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(NLBName) + '.rmf';
|
|||
|
if not FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
RM1.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1);
|
|||
|
RM1.printReport;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.Timer1Timer(Sender: TObject);
|
|||
|
begin
|
|||
|
Timer1.Enabled := False;
|
|||
|
if chkBBQ.Checked then
|
|||
|
begin
|
|||
|
if CDS_DDB.IsEmpty then
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select DISTINCT A.baoid ');
|
|||
|
sql.Add(' from CK_Cloth_CR A ');
|
|||
|
sql.Add(' where PrtBaoInt=0 and A.CRFlag in (''<27><><EFBFBD><EFBFBD>'',''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'') and isnull(A.BaoID,'''')<>'''' ');
|
|||
|
if Packer.Text <> '' then
|
|||
|
begin
|
|||
|
sql.Add('and Packer=' + QuotedStr(Packer.Text));
|
|||
|
end;
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if not ADOQueryTemp.IsEmpty then
|
|||
|
begin
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_DDB);
|
|||
|
with CDS_DDB do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
PrintBao(CDS_DDB.FieldByName('Baoid').AsString);
|
|||
|
Next
|
|||
|
end;
|
|||
|
end;
|
|||
|
InitGrid();
|
|||
|
CDS_DDB.EmptyDataSet;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
Timer1.Enabled := true;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.Tv1DblClick(Sender: TObject);
|
|||
|
begin
|
|||
|
Edit1.Text := CDS_RKJL.FieldByName('BuyConNoMX').AsString;
|
|||
|
Button4.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
EndDate.DateTime := SGetServerDateTime(ADOQueryTemp);
|
|||
|
BegDate.DateTime := EndDate.DateTime;
|
|||
|
canshu2 := Trim(DParameters2);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
frmCPZDDB := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.InitDBJD();
|
|||
|
begin
|
|||
|
try
|
|||
|
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select A.* ,B.BuyConNoMX ');
|
|||
|
sql.Add(' from CK_Cloth_CR A left join SalesContract_Sub B on A.ConSubId=B.SubId ');
|
|||
|
sql.Add(' where A.CRFlag=''<27><><EFBFBD><EFBFBD>'' and ISNULL( A.BaoID,'''')<>'''' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDS_RKJL);
|
|||
|
|
|||
|
SInitCDSData(ADOQueryMain, CDS_RKJL);
|
|||
|
finally
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select A.* ,B.BuyConNoMX,B.SCSColorNo ');
|
|||
|
sql.Add(' from CK_Cloth_CR A WITH (NOLOCK) left join SalesContract_Sub B on A.ConSubId=B.SubId ');
|
|||
|
sql.Add(' where A.CRFlag=''<27><><EFBFBD><EFBFBD>'' and ISNULL( A.BaoID,'''')<>'''' ');
|
|||
|
sql.Add('and exists(select jyid from jy_cloth E WHERE E.JYID=A.JYID AND E.fdanwei= ' + QuotedStr(Trim(canshu2)));
|
|||
|
// sql.Add(' and Convert(varchar(10),BaoTime,120)=Convert(varchar(10),getdate(),120)');
|
|||
|
//
|
|||
|
sql.Add(' )and BaoTime>=' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)));
|
|||
|
sql.Add(' and BaoTime<' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)));
|
|||
|
if Packer.Text <> '' then
|
|||
|
begin
|
|||
|
sql.Add('and Packer=' + QuotedStr(Packer.Text));
|
|||
|
end;
|
|||
|
// showmessage(sql.Text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDS_RKJL);
|
|||
|
|
|||
|
SInitCDSData(ADOQueryMain, CDS_RKJL);
|
|||
|
finally
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.FormShow(Sender: TObject);
|
|||
|
var
|
|||
|
fsj: string;
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
|
|||
|
ReadCxGrid('<27><>Ʒɨ<C6B7><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
|||
|
// fsj := 'select distinct name=Packer from JY_Cloth order by Packer ';
|
|||
|
// SInitComBoxBySql(ADOQueryCmd, Packer, False, fsj);
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select baoid=cast('''' as varchar(100)) ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_DDB);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.Button1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.Button2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid('<27><>Ʒɨ<C6B7><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.Button3Click(Sender: TObject);
|
|||
|
var
|
|||
|
MBaoId: string;
|
|||
|
begin
|
|||
|
with CDS_RKJL do
|
|||
|
begin
|
|||
|
DisableControls;
|
|||
|
while CDS_RKJL.Locate('SSel', True, []) do
|
|||
|
begin
|
|||
|
MBaoId := Trim(CDS_RKJL.FieldByName('BaoId').AsString);
|
|||
|
PrintBao(MBaoId);
|
|||
|
while CDS_RKJL.Locate('SSel;BaoId', VarArrayOf([True, MBaoId]), []) do
|
|||
|
begin
|
|||
|
CDS_RKJL.Edit;
|
|||
|
CDS_RKJL.FieldByName('SSel').Value := False;
|
|||
|
CDS_RKJL.Post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
EnableControls;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.Button4Click(Sender: TObject);
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
|
|||
|
sql.Add('select B.BuyConNoMX ');
|
|||
|
sql.Add(',JYPS=SUM(case when isnull(BaoID,'''')='''' then 1 else 0 end) ');
|
|||
|
sql.Add(',DBPS=SUM(case when isnull(BaoID,'''')='''' then 0 else 1 end) ');
|
|||
|
sql.Add('from JY_Cloth A inner join SalesContract_Sub B on A.ConSubId=B.SubId ');
|
|||
|
sql.Add('where A.JYType=''<27><>Ʒ'' and B.BuyConNoMX=' + QuotedStr(Trim(Edit1.Text)));
|
|||
|
sql.Add('group by B.BuyConNoMX ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
lbldb.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' + ADOQueryTemp.FieldByName('JYPS').AsString + ' <20>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>' + ADOQueryTemp.FieldByName('DBPS').AsString;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.MenuItem1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_RKJL, True);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.MenuItem2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_RKJL, False);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCPZDDB.N1Click(Sender: TObject);
|
|||
|
var
|
|||
|
NBaoID: string;
|
|||
|
begin
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
NBaoID := trim(CDS_RKJL.FieldByName('BaoID').AsString);
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
|
|||
|
sql.Add('Update JY_Cloth Set BaoNo=null,BaoID=null where isnull(BaoID,'''')<>'''' and BaoID=' + QuotedStr(NBaoID));
|
|||
|
|
|||
|
sql.Add('Update CK_Cloth_CR Set BaoNo=null,BaoID=null,PrtBaoInt=0 where BaoID=' + QuotedStr(NBaoID));
|
|||
|
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
|
|||
|
sql.Add(' ' + quotedstr(trim(DName)));
|
|||
|
sql.Add(',getdate() ');
|
|||
|
sql.Add(',' + quotedstr(trim(self.Caption)));
|
|||
|
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')));
|
|||
|
sql.Add(',' + quotedstr(NBaoID));
|
|||
|
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
|||
|
sql.Add(')');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|