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

534 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_PBCKInPut;
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
TfrmPBCKInPut = class(TForm)
ToolBar1: TToolBar;
TBAdd: TToolButton;
TBDel: TToolButton;
TBSave: TToolButton;
TBClose: TToolButton;
DataSource3: TDataSource;
CDS_Sub: TClientDataSet;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
cxGridPopupMenu2: TcxGridPopupMenu;
cxGrid2: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column6: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column11: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
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 v1Column3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v1Column14PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v2Column1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure v2Column3PropertiesEditValueChanged(Sender: TObject);
private
{ Private declarations }
function SaveCKData():Boolean;
public
{ Public declarations }
FBCId:String;
end;
var
frmPBCKInPut: TfrmPBCKInPut;
implementation
uses
U_DataLink,U_RTFun,U_ClothContractListHZCX,U_ZDYHelp, U_GYSSelList;
{$R *.dfm}
procedure TfrmPBCKInPut.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmPBCKInPut.TBAddClick(Sender: TObject);
begin
with CDS_Sub do
begin
Append;
FieldByName('CRTime').Value:=Trim(FormatDateTime('yyyy-MM-dd',Now));
Post;
end;
end;
function TfrmPBCKInPut.SaveCKData():Boolean;
var
FCRID,Maxno:string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
CDS_Sub.DisableControls;
with CDS_Sub do
begin
First;
while not eof do
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_KC where BatchNo='''+Trim(CDS_Sub.fieldbyname('BatchNo').AsString)+'''');
sql.Add(' and isnull(CKName,'''')=''<27><><EFBFBD><EFBFBD>'' ');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
FCRID:=Trim(ADOQueryTemp.fieldbyname('CRID').AsString);
end else
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_CRID');
Open;
end;
if ADOQueryTemp.IsEmpty then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into CK_SXPB_CRID select 0');
sql.Add(' select * from CK_SXPB_CRID');
Open;
end;
FCRID:=Trim(ADOQueryCmd.fieldbyname('CRID').AsString);
end else
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update CK_SXPB_CRID Set CRID=CRID+1');
sql.Add(' select * from CK_SXPB_CRID');
Open;
end;
FCRID:=Trim(ADOQueryCmd.fieldbyname('CRID').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_KC where CRID='+FCRID);
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('CRID').Value:=FCRID;
FieldByName('CKName').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('BatchNo').Value:=CDS_Sub.fieldbyname('BatchNo').Value;
FieldByName('SPType').Value:=CDS_Sub.fieldbyname('SPType').Value;
FieldByName('FactoryName').Value:=CDS_Sub.fieldbyname('FactoryName').Value;
FieldByName('FactoryNo').Value:=CDS_Sub.fieldbyname('FactoryNo').Value;
FieldByName('SPName').Value:=CDS_Sub.fieldbyname('SPName').Value;
FieldByName('SPCF').Value:=CDS_Sub.fieldbyname('SPCF').Value;
FieldByName('SPMF').Value:=CDS_Sub.fieldbyname('SPMF').Value;
FieldByName('SPKZ').Value:=CDS_Sub.fieldbyname('SPKZ').Value;
FieldByName('ShaZhi').Value:=CDS_Sub.fieldbyname('ShaZhi').Value;
FieldByName('KCNote').Value:=CDS_Sub.fieldbyname('Note').Value;
Post;
end;
end;
if Trim(CDS_Sub.fieldbyname('SPID').AsString)='' then
begin
if GetLSNo(ADOQueryCmd,Maxno,'PR','CK_SXPB_CR',3,1)=False then
begin
Result:=False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
end else
begin
Maxno:=Trim(CDS_Sub.fieldbyname('SPID').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_CR where SPID='''+Trim(Maxno)+'''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(CDS_Sub.fieldbyname('SPID').AsString)='' then
begin
Append;
end else
begin
Edit;
end;
FieldByName('SPID').Value:=Trim(Maxno);
FieldByName('CKName').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('FactoryNo').Value:=Trim(CDS_Sub.fieldbyname('FactoryNo').AsString);
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('CRQtyFlag').Value:=1;
FieldByName('CRID').Value:=FCRID;
RTSetSaveDataCDS(ADOQueryCmd,Tv1,CDS_Sub,'CK_SX_CR',2);
if Trim(CDS_Sub.fieldbyname('SPID').AsString)='' then
FieldByName('Filler').Value:=Trim(DName)
else
begin
FieldByName('Editer').Value:=Trim(DName);
FieldByName('EditTime').Value:=SGetServerDate(ADOQueryTemp);
end;
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update CK_SXPB_KC Set KCKGQty=(select sum(isnull(KGQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.CRID=CK_SXPB_KC.CRID)');
sql.Add(',KCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.CRID=CK_SXPB_KC.CRID)');
sql.Add(' where CRID='+FCRID);
ExecSQL;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_KC where CRID='+Trim(FCRID));
Open;
end;
if ADOQueryTemp.FieldByName('KCKGQty').Value<0 then
begin
CDS_Sub.DisableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><E2B9AB><EFBFBD><EFBFBD>С<EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD><E2B9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
{ if ADOQueryTemp.FieldByName('KCKeQty').Value<0 then
begin
CDS_Sub.DisableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!','<27><>ʾ',0);
Exit;
end; }
Edit;
FieldByName('SPID').Value:=Trim(Maxno);
FieldByName('CRID').Value:=Trim(FCRID);
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 TfrmPBCKInPut.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
Close;
end;
procedure TfrmPBCKInPut.FormShow(Sender: TObject);
var
fsj:String;
begin
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
fsj:=' select Code=BatchNo,Name=BatchNo from CK_SXPB_CR where isnull(CKName,'''')=''<27><><EFBFBD><EFBFBD>'' Group by BatchNo';
SInitCxGridComboBoxBySql(ADOQueryTemp,v2Column3,fsj,0,True,'');
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add(' select A.* ');
sql.Add(' from CK_SXPB_CR A');
sql.Add(' where SPID='''+Trim(FBCId)+'''');
Open;
end;
SCreateCDS20(ADOQueryTemp,CDS_Sub);
SInitCDSData20(ADOQueryTemp,CDS_Sub);
end;
procedure TfrmPBCKInPut.TBDelClick(Sender: TObject);
begin
if CDS_Sub.IsEmpty then Exit;
if Trim(CDS_Sub.fieldbyname('SPID').AsString)<>'' then
begin
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add(' delete CK_SXPB_CR where SPID='''+Trim(CDS_Sub.fieldbyname('SPID').AsString)+'''');
sql.Add('Update CK_SXPB_KC Set KCKGQty=(select sum(isnull(KGQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.CRID=CK_SXPB_KC.CRID)');
sql.Add(',KCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.CRID=CK_SXPB_KC.CRID)');
sql.Add(' where CRID='+Trim(CDS_Sub.fieldbyname('CRID').AsString));
ExecSQL;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_KC where CRID='+Trim(CDS_Sub.fieldbyname('CRID').AsString));
Open;
end;
if ADOQueryTemp.FieldByName('KCKGQty').Value<0 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><E2B9AB><EFBFBD><EFBFBD>С<EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD><E2B9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
Exit;
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 TfrmPBCKInPut.TBSaveClick(Sender: TObject);
begin
if CDS_Sub.IsEmpty then Exit;
if CDS_Sub.Locate('CRTime',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4B2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('CRType',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('BatchNo',null,[])=True then
begin
Application.MessageBox(<>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('SPName',null,[])=True then
begin
Application.MessageBox('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('SPType',null,[])=True then
begin
Application.MessageBox('<27><>ƥ<EFBFBD><C6A5><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('SPCF',null,[])=True then
begin
Application.MessageBox('<27>ɷֲ<C9B7><D6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('SPMF',null,[])=True then
begin
Application.MessageBox('<27>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('SPKZ',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD>ز<EFBFBD><D8B2><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('PiQty',null,[])=True then
begin
Application.MessageBox(<><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('KGQty',null,[])=True then
begin
Application.MessageBox('<27>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('CostPrice',null,[])=True then
begin
Application.MessageBox('<27>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('CRType;Price',VarArrayOf(['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',Null]),[loPartialKey])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>ɹ<EFBFBD><C9B9>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if SaveCKData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
//ModalResult:=1;
Exit;
end;
end;
procedure TfrmPBCKInPut.v1Column3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='SXKuWei';
flagname:='<27><>λ';
if ShowModal=1 then
begin
with Self.CDS_Sub do
begin
Edit;
FieldByName('KuWei').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmPBCKInPut.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('KHNameJC').AsString);
//Post;
end;
end;
end;
finally
frmGYSSelList.Free;
end;
end;
procedure TfrmPBCKInPut.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('SPName').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmPBCKInPut.Tv1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if CDS_Sub.IsEmpty then Exit;
if Trim(CDS_Sub.fieldbyname('SPID').AsString)<>'' then
begin
v2Column3.Options.Focusing:=False;
end else
begin
v2Column3.Options.Focusing:=True;
end;
end;
procedure TfrmPBCKInPut.v2Column3PropertiesEditValueChanged(
Sender: TObject);
var
mvalue:string;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
with CDS_Sub do
begin
Edit;
FieldByName('BatchNo').Value:=mvalue;
Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 1 * from CK_SXPB_CR where BatchNo='''+Trim(CDS_Sub.fieldbyname('BatchNo').AsString)+'''');
sql.Add(' and isnull(CKName,'''')=''<27><><EFBFBD><EFBFBD>'' ');
sql.Add(' order by FillTIme desc');
Open;
end;
with CDS_Sub do
begin
Edit;
FieldByName('FactoryName').Value:=ADOQueryTemp.fieldbyname('FactoryName').Value;
FieldByName('FactoryNo').Value:=ADOQueryTemp.fieldbyname('FactoryNo').Value;
FieldByName('SPType').Value:=ADOQueryTemp.fieldbyname('SPType').Value;
FieldByName('SPName').Value:=ADOQueryTemp.fieldbyname('SPName').Value;
FieldByName('SPCF').Value:=ADOQueryTemp.fieldbyname('SPCF').Value;
FieldByName('SPMF').Value:=ADOQueryTemp.fieldbyname('SPMF').Value;
FieldByName('SPKZ').Value:=ADOQueryTemp.fieldbyname('SPKZ').Value;
FieldByName('ShaZhi').Value:=ADOQueryTemp.fieldbyname('ShaZhi').Value;
FieldByName('Price').Value:=ADOQueryTemp.fieldbyname('Price').Value;
FieldByName('CostPrice').Value:=ADOQueryTemp.fieldbyname('CostPrice').Value;
Post;
end;
end;
end.