333 lines
8.8 KiB
ObjectPascal
333 lines
8.8 KiB
ObjectPascal
|
unit U_TradeCardInPut;
|
|||
|
|
|||
|
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, cxPC, MovePanel, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
|
|||
|
dxBarBuiltInMenu, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
|
|||
|
U_BaseList, Vcl.Menus, U_BaseInput, System.ImageList, Vcl.ImgList, StrUtils,
|
|||
|
dxSkinWXI, dxScrollbarAnnotations, cxContainer, cxMaskEdit, cxDropDownEdit;
|
|||
|
|
|||
|
type
|
|||
|
TfrmTradeCardInPut = class(TfrmBaseInput)
|
|||
|
GPM_1: TcxGridPopupMenu;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
DS_1: TDataSource;
|
|||
|
CDS_1: TClientDataSet;
|
|||
|
PM_1: TPopupMenu;
|
|||
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
cxStyle1: TcxStyle;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v3Column8: TcxGridDBColumn;
|
|||
|
Tv1Column7: TcxGridDBColumn;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
Tv1Column6: TcxGridDBColumn;
|
|||
|
cxGridLevel2: TcxGridLevel;
|
|||
|
Panel3: TPanel;
|
|||
|
Label1: TLabel;
|
|||
|
Label12: TLabel;
|
|||
|
Label13: TLabel;
|
|||
|
Label16: TLabel;
|
|||
|
Label17: TLabel;
|
|||
|
Label2: TLabel;
|
|||
|
Label3: TLabel;
|
|||
|
Label6: TLabel;
|
|||
|
Label5: TLabel;
|
|||
|
Label8: TLabel;
|
|||
|
C_Name: TcxTextEdit;
|
|||
|
C_Code: TcxTextEdit;
|
|||
|
ConNo: TcxTextEdit;
|
|||
|
GC_Name: TcxTextEdit;
|
|||
|
CraftCode: TcxTextEdit;
|
|||
|
C_Color: TcxTextEdit;
|
|||
|
C_Pattern: TcxTextEdit;
|
|||
|
C_ColorConfirm: TcxTextEdit;
|
|||
|
C_ColorNo: TcxTextEdit;
|
|||
|
OrderNo: TcxTextEdit;
|
|||
|
ToolBar1: TToolBar;
|
|||
|
ToolButton12: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
ADO_1: TADOQuery;
|
|||
|
RM1: TRMGridReport;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
RMDB_1: TRMDBDataSet;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure ToolButton12Click(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
private
|
|||
|
procedure InitOrd();
|
|||
|
procedure InitGrid1();
|
|||
|
procedure PrtData(MCIID: string);
|
|||
|
procedure SaveCard(MCardQty: Integer; MBatchNo: string);
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
FMainId, FSubId: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmTradeCardInPut: TfrmTradeCardInPut;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp, U_InputBoxCard, U_LabelPrint, U_TradePlanSel;
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.PrtData(MCIID: string);
|
|||
|
var
|
|||
|
fPrintFile, FLabVolume: string;
|
|||
|
Txt, fImagePath, Txt2, fImagePath2: string;
|
|||
|
Moudle: THandle;
|
|||
|
Makebar: TMakebar;
|
|||
|
Mixtext: TMixtext;
|
|||
|
begin
|
|||
|
with ADOQueryPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' EXEC P_Trade_Card_Prt1 ');
|
|||
|
SQL.Add(' @Filtration=''' + Trim(MCIID) + '''');
|
|||
|
// ShowMessage(sql.Text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryPrint.IsEmpty then
|
|||
|
begin
|
|||
|
application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
FLabVolume := Trim(ADOQueryPrint.fieldbyname('LabVolume').AsString);
|
|||
|
ExportFtErpFile(FLabVolume + '.rmf', ADOQueryTemp);
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLabVolume + '.rmf';
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
RM1.DefaultCopies := 1;
|
|||
|
RM1.PrintReport;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('update Trade_Plan_Card ');
|
|||
|
sql.Add('set PRTer=' + quotedstr(DName));
|
|||
|
sql.Add(', PRTCount=PRTCount+1');
|
|||
|
sql.Add(', PRTDate=getdate()');
|
|||
|
sql.Add(' where EXISTS(select X.RTValue from [dbo].[F_Tool_SplitString](' + QuotedStr(MCIID) + ','','') X where Trade_Plan_Card.PCID=X.RTValue ) ');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.InitOrd();
|
|||
|
begin
|
|||
|
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select A.*,B.*');
|
|||
|
sql.Add(' ,YAPPS=ISNULL((select count(*) from Trade_Plan_Card X where X.MainId=A.MainId),0)');
|
|||
|
sql.Add(' ,WAPPS=OrdPiece-ISNULL((select count(*) from Trade_Plan_Card X where X.MainId=A.MainId),0)');
|
|||
|
sql.Add(' from Trade_Plan_Main A');
|
|||
|
sql.Add(' inner join Trade_Plan_Sub B on A.MainId=B.MainId ');
|
|||
|
sql.Add(' where B.SubId=' + QuotedStr(FSubId));
|
|||
|
// ShowMessage(sql.Text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCSHData(ADOQueryMain, Panel3, 0);
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.InitGrid1();
|
|||
|
var
|
|||
|
fwhere: string;
|
|||
|
begin
|
|||
|
try
|
|||
|
ADO_1.DisableControls;
|
|||
|
with ADO_1 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select *');
|
|||
|
sql.Add(' from Trade_Plan_Card A where Subid =''' + trim(FSubid) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADO_1, CDS_1);
|
|||
|
SInitCDSData(ADO_1, CDS_1);
|
|||
|
finally
|
|||
|
ADO_1.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
frmTradeCardInPut := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
Close;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid1();
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, 'ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
InitOrd();
|
|||
|
InitGrid1();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid1();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.ToolButton12Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, 'ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
try
|
|||
|
frmInputBoxCard := TfrmInputBoxCard.Create(Application);
|
|||
|
with frmInputBoxCard do
|
|||
|
begin
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
SaveCard(StrToIntDef(TTE_CardQty.Text, 0), TTE_BatchNo.Text);
|
|||
|
InitGrid1();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmInputBoxCard.Free;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
PrtData(SelCDSKey(CDS_1, ['PCID'])[0]);
|
|||
|
InitGrid1();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeCardInPut.SaveCard(MCardQty: Integer; MBatchNo: string);
|
|||
|
var
|
|||
|
maxno, maxPCId, WSql: string;
|
|||
|
i, j, MPCNo: integer;
|
|||
|
begin
|
|||
|
|
|||
|
if MCardQty = 0 then
|
|||
|
Exit;
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select PCNo=isnull(Max(PCNo),0) ');
|
|||
|
sql.Add('from Trade_Plan_Card A ');
|
|||
|
sql.Add('where A.Subid=' + Quotedstr(Trim(FSubid)));
|
|||
|
|
|||
|
sql.Add('and A.BatchNo=' + Quotedstr(Trim(MBatchNo)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryTemp.IsEmpty then
|
|||
|
MPCNo := 1
|
|||
|
else
|
|||
|
MPCNo := ADOQueryTemp.FieldByName('PCNo').AsInteger + 1;
|
|||
|
////////////////// <20><><EFBFBD>벼Ʊ //////////////////////
|
|||
|
if GetLSNo(ADOQueryTemp, maxno, 'PC', 'Trade_Plan_Mach', 2, 1) = False then
|
|||
|
begin
|
|||
|
raise Exception.Create('ȡ<><C8A1>Ʊ<EFBFBD><C6B1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!');
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' insert into Trade_Plan_Card(MainId,SubId,PCId,PCNo,PCDate,Filler,BatchNo) values');
|
|||
|
for j := 1 to MCardQty do
|
|||
|
begin
|
|||
|
maxPCId := maxno + RightStr('00' + inttostr(j), 3);
|
|||
|
if j > 1 then
|
|||
|
sql.Add(',');
|
|||
|
sql.Add(' (' + Quotedstr(Trim(FMainId)));
|
|||
|
sql.Add(',' + Quotedstr(Trim(FSubId)));
|
|||
|
sql.Add(',' + Quotedstr(maxPCId));
|
|||
|
sql.Add(',' + Quotedstr(IntToStr(MPCNo)));
|
|||
|
sql.Add(',getdate() ');
|
|||
|
sql.Add(',' + Quotedstr(Trim(DName)));
|
|||
|
sql.Add(',' + Quotedstr(Trim(MBatchNo)));
|
|||
|
sql.Add(' )');
|
|||
|
MPCNo := MPCNo + 1;
|
|||
|
|
|||
|
if WSql <> '' then
|
|||
|
begin
|
|||
|
WSql := WSql + ',' + (Trim(maxPCId));
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
WSql := (Trim(maxPCId));
|
|||
|
end;
|
|||
|
end;
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
PrtData(WSql);
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
if GetLSNo(ADOQueryTemp, maxPCId, 'PC', 'Trade_Plan_Mach', 3, 1) = False then
|
|||
|
begin
|
|||
|
// raise Exception.Create('ȡ<><C8A1>Ʊ<EFBFBD><C6B1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!');
|
|||
|
end;
|
|||
|
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
|
|||
|
InitGrid1();
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|