D7zzXiangHeng/坯布生产计划(WeavingSchedule)/U_ClothSCDCGAnPai.pas
DESKTOP-E401PHE\Administrator 0026e9e246 0
2025-08-08 10:42:50 +08:00

1417 lines
50 KiB
ObjectPascal
Raw Permalink 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_ClothSCDCGAnPai;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxGrid, DBClient, cxCalendar, cxButtonEdit, cxSplitter, RM_Common, RM_Class,
RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, cxTextEdit, cxCheckBox,
BtnEdit, RM_BarCode, cxPC, Menus, cxLookAndFeels, cxLookAndFeelPainters,
cxNavigator, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringTime, dxSkinStardust,
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinsDefaultPainters,
dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue,
dxSkinscxPCPainter;
type
TfrmClothSCDCGAnPai = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
Label3: TLabel;
ConNo: TEdit;
CDS_PRT: TClientDataSet;
RM2: TRMGridReport;
RMDBPRT: TRMDBDataSet;
ADOQueryPrint: TADOQuery;
DSAnPai: TDataSource;
CDS_AnPai: TClientDataSet;
cxGridPopupMenu2: TcxGridPopupMenu;
ZhuanQty: TEdit;
Label9: TLabel;
Panel2: TPanel;
cxGrid3: TcxGrid;
Tv3: TcxGridDBTableView;
cxGridLevel2: TcxGridLevel;
v3Column1: TcxGridDBColumn;
v3Column2: TcxGridDBColumn;
Label2: TLabel;
C_CodeName: TEdit;
Label6: TLabel;
PS: TEdit;
Label7: TLabel;
JXPerson: TBtnEditA;
Button2: TButton;
Button1: TButton;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
v2Column2: TcxGridDBColumn;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
v2Column4: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
DataSource3: TDataSource;
ClientDataSet3: TClientDataSet;
v3Column3: TcxGridDBColumn;
v3Column4: TcxGridDBColumn;
v3Column5: TcxGridDBColumn;
Label4: TLabel;
C_Code: TEdit;
Label5: TLabel;
Label8: TLabel;
APPS: TEdit;
PSSX: TEdit;
Label10: TLabel;
v2Column3: TcxGridDBColumn;
v3Column7: TcxGridDBColumn;
Button3: TButton;
v3Column8: TcxGridDBColumn;
v3Column10: TcxGridDBColumn;
v3Column11: TcxGridDBColumn;
v3Column13: TcxGridDBColumn;
v3Column15: TcxGridDBColumn;
v3Column16: TcxGridDBColumn;
v3Column17: TcxGridDBColumn;
Label13: TLabel;
Label14: TLabel;
APBatchNo: TEdit;
v2Column5: TcxGridDBColumn;
v3Column20: TcxGridDBColumn;
Button4: TButton;
pm1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
PopupMenu1: TPopupMenu;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ADOQuery1: TADOQuery;
Tv3Column1: TcxGridDBColumn;
ToolButton4: TToolButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ConNoChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure JXPersonBtnClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure Tv3CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
procedure Button3Click(Sender: TObject);
procedure v3Column8PropertiesEditValueChanged(Sender: TObject);
procedure PSKeyPress(Sender: TObject; var Key: Char);
procedure Button4Click(Sender: TObject);
procedure ConNoKeyPress(Sender: TObject; var Key: Char);
procedure C_CodeNameKeyPress(Sender: TObject; var Key: Char);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure MenuItem2Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure ToolButton4Click(Sender: TObject);
private
FInt, PFInt: Integer;
FFMainID, BPFlag: string;
procedure InitGrid();
procedure InitForm();
function SaveDataAP(): Boolean;
{ Private declarations }
public
canshu1: string;
{ Public declarations }
end;
implementation
uses
U_DataLink, U_Fun, U_ZDYHelp, U_SysLogHelp;
{$R *.dfm}
procedure TfrmClothSCDCGAnPai.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
WriteCxGrid('DCG131', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
end;
procedure TfrmClothSCDCGAnPai.TBCloseClick(Sender: TObject);
begin
if canshu1 = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
WriteCxGrid('DCG12', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
WriteCxGrid('DCG131', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
end
else
begin
WriteCxGrid('DCG12һ<32><D2BB><EFBFBD><EFBFBD>', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
WriteCxGrid('DCG131һ<31><D2BB><EFBFBD><EFBFBD>', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
end;
Close;
end;
procedure TfrmClothSCDCGAnPai.InitGrid();
begin
FFMainID := '';
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
// Filtered := False;
Close;
sql.Clear;
sql.Add('select A.*,B.ConNo,C.gongyi,B.GCCode,C.C_CodeName,C.ZhenCun,C_Qty=C.ZSCQty,C.C_Code,PiQty=C.ZSCPS ');
sql.Add(',C.pikgqty,B.LabName,C.BatchNoHZ,C.ChouZhen,C.CarType,C.C_Spec,C.C_Color,JHCHEJIAN');
sql.Add(',CPName=( select TOP 1 CPName from CP_YDang X inner join CP_Type Y on X.CYType=Y.CPID where X.CYName=C.C_CodeName )');
sql.Add(',APPS=(select count(*) from JYCon_Sub_AnPai JSA where JSA.MainId=A.MainId and JSA.CarNo=A.CarNo )');
sql.Add(',APPSHZ=(select count(*) from JYCon_Sub_AnPai JSA where JSA.MainId=A.MainId )');
sql.Add(',KHDM=(SELECT TOP 1 CODM FROM COMPANY G WHERE G.CONAME=B.KHNAME)');
sql.Add(',JYPS=isnull((select Count(*) from WFB_MJJY_PB CR where CR.MainId=A.MainId ),0) ');
sql.Add(',WJYPS=isnull((select Count(*) from JYCon_Sub_AnPai AP where b.MainId=AP.MainId AND JYFlag=0 ),0) ');
sql.Add(',JXPerson10=(select Top 1 JXPerson from JYCon_Sub_AnPai AP ');
sql.Add(' where AP.MainId=B.MainId and AP.CarNo=A.CarNo and isnull(AP.JXPerson,'''')<>'''' Order by AP.FillTime Desc)');
sql.Add(',ZJPH=(select Top 1 APBatchNo from JYCon_Sub_AnPai AP WHERE AP.MAINID=B.MAINID ORDER BY FILLTIME DESC )');
if BPFlag = 'BS' then
sql.Add(' , CustomerNoName=(select TOP 1 X.CoHRName from Company X where X.CoName=B.KHNAME and CoType=''<27>ͻ<EFBFBD>'') ')
else
sql.Add(' ,B.KHNAME CustomerNoName ');
sql.Add(' from Cloth_JiTai A');
sql.Add(' inner join Cloth_Main B on A.MainId=B.MainId');
sql.Add(' inner join Cloth_Sub C on A.SubId=C.SubId');
sql.Add(' where B.EndFlag=0 ');
SQL.Add('AND ISNULL(JHCHEJIAN,''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'')=' + QuotedStr(Trim(canshu1)));
sql.Add(' order by A.CarNo ');
Open;
end;
SCreateCDS20(ADOQueryMain, ClientDataSet3);
SInitCDSData20(ADOQueryMain, ClientDataSet3);
finally
ADOQueryMain.EnableControls;
end;
Button2.Enabled := true;
cxGrid3.Enabled := true;
end;
procedure TfrmClothSCDCGAnPai.InitForm();
var
fsj: string;
begin
BPFlag := Trim(DParameters1);
if canshu1 = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
ReadCxGrid('DCG12', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
ReadCxGrid('DCG131', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
end
else
begin
ReadCxGrid('DCG12һ<32><D2BB><EFBFBD><EFBFBD>', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
ReadCxGrid('DCG131һ<31><D2BB><EFBFBD><EFBFBD>', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
end;
if (Self.Caption = '<27><>Ʊ<EFBFBD><C6B1>ӡ(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>)') or (Self.Caption = '<27><>Ʊ<EFBFBD><C6B1>ӡ(һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>)') then
begin
Button3.Visible := True;
end
else
begin
Button3.Visible := False;
end;
InitGrid();
end;
procedure TfrmClothSCDCGAnPai.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmClothSCDCGAnPai.ConNoChange(Sender: TObject);
begin
if ADOQueryMain.Active = False then
Exit;
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS20(ADOQueryMain, ClientDataSet3);
SInitCDSData20(ADOQueryMain, ClientDataSet3);
end;
procedure TfrmClothSCDCGAnPai.FormShow(Sender: TObject);
begin
InitForm();
end;
procedure TfrmClothSCDCGAnPai.JXPersonBtnClick(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'JXPerson';
flagname := '<27><><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
JXPerson.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmClothSCDCGAnPai.Button2Click(Sender: TObject);
var
FFDS: Integer;
FGYCarNo: string;
begin
if ClientDataSet3.IsEmpty then
Exit;
if ClientDataSet3.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end
else
begin
Label10.Caption := Trim(ClientDataSet3.fieldbyname('ConNo').AsString);
APPS.Text := Trim(ClientDataSet3.fieldbyname('APPSHZ').AsString);
PSSX.Text := Trim(ClientDataSet3.fieldbyname('PiQty').AsString);
// APBatchNo.Text := Trim(ClientDataSet3.fieldbyname('BatchNoHZ').AsString);
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add(' select A.*');
sql.Add(' from JYCon_Sub_AnPai A');
sql.Add(' where A.SubId=''' + Trim(ClientDataSet3.fieldbyname('SubId').AsString) + '''');
sql.Add(' and A.MainId=''' + Trim(ClientDataSet3.fieldbyname('MainId').AsString) + '''');
sql.Add(' and A.CarNo=''' + Trim(ClientDataSet3.fieldbyname('CarNo').AsString) + '''');
Open;
end;
SCreateCDS20(ADOQueryTemp, CDS_AnPai);
SInitCDSData20(ADOQueryTemp, CDS_AnPai);
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add(' select COUNT(JYFlag) wjps');
sql.Add(' from JYCon_Sub_AnPai A');
sql.Add(' where A.JYFlag=0 and A.SubId=''' + Trim(ClientDataSet3.fieldbyname('SubId').AsString) + '''');
sql.Add(' and A.MainId=''' + Trim(ClientDataSet3.fieldbyname('MainId').AsString) + '''');
sql.Add(' and A.CarNo=''' + Trim(ClientDataSet3.fieldbyname('CarNo').AsString) + '''');
Open;
end;
Label13.caption := <><CEB4><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>' + trim(inttostr(ADOQueryTemp.fieldbyname('wjps').asinteger));
// v2Column3.SortOrder := soDescending;
CDS_AnPai.Last;
// if CDS_AnPai.IsEmpty then
// APBatchNo.Text := Trim(ClientDataSet3.fieldbyname('BatchNoHZ').AsString)
// else
// APBatchNo.Text := Trim(CDS_AnPai.fieldbyname('APBatchNo').AsString);
end;
if Trim(PS.Text) = '' then
begin
Application.MessageBox(<><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if TryStrToInt(Trim(PS.Text), FFDS) = False then
begin
Application.MessageBox(<><C6A5><EFBFBD>Ƿ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
// if Trim(JXPerson.Text) = '' then
// begin
// Application.MessageBox('<27><><EFBFBD>Ի<EFBFBD><D4BB>޲<EFBFBD><DEB2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
// Exit;
// end;
// if Trim(APBatchNo.Text) = '' then
// begin
// Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
// Exit;
// end;
FFDS := 0;
FGYCarNo := Trim(ClientDataSet3.fieldbyname('CarNo').AsString);
ClientDataSet3.DisableControls;
with ClientDataSet3 do
begin
First;
while not Eof do
begin
if ClientDataSet3.FieldByName('SSel').AsBoolean = True then
begin
FFDS := FFDS + 1;
end;
ClientDataSet3.Next;
end;
end;
ClientDataSet3.EnableControls;
ClientDataSet3.Locate('CarNo', FGYCarNo, []);
if FFDS * strtoint(PS.Text) + strtoint(APPS.Text) > StrToInt(PSSX.Text) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
Button2.Enabled := False;
if SaveDataAP() then
begin
InitGrid();
end;
CDS_AnPai.Last;
end;
function TfrmClothSCDCGAnPai.SaveDataAP(): Boolean;
var
maxno, fPrintFile, maxID: string;
i, MAXJH: Integer;
FDate: string;
Txt, fImagePath: string;
Moudle: THandle;
Makebar: TMakebar;
Mixtext: TMixtext;
GYMainId, GYSubId, GYCarNo, GYC_Code, GYC_CodeName: string;
GYConNo, GYXHInt, GYLabName, GYCheJian, GYBatchNOHZ: string;
GYChouZhen, GYCarType, GYC_Spec, GYC_CPName, GYC_ZhenCun: string;
GYC_Custom, GYC_gongyi, GYC_PiKgQty, GYapBatchNo: string;
gygkdm: string;
begin
cxGrid3.Enabled := False;
FDate := FormatDateTime('yyyy-MM-dd', SGetServerDate(ADOQueryTemp));
// with ClientDataSet3 do
// begin
// First;
// while Locate('SSel', True, []) do
// begin
//
// try
// ADOQueryCmd.Connection.BeginTrans;
// if GetLSNo(ADOQueryCmd, maxID, 'XH', 'JYCon_Sub_AnPai', 4, 1) = False then
// begin
// cxGrid3.Enabled := True;
// ADOQueryCmd.Connection.RollbackTrans;
// Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><ECB3A3>', '<27><>ʾ', 0);
// exit;
// end;
// ADOQueryCmd.Connection.CommitTrans;
// except
// ADOQueryCmd.Connection.RollbackTrans;
// Application.MessageBox('<27><>ӡ<EFBFBD>쳣!', '<27><>ʾ', 0);
// end;
//
// with ADOQueryTemp do
// begin
// Close;
// sql.Clear;
// SQL.Add(' select MAXJH=isnull(Max(XHInt),0)+1');
// sql.Add(' from JYCon_Sub_AnPai A');
// sql.Add(' where A.MainId=''' + Trim(ClientDataSet3.fieldbyname('Mainid').AsString) + '''');
// sql.Add(' and A.CarNo=''' + Trim(ClientDataSet3.fieldbyname('CarNo').AsString) + '''');
// Open;
// end;
// MAXJH := ADOQueryTemp.fieldbyname('MAXJH').AsInteger;
//
// try
// ADOQueryCmd.Connection.BeginTrans;
//
// with ADOQueryCmd do
// begin
// Close;
// sql.Clear;
// sql.Add('insert into JYCon_Sub_AnPai(MainID,SubID,APId,XHInt,JXPerson,APBatchNo,CarNo,CheJian,PRTCount,Filler,APDATE) values');
// for i := 1 to StrToInt(PS.Text) do
// begin
// maxno := maxID + '-' + IntToStr(i);
// if i > 1 then
// sql.Add(',');
// sql.Add('(' + quotedstr(trim(ClientDataSet3.fieldbyname('Mainid').AsString)));
// sql.Add(',' + quotedstr(trim(ClientDataSet3.fieldbyname('SubID').AsString)));
// sql.Add(',' + quotedstr(trim(maxno)));
// sql.Add(',' + trim(IntToStr(MAXJH)));
// sql.Add(',' + quotedstr(trim(JXPerson.Text)));
// sql.Add(',' + quotedstr(trim(APBatchNo.Text)));
// sql.Add(',' + quotedstr(Trim(ClientDataSet3.fieldbyname('CarNo').AsString)));
// sql.Add(',' + quotedstr(Trim(ClientDataSet3.fieldbyname('chejian').AsString)));
// sql.Add(',1');
// sql.Add(',' + quotedstr(trim(DName)));
// sql.Add(',' + quotedstr(trim(FDate)));
// sql.Add(')');
// MAXJH := MAXJH + 1;
//
// end;
// ExecSQL;
// end;
//
// ADOQueryCmd.Connection.CommitTrans;
// except
// ADOQueryCmd.Connection.RollbackTrans;
// Application.MessageBox('<27><>ӡ<EFBFBD><EFBFBD><ECB3A3>', '<27><>ʾ', 0);
// Exit;
// end;
//
// with ADOQueryTemp do
// begin
// Close;
// sql.Clear;
// SQL.Add(' select A.*');
// sql.Add(' from JYCon_Sub_AnPai A');
// sql.Add(' where A.SubId=''' + Trim(ClientDataSet3.fieldbyname('SubId').AsString) + '''');
// sql.Add(' and A.MainId=''' + Trim(ClientDataSet3.fieldbyname('Mainid').AsString) + '''');
// sql.Add(' and A.CarNo=''' + Trim(ClientDataSet3.fieldbyname('CarNo').AsString) + '''');
// Open;
// end;
// SCreateCDS20(ADOQueryTemp, CDS_AnPai);
// SInitCDSData20(ADOQueryTemp, CDS_AnPai);
//
// with ADOQueryTemp do
// begin
// Close;
// sql.Clear;
// sql.add(' select * ');
// sql.add(',KHDM=(SELECT TOP 1 CODM FROM COMPANY G WHERE G.CONAME=B.KHNAME)');
// sql.Add(',CPName=( select TOP 1 CPName from CP_YDang X inner join CP_Type Y on X.CYType=Y.CPID where X.CYName=c.C_CodeName )');
//// sql.Add(' ,CustomerNoName=(select top 1 CustomerNoName from JYOrderCon_Main_PB X where X.MainId=B.ConMainId) ');
// sql.add(' from JYCon_Sub_AnPai A INNER JOIN Cloth_Main B on A.MainID =B.MainID ');
// sql.add(' INNER JOIN Cloth_Sub C on B.MainID =C.MainID ');
// sql.add(' where left(A.APID,12) = ' + quotedstr(Trim(maxID)));
// sql.Add(' and A.SubId=''' + Trim(ClientDataSet3.fieldbyname('SubId').AsString) + '''');
// sql.Add(' and A.MainId=''' + Trim(ClientDataSet3.fieldbyname('Mainid').AsString) + '''');
// sql.Add(' and A.CarNo=''' + Trim(ClientDataSet3.fieldbyname('CarNo').AsString) + '''');
// sql.add(' Order by XHInt');
// Open;
// end;
// SCreateCDS20(ADOQueryTemp, CDS_PRT);
// SInitCDSData20(ADOQueryTemp, CDS_PRT);
//
// with CDS_PRT do
// begin
// First;
// while not Eof do
// begin
// fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
// if FileExists(fImagePath) then
// DeleteFile(fImagePath);
// try
// if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
// CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
// if FileExists(fImagePath) then
// DeleteFile(fImagePath);
// Moudle := LoadLibrary('MakeQRBarcode.dll');
// @Makebar := GetProcAddress(Moudle, 'Make');
// @Mixtext := GetProcAddress(Moudle, 'MixText');
// Txt := Trim(CDS_PRT.fieldbyname('APID').AsString);
// Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
// except
// cxGrid3.Enabled := True;
// application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
// exit;
// end;
// Sleep(300);
// GYLabName := Trim(ClientDataSet3.fieldbyname('LabName').AsString);
// if Trim(GYLabName) = '<27><>̧ͷ<CCA7><CDB7>ǩ' then
// begin
// ExportFtErpFile('<27><>̧ͷ<CCA7><CDB7>ǩ.rmf', ADOQueryTemp);
// fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>̧ͷ<CCA7><CDB7>ǩ.rmf';
//
// end
// else if Trim(GYLabName) = '<27><>̧ͷ<CCA7><CDB7>ǩ' then
// begin
// ExportFtErpFile('<27><>̧ͷ<CCA7><CDB7>ǩ.rmf', ADOQueryTemp);
// fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>̧ͷ<CCA7><CDB7>ǩ.rmf';
// end
// else
// begin
//
// ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf', ADOQueryTemp);
// fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf';
// end;
//
// if FileExists(fPrintFile) then
// begin
// RM2.LoadFromFile(fPrintFile);
// RMVariables['QRBARCODE'] := fImagePath;
// RMVariables['PRTCS'] := '';
//// RMVariables['XHINT'] := ADOQueryTemp.fieldbyname('XHINT').AsString;
// RM2.PrintReport;
// end
// else
// begin
// cxGrid3.Enabled := True;
// Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf'), '<27><>ʾ', 0);
// Exit;
// end;
// Next;
// end;
// end;
//
// ClientDataSet3.Delete;
// end;
// end;
//
FFMainID := '';
cxGrid3.Enabled := True;
Result := True;
//
ClientDataSet3.DisableControls;
with ClientDataSet3 do
begin
First;
while Locate('SSel', True, []) do
begin
GYMainId := Trim(ClientDataSet3.fieldbyname('Mainid').AsString);
GYSubId := Trim(ClientDataSet3.fieldbyname('SubId').AsString);
GYCarNo := Trim(ClientDataSet3.fieldbyname('CarNo').AsString);
GYC_Code := Trim(ClientDataSet3.fieldbyname('C_Code').AsString);
GYC_CodeName := Trim(ClientDataSet3.fieldbyname('C_CodeName').AsString);
GYConNo := Trim(ClientDataSet3.fieldbyname('ConNo').AsString);
GYLabName := Trim(ClientDataSet3.fieldbyname('LabName').AsString);
GYCheJian := Trim(ClientDataSet3.fieldbyname('JHCHEJIAN').AsString);
GYBatchNOHZ := Trim(ClientDataSet3.fieldbyname('BatchNOHZ').AsString);
gygkdm := Trim(ClientDataSet3.fieldbyname('khdm').AsString);
GYChouZhen := Trim(ClientDataSet3.fieldbyname('ChouZhen').AsString);
GYCarType := Trim(ClientDataSet3.fieldbyname('CarType').AsString);
GYC_Spec := Trim(ClientDataSet3.fieldbyname('C_Spec').AsString);
GYC_Custom := Trim(ClientDataSet3.fieldbyname('CustomerNoName').AsString);
GYC_gongyi := Trim(ClientDataSet3.fieldbyname('gongyi').AsString);
GYC_CPName := Trim(ClientDataSet3.fieldbyname('CPName').AsString);
GYC_ZhenCun := Trim(ClientDataSet3.fieldbyname('ZhenCun').AsString);
GYC_PiKgQty := Trim(ClientDataSet3.fieldbyname('PiKgQty').AsString);
for i := 1 to StrToInt(PS.Text) do
begin
try
ADOQueryCmd.Connection.BeginTrans;
if GetLSNo(ADOQuery1, maxno, 'XH', 'JYCon_Sub_AnPai', 4, 1) = False then
begin
cxGrid3.Enabled := True;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><ECB3A3>', '<27><>ʾ', 0);
exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.Add('select * from JYCon_Sub_AnPai where 1=2');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('MainId').Value := Trim(GYMainId);
FieldByName('SubId').Value := Trim(GYSubId);
FieldByName('APId').Value := Trim(maxno);
FieldByName('JXPerson').Value := Trim(JXPerson.Text);
FieldByName('APBatchNo').Value := Trim(APBatchNo.Text);
FieldByName('CarNo').Value := Trim(GYCarNo);
FieldByName('CheJian').Value := Trim(GYCheJian);
FieldByName('PRTCount').Value := 1;
FieldByName('APDate').Value := FDate;
FieldByName('Filler').Value := Trim(DName);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add(' Update JYCon_Sub_AnPai Set XHInt=isnull((select Max(XHInt) from JYCon_Sub_AnPai A where A.MainId=JYCon_Sub_AnPai.MainId and A.CarNo=JYCon_Sub_AnPai.CarNo ),0)+1');
sql.Add(' ,QDTime=(select DoTime from Cloth_JiTai JT where JT.MainId=''' + Trim(GYMainId) + ''' and CarNo=''' + Trim(GYCarNo) + '''');
sql.Add(' and StopFlag=0 )');
sql.Add(' where APId=''' + Trim(maxno) + '''');
ExecSQL;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select XHInt from JYCon_Sub_AnPai A where A.APId=''' + Trim(maxno) + '''');
Open;
end;
GYXHInt := Trim(ADOQueryTemp.fieldbyname('XHInt').AsString);
with CDS_AnPai do
begin
Append;
FieldByName('MainId').Value := Trim(GYMainId);
FieldByName('SubId').Value := Trim(GYSubId);
FieldByName('APId').Value := Trim(maxno);
FieldByName('JXPerson').Value := Trim(JXPerson.Text);
FieldByName('APBatchNo').Value := Trim(APBatchNo.Text);
// FieldByName('APBatchNo').Value := ADOQueryTemp.fieldbyname('APBatchNo').Value;
FieldByName('CarNo').Value := Trim(GYCarNo);
FieldByName('XHInt').Value := ADOQueryTemp.fieldbyname('XHInt').Value;
FieldByName('APDate').Value := FDate;
FieldByName('PRTCount').Value := 1;
Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add('select * from JYCon_Sub_AnPai where APID=''' + Trim(maxno) + '''');
sql.Add(' and CarNo=''' + Trim(GYCarNo) + '''');
sql.Add(' and JXPerson=''' + Trim(JXPerson.Text) + '''');
sql.Add(' and MainId=''' + Trim(GYMainId) + '''');
sql.Add(' and SubId=''' + Trim(GYSubId) + '''');
Open;
end;
if ADOQueryTemp.IsEmpty then
begin
cxGrid3.Enabled := True;
ClientDataSet3.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><>ӡ<EFBFBD><EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD>Ѵ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD>ı<EFBFBD>ǩ<EFBFBD><C7A9>Ч!', '<27><>ʾ', 0);
Exit;
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
ClientDataSet3.EnableControls;
Application.MessageBox('<27><>ӡ<EFBFBD><EFBFBD><ECB3A3>', '<27><>ʾ', 0);
Exit;
end;
fImagePath := ExtractFilePath(Application.ExeName) + 'image\' + trim(maxno) + '.bmp';
if FileExists(fImagePath) then
DeleteFile(fImagePath);
try
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
if FileExists(fImagePath) then
DeleteFile(fImagePath);
Moudle := LoadLibrary('MakeQRBarcode.dll');
@Makebar := GetProcAddress(Moudle, 'Make');
@Mixtext := GetProcAddress(Moudle, 'MixText');
Txt := Trim(maxno);
Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
except
cxGrid3.Enabled := True;
ClientDataSet3.EnableControls;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
Sleep(300);
if Trim(GYLabName) = '<27><>̧ͷ<CCA7><CDB7>ǩ' then
begin
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>̧ͷ<CCA7><CDB7>ǩ.rmf';
end
else if Trim(GYLabName) = '<27><>̧ͷ<CCA7><CDB7>ǩ' then
begin
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>̧ͷ<CCA7><CDB7>ǩ.rmf';
end
else
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf';
if FileExists(fPrintFile) then
begin
RM2.LoadFromFile(fPrintFile);
RMVariables['KHDM'] := Trim(gygkdm);
RMVariables['QRBARCODE'] := fImagePath;
RMVariables['PRTCS'] := '';
RMVariables['CDFLAG'] := '';
RMVariables['ConNo'] := Trim(GYConNo);
RMVariables['APID'] := Trim(maxno);
RMVariables['C_Code'] := Trim(GYC_Code);
RMVariables['C_CodeName'] := Trim(GYC_CodeName);
RMVariables['JXPerson'] := Trim(JXPerson.Text);
RMVariables['APBatchNo'] := Trim(apbatchno.text);
RMVariables['CarNo'] := Trim(GYCarNo);
RMVariables['CheJian'] := Trim(GYCheJian);
RMVariables['XHInt'] := Trim(GYXHInt);
RMVariables['BatchNoHZ'] := Trim(GYBatchNOHZ);
RMVariables['ChouZhen'] := Trim(GYChouZhen);
RMVariables['CarType'] := Trim(GYCarType);
RMVariables['C_Spec'] := Trim(GYC_Spec);
RMVariables['CustomerNoName'] := Trim(GYC_Custom);
RMVariables['gongyi'] := Trim(GYC_gongyi);
RMVariables['CPName'] := Trim(GYC_CPName);
RMVariables['ZhenCun'] := Trim(GYC_ZhenCun);
RMVariables['PiKgQty'] := Trim(GYC_PiKgQty);
RM2.PrintReport;
end
else
begin
cxGrid3.Enabled := True;
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf'), '<27><>ʾ', 0);
ClientDataSet3.EnableControls;
Exit;
end;
if FileExists(fImagePath) then
DeleteFile(fImagePath);
end;
ClientDataSet3.Delete;
end;
end;
ClientDataSet3.EnableControls;
FFMainID := '';
cxGrid3.Enabled := True;
Result := True;
end;
procedure TfrmClothSCDCGAnPai.Button1Click(Sender: TObject);
begin
if CDS_AnPai.IsEmpty then
Exit;
if CDS_AnPai.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if CDS_AnPai.Locate('SSel;JYFlag', VarArrayOf([True, True]), []) then
begin
Application.MessageBox('<27>Ѽ<EFBFBD><D1BC><EFBFBD><E9B2BB><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;
try
ADOQueryCmd.Connection.BeginTrans;
CDS_AnPai.DisableControls;
with CDS_AnPai do
begin
while CDS_AnPai.FieldByName('SSel').AsBoolean = True do
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete JYCon_Sub_AnPai ');
sql.Add(' where APId=''' + Trim(CDS_AnPai.fieldbyname('APID').AsString) + '''');
sql.Add(' and not exists(select * from WFB_MJJY_PB A where A.MJID=JYCon_Sub_AnPai.APID)');
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>Ʊ')));
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD>:' + trim(CDS_AnPai.FieldByName('apid').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(CDS_AnPai.FieldByName('carno').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(CDS_AnPai.FieldByName('APBatchNo').AsString) + ' MAINID:' + trim(CDS_AnPai.FieldByName('mainid').AsString))));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
ExecSQL;
end;
CDS_AnPai.Delete;
end;
end;
CDS_AnPai.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
CDS_AnPai.EnableControls;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
end;
procedure TfrmClothSCDCGAnPai.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmClothSCDCGAnPai.Tv3CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
Label10.Caption := Trim(ClientDataSet3.fieldbyname('ConNo').AsString);
APPS.Text := Trim(ClientDataSet3.fieldbyname('APPSHZ').AsString);
PSSX.Text := Trim(ClientDataSet3.fieldbyname('PiQty').AsString);
// APBatchNo.Text := Trim(ClientDataSet3.fieldbyname('BatchNoHZ').AsString);
// APBatchNo.Text := Trim(ClientDataSet3.fieldbyname('C_Code').AsString);
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add(' select A.*');
sql.Add(' from JYCon_Sub_AnPai A');
sql.Add(' where A.SubId=''' + Trim(ClientDataSet3.fieldbyname('SubId').AsString) + '''');
sql.Add(' and A.MainId=''' + Trim(ClientDataSet3.fieldbyname('MainId').AsString) + '''');
sql.Add(' and A.CarNo=''' + Trim(ClientDataSet3.fieldbyname('CarNo').AsString) + '''');
Open;
end;
SCreateCDS20(ADOQueryTemp, CDS_AnPai);
SInitCDSData20(ADOQueryTemp, CDS_AnPai);
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add(' select COUNT(JYFlag) wjps');
sql.Add(' from JYCon_Sub_AnPai A');
sql.Add(' where A.JYFlag=0 and A.SubId=''' + Trim(ClientDataSet3.fieldbyname('SubId').AsString) + '''');
sql.Add(' and A.MainId=''' + Trim(ClientDataSet3.fieldbyname('MainId').AsString) + '''');
sql.Add(' and A.CarNo=''' + Trim(ClientDataSet3.fieldbyname('CarNo').AsString) + '''');
Open;
end;
Label13.caption := <><CEB4><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>' + trim(inttostr(ADOQueryTemp.fieldbyname('wjps').asinteger));
// v2Column3.SortOrder := soDescending;
end;
procedure TfrmClothSCDCGAnPai.Button3Click(Sender: TObject);
var
fPrintFile: string;
i: Integer;
FDate: string;
Txt, fImagePath: string;
Moudle: THandle;
Makebar: TMakebar;
Mixtext: TMixtext;
GYLabName: string;
begin
if ClientDataSet3.IsEmpty then
Exit;
if CDS_AnPai.IsEmpty then
Exit;
if CDS_AnPai.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if CDS_AnPai.Locate('SSel;JYFlag', VarArrayOf([True, True]), []) then
begin
Application.MessageBox('<27>Ѽ<EFBFBD><D1BC><EFBFBD><E9B2BB><EFBFBD>ش<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
with CDS_AnPai do
begin
while CDS_AnPai.Locate('SSel', true, []) do
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Cloth_Main where Mainid=''' + Trim(CDS_AnPai.fieldbyname('MainId').AsString) + '''');
Open;
end;
GYLabName := Trim(ADOQueryTemp.fieldbyname('LabName').AsString);
CDS_AnPai.Edit;
CDS_AnPai.FieldByName('PRTFlag').Value := 1;
CDS_AnPai.FieldByName('PRTCount').Value := 2;
CDS_AnPai.Post;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate JYCon_Sub_AnPai Set PRTFlag=1,PRTCount=2 ');
sql.Add(' where APId=''' + Trim(CDS_AnPai.fieldbyname('APID').AsString) + '''');
ExecSQL;
end;
try
Moudle := LoadLibrary('MakeQRBarcode.dll');
@Makebar := GetProcAddress(Moudle, 'Make');
@Mixtext := GetProcAddress(Moudle, 'MixText');
Txt := Trim(CDS_AnPai.fieldbyname('APId').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;
if Trim(GYLabName) = '<27><>̧ͷ<CCA7><CDB7>ǩ' then
begin
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>̧ͷ<CCA7><CDB7>ǩ.rmf';
end
else if Trim(GYLabName) = '<27><>̧ͷ<CCA7><CDB7>ǩ' then
begin
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>̧ͷ<CCA7><CDB7>ǩ.rmf';
end
else
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf';
if FileExists(fPrintFile) then
begin
with ADOQueryPrint do
begin
Close;
sql.Clear;
sql.Add('select A.*,B.*, ');
sql.Add(' AA.APID,A.ZhuanQty,AA.SCPerson,AA.CarNo,AA.CheJian ,AA.XHInt,AA.JXPerson,AA.APBatchNo,aa.PRTFlag');
sql.add(',KHDM=(SELECT TOP 1 CODM FROM COMPANY G WHERE G.CONAME=B.KHNAME)');
sql.Add(',CPName=( select TOP 1 CPName from CP_YDang X inner join CP_Type Y on X.CYType=Y.CPID where X.CYName=A.C_CodeName )');
sql.Add(' ,CustomerNoName=(select top 1 CustomerNoName from JYOrderCon_Main_PB X where X.MainId=B.ConMainId) ');
sql.Add(' from JYCon_Sub_AnPai AA');
sql.Add(' inner join Cloth_Sub A on AA.SubId=A.SubId and AA.Mainid=A.MainId');
sql.Add(' inner join Cloth_Main B on AA.MainId=B.MainId ');
sql.Add(' where AA.APId=''' + Trim(CDS_AnPai.fieldbyname('APID').AsString) + '''');
Open;
end;
RM2.LoadFromFile(fPrintFile);
RMVariables['QRBARCODE'] := fImagePath;
RMVariables['PRTCS'] := '2';
RMVariables['ConNo'] := Trim(ADOQueryPrint.fieldbyname('ConNo').AsString);
RMVariables['APID'] := Trim(ADOQueryPrint.fieldbyname('APID').AsString);
RMVariables['C_Code'] := Trim(ADOQueryPrint.fieldbyname('C_Code').AsString);
RMVariables['KHDM'] := Trim(ADOQueryPrint.fieldbyname('KHDM').AsString);
if Trim(ADOQueryPrint.fieldbyname('PRTFlag').AsString) = '0' then
begin
RMVariables['CDFLAG'] := '';
end
else
begin
RMVariables['CDFLAG'] := '<27><><EFBFBD>ش<EFBFBD>';
end;
RMVariables['C_CodeName'] := Trim(ADOQueryPrint.fieldbyname('C_CodeName').AsString);
RMVariables['CustomerNoName'] := Trim(ADOQueryPrint.fieldbyname('CustomerNoName').AsString);
RMVariables['JXPerson'] := Trim(ADOQueryPrint.fieldbyname('JXPerson').AsString);
RMVariables['CarNo'] := Trim(ADOQueryPrint.fieldbyname('CarNo').AsString);
RMVariables['CheJian'] := Trim(ADOQueryPrint.fieldbyname('JHCheJian').AsString);
RMVariables['XHInt'] := Trim(ADOQueryPrint.fieldbyname('XHInt').AsString);
RMVariables['BatchNoHZ'] := Trim(ADOQueryPrint.fieldbyname('BatchNoHZ').AsString);
RMVariables['ChouZhen'] := Trim(ADOQueryPrint.fieldbyname('ChouZhen').AsString);
RMVariables['CarType'] := Trim(ADOQueryPrint.fieldbyname('CarType').AsString);
RMVariables['C_Spec'] := Trim(ADOQueryPrint.fieldbyname('C_Spec').AsString);
RMVariables['C_Color'] := Trim(ADOQueryPrint.fieldbyname('C_Color').AsString);
RMVariables['gongyi'] := Trim(ADOQueryPrint.fieldbyname('gongyi').AsString);
RMVariables['APBatchNo'] := Trim(ADOQueryPrint.fieldbyname('APBatchNo').AsString);
RMVariables['CPName'] := Trim(ADOQueryPrint.fieldbyname('CPName').AsString);
RMVariables['ZhenCun'] := Trim(ADOQueryPrint.fieldbyname('ZhenCun').AsString);
RMVariables['PiKgQty'] := Trim(ADOQueryPrint.fieldbyname('PiKgQty').AsString);
RM2.PrintReport;
end
else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf'), '<27><>ʾ', 0);
Exit;
end;
CDS_AnPai.Edit;
CDS_AnPai.FieldByName('SSel').Value := false;
end;
end;
end;
procedure TfrmClothSCDCGAnPai.v3Column8PropertiesEditValueChanged(Sender: TObject);
var
mvale: Boolean;
fsj: string;
begin
mvale := TcxCheckBox(Sender).EditingValue;
APBatchNo.Text := '';
ps.Text := '';
if mvale = True then
begin
// CDS_AnPai.Last;
// if CDS_AnPai.IsEmpty then
// APBatchNo.Text := Trim(ClientDataSet3.fieldbyname('C_Code').AsString)
// else
// APBatchNo.Text := Trim(ClientDataSet3.fieldbyname('C_Code').AsString);
APBatchNo.Text := Trim(ClientDataSet3.fieldbyname('ZJPH').AsString);
if Trim(FFMainID) = '' then
begin
FFMainID := Trim(ClientDataSet3.fieldbyname('Mainid').AsString)
end
else
begin
if Trim(FFMainID) <> Trim(ClientDataSet3.fieldbyname('Mainid').AsString) then
begin
with ClientDataSet3 do
begin
Edit;
FieldByName('SSel').Value := False;
end;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ͬ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
end;
Label10.Caption := Trim(ClientDataSet3.fieldbyname('ConNo').AsString);
APPS.Text := Trim(ClientDataSet3.fieldbyname('APPSHZ').AsString);
PSSX.Text := Trim(ClientDataSet3.fieldbyname('PiQty').AsString);
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add(' select A.*');
sql.Add(' from JYCon_Sub_AnPai A');
sql.Add(' where A.SubId=''' + Trim(ClientDataSet3.fieldbyname('SubId').AsString) + '''');
sql.Add(' and A.MainId=''' + Trim(ClientDataSet3.fieldbyname('MainId').AsString) + '''');
sql.Add(' and A.CarNo=''' + Trim(ClientDataSet3.fieldbyname('CarNo').AsString) + '''');
Open;
end;
SCreateCDS20(ADOQueryTemp, CDS_AnPai);
SInitCDSData20(ADOQueryTemp, CDS_AnPai);
end;
fsj := Trim(ClientDataSet3.fieldbyname('JTID').AsString);
with ClientDataSet3 do
begin
Edit;
FieldByName('SSel').Value := mvale;
end;
if mvale = True then
begin
JXPerson.Text := Trim(ClientDataSet3.fieldbyname('JXPerson10').AsString);
end
else
begin
ClientDataSet3.Locate('SSel', True, []);
JXPerson.Text := Trim(ClientDataSet3.fieldbyname('JXPerson10').AsString);
end;
if ClientDataSet3.Locate('SSel', True, []) = False then
begin
JXPerson.Text := '';
FFMainID := '';
end;
ClientDataSet3.Locate('JTID', fsj, []);
end;
procedure TfrmClothSCDCGAnPai.PSKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Button2.Click;
end;
end;
procedure TfrmClothSCDCGAnPai.Button4Click(Sender: TObject);
var
fPrintFile: string;
i: Integer;
FDate: string;
Txt, fImagePath: string;
Moudle: THandle;
Makebar: TMakebar;
Mixtext: TMixtext;
GYLabName: string;
begin
if ClientDataSet3.IsEmpty then
Exit;
if CDS_AnPai.IsEmpty then
Exit;
if CDS_AnPai.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if CDS_AnPai.Locate('SSel;JYFlag', VarArrayOf([True, True]), []) then
begin
Application.MessageBox('<27>Ѽ<EFBFBD><D1BC><EFBFBD><E9B2BB><EFBFBD>ش<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
with CDS_AnPai do
begin
while CDS_AnPai.Locate('SSel', true, []) do
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Cloth_Main where Mainid=''' + Trim(CDS_AnPai.fieldbyname('MainId').AsString) + '''');
Open;
end;
GYLabName := Trim(ADOQueryTemp.fieldbyname('LabName').AsString);
CDS_AnPai.Edit;
CDS_AnPai.FieldByName('PRTFlag').Value := 1;
CDS_AnPai.FieldByName('PRTCount').Value := 2;
CDS_AnPai.Post;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate JYCon_Sub_AnPai Set PRTFlag=1,PRTCount=2 ');
sql.Add(',APBatchNo =' + quotedstr(Trim(APBatchNo.Text)));
sql.Add(' where APId=''' + Trim(CDS_AnPai.fieldbyname('APID').AsString) + '''');
ExecSQL;
end;
try
Moudle := LoadLibrary('MakeQRBarcode.dll');
@Makebar := GetProcAddress(Moudle, 'Make');
@Mixtext := GetProcAddress(Moudle, 'MixText');
Txt := Trim(CDS_AnPai.fieldbyname('APId').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;
if Trim(GYLabName) = '<27><>̧ͷ<CCA7><CDB7>ǩ' then
begin
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>̧ͷ<CCA7><CDB7>ǩ.rmf';
end
else if Trim(GYLabName) = '<27><>̧ͷ<CCA7><CDB7>ǩ' then
begin
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>̧ͷ<CCA7><CDB7>ǩ.rmf';
end
else
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf';
if FileExists(fPrintFile) then
begin
with ADOQueryPrint do
begin
Close;
sql.Clear;
sql.Add('select A.*,B.*, ');
sql.Add(' AA.APID,A.ZhuanQty,AA.SCPerson,AA.CarNo,AA.CheJian ,AA.XHInt,AA.JXPerson,AA.APBatchNo');
sql.Add(',CPName=( select TOP 1 CPName from CP_YDang X inner join CP_Type Y on X.CYType=Y.CPID where X.CYName=A.C_CodeName )');
sql.Add(' ,CustomerNoName=(select top 1 CustomerNoName from JYOrderCon_Main_PB X where X.MainId=B.ConMainId) ');
sql.Add(' from JYCon_Sub_AnPai AA');
sql.Add(' inner join Cloth_Sub A on AA.SubId=A.SubId and AA.Mainid=A.MainId');
sql.Add(' inner join Cloth_Main B on AA.MainId=B.MainId ');
sql.Add(' where AA.APId=''' + Trim(CDS_AnPai.fieldbyname('APID').AsString) + '''');
Open;
end;
RM2.LoadFromFile(fPrintFile);
RMVariables['QRBARCODE'] := fImagePath;
RMVariables['PRTCS'] := '2';
RMVariables['ConNo'] := Trim(ADOQueryPrint.fieldbyname('ConNo').AsString);
RMVariables['APID'] := Trim(ADOQueryPrint.fieldbyname('APID').AsString);
RMVariables['C_Code'] := Trim(ADOQueryPrint.fieldbyname('C_Code').AsString);
RMVariables['C_CodeName'] := Trim(ADOQueryPrint.fieldbyname('C_CodeName').AsString);
RMVariables['CustomerNoName'] := Trim(ADOQueryPrint.fieldbyname('CustomerNoName').AsString);
RMVariables['JXPerson'] := Trim(ADOQueryPrint.fieldbyname('JXPerson').AsString);
RMVariables['CarNo'] := Trim(ADOQueryPrint.fieldbyname('CarNo').AsString);
RMVariables['CheJian'] := Trim(ADOQueryPrint.fieldbyname('CheJian').AsString);
RMVariables['XHInt'] := Trim(ADOQueryPrint.fieldbyname('XHInt').AsString);
RMVariables['BatchNoHZ'] := Trim(ADOQueryPrint.fieldbyname('BatchNoHZ').AsString);
RMVariables['ChouZhen'] := Trim(ADOQueryPrint.fieldbyname('ChouZhen').AsString);
RMVariables['CarType'] := Trim(ADOQueryPrint.fieldbyname('CarType').AsString);
RMVariables['C_Spec'] := Trim(ADOQueryPrint.fieldbyname('C_Spec').AsString);
RMVariables['C_Color'] := Trim(ADOQueryPrint.fieldbyname('C_Color').AsString);
RMVariables['gongyi'] := Trim(ADOQueryPrint.fieldbyname('gongyi').AsString);
RMVariables['APBatchNo'] := Trim(ADOQueryPrint.fieldbyname('APBatchNo').AsString);
RMVariables['CPName'] := Trim(ADOQueryPrint.fieldbyname('CPName').AsString);
RMVariables['ZhenCun'] := Trim(ADOQueryPrint.fieldbyname('ZhenCun').AsString);
RMVariables['PiKgQty'] := Trim(ADOQueryPrint.fieldbyname('PiKgQty').AsString);
// RM2.PrintReport;
end
else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩAP.rmf'), '<27><>ʾ', 0);
Exit;
end;
CDS_AnPai.Edit;
CDS_AnPai.FieldByName('SSel').Value := false;
CDS_AnPai.FieldByName('APBatchNo').Value := Trim(APBatchNo.Text);
end;
end;
end;
procedure TfrmClothSCDCGAnPai.ConNoKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
TBRafresh.Click();
if ADOQueryMain.Active = False then
Exit;
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS20(ADOQueryMain, ClientDataSet3);
SInitCDSData20(ADOQueryMain, ClientDataSet3);
end;
procedure TfrmClothSCDCGAnPai.C_CodeNameKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
TBRafresh.Click();
if ADOQueryMain.Active = False then
Exit;
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS20(ADOQueryMain, ClientDataSet3);
SInitCDSData20(ADOQueryMain, ClientDataSet3);
end;
procedure TfrmClothSCDCGAnPai.N1Click(Sender: TObject);
begin
SelOKNo(CDS_anpai, True);
end;
procedure TfrmClothSCDCGAnPai.N2Click(Sender: TObject);
begin
SelOKNo(CDS_anpai, false);
end;
procedure TfrmClothSCDCGAnPai.MenuItem1Click(Sender: TObject);
begin
if ClientDataSet3.IsEmpty then
Exit;
ClientDataSet3.DisableControls;
with ClientDataSet3 do
begin
First;
while not Eof do
begin
if Trim(FFMainID) = '' then
begin
FFMainID := Trim(ClientDataSet3.fieldbyname('Mainid').AsString)
end
else
begin
if Trim(FFMainID) <> Trim(ClientDataSet3.fieldbyname('Mainid').AsString) then
begin
with ClientDataSet3 do
begin
Edit;
FieldByName('SSel').Value := False;
end;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ͬ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
ClientDataSet3.EnableControls;
Exit;
end;
end;
if FieldByName('SSel').AsBoolean = FALSE then
begin
Edit;
FieldByName('SSel').Value := TRUE;
Post;
end;
Next;
end;
end;
ClientDataSet3.EnableControls;
end;
procedure TfrmClothSCDCGAnPai.MenuItem2Click(Sender: TObject);
begin
SelOKNo(ClientDataSet3, false);
FFMainID := '';
end;
procedure TfrmClothSCDCGAnPai.ToolButton3Click(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
if canshu1 = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
flag := 'SCPerson';
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)';
end
else
begin
flag := 'SCPerson2';
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(һ<><D2BB><EFBFBD><EFBFBD>)';
end;
// fnote := True;
// V1Note.Caption := '<27><><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
end;
end;
finally
frmZDYHelp.free;
end;
end;
procedure TfrmClothSCDCGAnPai.ToolButton2Click(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'ClothType';
flagname := '<27><>ƥ<EFBFBD>ȼ<EFBFBD>';
if ShowModal = 1 then
begin
end;
end;
finally
frmZDYHelp.free;
end;
end;
procedure TfrmClothSCDCGAnPai.ToolButton1Click(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
if canshu1 = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
flag := 'WFBCPBZZ';
flagname := '<27>õ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)';
end
else
begin
flag := 'WFBCPBZZY';
flagname := '<27>õ<EFBFBD>(һ<><D2BB><EFBFBD><EFBFBD>)';
end;
fnote := True;
// V1Note.Caption:='Ӣ<><D3A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmClothSCDCGAnPai.Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
F1, F2: Double;
begin
F1 := StrToFloatDef((AViewInfo.GridRecord.Values[v3Column7.Index]), 0);
F2 := StrToFloatDef((AViewInfo.GridRecord.Values[v3Column15.Index]), 0);
if F1 >= F2 * 0.8 then
begin
ACanvas.Brush.Color := clRed;
end;
// if (AViewInfo.GridRecord.Values[v3Column3.Index]) <= (AViewInfo.GridRecord.Values[v3Column20.Index] <> '$FFFFFF') then
// begin
// ACanvas.Brush.Color := clRed;
// end;
end;
procedure TfrmClothSCDCGAnPai.ToolButton4Click(Sender: TObject);
begin
frmSysLogHelp := TfrmSysLogHelp.create(self);
with frmSysLogHelp do
begin
// fModel := self.caption;
facction := '<27><><EFBFBD>ϲ<EFBFBD>Ʊ';
showmodal;
free;
end;
end;
end.