D7wmguihua/桂华管理系统/U_HCList.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

466 lines
14 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_HCList;
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, cxCheckBox,
RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, BtnEdit, 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;
type
TfrmHCList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBExport: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
cxGridPopupMenu1: TcxGridPopupMenu;
Label3: TLabel;
Label4: TLabel;
C_CodeName: TEdit;
C_Color: TEdit;
Label1: TLabel;
Label2: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
CDS_Main: TClientDataSet;
Tv1: TcxGridDBTableView;
cxGrid2Level1: TcxGridLevel;
cxGrid2: TcxGrid;
Label5: TLabel;
conNO: TEdit;
Label6: TLabel;
MJID: TEdit;
Label8: TLabel;
KZ: TEdit;
Label9: TLabel;
MF: TEdit;
Label7: TLabel;
CPType: TComboBox;
MovePanel2: TMovePanel;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
Label10: TLabel;
AOrddefstr1: TEdit;
Label11: TLabel;
AOrddefstr4: TEdit;
v1Column11: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
v1Column13: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
v1Column15: TcxGridDBColumn;
v1Column16: TcxGridDBColumn;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
cxStyle2: TcxStyle;
cxStyle_gridRow: TcxStyle;
cxStyle_gridFoot: TcxStyle;
cxStyle_gridHead: TcxStyle;
cxStyle_gridGroupBox: TcxStyle;
cxStyle_yellow: TcxStyle;
cxStyle_Red: TcxStyle;
cxStyle_fontBlack: TcxStyle;
cxStyle_fontclFuchsia: TcxStyle;
cxStyle_fontclPurple: TcxStyle;
cxStyle_fontclGreen: TcxStyle;
cxStyle_fontclBlue: TcxStyle;
cxStyle_fontclTeal: TcxStyle;
cxStyle_fontclOlive: TcxStyle;
v1Column17: TcxGridDBColumn;
Tprint: TToolButton;
RM1: TRMGridReport;
RMDBMain: TRMDBDataSet;
ADOQueryPrint: TADOQuery;
CheckBox1: TCheckBox;
v1Column18: TcxGridDBColumn;
v1Column19: TcxGridDBColumn;
HCType: TEdit;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
edit_conNo: TBtnEditA;
edit_AOrdQty5: TEdit;
edit_AOrdQty6: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ToolButton1: TToolButton;
Panel_TS: TPanel;
Tv1Column1: TcxGridDBColumn;
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 C_CodeNameChange(Sender: TObject);
procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
procedure Tv1CustomDrawIndicatorCell(Sender: TcxGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
var ADone: Boolean);
procedure TprintClick(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure edit_conNoBtnClick(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure InitGrid();
{ Private declarations }
public
{ Public declarations }
end;
var
frmHCList: TfrmHCList;
implementation
uses
U_DataLink,U_Fun,U_ClothContractList_sel;
{$R *.dfm}
procedure TfrmHCList.FormDestroy(Sender: TObject);
begin
frmHCList:=nil;
end;
procedure TfrmHCList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmHCList.FormCreate(Sender: TObject);
begin
cxGrid2.Align:=alClient;
BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp)
end;
procedure TfrmHCList.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
sql.Clear;
Filtered:=False;
sql.Add('select AA.*,Num_Rate=case when (AOrdQty1=0 OR JY_Qty=0) then 0 else (JY_Qty-AOrdQty1)/AOrdQty1*100.00 end ');
sql.Add('from( ');
sql.Add('select A.*,hC_ps=A.AordQty2,JY_ps=(select count(MainID) from WFB_MJJY X where X.APID=A.APID),');
sql.Add('JY_Qty=(select sum(MJLen) from WFB_MJJY X where X.APID=A.APID), ');
sql.Add('RK_RollNum=(select sum(RollNum) from CK_BanCP_CR X where X.APID=A.APID and X.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>''),');
sql.Add('RK_Qty=(select sum(Qty) from CK_BanCP_CR X where X.APID=A.APID and X.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>''), ');
sql.Add('TPconNO=(select conNO from Contract_Main X where X.MainId=A.mainID),');
sql.Add('hCType=(select conType from Contract_Main X where X.MainId=A.mainID)');
sql.Add('from JYOrder_sub_anPai A ');
SQL.Add('WHERE ADefDate1>='''+formatdateTime('yyyy-MM-dd',BegDate.DateTime)+''' ');
SQL.Add('AND ADefDate1<'''+formatdateTime('yyyy-MM-dd',enddate.DateTime+1)+''' ');
sql.Add(' ) AA ');
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
finally
ADOQueryMain.EnableControls;
TBFind.Click;
end;
end;
procedure TfrmHCList.TBRafreshClick(Sender: TObject);
begin
//BegDate.SetFocus;
MovePanel2.Visible:=True;
MovePanel2.Refresh;
InitGrid();
MovePanel2.Visible:=False;
end;
procedure TfrmHCList.ConNoMChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
end;
end;
procedure TfrmHCList.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(self.Caption,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
Close;
end;
procedure TfrmHCList.FormShow(Sender: TObject);
begin
ReadCxGrid(self.Caption,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
//InitGrid();
end;
procedure TfrmHCList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then exit;
TcxGridToExcel(self.Caption,cxGrid2);
end;
procedure TfrmHCList.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 TfrmHCList.C_CodeNameChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmHCList.Tv1CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
begin
{ IF AViewInfo.GridRecord.Values[tv1.GetColumnByFieldName('Num_Rate').Index]>10.0 then
begin
ACanvas.Brush.Color:=clSkyBlue;
end
else IF AViewInfo.GridRecord.Values[tv1.GetColumnByFieldName('Num_Rate').Index]<-3.0 then
begin
ACanvas.Brush.Color:=clred;
end;
}
end;
procedure TfrmHCList.Tv1CustomDrawIndicatorCell(Sender: TcxGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
var ADone: Boolean);
var
FValue: string;
FBounds: TRect;
begin
FBounds := AViewInfo.Bounds;
if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
begin
ACanvas.FillRect(FBounds);
ACanvas.DrawComplexFrame(FBounds, clBtnHighlight, clBtnShadow, [bBottom, bLeft, bRight], 1);
FValue :=IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index+1);
InflateRect(FBounds, -1, -1) ;
ACanvas.Font.Color := clBlack;
ACanvas.Brush.Style := bsClear;
ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
ADone := True;
end;
end;
procedure TfrmHCList.TprintClick(Sender: TObject);
var
fPrintFile:string;
Txt,fImagePath:string;
Moudle: THandle;
Makebar:TMakebar;
Mixtext:TMixtext;
begin
if CDS_Main.IsEmpty then Exit;
if CDS_Main.Locate('ssel',true,[])=false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD>ǩ.rmf' ;
if not FileExists(fPrintFile) then
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD>ǩ.rmf'),'<27><>ʾ',0);
Exit;
end;
with CDS_Main do
begin
DisableControls;
First;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
with ADOQueryPrint do
begin
close;
sql.Clear;
sql.Add('select A.* ');
sql.Add(',CPKW=(select Top 1 zdyCode from KH_Zdy_Attachment X where X.DEFstr1=A.C_CodeName and X.DEFstr2=A.C_Color)');
sql.Add(',CPNUM=(select count(CRID) from CK_BanCP_KC X where X.C_CodeName=A.C_CodeName and X.C_Color=A.C_Color)');
sql.Add('from JYOrder_Sub_AnPai A ');
sql.Add('where Apid='+quotedstr(trim(CDS_Main.fieldbyname('apid').AsString)));
open;
if isempty then
begin
CDS_Main.EnableControls;
application.MessageBox('<27>˻زֵ<D8B2>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><E6A3AC><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
end;
try
Moudle:=LoadLibrary('MakeQRBarcode.dll');
@Makebar:=GetProcAddress(Moudle,'Make');
@Mixtext:=GetProcAddress(Moudle,'MixText');
Txt:=Trim(ADOQueryPrint.fieldbyname('APID').AsString);
fImagePath:=ExtractFilePath(Application.ExeName)+'image\temp.bmp';
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName)+'image')) then
CreateDirectory(pchar(ExtractFilePath(Application.ExeName)+'image'),nil);
if FileExists(fImagePath) then DeleteFile(fImagePath);
Makebar(pchar(Txt),Length(Txt),3,3,0,PChar(fImagePath),3);
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
CDS_Main.EnableControls;
exit;
end;
RMVariables['QRBARCODE']:=fImagePath;
RM1.LoadFromFile(fPrintFile);
// RM1.ShowReport;
RM1.PrintReport;
{ if CheckBox1.Checked then RM1.ShowReport
else
begin
// RM1.DefaultCopies:=strtointdef(trim(edit2.Text),1);
RM1.PrintReport;
end; }
end;
next;
end;
EnableControls;
First;
end;
end;
procedure TfrmHCList.CheckBox1Click(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value:=checkbox1.Checked;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmHCList.ToolButton1Click(Sender: TObject);
begin
edit_conNo.Text:='';
edit_AOrdQty5.Text:='';
edit_AOrdQty6.Text:='';
Panel_TS.Left:=(self.Width -Panel_TS.Width) div 2;
Panel_TS.Visible:=true;
end;
procedure TfrmHCList.edit_conNoBtnClick(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
frmClothContractList_sel:=TfrmClothContractList_sel.create(self);
with frmClothContractList_sel do
begin
ffactoryName:=self.CDS_Main.fieldbyname('AOrddefstr4').AsString;
C_CodeName.Text:=self.CDS_Main.fieldbyname('C_CodeName').AsString;
if showmodal=1 then
begin
edit_conNo.Text:=Order_Main.fieldbyname('conNo').AsString;
end;
free;
end;
end;
procedure TfrmHCList.Button3Click(Sender: TObject);
begin
IF CDS_Main.IsEmpty then exit;
try
with CDS_Main do
begin
CDS_Main.First;
CDS_Main.EnableControls;
while not eof do
begin
IF fieldbyName('Ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update JYOrder_sub_anPai SET conNo='''+trim(edit_conNo.Text)+''' ');
sql.Add('where APID='''+trim(CDS_Main.fieldbyName('APID').AsString)+''' ');
execsql;
end;
end;
next;
end;
CDS_Main.EnableControls;
end;
Panel_TS.Visible:=false;
TBRafresh.Click;
except
CDS_Main.EnableControls;
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
end;
end;
procedure TfrmHCList.Button2Click(Sender: TObject);
begin
Panel_TS.Visible:=false;
end;
end.