418 lines
12 KiB
ObjectPascal
418 lines
12 KiB
ObjectPascal
unit U_TradePlanCard;
|
||
|
||
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, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
|
||
dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu,
|
||
U_BaseList, Vcl.Menus, Vcl.Clipbrd, dxSkinWXI, dxScrollbarAnnotations,
|
||
FrameDateSel, cxContainer;
|
||
|
||
type
|
||
TfrmTradePlanCard = class(TfrmBaseList)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
GPM_1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADO_2: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
Label3: TLabel;
|
||
ConNo: TcxTextEdit;
|
||
ADOQueryPrint: TADOQuery;
|
||
Label2: TLabel;
|
||
C_Name: TcxTextEdit;
|
||
DS_2: TDataSource;
|
||
CDS_2: TClientDataSet;
|
||
Label4: TLabel;
|
||
C_Code: TcxTextEdit;
|
||
ToolButton2: TToolButton;
|
||
Label5: TLabel;
|
||
OrderNo: TcxTextEdit;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
ToolButton3: TToolButton;
|
||
N3: TMenuItem;
|
||
ToolButton5: TToolButton;
|
||
frmFrameDateSel1: TfrmFrameDateSel;
|
||
cxGrid1: TcxGrid;
|
||
TV1: TcxGridDBTableView;
|
||
v1Column16: TcxGridDBColumn;
|
||
v1OrdDate: TcxGridDBColumn;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
Tv1Column19: TcxGridDBColumn;
|
||
v1OrderNo: TcxGridDBColumn;
|
||
v1DeliveryDate: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
Tv1Column22: TcxGridDBColumn;
|
||
Tv1Column12: TcxGridDBColumn;
|
||
cxGridDBColumn4: TcxGridDBColumn;
|
||
Tv1Column20: TcxGridDBColumn;
|
||
Tv1Column21: TcxGridDBColumn;
|
||
Tv1Column13: TcxGridDBColumn;
|
||
Tv1Column14: TcxGridDBColumn;
|
||
Tv1Column15: TcxGridDBColumn;
|
||
Tv1Column16: TcxGridDBColumn;
|
||
Tv1Column11: TcxGridDBColumn;
|
||
Tv1Column10: TcxGridDBColumn;
|
||
v1Column11: TcxGridDBColumn;
|
||
cxGridDBColumn5: TcxGridDBColumn;
|
||
cxGridDBColumn6: TcxGridDBColumn;
|
||
cxGridDBColumn7: TcxGridDBColumn;
|
||
cxGridDBColumn8: TcxGridDBColumn;
|
||
cxGridDBColumn9: TcxGridDBColumn;
|
||
Tv1Column17: TcxGridDBColumn;
|
||
Tv1Column18: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
TV1Column1: TcxGridDBColumn;
|
||
TV1Column2: TcxGridDBColumn;
|
||
Panel2: TPanel;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
v3Column8: TcxGridDBColumn;
|
||
Tv2Column7: TcxGridDBColumn;
|
||
Tv2Column3: TcxGridDBColumn;
|
||
Tv2Column4: TcxGridDBColumn;
|
||
Tv2Column5: TcxGridDBColumn;
|
||
Tv2Column6: TcxGridDBColumn;
|
||
cxGridLevel2: TcxGridLevel;
|
||
cxTabControl1: TcxTabControl;
|
||
ToolBar2: TToolBar;
|
||
ToolButton8: TToolButton;
|
||
ToolButton10: TToolButton;
|
||
ADO_1: TADOQuery;
|
||
GPM_2: TcxGridPopupMenu;
|
||
CDS_1: TClientDataSet;
|
||
DS_1: TDataSource;
|
||
Label1: TLabel;
|
||
Label6: TLabel;
|
||
CraftCode: TcxTextEdit;
|
||
GC_Name: TcxTextEdit;
|
||
RM1: TRMGridReport;
|
||
RMDB_1: TRMDBDataSet;
|
||
ADOQuery1: TADOQuery;
|
||
ToolButton1: TToolButton;
|
||
Tv2Column1: TcxGridDBColumn;
|
||
Tv2Column2: TcxGridDBColumn;
|
||
Tv2Column8: TcxGridDBColumn;
|
||
Tv2Column9: TcxGridDBColumn;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ConNoChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure N3Click(Sender: TObject);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
procedure TV1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
procedure ToolButton10Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
FInt, PFInt: Integer;
|
||
FFMainID, BPFlag: string;
|
||
procedure InitGrid1();
|
||
procedure InitGrid2();
|
||
procedure PrtData(MCIID: string);
|
||
{ Private declarations }
|
||
public
|
||
canshu1: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp, U_LabelPrint, U_TradeCardInPut,
|
||
U_TradeCardInStk;
|
||
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmTradePlanCard.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 TfrmTradePlanCard.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
WriteCxGrid('DCG13', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.InitGrid1();
|
||
var
|
||
Msql, mbegdate, menddate: string;
|
||
SqlStr: string;
|
||
begin
|
||
SqlStr := 'select * from Trade_Plan_Main A ';
|
||
SqlStr := SqlStr + ' left join Trade_Plan_Sub B on A.MainID=B.MainID ';
|
||
SqlStr := SqlStr + ' left join Trade_Plan_Fty C on A.MainID=C.MainID ';
|
||
SqlStr := SqlStr + ' left join Trade_Cloth_Inspect_Rule D on A.MainID=D.RuleID ';
|
||
SqlStr := SqlStr + ' where A.OrdDate>=''' + Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.BegDate.Date)) + '''';
|
||
SqlStr := SqlStr + ' and A.OrdDate<''' + Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.enddate.Date + 1)) + '''';
|
||
InitCDSData(ADO_1, CDS_1, Tv1, SqlStr, SGetFilters(Panel1, 1, 2), 'SubId');
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.InitGrid2();
|
||
var
|
||
SqlStr: string;
|
||
begin
|
||
SqlStr := 'select * from Trade_Plan_Card A ';
|
||
SqlStr := SqlStr + ' where A.SubId=' + QuotedStr(Trim(CDS_1.FieldByName('SubId').AsString));
|
||
InitCDSData(ADO_2, CDS_2, Tv2, SqlStr, '', '');
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_2, true)
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_2, false);
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.N3Click(Sender: TObject);
|
||
begin
|
||
Clipboard.SetTextBuf(PChar(Trim(CDS_2.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid1();
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.ToolButton10Click(Sender: TObject);
|
||
begin
|
||
PrtData(SelCDSKey(CDS_2, ['PCID'])[0]);
|
||
InitGrid2();
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
|
||
try
|
||
frmTradeCardInStk := TfrmTradeCardInStk.Create(Application);
|
||
with frmTradeCardInStk do
|
||
begin
|
||
FMainId := Trim(Self.CDS_1.fieldbyname('MainId').AsString);
|
||
FSubId := Trim(Self.CDS_1.fieldbyname('SubId').AsString);
|
||
if ShowModal = 1 then
|
||
begin
|
||
InitGrid2();
|
||
end;
|
||
end;
|
||
finally
|
||
frmTradeCardInStk.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
|
||
try
|
||
frmTradeCardInPut := TfrmTradeCardInPut.Create(Application);
|
||
with frmTradeCardInPut do
|
||
begin
|
||
FMainId := Trim(Self.CDS_1.fieldbyname('MainId').AsString);
|
||
FSubId := Trim(Self.CDS_1.fieldbyname('SubId').AsString);
|
||
if ShowModal = 1 then
|
||
begin
|
||
InitGrid2();
|
||
end;
|
||
end;
|
||
finally
|
||
frmTradeCardInPut.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.ToolButton4Click(Sender: TObject);
|
||
var
|
||
WSql: string;
|
||
begin
|
||
if CDS_2.IsEmpty then
|
||
Exit;
|
||
Tv1.OnFocusedRecordChanged := nil;
|
||
if CDS_2.Locate('SSel', True, []) = False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
WSql := '';
|
||
CDS_2.DisableControls;
|
||
|
||
with CDS_2 do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if CDS_2.fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
if WSql <> '' then
|
||
begin
|
||
WSql := WSql + ',' + (Trim(CDS_2.fieldbyname('PCID').AsString));
|
||
end
|
||
else
|
||
begin
|
||
WSql := (Trim(CDS_2.fieldbyname('PCID').AsString));
|
||
end;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
CDS_2.Locate('SSel', True, []);
|
||
CDS_2.EnableControls;
|
||
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
// with ADOQueryCmd do
|
||
// begin
|
||
// Close;
|
||
// sql.Clear;
|
||
// sql.Add('insert into Trade_Need_Up(UOperation,UType,UDataId) values(''<27><><EFBFBD><EFBFBD>'',''<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>'',' + quotedstr(MCIIDS) + ') ');
|
||
// ExecSQL;
|
||
// end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
Sql.Clear;
|
||
Sql.Add('exec P_Trade_Card_Del ');
|
||
Sql.Add('@PCIDS=' + quotedstr(Trim(WSql)));
|
||
Sql.Add(',@DCode=' + Quotedstr(DCode));
|
||
Sql.Add(',@DName=' + Quotedstr(DName));
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
|
||
begin
|
||
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
InitGrid2();
|
||
application.MessageBox('ɾ<><C9BE><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.ToolButton5Click(Sender: TObject);
|
||
begin
|
||
|
||
// try
|
||
// frmTradePlanCardDel := TfrmTradePlanCardDel.Create(Application);
|
||
// with frmTradePlanCardDel do
|
||
// begin
|
||
// if ShowModal = 1 then
|
||
// begin
|
||
// end;
|
||
// end;
|
||
// finally
|
||
// frmTradePlanCardDel.Free;
|
||
// end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.TV1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
InitGrid2();
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.ConNoChange(Sender: TObject);
|
||
begin
|
||
if ADO_1.Active = False then
|
||
Exit;
|
||
SDofilter(ADO_1, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADO_1, CDS_1);
|
||
SInitCDSData(ADO_1, CDS_1);
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmFrameDateSel1.EndDate.Date := SGetServerDate(ADOQueryTemp);
|
||
frmFrameDateSel1.BegDate.Date := frmFrameDateSel1.EndDate.Date - 1;
|
||
ReadCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
||
InitGrid1();
|
||
end;
|
||
|
||
procedure TfrmTradePlanCard.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid1();
|
||
end;
|
||
|
||
end.
|
||
|