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

330 lines
8.7 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_SXJGDZInPut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit,
ComCtrls, ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxButtonEdit,
cxTextEdit;
type
TfrmSXJGDZInPut = class(TForm)
cxGrid2: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column2: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
ToolBar1: TToolBar;
TBAdd: TToolButton;
TBDel: TToolButton;
TBSave: TToolButton;
TBClose: TToolButton;
DataSource3: TDataSource;
CDS_Sub: TClientDataSet;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
cxGridPopupMenu2: TcxGridPopupMenu;
v1Column12: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBAddClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure v1Column14PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v2Column1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v2Column6PropertiesEditValueChanged(Sender: TObject);
private
{ Private declarations }
function SaveCKData():Boolean;
public
{ Public declarations }
FBCId:String;
end;
var
frmSXJGDZInPut: TfrmSXJGDZInPut;
implementation
uses
U_DataLink,U_RTFun,U_ClothContractListHZCX,U_ZDYHelp, U_GYSSelList,U_ContractCGJGSXSelList;
{$R *.dfm}
procedure TfrmSXJGDZInPut.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmSXJGDZInPut.TBAddClick(Sender: TObject);
begin
with CDS_Sub do
begin
Append;
FieldByName('DZDate').Value:=Trim(FormatDateTime('yyyy-MM-dd',Now));
Post;
end;
end;
function TfrmSXJGDZInPut.SaveCKData():Boolean;
var
FCRID,Maxno,FDZID:string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
CDS_Sub.DisableControls;
with CDS_Sub do
begin
First;
while not eof do
begin
if Trim(CDS_Sub.fieldbyname('DZID').AsString)='' then
begin
if GetLSNo(ADOQueryCmd,Maxno,'SJ','JYOrder_Main_MD_DuiZhang',3,1)=False then
begin
Result:=False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('ȡɴ<C8A1>߼ӹ<DFBC><D3B9><EFBFBD><EFBFBD>˱<EFBFBD><CBB1><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
end else
begin
Maxno:=Trim(CDS_Sub.fieldbyname('DZID').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(Maxno)+'''');
Open;
end;
with ADOQueryCmd do
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Main_MD_DuiZhang');
sql.Add(' where DZID='''+Trim(CDS_Sub.fieldbyname('DZID').AsString)+'''');
Open;
end;
FDZID:=Trim(ADOQueryTemp.fieldbyname('DZID').AsString);
if Trim(FDZID)='' then
begin
Append;
FieldByName('Filler').Value:=Trim(DName);
end else
begin
Edit;
FieldByName('Editer').Value:=Trim(DName);
FieldByName('EditTime').Value:=SGetServerDate(ADOQueryTemp);
end;
FieldByName('DZID').Value:=Trim(Maxno);
FieldByName('DZType').Value:=<>߼ӹ<DFBC>';
FieldByName('Status').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('FactoryNo').Value:=Trim(CDS_Sub.fieldbyname('FactoryNo').AsString);
RTSetSaveDataCDS(ADOQueryCmd,Tv1,CDS_Sub,'JYOrder_Main_MD_DuiZhang',2);
Post;
end;
Edit;
FieldByName('DZID').Value:=Trim(Maxno);
Post;
Next;
end;
end;
CDS_Sub.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
Result:=True;
except
Result:=False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
procedure TfrmSXJGDZInPut.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(<>߶<EFBFBD><DFB6><EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Close;
end;
procedure TfrmSXJGDZInPut.FormShow(Sender: TObject);
begin
ReadCxGrid(<>߶<EFBFBD><DFB6><EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add(' select A.* ');
sql.Add(' from JYOrder_Main_MD_DuiZhang A');
sql.Add(' where DZID='''+Trim(FBCId)+'''');
Open;
end;
SCreateCDS20(ADOQueryTemp,CDS_Sub);
SInitCDSData20(ADOQueryTemp,CDS_Sub);
end;
procedure TfrmSXJGDZInPut.TBDelClick(Sender: TObject);
begin
if CDS_Sub.IsEmpty then Exit;
if Trim(CDS_Sub.fieldbyname('DZID').AsString)<>'' then
begin
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(CDS_Sub.fieldbyname('DZID').AsString)+'''');
sql.Add(' and isnull(Status,'''')=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
Exit;
end;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add(' delete JYOrder_Main_MD_DuiZhang where DZID='''+Trim(CDS_Sub.fieldbyname('DZID').AsString)+'''');
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
CDS_Sub.Delete;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C9BE><EFBFBD>쳣!','<27><>ʾ',0);
end;
end else
begin
CDS_Sub.Delete;
end;
end;
procedure TfrmSXJGDZInPut.TBSaveClick(Sender: TObject);
begin
if CDS_Sub.IsEmpty then Exit;
if CDS_Sub.Locate('DZDate',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('MPRTCodeName',null,[])=True then
begin
Application.MessageBox('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('FactoryName',null,[])=True then
begin
Application.MessageBox('<27><>Ӧ<EFBFBD>̲<EFBFBD><CCB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('Qty',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('Price',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
ToolBar1.SetFocus;
if SaveCKData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
//ModalResult:=1;
Exit;
end;
end;
procedure TfrmSXJGDZInPut.v1Column14PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmGYSSelList:=TfrmGYSSelList.Create(Application);
with frmGYSSelList do
begin
if ShowModal=1 then
begin
with Self.CDS_Sub do
begin
edit;
FieldByName('FactoryNo').Value:=Trim(frmGYSSelList.Order_Main.fieldbyname('ZKID').AsString) ;
FieldByName('FactoryName').Value:=Trim(frmGYSSelList.Order_Main.fieldbyname('KHName').AsString);
//Post;
end;
end;
end;
finally
frmGYSSelList.Free;
end;
end;
procedure TfrmSXJGDZInPut.v2Column1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='PBName';
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal=1 then
begin
with Self.CDS_Sub do
begin
Edit;
FieldByName('MPRTCodeName').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmSXJGDZInPut.v2Column6PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FName,FQty,FPrice:String;
begin
FName:=Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then mvalue:='0';
with CDS_Sub do
begin
edit;
FieldByName(FName).Value:=mvalue;
//Post;
end;
FQty:=CDS_Sub.fieldbyname('Qty').AsString;
FPrice:=CDS_Sub.fieldbyname('Price').AsString;
if Trim(FQty)='' then FQty:='0';
if Trim(FPrice)='' then FPrice:='0';
with CDS_Sub do
begin
Edit;
FieldByName('Money').Value:=StrToFloat(FQty)*StrToFloat(FPrice);
//Post;
end;
end;
end.