469 lines
13 KiB
ObjectPascal
469 lines
13 KiB
ObjectPascal
unit U_ShuttleClothJGList;
|
||
|
||
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, cxMemo,
|
||
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;
|
||
|
||
type
|
||
TfrmShuttleClothJGList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBPrint: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
Label5: TLabel;
|
||
P_Code: TEdit;
|
||
TBExport: TToolButton;
|
||
Order_Main: TClientDataSet;
|
||
RM1: TRMGridReport;
|
||
RMXLSExport1: TRMXLSExport;
|
||
CDS_PM: TClientDataSet;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1PRTOrderQty: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
RMDB_Main: TRMDBDataSet;
|
||
TBView: TToolButton;
|
||
v1Column19: TcxGridDBColumn;
|
||
v1Column31: TcxGridDBColumn;
|
||
KHNAME: TEdit;
|
||
Label7: TLabel;
|
||
RMDB_JS: TRMDBDataSet;
|
||
CDS_PJS: TClientDataSet;
|
||
RMDB_WS: TRMDBDataSet;
|
||
CDS_PWS: TClientDataSet;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
Label35: TLabel;
|
||
ConNoType: TComboBox;
|
||
v1Column8: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
v1Column11: TcxGridDBColumn;
|
||
v1Column12: TcxGridDBColumn;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBPrintClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ConNoChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBViewClick(Sender: TObject);
|
||
procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
procedure v1Column3PropertiesEditValueChanged(Sender: TObject);
|
||
procedure v1Column6PropertiesEditValueChanged(Sender: TObject);
|
||
private
|
||
FInt, PFInt: Integer;
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
function DelData(): Boolean;
|
||
{ Private declarations }
|
||
public
|
||
canshu1, FCheJian: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun, U_ZDYHelp, U_ShuttleClothSCInPut;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmShuttleClothJGList.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.InitGrid();
|
||
|
||
var i,ti:integer;
|
||
begin
|
||
|
||
i:=Tv1.Controller.FocusedRowIndex; //<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>
|
||
ti:=Tv1.Controller.TopRowIndex; //<2F><>¼<EFBFBD><C2BC><EFBFBD>к<EFBFBD>
|
||
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,B.*, JGGNote=CAST((SELECT C.PYXH +'': ''+C.Y_Name+'';'' FROM PD_Plan_Yarn C WHERE C.MainId=B.MainId AND C.Y_Name<>'''' ');
|
||
SQL.Add(' AND C.PYType=''<27><>˿'' for xml path(''''))as varchar(8000))');
|
||
sql.Add(' from PD_Plan_Main A inner join PD_Plan_Sub B on A.Mainid=B.MainId');
|
||
sql.Add(' where A.FillTIme>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + '''');
|
||
sql.Add(' and A.FillTIme<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1)) + '''');
|
||
//ShowMessage(SQL.Text);
|
||
Open;
|
||
end;
|
||
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
|
||
Tv1.Controller.FocusedRowIndex:=i; //<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>¼ֵ
|
||
Tv1.Controller.TopRowIndex:=ti; //<2F><><EFBFBD><EFBFBD> <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>¼ֵ
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.InitForm();
|
||
begin
|
||
ReadCxGrid(Trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
BegDate.DateTime := SGetServerDate10(ADOQueryTemp) - 30;
|
||
EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.TBFindClick(Sender: TObject);
|
||
begin
|
||
Panel1.SetFocus;
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.TBDelClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select A.*');
|
||
sql.Add('from PD_Plan_Card A');
|
||
sql.Add(' where A.SubId=''' + Trim(Order_Main.fieldbyname('SubId').AsString) + '''');
|
||
sql.Add(' and A.MainId=''' + Trim(Order_Main.fieldbyname('MainId').AsString) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty = False then
|
||
begin
|
||
Application.MessageBox('<27>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select TOP 1 A.*');
|
||
sql.Add('from CK_Cloth_CR A');
|
||
sql.Add(' where A.SubId=''' + Trim(Order_Main.fieldbyname('SubId').AsString) + '''');
|
||
sql.Add(' and A.MainId=''' + Trim(Order_Main.fieldbyname('MainId').AsString) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty = False then
|
||
begin
|
||
Application.MessageBox('<27>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
if DelData() then
|
||
begin
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
|
||
function TfrmShuttleClothJGList.DelData(): Boolean;
|
||
begin
|
||
try
|
||
Result := false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete PD_Plan_Main where MainId=''' + Trim(Order_Main.fieldbyname('MainId').AsString) + '''');
|
||
sql.Add('delete PD_Plan_Sub where SubId=''' + Trim(Order_Main.fieldbyname('SubId').AsString) + '''');
|
||
sql.Add('delete PD_Plan_Yarn where SubId=''' + Trim(Order_Main.fieldbyname('SubId').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 TfrmShuttleClothJGList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
Exit;
|
||
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.TBPrintClick(Sender: TObject);
|
||
var
|
||
fPrintFile, FWeiZhi: string;
|
||
i, j, k: integer;
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
ExportFtErpFile('<27><>֯<EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>.rmf', ADOQueryTemp);
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><>֯<EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>.rmf';
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from PD_Plan_Main A inner join PD_Plan_Sub B on A.Mainid=B.MainId where A.MainId=' + Quotedstr(Trim(Order_Main.fieldbyname('MainId').AsString)));
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, CDS_PM);
|
||
SInitCDSData20(ADOQueryTemp, CDS_PM);
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from PD_Plan_Yarn where PYType=''<27><>˿'' and MainId=' + Quotedstr(Trim(Order_Main.fieldbyname('MainId').AsString)));
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, CDS_PJS);
|
||
SInitCDSData20(ADOQueryTemp, CDS_PJS);
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from PD_Plan_Yarn where PYType=''γ˿'' and MainId=' + Quotedstr(Trim(Order_Main.fieldbyname('MainId').AsString)));
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, CDS_PWS);
|
||
SInitCDSData20(ADOQueryTemp, CDS_PWS);
|
||
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM1.LoadFromFile(fPrintFile);
|
||
|
||
RM1.ShowReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.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 TfrmShuttleClothJGList.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.TBViewClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmClothSCInPut := TfrmClothSCInPut.Create(Application);
|
||
with frmClothSCInPut do
|
||
begin
|
||
PState := 1;
|
||
FMainId := Trim(Self.Order_Main.fieldbyname('MainId').AsString);
|
||
FSubId := Trim(Self.Order_Main.fieldbyname('SubId').AsString);
|
||
FConNo := Trim(Self.Order_Main.fieldbyname('ConNo').AsString);
|
||
TBSave.Visible := False;
|
||
|
||
ScrollBox1.Enabled := False;
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmClothSCInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.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 TfrmShuttleClothJGList.v1Column3PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue, FFieldName,FValue: string;
|
||
IntValue : Double;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
|
||
if Pos('=',mvalue)=1 then
|
||
begin
|
||
Application.MessageBox('<27>Ⱥ<EFBFBD>ǰ<EFBFBD>治<EFBFBD><E6B2BB>û<EFBFBD><C3BB><EFBFBD>㹫ʽ','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
|
||
if Pos('=',mvalue)>0 then
|
||
begin
|
||
mvalue := Copy(mvalue,1,(Pos('=',mvalue)-1));
|
||
end;
|
||
|
||
|
||
|
||
|
||
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with Order_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value := Trim(mvalue);
|
||
Post;
|
||
end;
|
||
if mvalue <> '' then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_CK_Cloth_JiSuan ');
|
||
sql.add('@Fmvalue=' + QuotedStr(Trim(mvalue)));
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.IsEmpty=False then
|
||
begin
|
||
FValue:=Trim(ADOQueryCmd.fieldbyname('mvalue').AsString);
|
||
if TryStrToFloat(mvalue,IntValue)=False then
|
||
begin
|
||
mvalue:=mvalue+'='+FValue;
|
||
end
|
||
else
|
||
begin
|
||
mvalue:=FValue;
|
||
end;
|
||
|
||
end
|
||
else
|
||
Exit;
|
||
end;
|
||
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate PD_Plan_Sub ');
|
||
sql.Add(' Set ' + FFieldName + '=''' + Trim(mvalue) + '''');
|
||
sql.Add(' where SubId=' + quotedstr(Order_Main.fieldbyname('SubId').AsString));
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
InitGrid();
|
||
/////////<2F><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>cxgrid<69><64>Properties<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>//////////////////////////
|
||
// Tv1.GetColumnByFieldName('FSNote').PropertiesClass := TcxMemoProperties;
|
||
// with TcxMemoProperties(Tv1.GetColumnByFieldName('FSNote').Properties) do
|
||
// begin
|
||
// ScrollBars:=ssVertical;
|
||
// end;
|
||
/////////<2F><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>cxgrid<69><64>Properties<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>//////////////////////////
|
||
except
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
end
|
||
end;
|
||
|
||
procedure TfrmShuttleClothJGList.v1Column6PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue, FFieldName,FValue: string;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with Order_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value := Trim(mvalue);
|
||
Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate PD_Plan_Sub ');
|
||
sql.Add(' Set ' + FFieldName + '=''' + Trim(mvalue) + '''');
|
||
sql.Add(' where SubId=' + quotedstr(Order_Main.fieldbyname('SubId').AsString));
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
InitGrid();
|
||
except
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
end
|
||
end;
|
||
|
||
end.
|
||
|