RTFormwork/项目代码/RTBasicsV1/T00贸易通用窗体/U_TradePlanSel.pas

236 lines
6.4 KiB
ObjectPascal
Raw Normal View History

2024-07-07 09:35:27 +08:00
unit U_TradePlanSel;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, ToolWin, ComCtrls, U_BaseHelp, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls,
cxGridCustomView, cxGrid, DBClient, ADODB, ImgList, StdCtrls, ExtCtrls,
cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels,
cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, cxNavigator,
dxDateRanges, dxBarBuiltInMenu, System.ImageList, U_BaseInput, cxCheckBox,
cxCalendar, Vcl.Menus;
type
TfrmTradePlanSel = class(TfrmBaseHelp)
ToolBar1: TToolBar;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
DS_1: TDataSource;
CDS_1: TClientDataSet;
TBSave: TToolButton;
TBClose: TToolButton;
ToolButton1: TToolButton;
ADOConnection1: TADOConnection;
Panel1: TPanel;
GPM_1: TcxGridPopupMenu;
ImageList1: TImageList;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column7: TcxGridDBColumn;
v1OrderNo: TcxGridDBColumn;
v1ConNo: TcxGridDBColumn;
Tv1Column11: TcxGridDBColumn;
v1OrdDefStr1: TcxGridDBColumn;
v1MPRTCodeName: TcxGridDBColumn;
v1MPRTSpec: TcxGridDBColumn;
Tv1Column1: TcxGridDBColumn;
v1MPRTMF: TcxGridDBColumn;
v1MPRTKZ: TcxGridDBColumn;
v1PRTColor: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1PRTOrderQty: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1DeliveryDate: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
Tv1Column3: TcxGridDBColumn;
Tv1Column4: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
Tv1Column2: TcxGridDBColumn;
Label3: TLabel;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
OrderNo: TEdit;
C_Name: TEdit;
C_Color: TEdit;
C_ColorNo: TEdit;
C_Pattern: TEdit;
C_Code: TEdit;
ConNo: TEdit;
Tv1Column6: TcxGridDBColumn;
Tv1Column7: TcxGridDBColumn;
ThreeColorBase: TcxStyleRepository;
SHuangSe: TcxStyle;
SkyBlue: TcxStyle;
Default: TcxStyle;
QHuangSe: TcxStyle;
Red: TcxStyle;
FontBlue: TcxStyle;
TextSHuangSe: TcxStyle;
FonePurple: TcxStyle;
FoneClMaroon: TcxStyle;
FoneRed: TcxStyle;
RowColor: TcxStyle;
handBlack: TcxStyle;
cxBlue: TcxStyle;
SHuangSeCu: TcxStyle;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure OrderNoChange(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Tv1DblClick(Sender: TObject);
procedure Tv1Column6CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
private
procedure InitGrid();
{ Private declarations }
public
FCoType, FAuthority, FSTKNAME: string;
{ Public declarations }
end;
var
frmTradePlanSel: TfrmTradePlanSel;
implementation
uses
U_DataLink, U_RTFun;
{$R *.dfm}
procedure TfrmTradePlanSel.FormCreate(Sender: TObject);
begin
inherited;
try
with ADOConnection1 do
begin
Connected := false;
ConnectionString := DConString;
Connected := true;
end;
ADOQueryBaseCmd.Connection := ADOConnection1;
ADOQueryBaseTemp.Connection := ADOConnection1;
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
end;
end;
procedure TfrmTradePlanSel.FormDestroy(Sender: TObject);
begin
inherited;
frmTradePlanSel := nil;
end;
procedure TfrmTradePlanSel.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := cahide;
end;
procedure TfrmTradePlanSel.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
sql.Clear;
sql.Add('select A.* ');
sql.Add(',SumPiece=(select Sum(X.Piece) from BS_Cloth_IO X where X.IOFlag=''<27><><EFBFBD><EFBFBD>'' and X.fromSubID=A.SubID and isnull(X.STKNAME,'''')=' + Quotedstr(Trim(FSTKNAME)) + ')');
sql.Add(',SumQty=(select Sum(X.Qty) from BS_Cloth_IO X where X.IOFlag=''<27><><EFBFBD><EFBFBD>'' and X.fromSubID=A.SubID and isnull(X.STKNAME,'''')=' + Quotedstr(Trim(FSTKNAME)) + ')');
sql.Add('from V_Trade_Plan_Fty A ');
sql.add('where Status=''9'' ');
// ShowMessage(sql.Text);
Open;
end;
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmTradePlanSel.N1Click(Sender: TObject);
begin
SelOKNo(CDS_1, True);
end;
procedure TfrmTradePlanSel.N2Click(Sender: TObject);
begin
SelOKNo(CDS_1, False);
end;
procedure TfrmTradePlanSel.OrderNoChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
end;
end;
procedure TfrmTradePlanSel.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid('<27><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>' + Trim(FCoType), TV1, '<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
InitGrid();
end;
procedure TfrmTradePlanSel.TBCloseClick(Sender: TObject);
begin
inherited;
Close;
end;
procedure TfrmTradePlanSel.TBSaveClick(Sender: TObject);
begin
WriteCxGrid('<27><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>' + Trim(FCoType), TV1, '<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmTradePlanSel.ToolButton1Click(Sender: TObject);
begin
ModalResult := 1;
end;
procedure TfrmTradePlanSel.Tv1Column6CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('SumPiece').Index] = null then
Exit;
if (AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('SumPiece').Index]) > 0 then
ACanvas.Brush.Color := $00FF00;
end;
procedure TfrmTradePlanSel.Tv1DblClick(Sender: TObject);
begin
ModalResult := 1;
end;
end.