326 lines
11 KiB
ObjectPascal
326 lines
11 KiB
ObjectPascal
![]() |
unit U_CKJYList;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
|||
|
cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView,
|
|||
|
cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses,
|
|||
|
cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls,
|
|||
|
ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient,
|
|||
|
cxDropDownEdit, MovePanel, cxButtonEdit, cxCalendar, cxPC, cxLookAndFeels,
|
|||
|
cxLookAndFeelPainters, 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, cxNavigator, dxBarBuiltInMenu;
|
|||
|
|
|||
|
type
|
|||
|
TfrmCKJYList = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBFind: TToolButton;
|
|||
|
TBExport: TToolButton;
|
|||
|
TBPrint: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
Label1: TLabel;
|
|||
|
Label2: TLabel;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
Label8: TLabel;
|
|||
|
MPRTKZ: TEdit;
|
|||
|
Label9: TLabel;
|
|||
|
MPRTMF: TEdit;
|
|||
|
Label7: TLabel;
|
|||
|
CPType: TComboBox;
|
|||
|
MovePanel2: TMovePanel;
|
|||
|
Label10: TLabel;
|
|||
|
Label11: TLabel;
|
|||
|
Label12: TLabel;
|
|||
|
YWY: TEdit;
|
|||
|
OrdPerson1: TEdit;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1Column1: TcxGridDBColumn;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
v1Column6: TcxGridDBColumn;
|
|||
|
v1Column12: TcxGridDBColumn;
|
|||
|
v1Column7: TcxGridDBColumn;
|
|||
|
v2Column5: TcxGridDBColumn;
|
|||
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
orderNo: TEdit;
|
|||
|
Label5: TLabel;
|
|||
|
Label6: TLabel;
|
|||
|
PRTColor: TEdit;
|
|||
|
Label13: TLabel;
|
|||
|
filler: TEdit;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
v1Column5: TcxGridDBColumn;
|
|||
|
conNo: TEdit;
|
|||
|
Label4: TLabel;
|
|||
|
Panel4: TPanel;
|
|||
|
Label14: TLabel;
|
|||
|
Panel10: TPanel;
|
|||
|
Image2: TImage;
|
|||
|
RichEdit1: TRichEdit;
|
|||
|
v1Column8: TcxGridDBColumn;
|
|||
|
KHCONNO: TEdit;
|
|||
|
Label15: TLabel;
|
|||
|
cxTabControl1: TcxTabControl;
|
|||
|
v1Column9: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
v1Column13: TcxGridDBColumn;
|
|||
|
Label16: TLabel;
|
|||
|
wangno: TEdit;
|
|||
|
v1Column4: TcxGridDBColumn;
|
|||
|
huaname: TEdit;
|
|||
|
Label3: TLabel;
|
|||
|
Label17: TLabel;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure ConNoMChange(Sender: TObject);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TBExportClick(Sender: TObject);
|
|||
|
procedure TBFindClick(Sender: TObject);
|
|||
|
procedure MPRTCodeNameChange(Sender: TObject);
|
|||
|
procedure v1Column5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
|||
|
procedure PRTColorChange(Sender: TObject);
|
|||
|
procedure Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|||
|
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
|
|||
|
procedure Image2Click(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
private
|
|||
|
FLeft, FTop: Integer;
|
|||
|
procedure InitGrid();
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmCKJYList: TfrmCKJYList;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_Fun, U_ZDYHelp, U_CKJYListMX;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmCKJYList.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmCKJYList := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
//cxGrid1.Align:=alClient;
|
|||
|
BegDate.DateTime := SGetServerDateTime(ADOQueryTemp);
|
|||
|
EndDate.DateTime := SGetServerDateTime(ADOQueryTemp)
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
Filtered := False;
|
|||
|
// sql.Add('select convert(char(10),A.FillTime,120) as CRTime,A.mainID,A.MjTypeOther,C.OrderNo,D.PRTCodeName,C.conNo,C.CustomerNoName,'); //D.PrtColor,
|
|||
|
sql.Add('select convert(char(10),A.FillTime,120) as CRTime,A.Filler,count(A.MainId) as JQty,SUM(A.MJlen) as Qty,SUM(A.MJmaoZ) as KGQty,SUM(A.MJQty4) as MJQty4,SUM(A.MJQty5) as MJQty5');
|
|||
|
// sql.Add('khconNO=(select top 1 khconNo from JYOrderCon_Main X where X.conNO=C.conNO),');
|
|||
|
// sql.Add('Qty_M=sum(case when MjTypeOther=''Y'' then cast(MJlen*0.9144 as decimal(18,2)) else MJLen end)');
|
|||
|
// sql.Add(',Roll_M= cast(sum(case when MjTypeOther=''Y'' then cast(MJlen*0.9144 as decimal(18,2)) else MJLen end)/count(A.MainId) as decimal(18,2))');
|
|||
|
// SQL.Add(',CJQTY=(select count(X.Mainid) from WFB_MJJY X where X.Mainid=A.Mainid and convert(char(10),X.FillTime,120)=convert(char(10),A.FillTime,120) and baoID<>'''' and X.MJTypeOther=A.MJTypeOther)');
|
|||
|
// SQL.Add(',CQTY=(select SUM(MJlen) from WFB_MJJY X where X.Mainid=A.Mainid and convert(char(10),X.FillTime,120)=convert(char(10),A.FillTime,120) and baoID<>'''' and X.MJTypeOther=A.MJTypeOther)');
|
|||
|
// SQL.Add(',CKGQTY=(select SUM(MJmaoZ) from WFB_MJJY X where X.Mainid=A.Mainid and convert(char(10),X.FillTime,120)=convert(char(10),A.FillTime,120) and baoID<>'''' and X.MJTypeOther=A.MJTypeOther)');
|
|||
|
// SQL.Add(',CMJQty4=(select SUM(MJQty4) from WFB_MJJY X where X.Mainid=A.Mainid and convert(char(10),X.FillTime,120)=convert(char(10),A.FillTime,120) and baoID<>'''' and X.MJTypeOther=A.MJTypeOther)');
|
|||
|
// sql.Add(',ZQTY=(select sum(PRTOrderQty) from JYOrder_sub X where X.mainid=A.mainid)');
|
|||
|
sql.Add('from WFB_MJJY A ');
|
|||
|
sql.Add('inner join JYOrder_Main C on C.MainId=A.MainId ');
|
|||
|
sql.Add('inner join JYOrder_sub D on D.subID=A.subID ');
|
|||
|
Sql.add('where A.FillTime>=''' + formatdateTime('yyyy-MM-dd', begdate.Date) + ''' ');
|
|||
|
Sql.add('and A.FillTime<''' + formatdateTime('yyyy-MM-dd', enddate.Date + 1) + ''' ');
|
|||
|
if cxTabControl1.TabIndex = 0 then
|
|||
|
Sql.add('and not exists(select MJID from CK_BanCP_KC X where X.MJID=A.MJID) ')
|
|||
|
else if cxTabControl1.TabIndex = 1 then
|
|||
|
Sql.add('and exists(select MJID from CK_BanCP_KC X where X.MJID=A.MJID) ');
|
|||
|
Sql.add('group by convert(char(10),A.FillTime,120),A.Filler '); //,A.mainID,A.MjTypeOther,C.OrderNo,D.PRTCodeName,C.conNo,C.CustomerNoName
|
|||
|
// ShowMessage(SQL.text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS_Main);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
//BegDate.SetFocus;
|
|||
|
MovePanel2.Visible := True;
|
|||
|
MovePanel2.Refresh;
|
|||
|
InitGrid();
|
|||
|
MovePanel2.Visible := False;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.ConNoMChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(self.Caption + tv1.Name, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>11');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
ReadCxGrid(self.Caption + tv1.Name, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>11');
|
|||
|
if Trim(DParameters2) = '<27><><EFBFBD><EFBFBD>' then
|
|||
|
begin
|
|||
|
//v1Column5.Options.Focusing:=True;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
//v1Column5.Options.Focusing:=False;
|
|||
|
end;
|
|||
|
//InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.TBExportClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
exit;
|
|||
|
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>', cxGrid2);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.TBFindClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
SCreateCDS20(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS_Main);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.MPRTCodeNameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.v1Column5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'SOrdDefStr10';
|
|||
|
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵص<C5B5>';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('SOrdDefStr10').Value := Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('Update JYOrder_Sub Set SOrdDefStr10=''' + Trim(ClientDataSet1.fieldbyname('ZdyName').AsString) + '''');
|
|||
|
sql.Add(' where SubId=''' + Trim(Self.CDS_Main.fieldbyname('SubId').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.PRTColorChange(Sender: TObject);
|
|||
|
begin
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|||
|
begin
|
|||
|
FLeft := X;
|
|||
|
FTop := Y;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
|
|||
|
begin
|
|||
|
Panel4.Left := FLeft;
|
|||
|
Panel4.Top := FTop + 110;
|
|||
|
Panel4.Visible := True;
|
|||
|
Panel10.Caption := Trim(TV1.Controller.FocusedColumn.Caption);
|
|||
|
RichEdit1.Text := CDS_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString;
|
|||
|
application.ProcessMessages;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.Image2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Panel4.Visible := False;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
TBRafresh.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKJYList.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
frmCKJYListMX := TfrmCKJYListMX.create(self);
|
|||
|
with frmCKJYListMX do
|
|||
|
begin
|
|||
|
fkeyNO := Self.CDS_Main.fieldbyname('filler').AsString;
|
|||
|
BegDate.DateTime := self.BegDate.DateTime;
|
|||
|
EndDate.DateTime := self.EndDate.DateTime;
|
|||
|
TBRafresh.Click;
|
|||
|
showmodal;
|
|||
|
free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|