412 lines
12 KiB
ObjectPascal
412 lines
12 KiB
ObjectPascal
unit U_ClothCLList2;
|
||
|
||
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, 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, math;
|
||
|
||
type
|
||
TfrmClothCLList2 = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
Label3: TLabel;
|
||
ConNo: TEdit;
|
||
Label5: TLabel;
|
||
C_CodeName: TEdit;
|
||
TBExport: TToolButton;
|
||
Order_Main: TClientDataSet;
|
||
RM1: TRMGridReport;
|
||
RMXLSExport1: TRMXLSExport;
|
||
CDS_PRT: TClientDataSet;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1OrderNo: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1PRTOrderQty: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1Column6: TcxGridDBColumn;
|
||
RMDBPRT: TRMDBDataSet;
|
||
RMDBPZ: TRMDBDataSet;
|
||
CDS_PZ: TClientDataSet;
|
||
CDS_SJ: TClientDataSet;
|
||
RMDBSJ: TRMDBDataSet;
|
||
v1Column21: TcxGridDBColumn;
|
||
Label10: TLabel;
|
||
C_Code: TEdit;
|
||
RMDBDataSet1: TRMDBDataSet;
|
||
ClientDataSet1: TClientDataSet;
|
||
CDS_WJG: TClientDataSet;
|
||
RMDBWJG: TRMDBDataSet;
|
||
v1Column31: TcxGridDBColumn;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
cxStyleRepository2: TcxStyleRepository;
|
||
cxStyle2: TcxStyle;
|
||
cxStyle3: TcxStyle;
|
||
cxStyleRepository3: TcxStyleRepository;
|
||
cxStyle4: TcxStyle;
|
||
KHName: TEdit;
|
||
Label4: TLabel;
|
||
v1Column12: TcxGridDBColumn;
|
||
v1Column13: TcxGridDBColumn;
|
||
cxStyle5: TcxStyle;
|
||
cxStyle6: TcxStyle;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
Panel2: TPanel;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
cxGridDBColumn4: TcxGridDBColumn;
|
||
cxGridDBColumn5: TcxGridDBColumn;
|
||
cxGridDBColumn6: TcxGridDBColumn;
|
||
cxGridDBColumn8: TcxGridDBColumn;
|
||
cxGridDBColumn9: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
CDS_2: TClientDataSet;
|
||
DS_2: TDataSource;
|
||
cxGrid3: TcxGrid;
|
||
TV3: TcxGridDBTableView;
|
||
v1Column24: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
cxGridDBColumn7: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
cxGridDBColumn10: TcxGridDBColumn;
|
||
cxGridLevel2: TcxGridLevel;
|
||
CDS_3: TClientDataSet;
|
||
DS_3: TDataSource;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ConNoChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure conPress(Sender: TObject; var Key: Char);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure Tv1DblClick(Sender: TObject);
|
||
procedure RTAPJTInfoKeyPress(Sender: TObject; var Key: Char);
|
||
procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
procedure TV2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
private
|
||
FInt, PFInt: Integer;
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
function DelData(): Boolean;
|
||
procedure InitButton();
|
||
{ Private declarations }
|
||
public
|
||
canshu1, FCheJian: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmClothCLList2: TfrmClothCLList2;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun, U_ZDYHelp, U_ClothCLCXList;
|
||
//U_ClothSCInPutSC ,U_ClothSCInPut ,U_SCPerson
|
||
|
||
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmClothCLList2.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.InitButton();
|
||
begin
|
||
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid('<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ1', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' exec P_View_DDJD1 ''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + '''');
|
||
sql.Add(' ,''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1)) + '''');
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.InitForm();
|
||
begin
|
||
InitButton();
|
||
ReadCxGrid('<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ1', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
BegDate.DateTime := SGetServerDate10(ADOQueryTemp) - 7;
|
||
EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
end;
|
||
|
||
function TfrmClothCLList2.DelData(): Boolean;
|
||
begin
|
||
try
|
||
Result := false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Cloth_Sub where SubId=''' + Trim(Order_Main.fieldbyname('SubId').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Cloth_Sub where MainId=''' + Trim(Order_Main.fieldbyname('MainId').AsString) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Cloth_Main where MainId=''' + Trim(Order_Main.fieldbyname('MainId').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
if Trim(Order_Main.fieldbyname('SubId').AsString) = '' then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Cloth_Main where MainId=''' + Trim(Order_Main.fieldbyname('MainId').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Cloth_PaiZhen where MainId=''' + Trim(Order_Main.fieldbyname('MainId').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Cloth_YCL_PB where MainId=''' + Trim(Order_Main.fieldbyname('MainId').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result := True;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Result := False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>', '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
Exit;
|
||
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.ConNoChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.FormShow(Sender: TObject);
|
||
begin
|
||
panel2.width := ceil(frmClothCLList2.width / 2);
|
||
InitForm();
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.conPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
begin
|
||
if Length(Trim(ConNo.Text)) < 4 then
|
||
Exit;
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
//sql.Add('exec Cloth_QryList :MainId,:WSql');
|
||
// Parameters.ParamByName('WSql').Value:=' and OM.conNo like '''+'%'+Trim(ConNoM.Text)+'%'+''''
|
||
// +' and ConType=''<27><><EFBFBD><EFBFBD>'' ';
|
||
sql.Add('select * from Cloth_Main A inner join CLoth_Sub B on A.Mainid=B.MainId');
|
||
sql.Add(' where A.ConNo like ''' + '%' + Trim(ConNo.Text) + '%' + '''');
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmClothCLList2 := nil;
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.Tv1DblClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmClothCLCXList := TfrmClothCLCXList.Create(Application);
|
||
with frmClothCLCXList do
|
||
begin
|
||
FMainID := self.Order_Main.fieldbyname('MainID').asstring;
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmClothCLCXList.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.RTAPJTInfoKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
var
|
||
FDDZT: string;
|
||
begin
|
||
|
||
// if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('DDZT').Index] = null then
|
||
// Exit;
|
||
//
|
||
// FDDZT := AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('DDZT').Index];
|
||
//
|
||
// if FDDZT = '<27>ѿ<EFBFBD>ʼ' then
|
||
// ACanvas.Font.Color := $FF0000;
|
||
// if FDDZT = '<27>ѽ<EFBFBD><D1BD><EFBFBD>' then
|
||
// ACanvas.Font.Color := $0000FF;
|
||
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
try
|
||
ADOQueryCmd.DisableControls;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' exec P_View_DDJD2 ' + QuotedStr(ORDER_MAIN.FIELDBYNAME('MAINID').ASSTRING));
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryCmd, CDS_2);
|
||
SInitCDSData20(ADOQueryCmd, CDS_2);
|
||
finally
|
||
ADOQueryCmd.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothCLList2.TV2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
|
||
sql.add('SELECT B.MJID,B.APID, B.MJSTR2,B.MJSTR4,B.carno,b.mjmaoz,A.XHINT,B.FILLTIME FROM WFB_MJJY_pb B LEFT JOIN JYCon_Sub_AnPai A on B.APID=A.APID where ');
|
||
|
||
SQL.Add(' B.MAINID=' + QuotedStr(CDS_2.FIELDBYNAME('MAINID').ASSTRING));
|
||
|
||
SQL.Add(' and B.CarNo=' + QuotedStr(CDS_2.FIELDBYNAME('CARNO').ASSTRING));
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, CDS_3);
|
||
SInitCDSData20(ADOQueryTemp, CDS_3);
|
||
end;
|
||
|
||
end.
|
||
|