D7wmguihua/坯布码单待检(PBMDDJ.dll)/U_TJCKCKOK.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

563 lines
16 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_TJCKCKOK;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxButtonEdit, cxCalendar,
cxDropDownEdit, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridBandedTableView, cxGridDBBandedTableView, cxClasses, cxControls,
cxGridCustomView, cxGrid, StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBClient,
ADODB, cxCheckBox, cxPC, BtnEdit, cxGridDBTableView;
type
TfrmTJCKCKOK = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
Label3: TLabel;
OrderNo: TEdit;
ClientDataSet6: TClientDataSet;
DataSource6: TDataSource;
ADOQuery1: TADOQuery;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ScrollBox3: TScrollBox;
ScrollBox4: TScrollBox;
Panel3: TPanel;
Label2: TLabel;
Panel5: TPanel;
Label9: TLabel;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
v2Column2: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
cxGridLevel2: TcxGridLevel;
Panel4: TPanel;
Label12: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label21: TLabel;
Label25: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
ChuanY: TBtnEditC;
DLYDate: TDateTimePicker;
MPRTCodeName: TEdit;
MPRTSpec: TEdit;
MPRTCF: TEdit;
MPRTMF: TEdit;
MPRTKZ: TEdit;
MPRTKZNote: TEdit;
MPRTCode: TBtnEditA;
LiDanPerson: TEdit;
ScrollBox6: TScrollBox;
Panel7: TPanel;
Label13: TLabel;
cxGrid5: TcxGrid;
Tv5: TcxGridDBTableView;
v5Column8: TcxGridDBColumn;
cxGridDBColumn9: TcxGridDBColumn;
v5Column2: TcxGridDBColumn;
v5Column7: TcxGridDBColumn;
cxGridDBColumn8: TcxGridDBColumn;
v5Column3: TcxGridDBColumn;
v5Column4: TcxGridDBColumn;
v5Column5: TcxGridDBColumn;
v5Column1: TcxGridDBColumn;
v5Column9: TcxGridDBColumn;
v5Column6: TcxGridDBColumn;
cxGridLevel4: TcxGridLevel;
Panel2: TPanel;
Label4: TLabel;
Edit1: TEdit;
Label5: TLabel;
Edit2: TEdit;
cxGrid6: TcxGrid;
Tv6: TcxGridDBTableView;
v3Column1: TcxGridDBColumn;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
cxGridDBColumn11: TcxGridDBColumn;
cxGridDBColumn14: TcxGridDBColumn;
cxGridDBColumn12: TcxGridDBColumn;
Tv6Column1: TcxGridDBColumn;
Tv6Column2: TcxGridDBColumn;
Tv6Column3: TcxGridDBColumn;
v3Column2: TcxGridDBColumn;
v3Column3: TcxGridDBColumn;
v3Column4: TcxGridDBColumn;
v3Column5: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
v3Column6: TcxGridDBColumn;
v3Column7: TcxGridDBColumn;
v3Column8: TcxGridDBColumn;
v3Column9: TcxGridDBColumn;
v3Column10: TcxGridDBColumn;
v3Column12: TcxGridDBColumn;
v3Column13: TcxGridDBColumn;
v3Column11: TcxGridDBColumn;
cxGrid3: TcxGrid;
Tv3: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn10: TcxGridDBColumn;
cxGridDBColumn13: TcxGridDBColumn;
cxGridDBColumn15: TcxGridDBColumn;
cxGridDBColumn16: TcxGridDBColumn;
cxGridDBColumn17: TcxGridDBColumn;
cxGridDBColumn18: TcxGridDBColumn;
cxGridDBColumn19: TcxGridDBColumn;
cxGridDBColumn20: TcxGridDBColumn;
cxGridDBColumn21: TcxGridDBColumn;
cxGridDBColumn22: TcxGridDBColumn;
cxGridDBColumn23: TcxGridDBColumn;
cxGridDBColumn24: TcxGridDBColumn;
cxGridDBColumn25: TcxGridDBColumn;
cxGridDBColumn26: TcxGridDBColumn;
cxGridDBColumn27: TcxGridDBColumn;
cxGridDBColumn28: TcxGridDBColumn;
cxGridDBColumn29: TcxGridDBColumn;
cxGridDBColumn30: TcxGridDBColumn;
cxGridDBColumn31: TcxGridDBColumn;
cxGridDBColumn32: TcxGridDBColumn;
cxGridDBColumn33: TcxGridDBColumn;
cxGridLevel3: TcxGridLevel;
ToolBar2: TToolBar;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
Tv3Column1: TcxGridDBColumn;
CDS_OrderNo: TClientDataSet;
DS_OrderNo: TDataSource;
cxGrid4: TcxGrid;
TvOrdeNo: TcxGridDBTableView;
cxGridDBColumn34: TcxGridDBColumn;
cxGridDBColumn35: TcxGridDBColumn;
cxGrid4Level1: TcxGridLevel;
ClientDataSet2: TClientDataSet;
DataSource2: TDataSource;
ClientDataSet5: TClientDataSet;
DataSource5: TDataSource;
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
ClientDataSet3: TClientDataSet;
DataSource3: TDataSource;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column2: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1SOrddefstr1: TcxGridDBColumn;
v1PRTColor: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1PRTOrderQty: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1OrderUnit: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBRafreshClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure v6Column2PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v6Column14PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
procedure Edit2Change(Sender: TObject);
procedure TvOrdeNoDblClick(Sender: TObject);
procedure v5Column8PropertiesEditValueChanged(Sender: TObject);
procedure v2Column2PropertiesEditValueChanged(Sender: TObject);
procedure v1Column2PropertiesEditValueChanged(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
private
{ Private declarations }
FMainId,SParameters1:String;
procedure InitGrid();
procedure InitGridCK();
public
{ Public declarations }
end;
var
frmTJCKCKOK: TfrmTJCKCKOK;
implementation
uses
U_DataLink,U_RTFun, U_GYSList;
{$R *.dfm}
procedure TfrmTJCKCKOK.FormDestroy(Sender: TObject);
begin
frmTJCKCKOK:=nil;
end;
procedure TfrmTJCKCKOK.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmTJCKCKOK.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTJCKCKOK.InitGrid();
begin
with ADOQuery1 do
begin
Close;
sql.Clear;
sql.Add('select JM.OrderNo, A.*,B.PSName OrdPSName,C.ConNo,C.FactoryNoName,D.Price, ');
sql.Add(' JS.PRTHX,JS.PRTColor,JS.PRTColorNo,');
sql.Add(' JSKCPS=(select sum(PS*QtyFlag) from JYOrder_Main_MD JMM where JMM.RKMDID=A.MDID ),');
sql.Add(' JSKCQty=(select sum(Qty*QtyFlag) from JYOrder_Main_MD JMM where JMM.RKMDID=A.MDID )');
sql.Add(' from JYOrder_Main_MD A');
sql.Add(' inner join JYOrder_Main JM on A.OrdMainId=JM.MainId');
sql.Add(' left join JYOrder_Sub JS on A.OrdSubId=JS.SubId');
sql.Add(' inner join JYOrder_Process B on A.PSID=B.PSID');
sql.Add(' inner join Contract_Main C on A.ConMainid=C.MainID');
sql.Add(' inner join Contract_Sub D on A.ConSubid=D.SubID');
SQL.Add(' where isnull(A.CKName,'''')=''<27><><EFBFBD>ڲֿ<DAB2>'' ');
sql.Add(' and isnull(A.CRFlag,'''')=''<27><><EFBFBD><EFBFBD>'' ');
sql.Add(' and A.KCQty>0');
Open;
end;
SCreateCDS20(ADOQuery1,ClientDataSet6);
SInitCDSData20(ADOQuery1,ClientDataSet6);
end;
procedure TfrmTJCKCKOK.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmTJCKCKOK.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTJCKCKOK.v6Column2PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmGYSList:=TfrmGYSList.Create(Application);
with frmGYSList do
begin
if ShowModal=1 then
begin
with Self.ClientDataSet6 do
begin
Edit;
FieldByName('DutyFactoryNo').Value:=Trim(frmGYSList.Order_Main.fieldbyname('ZKID').AsString) ;
FieldByName('DutyFactoryName').Value:=Trim(frmGYSList.Order_Main.fieldbyname('KHNameJC').AsString);
//Post;
end;
end;
end;
finally
frmGYSList.Free;
end;
end;
procedure TfrmTJCKCKOK.v6Column14PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmGYSList:=TfrmGYSList.Create(Application);
with frmGYSList do
begin
if ShowModal=1 then
begin
with Self.ClientDataSet6 do
begin
Edit;
FieldByName('ToFactoryNo').Value:=Trim(frmGYSList.Order_Main.fieldbyname('ZKID').AsString) ;
FieldByName('ToFactoryName').Value:=Trim(frmGYSList.Order_Main.fieldbyname('KHNameJC').AsString);
//Post;
end;
end;
end;
finally
frmGYSList.Free;
end;
end;
procedure TfrmTJCKCKOK.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
begin
if Trim(OrderNo.Text)='' then Exit;
with ADOQuery1 do
begin
Close;
sql.Clear;
sql.Add('select JM.OrderNo, A.*,B.PSName OrdPSName,C.ConNo,C.FactoryNoName,D.Price, ');
sql.Add(' JS.PRTHX,JS.PRTColor,JS.PRTColorNo,');
sql.Add(' JSKCPS=(select sum(PS*QtyFlag) from JYOrder_Main_MD JMM where JMM.RKMDID=A.MDID ),');
sql.Add(' JSKCQty=(select sum(Qty*QtyFlag) from JYOrder_Main_MD JMM where JMM.RKMDID=A.MDID )');
sql.Add(' from JYOrder_Main_MD A');
sql.Add(' inner join JYOrder_Main JM on A.OrdMainId=JM.MainId');
sql.Add(' left join JYOrder_Sub JS on A.OrdSubId=JS.SubId');
sql.Add(' inner join JYOrder_Process B on A.PSID=B.PSID');
sql.Add(' inner join Contract_Main C on A.ConMainid=C.MainID');
sql.Add(' inner join Contract_Sub D on A.ConSubid=D.SubID');
sql.Add(' where JM.OrderNo like '''+'%'+Trim(OrderNo.Text)+'%'+'''');
sql.Add(' and isnull(A.CRFlag,'''')=''<27><><EFBFBD><EFBFBD>'' ');
sql.Add(' and A.KCQty>0');
Open;
end;
SCreateCDS20(ADOQuery1,ClientDataSet6);
SInitCDSData20(ADOQuery1,ClientDataSet6);
end;
end;
procedure TfrmTJCKCKOK.Edit2Change(Sender: TObject);
var
mvalue:String;
begin
mvalue:=Trim(Edit2.Text);
if Length(Trim(mvalue))<2 then
begin
cxGrid4.Visible:=False;
Exit;
end;
mvalue:='%'+Trim(mvalue)+'%';
with ADOQuery1 do
begin
Close;
sql.Clear;
sql.Add('select OrderNo,MPRTCodeName,A.MainId from JYOrder_Main A');
sql.Add(' where A.orderno like :orderno ');
//sql.Add(' and A.MainId in(select MainId from JYOrder_Sub B where B.Mainid=A.MainId and B.subId in(select OrdSubId from Contract_Cloth_LL))');
Parameters.ParamByName('orderno').Value:=mvalue;
Open;
end;
SCreateCDS20(ADOQuery1,CDS_OrderNo);
SInitCDSData20(ADOQuery1,CDS_OrderNo);
if CDS_OrderNo.IsEmpty then cxGrid4.Visible:=False else cxGrid4.Visible:=True;
end;
procedure TfrmTJCKCKOK.TvOrdeNoDblClick(Sender: TObject);
begin
Edit2.Text:=CDS_OrderNo.fieldbyname('OrderNo').AsString;
cxGrid4.Visible:=False;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Main where Orderno='''+Trim(Edit2.Text)+'''');
Open;
end;
SCSHData(ADOQueryTemp,Panel4,2);
FMainId:=Trim(ADOQueryTemp.fieldbyname('MainId').AsString);
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Sub where MainId='''+Trim(FMainId)+'''');
Open;
end;
SCreateCDS20(ADOQueryTemp,ClientDataSet1);
SInitCDSData20(ADOQueryTemp,ClientDataSet1);
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Contract_Main A inner join Contract_Sub B on A.MainId=B.MainId ');
sql.Add(' where A.ConNo like '''+'%'+Trim(Edit2.Text)+'%'+'''');
Open;
end;
SCreateCDS20(ADOQueryTemp,ClientDataSet5);
SInitCDSData20(ADOQueryTemp,ClientDataSet5);
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Process where MainId='''+Trim(FMainId)+'''');
Open;
end;
SCreateCDS20(ADOQueryTemp,ClientDataSet2);
SInitCDSData20(ADOQueryTemp,ClientDataSet2);
//InitGrid();
end;
procedure TfrmTJCKCKOK.v5Column8PropertiesEditValueChanged(
Sender: TObject);
var
PSID:String;
Mvalue:Boolean;
begin
Mvalue:=TcxCheckBox(Sender).EditingValue;
PSID:=Trim(ClientDataSet5.fieldbyname('SubID').AsString);
with ClientDataSet5 do
begin
while ClientDataSet5.Locate('SSel',True,[])=True do
begin
Edit;
FieldByName('SSel').Value:=False;
Post;
end;
ClientDataSet5.Locate('SubID',PSID,[]);
Edit;
FieldByName('SSel').Value:=Mvalue;
Post;
end;
InitGridCK();
end;
procedure TfrmTJCKCKOK.v2Column2PropertiesEditValueChanged(
Sender: TObject);
var
PSID:String;
Mvalue:Boolean;
begin
Mvalue:=TcxCheckBox(Sender).EditingValue;
PSID:=Trim(ClientDataSet2.fieldbyname('PSID').AsString);
with ClientDataSet2 do
begin
while ClientDataSet2.Locate('SSel',True,[])=True do
begin
Edit;
FieldByName('SSel').Value:=False;
Post;
end;
ClientDataSet2.Locate('PSID',PSID,[]);
Edit;
FieldByName('SSel').Value:=Mvalue;
Post;
end;
InitGridCK();
end;
procedure TfrmTJCKCKOK.v1Column2PropertiesEditValueChanged(
Sender: TObject);
var
PSID:String;
Mvalue:Boolean;
begin
Mvalue:=TcxCheckBox(Sender).EditingValue;
PSID:=Trim(ClientDataSet1.fieldbyname('SubID').AsString);
with ClientDataSet1 do
begin
while ClientDataSet1.Locate('SSel',True,[])=True do
begin
Edit;
FieldByName('SSel').Value:=False;
Post;
end;
ClientDataSet1.Locate('SubID',PSID,[]);
Edit;
FieldByName('SSel').Value:=Mvalue;
Post;
end;
InitGridCK();
end;
procedure TfrmTJCKCKOK.InitGridCK();
var
FPSID,FOrdSubId,FConSubId:String;
begin
if ClientDataSet2.Locate('SSel',True,[])=True then
begin
FPSID:=Trim(ClientDataSet2.fieldbyname('PSID').AsString);
end else
begin
FPSID:='';
end;
if ClientDataSet5.Locate('SSel',True,[])=True then
begin
FConSubId:=Trim(ClientDataSet5.fieldbyname('SubId').AsString);
end else
begin
FConSubId:='';
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select A.*,B.PSName OrdPSName,C.ConNo,C.FactoryNoName,D.Price ');
sql.Add(' from JYOrder_Main_MD A');
sql.Add(' inner join JYOrder_Process B on A.PSID=B.PSID');
sql.Add(' inner join Contract_Main C on A.ConMainid=C.MainID');
sql.Add(' inner join Contract_Sub D on A.ConSubid=D.SubID');
sql.Add(' where A.ORDMainId='''+Trim(FMainId)+'''');
if Trim(FPSID)<>'' then
begin
sql.Add(' and A.PSID='''+Trim(FPSID)+'''');
end;
if Trim(FConSubId)<>'' then
begin
sql.Add(' and A.ConSubID='''+Trim(FConSubId)+'''');
end;
if ClientDataSet1.Locate('SSel',True,[])=True then
begin
FOrdSubId:=Trim(ClientDataSet1.fieldbyname('SubId').AsString);
end else
begin
FOrdSubId:='';
end;
if Trim(SParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
SQL.Add(' and A.Filler='''+Trim(DName)+'''');
end;
// sql.Add(' and A.MDType=''<27><>Χ'' ');
SQL.Add(' and isnull(CKName,'''')=''<27><><EFBFBD>ڲֿ<DAB2>'' ');
sql.Add(' and isnull(CRFlag,'''')=''<27><><EFBFBD><EFBFBD>'' ');
Open;
end;
SCreateCDS20(ADOQueryTemp,ClientDataSet3);
SInitCDSData20(ADOQueryTemp,ClientDataSet3);
end;
procedure TfrmTJCKCKOK.ToolButton3Click(Sender: TObject);
begin
if Trim(FMainId)='' then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD>񶩵<EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if ClientDataSet5.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD>ͬ!','<27><>ʾ',0);
Exit;
end;
if ClientDataSet2.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
with ClientDataSet6 do
begin
Append;
ClientDataSet5.Locate('SSel',True,[]);
ClientDataSet2.Locate('SSel',True,[]);
FieldByName('ConNo').Value:=ClientDataSet5.fieldbyname('ConNo').Value;
FieldByName('FactoryNo').Value:=ClientDataSet5.fieldbyname('FactoryNoName').Value;
FieldByName('FactoryName').Value:=ClientDataSet5.fieldbyname('FactoryNoName').Value;
FieldByName('FactoryNoName').Value:=ClientDataSet5.fieldbyname('FactoryNoName').Value;
FieldByName('Price').Value:=ClientDataSet5.fieldbyname('Price').Value;
FieldByName('PSName').Value:=ClientDataSet2.fieldbyname('PSName').Value;
FieldByName('QtyUnit').Value:=ClientDataSet5.fieldbyname('C_Unit').Value;
FieldByName('Filler').Value:=Trim(DName);
FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
Post;
end;
end;
end.