872 lines
26 KiB
ObjectPascal
872 lines
26 KiB
ObjectPascal
unit U_JYLIST;
|
||
|
||
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, cxTextEdit, cxPC,
|
||
cxCheckBox, Menus, U_SLT, jpeg, cxContainer, cxMaskEdit, MovePanel,
|
||
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu,
|
||
cxCalendar, cxSplitter, dxSkinsCore, dxSkinsDefaultPainters,
|
||
dxSkinscxPCPainter;
|
||
|
||
type
|
||
TfrmJYGLlistSH = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1CRType: TcxGridDBColumn;
|
||
v1CRTime: TcxGridDBColumn;
|
||
v1CRNO: TcxGridDBColumn;
|
||
v1Filler: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
CRType: TComboBox;
|
||
Label5: TLabel;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTmp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
CDS_Main: TClientDataSet;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOPrint: TADOQuery;
|
||
RMXLSExport1: TRMXLSExport;
|
||
v1inoutNO: TcxGridDBColumn;
|
||
inoutNo: TEdit;
|
||
Label7: TLabel;
|
||
RMDB_Main: TRMDBDataSet;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
cxStyle2: TcxStyle;
|
||
cxStyle_gridRow: TcxStyle;
|
||
cxStyle_gridFoot: TcxStyle;
|
||
cxStyle_gridHead: TcxStyle;
|
||
cxStyle_gridGroupBox: TcxStyle;
|
||
cxStyle_yellow: TcxStyle;
|
||
cxStyle_Red: TcxStyle;
|
||
cxStyle_fontBlack: TcxStyle;
|
||
cxStyle_fontclFuchsia: TcxStyle;
|
||
cxStyle_fontclPurple: TcxStyle;
|
||
cxStyle_fontclGreen: TcxStyle;
|
||
cxStyle_fontclBlue: TcxStyle;
|
||
cxStyle_fontclTeal: TcxStyle;
|
||
cxStyle_fontclOlive: TcxStyle;
|
||
Label8: TLabel;
|
||
ToFactoryName: TEdit;
|
||
ADOQueryMain: TADOQuery;
|
||
RM1: TRMGridReport;
|
||
CODENAME: TEdit;
|
||
Color: TEdit;
|
||
Label10: TLabel;
|
||
Label11: TLabel;
|
||
CODE: TEdit;
|
||
Label14: TLabel;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
adoqueryPicture: TADOQuery;
|
||
cv1Column6: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
cxStyleRepository2: TcxStyleRepository;
|
||
cxStyle3: TcxStyle;
|
||
cxStyle4: TcxStyle;
|
||
cxStyle5: TcxStyle;
|
||
Label4: TLabel;
|
||
CPLeiBie: TComboBox;
|
||
Label6: TLabel;
|
||
salesman: TEdit;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
cxSplitter1: TcxSplitter;
|
||
Panel2: TPanel;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
cxGridDBColumn10: TcxGridDBColumn;
|
||
cxGridDBColumn13: TcxGridDBColumn;
|
||
cxGridDBColumn18: TcxGridDBColumn;
|
||
cxGridDBColumn20: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
CDS_SUB: TClientDataSet;
|
||
DataSource2: TDataSource;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
Tv1Column5: TcxGridDBColumn;
|
||
Tv1Column6: TcxGridDBColumn;
|
||
Tv1Column7: TcxGridDBColumn;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
ADOQuery1: TADOQuery;
|
||
Tv1Column8: TcxGridDBColumn;
|
||
TV2Column5: TcxGridDBColumn;
|
||
ToolButton1: TToolButton;
|
||
cxTabControl1: TcxTabControl;
|
||
TV2Column1: TcxGridDBColumn;
|
||
TV2Column2: TcxGridDBColumn;
|
||
TV2Column3: TcxGridDBColumn;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
CheckBox1: TCheckBox;
|
||
TV2Column4: TcxGridDBColumn;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure OrderNoChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure tbChkClick(Sender: TObject);
|
||
procedure tbChkNoClick(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure CheckBox1Click(Sender: TObject);
|
||
private
|
||
procedure InitGrid();
|
||
procedure InitSUB();
|
||
function YSData(ADO: TADOQuery): Boolean;
|
||
function YSData_Other(ADO: TADOQuery; fYFName: string; fmoney: double): Boolean;
|
||
|
||
|
||
{ Private declarations }
|
||
public
|
||
canshu1, canshu2, fCKName: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
Mach: array of TfrmSlt;
|
||
|
||
var
|
||
frmJYGLlistSH: TfrmJYGLlistSH;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun10, U_ZDYHelp, u_fun;
|
||
{$R *.dfm}
|
||
|
||
function TfrmJYGLlistSH.YSData(ADO: TADOQuery): Boolean;
|
||
var
|
||
CRID, YFID, Price, PriceUnit, OrderUnit, FComTaiTou, cust: string;
|
||
begin
|
||
Result := False;
|
||
with ADOQueryTmp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where FactoryName=''' + Trim(ADO.fieldbyname('custName').asstring) + ''' and YFDefFlag1=0 ');
|
||
Open;
|
||
end;
|
||
|
||
if not ADOQueryTmp.IsEmpty then
|
||
begin
|
||
CRID := ADOQueryTmp.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(ADO.fieldbyname('custName').asstring);
|
||
FieldByName('ZdyStr1').Value := 'Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete from YF_Money_CR ');
|
||
sql.Add(' where MainID=''' + Trim(ADO.fieldbyname('CRNO').AsString) + '''');
|
||
sql.Add(' and subID=''' + Trim(ADO.fieldbyname('CRID').AsString) + '''');
|
||
sql.Add(' and YFName=''<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>'' ');
|
||
execsql;
|
||
end;
|
||
|
||
with ADOQueryTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR ');
|
||
sql.Add(' where MainID=''' + Trim(ADO.fieldbyname('CRNO').AsString) + '''');
|
||
sql.Add(' and subID=''' + Trim(ADO.fieldbyname('CRID').AsString) + '''');
|
||
sql.Add(' and YFName=''<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
|
||
if ADOQueryTmp.IsEmpty then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, YFID, 'CS', 'YF_Money_CR', 4, 1) = False then
|
||
begin
|
||
Application.MessageBox('ȡӦ<C8A1><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(ADO.fieldbyname('CRNO').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(ADO.fieldbyname('custName').asstring);
|
||
FieldByName('CRTime').Value := Trim(FormatDateTime('yyyy-MM-dd', ADO.fieldbyname('CRTime').AsDateTime));
|
||
FieldByName('YFType').Value := '<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('ps').Value := ADO.fieldbyname('RollNum').AsFloat;
|
||
FieldByName('Qty').Value := ADO.fieldbyname('Qty').AsFloat;
|
||
FieldByName('Price').Value := ADO.fieldbyname('Price').AsFloat;
|
||
FieldByName('Money').Value := ADO.fieldbyname('Money').AsFloat;
|
||
FieldByName('BBMoney').Value := ADO.fieldbyname('Money').AsFloat;
|
||
FieldByName('HuiLv').Value := 1;
|
||
FieldByName('BZType').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('QtyUnit').Value := Trim(ADO.fieldbyname('QtyUnit').AsString);
|
||
FieldByName('ComTaiTou').Value := Trim(cust);
|
||
FieldByName('YFName').Value := '<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>';
|
||
FieldByName('MainId').Value := Trim(ADO.fieldbyname('CRNO').AsString);
|
||
FieldByName('subID').Value := Trim(ADO.fieldbyname('CRID').AsString);
|
||
FieldByName('status').Value := '0';
|
||
Post;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
YFID := Trim(ADOQueryTmp.fieldbyname('YFID').AsString);
|
||
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;
|
||
|
||
Result := True;
|
||
end;
|
||
|
||
function TfrmJYGLlistSH.YSData_Other(ADO: TADOQuery; fYFName: string; fmoney: double): Boolean;
|
||
var
|
||
CRID, YFID, Price, PriceUnit, OrderUnit, FComTaiTou, cust: string;
|
||
begin
|
||
Result := False;
|
||
with ADOQueryTmp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where FactoryName=''' + Trim(ADO.fieldbyname('custName').asstring) + ''' and YFDefFlag1=0 ');
|
||
Open;
|
||
end;
|
||
|
||
if not ADOQueryTmp.IsEmpty then
|
||
begin
|
||
CRID := ADOQueryTmp.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(ADO.fieldbyname('custName').asstring);
|
||
FieldByName('ZdyStr1').Value := 'Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete from YF_Money_CR ');
|
||
sql.Add(' where MainID=''' + Trim(ADO.fieldbyname('CRNO').AsString) + '''');
|
||
sql.Add(' and subID=''' + Trim(ADO.fieldbyname('CRID').AsString) + '''');
|
||
sql.Add(' and YFName=''' + trim(fYFName) + ''' ');
|
||
execsql;
|
||
end;
|
||
|
||
with ADOQueryTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR ');
|
||
sql.Add(' where MainID=''' + Trim(ADO.fieldbyname('CRNO').AsString) + '''');
|
||
sql.Add(' and subID=''' + Trim(ADO.fieldbyname('CRID').AsString) + '''');
|
||
sql.Add(' and YFName=''' + trim(fYFName) + ''' ');
|
||
Open;
|
||
end;
|
||
|
||
if ADOQueryTmp.IsEmpty then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, YFID, 'CS', 'YF_Money_CR', 4, 1) = False then
|
||
begin
|
||
Application.MessageBox('ȡӦ<C8A1><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(ADO.fieldbyname('CRNO').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(ADO.fieldbyname('custName').asstring);
|
||
FieldByName('CRTime').Value := Trim(FormatDateTime('yyyy-MM-dd', ADO.fieldbyname('CRTIme').AsDateTime));
|
||
FieldByName('YFType').Value := '<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('Qty').Value := 1;
|
||
FieldByName('Price').Value := fmoney;
|
||
FieldByName('Money').Value := fmoney;
|
||
FieldByName('BBMoney').Value := fmoney;
|
||
FieldByName('HuiLv').Value := 1;
|
||
FieldByName('BZType').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('QtyUnit').Value := '<27><>';
|
||
FieldByName('ComTaiTou').Value := Trim(cust);
|
||
FieldByName('YFName').Value := fYFName;
|
||
FieldByName('MainId').Value := Trim(ADO.fieldbyname('CRNO').AsString);
|
||
FieldByName('subID').Value := Trim(ADO.fieldbyname('CRID').AsString);
|
||
FieldByName('status').Value := '0';
|
||
Post;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
YFID := Trim(ADOQueryTmp.fieldbyname('YFID').AsString);
|
||
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;
|
||
|
||
Result := True;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.InitGrid();
|
||
begin
|
||
try
|
||
with ADOQueryMain do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select ZBZNOTE,inoutno,ywzb,ToFactoryName,CPLeiBie,CRTime,CRType,SHDiZhi,chker,SHDianHua,SHer,Filler,CPLeiBie,salesman,SEASON ');
|
||
|
||
SQL.Add(',CODE=cast((select P_CODE+'';'' from CK_Sample_CR B where B.INOUTNO=A.INOUTNO for xml path('''')) as varchar(200))');
|
||
SQL.Add(',CODENAME=cast((select P_CodeName+'';'' from CK_Sample_CR B where B.INOUTNO=A.INOUTNO for xml path('''')) as varchar(200))');
|
||
SQL.Add(',Color=cast((select P_Color+'';'' from CK_Sample_CR B where B.INOUTNO=A.INOUTNO for xml path('''')) as varchar(200))');
|
||
SQL.Add(' from CK_Sample_CR A ');
|
||
sql.Add(' where CRFlag=''<27><><EFBFBD><EFBFBD>'' and A.valid=''Y'' ');
|
||
sql.Add('and A.crtype IN (''<27><><EFBFBD>۳<EFBFBD><DBB3><EFBFBD>'',''<27><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>'') and isnull(A.Note,'''') <> ''<27><>Ʒ<EFBFBD><C6B7><EFBFBD>ã<EFBFBD><C3A3>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>'' '); //
|
||
// ,''<27><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>''
|
||
sql.Add(' and isnull(A.Chkstatus,''-1'')=''1''');
|
||
if CheckBox1.Checked = True then
|
||
begin
|
||
sql.Add(' and CRTime>=''' + formatdateTime('yyyy-MM-dd', begdate.Date) + ''' ');
|
||
sql.Add(' and CRTime<''' + formatdateTime('yyyy-MM-dd', enddate.Date + 1) + ''' ');
|
||
end;
|
||
|
||
if cxTabControl1.TabIndex = 0 then
|
||
SQL.Add(' and not exists(select YFPZNO from YF_Money_CR_Sub X where X.YFPZNO=A.inoutno ) ')
|
||
else
|
||
SQL.Add(' and exists(select YFPZNO from YF_Money_CR_Sub X where X.YFPZNO=A.inoutno )');
|
||
|
||
sql.Add('group by inoutno,chker,ToFactoryName,ZBZNOTE,CRTime,CPLeiBie,ywzb,SHer,SHDiZhi,SHDianHua,CRType,Filler,CPLeiBie,salesman,SEASON');
|
||
sql.Add(' order by inoutNo desc ');
|
||
|
||
open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, CDS_Main);
|
||
SInitCDSData20(ADOQueryMain, CDS_Main);
|
||
finally
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.InitSUB();
|
||
begin
|
||
try
|
||
with ADOQuery1 do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select inoutno,P_CODE,P_COLOR,gangno,QtyUnit,SUM(Qty)Qty,price,LSMONEY,SUM(MONEY)MONEY');
|
||
SQL.Add(',JMMONEY');
|
||
SQL.Add(',JISUANMONEY=SUM(Qty)*isnull(PRICE,0)+isnull(LSMONEY,0)-isnull(JMMONEY,0)');
|
||
SQL.Add(' from CK_Sample_CR A ');
|
||
sql.Add(' where CRFlag=''<27><><EFBFBD><EFBFBD>'' and A.valid=''Y'' ');
|
||
|
||
SQL.Add('AND INOUTNO=' + QUOTEDSTR(Trim(CDS_Main.fieldbyname('INOUTNO').AsString)));
|
||
|
||
sql.Add(' and isnull(A.Chkstatus,''-1'')=''1''');
|
||
// IF CheckBox1.Checked=
|
||
// sql.Add(' and CRTime>=''' + formatdateTime('yyyy-MM-dd', begdate.Date) + ''' ');
|
||
// sql.Add(' and CRTime<''' + formatdateTime('yyyy-MM-dd', enddate.Date + 1) + ''' ');
|
||
|
||
sql.Add('group by P_CODE,P_COLOR,gangno,QtyUnit,inoutno,price,LSMONEY,JMMONEY');
|
||
|
||
sql.Add(' order by inoutNo desc ');
|
||
|
||
open;
|
||
end;
|
||
SCreateCDS20(ADOQuery1, CDS_SUB);
|
||
SInitCDSData20(ADOQuery1, CDS_SUB);
|
||
finally
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := cafree;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.OrderNoChange(Sender: TObject);
|
||
begin
|
||
if ADOQuerymain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQuerymain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQuerymain, CDS_Main);
|
||
SInitCDSData20(ADOQuerymain, CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.FormShow(Sender: TObject);
|
||
begin
|
||
readCxGrid(trim(self.Caption), Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
readCxGrid(trim(self.Caption), Tv2, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>2');
|
||
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.FormCreate(Sender: TObject);
|
||
begin
|
||
EndDate.Date := SGetServerDate10(ADOQueryTmp);
|
||
BegDate.Date := EndDate.Date - 1;
|
||
cxGrid1.Align := alclient;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.TBDelClick(Sender: TObject);
|
||
var
|
||
YFID, CRID, note: string;
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
// if Trim(CDS_Main.fieldbyname('Filler').AsString) <> Trim(DName) then
|
||
// begin
|
||
// Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from CK_Sample_CR where Chkstatus=''1'' ');
|
||
SQL.Add('and inoutno=' + quotedstr(trim(cds_main.fieldbyname('inoutno').AsString)));
|
||
SQL.Add('AND VALID=''Y''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTmp.IsEmpty = False then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>ݣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
try
|
||
if Trim(CDS_Main.FieldByName('CRNO').AsString) <> '' then
|
||
begin
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('update CK_Sample_CR set Valid=''N'' where CRNO=' + quotedstr(Trim(CDS_Main.FieldByName('CRNO').AsString)));
|
||
sql.Add('delete yp_inout where fromCRNO=' + quotedstr(Trim(CDS_Main.FieldByName('CRNO').AsString)));
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('exec P_Up_SampleKc ' + quotedstr(trim(CDS_Main.fieldbyname('MJID').AsString)));
|
||
Open;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
CDS_Main.Delete;
|
||
end;
|
||
except
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
initGrid();
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.TBExportClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
TcxGridToExcel(self.Caption, cxgrid1);
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
|
||
var
|
||
colIdx0, colIdx1: integer;
|
||
begin
|
||
colIdx0 := tv1.GetColumnByFieldName('CRNO').Index;
|
||
if (ARow1.Values[colIdx0] = ARow2.Values[colIdx0]) then
|
||
AAreEqual := True
|
||
else
|
||
AAreEqual := False;
|
||
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, True);
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, False);
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.tbChkClick(Sender: TObject);
|
||
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;
|
||
try
|
||
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
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_Sample_CR SET Chkstatus=''1'',Chktime=getdate(),Chker= ' + quotedstr(trim(DName)));
|
||
sql.Add('where inoutno=' + quotedstr(trim(CDS_Main.fieldbyname('inoutno').AsString)));
|
||
execsql;
|
||
end;
|
||
// with ADOQueryCmd do
|
||
// begin
|
||
// close;
|
||
// sql.Clear;
|
||
// sql.Add('select * from CK_Sample_CR ');
|
||
// sql.Add('where crno=' + quotedstr(trim(CDS_Main.fieldbyname('crno').AsString)));
|
||
// Open;
|
||
// end;
|
||
// if ADOQueryCmd.fieldbyname('mjid').AsString <> '' then
|
||
// begin
|
||
// with ADOQueryCmd do
|
||
// begin
|
||
// Close;
|
||
// SQL.Clear;
|
||
// SQL.Add('exec P_Up_SampleKc ' + quotedstr(trim(CDS_Main.fieldbyname('MJID').AsString)));
|
||
// Open;
|
||
// end;
|
||
// end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
application.MessageBox('<27><><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
TBRafresh.Click;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.tbChkNoClick(Sender: TObject);
|
||
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;
|
||
try
|
||
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
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_Sample_CR SET Chkstatus=''0'',Chktime=null , Chker=null ');
|
||
sql.Add('where inoutno=' + quotedstr(trim(CDS_Main.fieldbyname('inoutno').AsString)));
|
||
execsql;
|
||
end;
|
||
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
TBRafresh.Click;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.ToolButton4Click(Sender: TObject);
|
||
var
|
||
fPrintFile: string;
|
||
EngMoney: string;
|
||
Porderno, LBName, SYRName: string;
|
||
i, j: Integer;
|
||
OrderKg: Double;
|
||
FDate: string;
|
||
Txt, fImagePath: string;
|
||
Moudle: THandle;
|
||
Makebar: TMakebar;
|
||
Mixtext: TMixtext;
|
||
begin
|
||
if CDS_sub.IsEmpty then
|
||
Exit;
|
||
if CDS_sub.Locate('SSel', True, []) = False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
ExportFtErpFile('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ.rmf', ADOQueryTmp);
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ.rmf';
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete TBSubID where DName=''' + Trim(DCode) + '''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('SELECT * FROM TBSubID where 1=2 ');
|
||
open;
|
||
end;
|
||
CDS_sub.DisableControls;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_sub do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if CDS_sub.Fieldbyname('Ssel').AsBoolean then
|
||
begin
|
||
|
||
ADOQueryCmd.append;
|
||
ADOQueryCmd.fieldbyname('SubId').Value := Trim(CDS_sub.fieldbyname('crno').AsString);
|
||
ADOQueryCmd.fieldbyname('Dname').Value := Trim(DCode);
|
||
ADOQueryCmd.post;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
end;
|
||
CDS_sub.EnableControls;
|
||
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_SUB do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Fieldbyname('Ssel').AsBoolean then
|
||
begin
|
||
|
||
with ADOPrint do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ');
|
||
SQL.Add(' from CK_Sample_CR A ');
|
||
sql.Add(' where CRFlag=''<27><><EFBFBD><EFBFBD>'' and A.valid=''Y'' ');
|
||
sql.Add(' and VisType=''<27><><EFBFBD><EFBFBD>'' ');
|
||
SQL.Add('and crno=' + quotedstr(Trim(CDS_SUB.fieldbyname('crno').AsString)));
|
||
// sql.Add('and EXISTS(select SubId from TBSubID X where X.SubId=A.crno and X.DName=' + quotedstr(Trim(DCode)));
|
||
// sql.Add(')');
|
||
// ShowMessage(sql.Text);
|
||
Open;
|
||
end;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
// RMVariables['EngMoney']:=EngMoney;
|
||
//RMVariables['enddate']:=enddate.DateTime;
|
||
try
|
||
Moudle := LoadLibrary('MakeQRBarcode.dll');
|
||
@Makebar := GetProcAddress(Moudle, 'Make');
|
||
@Mixtext := GetProcAddress(Moudle, 'MixText');
|
||
Txt := Trim((trim(CDS_SUB.fieldbyname('crno').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;
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RMVariables['QRBARCODE'] := fImagePath;
|
||
RM1.ShowReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
INITSUB();
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
writeCxGrid(trim(self.Caption), Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
writeCxGrid(trim(self.Caption), Tv2, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>2');
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
// if cxTabControl1.TabIndex <> 0 then
|
||
// exit;
|
||
ModalResult := 1;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmJYGLlistSH := nil;
|
||
end;
|
||
|
||
procedure TfrmJYGLlistSH.CheckBox1Click(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
end.
|
||
|