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

465 lines
12 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_GYSFPInPutWGL;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer,
cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB,
ExtCtrls, BtnEdit, cxDropDownEdit, cxCalendar, cxGridCustomPopupMenu,
cxGridPopupMenu, cxSplitter, cxCheckBox;
type
TfrmGYSFPInPutWGL = class(TForm)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
ADOTemp: TADOQuery;
ADOCmd: TADOQuery;
DataSource1: TDataSource;
Order_Sub: TClientDataSet;
ADOQuery1: TADOQuery;
cxGridPopupMenu1: TcxGridPopupMenu;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column6: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column20: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column18: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
v1Column4: TcxGridDBColumn;
ADOQueryMain: TADOQuery;
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure v1Column3PropertiesEditValueChanged(Sender: TObject);
procedure v1Column20PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v1Column18PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v1Column4PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
private
FXS:Integer;
procedure InitData();
procedure ZDYHelp(FButn:TcxButtonEdit;LType:string);
function SaveData():Boolean;
procedure GetMaxConNO();
{ Private declarations }
public
PState,PCopyInt:Integer;
FMainId,FConNo,FConType,FYLType:String;
{ Public declarations }
end;
var
frmGYSFPInPutWGL: TfrmGYSFPInPutWGL;
implementation
uses
U_DataLink,U_ZDYHelp,U_RTFun,U_ZDYHelpSel,U_BGMXSelList, U_GYSSelList;
{$R *.dfm}
procedure TfrmGYSFPInPutWGL.TBCloseClick(Sender: TObject);
begin
Close;
WriteCxGrid('<27><>Ӧ<EFBFBD>̷<EFBFBD>Ʊ¼<C6B1><C2BC>',Tv1,'<27><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>');
end;
procedure TfrmGYSFPInPutWGL.InitData();
begin
with ADOQuery1 do
begin
Close;
SQL.Clear;
sql.Add(' select A.* ');
SQL.Add(' from FP_GYSNB A');
sql.Add(' where A.FMID='''+Trim(FMainId)+'''');
Open;
end;
SCreateCDS20(ADOQuery1,Order_Sub);
SInitCDSData20(ADOQuery1,Order_Sub);
end;
procedure TfrmGYSFPInPutWGL.ZDYHelp(FButn:TcxButtonEdit;LType:string);
begin
end;
procedure TfrmGYSFPInPutWGL.FormShow(Sender: TObject);
begin
ReadCxGrid('<27><>Ӧ<EFBFBD>̷<EFBFBD>Ʊ¼<C6B1><C2BC>',Tv1,'<27><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>');
InitData();
end;
procedure TfrmGYSFPInPutWGL.GetMaxConNO();
begin
end;
function TfrmGYSFPInPutWGL.SaveData():Boolean;
var
maxno,LSFMID:String;
begin
try
Result:=False;
ADOCmd.Connection.BeginTrans;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Order_Sub.DisableControls;
with Order_Sub do
begin
First;
while not Eof do
begin
{ if Trim(Order_Sub.fieldbyname('OrderNo').AsString)<>'' then
begin
with ADOTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Main where OrderNo='''+Trim(Order_Sub.fieldbyname('OrderNo').AsString)+'''');
Open;
end;
if ADOTemp.IsEmpty then
begin
Order_Sub.EnableControls;
ADOCmd.Connection.RollbackTrans;
Application.MessageBox(PChar('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:'+Trim(Order_Sub.fieldbyname('OrderNo').AsString)+'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!'),'<27><>ʾ',0);
Exit;
end;
end; }
with ADOTemp do
begin
Close;
sql.Clear;
sql.Add('select * from FP_GYSNB where FMID='''+Trim(Order_Sub.fieldbyname('FMID').AsString)+'''');
Open;
end;
LSFMID:=Trim(ADOTemp.fieldbyname('FMID').AsString);
if Trim(LSFMID)='' then
begin
if GetLSNo(ADOCmd,maxno,'FM','FP_GYSNB',4,1)=False then
begin
Order_Sub.EnableControls;
ADOCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
end else
begin
maxno:=Trim(LSFMID);
end;
with ADOCmd do
begin
Close;
sql.Clear;
SQL.Add('select * from FP_GYSNB where FMID='''+Trim(Order_Sub.fieldbyname('FMID').AsString)+'''');
Open;
end;
with ADOCmd do
begin
if Trim(LSFMID)='' then
begin
Append;
end
else begin
Edit;
end;
FieldByName('FMID').Value:=Trim(maxno);
FieldByName('BGID').Value:=Order_Sub.fieldbyname('BGID').Value;
FieldByName('BCID').Value:=Order_Sub.fieldbyname('BCID').Value;
FieldByName('BFID').Value:=Order_Sub.fieldbyname('BFID').Value;
FieldByName('FactoryNo').Value:=Order_Sub.fieldbyname('FactoryNo').Value;
FieldByName('OrderNo').Value:=Order_Sub.fieldbyname('OrderNo').Value;
FieldByName('FMType').Value:='GYS';
RTSetSaveDataCDS(ADOCmd,Tv1,Order_Sub,'FP_GYSNB',0) ;
if Trim(LSFMID)='' then
begin
FieldByName('Filler').Value:=Trim(DName);
end else
begin
FieldByName('Editer').Value:=Trim(DName);
FieldByName('EditTime').Value:=SGetServerDateTime(ADOTemp);
end;
Post;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('select * from FP_GYSNB where FPNO='''+Trim(Order_Sub.fieldbyname('FPNO').AsString)+'''');
sql.Add(' and isnull(FMType,'''')=''GYS'' ');
Open;
end;
if ADOCmd.RecordCount>1 then
begin
Order_Sub.EnableControls;
ADOCmd.Connection.RollbackTrans;
Result:=False;
Application.MessageBox(PChar('<27><>Ʊ<EFBFBD><C6B1>:'+Trim(Order_Sub.fieldbyname('FPNO').AsString)+'<27>ظ<EFBFBD>!'),'',0);
Exit;
end;
Edit;
FieldByName('FMID').Value:=Trim(maxno);
Post;
Next;
end;
end;
Order_Sub.EnableControls;
ADOCmd.Connection.CommitTrans;
Result:=True;
except
Result:=False;
ADOCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
end;
end;
procedure TfrmGYSFPInPutWGL.TBSaveClick(Sender: TObject);
var
FPPrice,PRTPrice,BCMoney,FPQty,ChaMoney:string;
begin
ToolBar1.SetFocus;
if Order_Sub.IsEmpty then
begin
Application.MessageBox('<27><>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
exit;
end;
if Order_Sub.Locate('FPNO',null,[]) then
begin
Application.MessageBox('<27><>Ʊ<EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Order_Sub.Locate('FPDate',null,[]) then
begin
Application.MessageBox('<27><>Ʊ<EFBFBD><C6B1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Order_Sub.Locate('Qty',null,[]) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Order_Sub.Locate('Price',null,[]) then
begin
Application.MessageBox('<27><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Order_Sub.Locate('Money',null,[]) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EEB2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Order_Sub.Locate('GHDanWei',null,[]) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>˾̧ͷ<CCA7><CDB7><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Order_Sub.Locate('FactoryName',null,[]) then
begin
Application.MessageBox('<27><>Ӧ<EFBFBD>̲<EFBFBD><CCB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Order_Sub.Locate('BFName',null,[]) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
//ModalResult:=1;
end;
end;
procedure TfrmGYSFPInPutWGL.ToolButton3Click(Sender: TObject);
var
FSQDate:string;
begin
FSQDate:=Trim(FormatDateTime('yyyy-MM-dd',SGetServerDate(ADOTemp)));
if Order_Sub.IsEmpty=False then
begin
CopyAddRowCDS(Order_Sub);
end else
begin
with Order_Sub do
begin
Append;
FieldByName('FPDate').Value:=FSQDate;
FieldByName('QtyUnit').Value:='M';
Post;
end;
end;
with Order_Sub do
begin
Edit;
FieldByName('FMID').Value:=Null;
FieldByName('FPNO').Value:=Null;
Post;
end;
end;
procedure TfrmGYSFPInPutWGL.ToolButton4Click(Sender: TObject);
begin
if Order_Sub.IsEmpty then Exit;
if Trim(Order_Sub.fieldbyname('FMId').AsString)<>'' then
begin
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('delete FP_GYSNB where FMId='''+Trim(Order_Sub.fieldbyname('FMId').AsString)+'''');
ExecSQL;
end;
end;
Order_Sub.Delete;
end;
procedure TfrmGYSFPInPutWGL.v1Column3PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FQty,FPrice,FMoney,FName:String;
begin
FName:=Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then mvalue:='0';
with Order_Sub do
begin
Edit;
FieldByName(FName).Value:=mvalue;
Post;
end;
FQty:=Order_Sub.fieldbyname('Qty').AsString;
FPrice:=Order_Sub.fieldbyname('Price').AsString;
FMoney:=Order_Sub.fieldbyname('Money').AsString;
if Trim(FQty)='' then FQty:='0';
if Trim(FPrice)='' then FPrice:='0';
if Trim(FMoney)='' then FMoney:='0';
if Trim(FName)<>'Money' then
begin
with Order_Sub do
begin
Edit;
FieldByName('Money').Value:=StrToFloat(FQty)*StrToFloat(FPrice);
Post;
end;
end else
begin
if Trim(FQty)<>'0' then
begin
with Order_Sub do
begin
Edit;
FieldByName('Price').Value:=StrToFloat(FMoney)*1.000000/StrToFloat(FQty);
Post;
end;
end else
begin
with Order_Sub do
begin
Edit;
FieldByName('Price').Value:=Null;
Post;
end;
end;
end;
end;
procedure TfrmGYSFPInPutWGL.v1Column20PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='GSTT';
flagname:='<27><>˾̧ͷ';
V1ZdyStr1.Visible:=True;
V1ZdyStr2.Visible:=True;
V1ZdyStr3.Visible:=True;
V1ZdyStr4.Visible:=True;
V1ZdyStr1.Caption:='<27><><EFBFBD><EFBFBD>';
V1ZdyStr2.Caption:='<27>绰';
V1ZdyStr3.Caption:='<27><><EFBFBD><EFBFBD>';
V1ZdyStr4.Caption:='<27><>ַ';
frmZDYHelp.Align:=alClient;
if ShowModal=1 then
begin
with Order_Sub do
begin
Edit;
FieldByName('GHDanWei').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmGYSFPInPutWGL.v1Column18PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='GYSFPName';
flagname:='<27><><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>';
if ShowModal=1 then
begin
with Self.Order_Sub do
begin
Edit;
FieldByName('BFName').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmGYSFPInPutWGL.v1Column4PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmGYSSelList:=TfrmGYSSelList.Create(Application);
with frmGYSSelList do
begin
if ShowModal=1 then
begin
with Self.Order_Sub do
begin
edit;
FieldByName('FactoryNo').Value:=Trim(frmGYSSelList.Order_Main.fieldbyname('ZKID').AsString) ;
FieldByName('FactoryName').Value:=Trim(frmGYSSelList.Order_Main.fieldbyname('KHName').AsString);
FieldByName('XHDanWei').Value:=Trim(frmGYSSelList.Order_Main.fieldbyname('KHName').AsString);
//Post;
end;
end;
end;
finally
frmGYSSelList.Free;
end;
end;
end.