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

316 lines
8.4 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_CKPDlist;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, StdCtrls, ExtCtrls, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
cxButtonEdit, cxDropDownEdit, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
cxGridCustomView, cxGrid, DBClient, ADODB, cxGridCustomPopupMenu,
cxGridPopupMenu, RM_Common, RM_Class, RM_e_Xls, RM_GridReport, RM_System,
RM_Dataset, cxPC, MovePanel;
type
TfrmCKPDlist = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBExport: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
Label1: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1P_CodeName: TcxGridDBColumn;
v1RollNum: TcxGridDBColumn;
v1Qty: TcxGridDBColumn;
v1QtyUnit: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
v1CRTime: TcxGridDBColumn;
v1Filler: TcxGridDBColumn;
Label3: TLabel;
Label4: TLabel;
C_CodeName: TEdit;
P_Code: TEdit;
ADOQueryCmd: TADOQuery;
ADOQueryTmp: TADOQuery;
DataSource1: TDataSource;
CDS_Main: TClientDataSet;
cxGridPopupMenu1: TcxGridPopupMenu;
v1CPTYPE: TcxGridDBColumn;
ckName: TComboBox;
Label6: TLabel;
v1P_Color: TcxGridDBColumn;
ADOPrint: TADOQuery;
RMDB_MD: TRMDBDataSet;
RMGridReport1: TRMGridReport;
RMXLSExport1: TRMXLSExport;
v1inoutNO: TcxGridDBColumn;
kuwei: TEdit;
Label8: TLabel;
cxTabControl1: TcxTabControl;
C_Color: TEdit;
Label9: TLabel;
custName: TEdit;
Label2: TLabel;
Tchk: TToolButton;
Tnochk: TToolButton;
Label5: TLabel;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
TBPD: TToolButton;
MovePanel2: TMovePanel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure C_CodeNameChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure TchkClick(Sender: TObject);
procedure TnochkClick(Sender: TObject);
procedure TBPDClick(Sender: TObject);
private
procedure InitGrid();
procedure SetStatus();
{ Private declarations }
public
fCKName:string;
canshu1:string;
{ Public declarations }
end;
var
frmCKPDlist: TfrmCKPDlist;
implementation
uses
U_DataLink,U_Fun10,U_ZDYHelp,U_PDSMEdit;
{$R *.dfm}
procedure TfrmCKPDlist.SetStatus();
begin
Tchk.Visible:=false;
Tnochk.Visible:=false;
case cxTabControl1.TabIndex of
0:begin
Tchk.Visible:=true;
Tnochk.Visible:=true;
end;
1:begin
end;
end;
end;
procedure TfrmCKPDlist.InitGrid();
begin
try
with adoqueryTmp do
begin
close;
sql.Clear;
sql.Add('select A.* ');
sql.Add('from CK_BanCP_PD A');
sql.Add('where begTime>='''+formatdateTime('yyyy-MM-dd',begdate.Date)+''' ');
sql.Add('and begTime<'''+formatdateTime('yyyy-MM-dd',enddate.Date+1)+''' ');
if trim(FckName)<>'' then
sql.Add('and ckName='+quotedstr(trim(FckName)) );
if cxTabControl1.TabIndex<2 then
sql.Add('and A.status='''+inttostr(cxTabControl1.TabIndex)+''' ');
open;
end;
SCreateCDS20(adoqueryTmp,CDS_Main);
SInitCDSData20(adoqueryTmp,CDS_Main);
finally
end;
end;
procedure TfrmCKPDlist.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
writeCxGrid(self.Caption,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
Action:=cafree;
end;
procedure TfrmCKPDlist.FormDestroy(Sender: TObject);
begin
frmCKPDlist:=nil;
end;
procedure TfrmCKPDlist.C_CodeNameChange(Sender: TObject);
begin
if ADOQueryTmp.Active=False then Exit;
SDofilter(ADOQueryTmp,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryTmp,CDS_Main);
SInitCDSData20(ADOQueryTmp,CDS_Main);
end;
procedure TfrmCKPDlist.FormShow(Sender: TObject);
begin
readCxGrid(self.Caption,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
SetStatus();
InitGrid();
end;
procedure TfrmCKPDlist.FormCreate(Sender: TObject);
begin
BegDate.Date:=date()-7;
EndDate.Date:=date();
cxGrid1.Align:=alclient;
end;
procedure TfrmCKPDlist.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmCKPDlist.TBRafreshClick(Sender: TObject);
begin
initGrid();
end;
procedure TfrmCKPDlist.TBExportClick(Sender: TObject);
begin
if CDS_Main.IsEmpty then Exit;
TcxGridToExcel(self.Caption,cxgrid1);
end;
procedure TfrmCKPDlist.cxTabControl1Change(Sender: TObject);
begin
SetStatus();
initGrid();
end;
procedure TfrmCKPDlist.TchkClick(Sender: TObject);
var
fPDId:string;
begin
with adoqueryTmp do
begin
close;
sql.Clear;
sql.Add('select A.* ');
sql.Add('from CK_BanCP_PD A');
sql.ADD('where A.status=0 ');
if trim(FckName)<>'' then
sql.Add('and ckName='+quotedstr(trim(FckName)) );
// sql.Add('and A.status=0 ');
open;
end;
IF not adoqueryTmp.IsEmpty then
begin
application.MessageBox('<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飡','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
exit;
end;
with adoqueryTmp do
begin
close;
sql.Clear;
sql.Add('select A.C_CodeName,A.C_Color,A.KCQtyUnit,COUNT(A.MJID) as RollNum,SUM(KCQty) as Qty ');
sql.Add('from CK_BanCP_KC A ');
sql.Add('where A.KCQty>0 ');
if trim(FckName)<>'' then
sql.Add('and A.ckName='+quotedstr(trim(FckName)) );
sql.Add('group by A.C_CodeName,A.C_Color,A.KCQtyUnit ');
sql.Add('order by A.C_CodeName,A.C_Color,A.KCQtyUnit ');
open;
end;
if GetLSNo(ADOQueryCmd,fpdid,'PD','CK_BanCP_PD',3,1)=False then
begin
Application.MessageBox('ȡӦ<C8A1><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
MovePanel2.Left:=(self.Width - MovePanel2 .Width ) div 2;
MovePanel2.Visible:=True;
MovePanel2.Refresh;
ADOQueryCmd.Connection.BeginTrans;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from CK_BanCP_PD where 1=2');
open;
end;
while not adoqueryTmp.Eof do
begin
with ADOQueryCmd do
begin
append;
fieldbyName('PDID').Value:=fpdid;
fieldbyName('PDNO').Value:=adoqueryTmp.recNo;
fieldbyName('CKName').Value:=FckName;
fieldbyName('C_CodeName').Value:=trim(adoqueryTmp.fieldbyName('C_CodeName').AsString);
fieldbyName('C_Color').Value:=trim(adoqueryTmp.fieldbyName('C_Color').AsString);
fieldbyName('RollNum').Value:=adoqueryTmp.fieldbyName('RollNum').AsInteger;
fieldbyName('Qty').Value:=adoqueryTmp.fieldbyName('Qty').AsFloat;
fieldbyName('QtyUnit').Value:=trim(adoqueryTmp.fieldbyName('KCQtyUnit').AsString);
fieldbyName('Filler').Value:=trim(DName);
post;
end;
adoqueryTmp.Next;
end;
//˵<><CBB5>: CK_BanCP_KC PDFlag: 0:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>״̬<D7B4><CCAC>-1<><31><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>棬1<E6A3AC><31><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>2:<3A>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update CK_BanCP_KC SET PDFlag=-1 where KCQty<=0 ');
sql.Add('update CK_BanCP_KC SET PDFlag=1 where KCQty>0 ');
execsql;
end;
MovePanel2.Visible:=false;
ADOQueryCmd.Connection.CommitTrans;
TBRafresh.Click;
except
MovePanel2.Visible:=false;
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>!','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
end;
end;
procedure TfrmCKPDlist.TnochkClick(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
if Application.MessageBox(<><C8B7><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('update CK_BanCP_KC SET PDFlag=0 where PDFlag<>0 ');
sql.Add('update CK_BanCP_PD SET status=1 where pdid='''+trim(CDS_Main.fieldbyName('pdid').AsString)+''' ');
execsql;
end;
TBRafresh.Click;
except
Application.MessageBox('<27>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
end;
end;
procedure TfrmCKPDlist.TBPDClick(Sender: TObject);
begin
frmPDSMEdit:=TfrmPDSMEdit.Create(self);
with frmPDSMEdit do
begin
show;
end;
end;
end.