D7wmguihua/桂华管理系统/U_BanCpHCSaoM.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

265 lines
8.2 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_BanCpHCSaoM;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, StdCtrls, ExtCtrls, ADODB, DBClient,
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
cxControls, cxGridCustomView, cxGrid;
type
TfrmBanCpHCSaoM = class(TForm)
cxGrid2: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column1: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
cxGridPopupMenu1: TcxGridPopupMenu;
CDS_Main: TClientDataSet;
DataSource1: TDataSource;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
Panel1: TPanel;
XJID: TEdit;
Label1: TLabel;
Button1: TButton;
v1Column5: TcxGridDBColumn;
Button2: TButton;
v1Column6: TcxGridDBColumn;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure XJIDKeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
public
{ Public declarations }
end;
var
frmBanCpHCSaoM: TfrmBanCpHCSaoM;
implementation
uses
U_DataLink,U_Fun ;
{$R *.dfm}
procedure TfrmBanCpHCSaoM.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmBanCpHCSaoM.FormDestroy(Sender: TObject);
begin
frmBanCpHCSaoM:=nil;
end;
procedure TfrmBanCpHCSaoM.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
SQL.Add('select A.*,B.OrderNo,B.MPRTCodeName,C.PRTColor,B.MPRTMF,B.MPRTKZ ');
sql.add('from CK_BanCP_CR A ');
Sql.add(' inner join JYOrder_Main B on A.MainId=B.MainId');
Sql.add(' inner join JYOrder_Sub C on A.SubId=C.SubId');
sql.add('where 1<>1');
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmBanCpHCSaoM.FormShow(Sender: TObject);
begin
ReadCxGrid('<27><>Ʒ<EFBFBD>ز<EFBFBD>',Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
InitGrid();
end;
procedure TfrmBanCpHCSaoM.XJIDKeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add('select A.* ');
sql.add('from CK_BanCP_CR A ');
sql.add('where A.MJID='''+Trim(XJID.Text)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add('select A.*,B.OrderNo,B.MPRTCodeName,C.PRTColor,B.MPRTMF,B.MPRTKZ,F.KCQty,F.KCKgQty ');
sql.add('from CK_BanCP_CR A ');
Sql.add(' inner join JYOrder_Main B on A.MainId=B.MainId');
Sql.add(' inner join JYOrder_Sub C on A.SubId=C.SubId');
sql.Add(' inner join CK_BanCP_KC F on A.CRID=F.CRID');
sql.add('where A.MJID='''+Trim(XJID.Text)+'''');
sql.Add(' and KCQty=0 and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
Open;
end;
if ADOQueryTemp.IsEmpty=false then
begin
if CDS_Main.Locate('MJID',Trim(ADOQueryTemp.fieldbyname('MJID').AsString),[])=True then
begin
Application.MessageBox('<27>Ѿ<EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD>ɨ<EFBFBD>裡','<27><>ʾ',0);
Exit;
end;
with CDS_Main do
begin
Append;
FieldByName('OrderNo').Value:=ADOQueryTemp.fieldbyname('OrderNo').Value;
FieldByName('MPRTCodeName').Value:=ADOQueryTemp.fieldbyname('MPRTCodeName').Value;
FieldByName('PRTColor').Value:=ADOQueryTemp.fieldbyname('PRTColor').Value;
FieldByName('MPRTMF').Value:=ADOQueryTemp.fieldbyname('MPRTMF').Value;
FieldByName('MPRTKZ').Value:=ADOQueryTemp.fieldbyname('MPRTKZ').Value;
FieldByName('CRID').Value:=ADOQueryTemp.fieldbyname('CRID').Value;
FieldByName('CRTime').Value:=SGetServerDateTime(ADOQueryCmd);
FieldByName('KGQty').Value:=ADOQueryTemp.fieldbyname('KGQty').Value;
FieldByName('Qty').Value:=ADOQueryTemp.fieldbyname('Qty').Value;
FieldByName('QtyUnit').Value:=ADOQueryTemp.fieldbyname('QtyUnit').Value;
FieldByName('MainID').Value:=ADOQueryTemp.fieldbyname('MainID').Value;
FieldByName('SubID').Value:=ADOQueryTemp.fieldbyname('SubID').Value;
FieldByName('APID').Value:=ADOQueryTemp.fieldbyname('APID').Value;
FieldByName('CPType').Value:=ADOQueryTemp.fieldbyname('CPType').Value;
FieldByName('MJID').Value:=ADOQueryTemp.fieldbyname('MJID').Value;
Post;
end;
end else
begin
Application.MessageBox('<27>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>ڲֿ<DAB2><D6BF>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز֣<D8B2>','<27><>ʾ',0);
Exit;
end;
XJID.Text:='';
end;
end;
procedure TfrmBanCpHCSaoM.Button1Click(Sender: TObject);
var
maxno:string;
begin
if CDS_Main.IsEmpty then Exit;
if CDS_Main.Locate('KgQty',0,[]) then
begin
Application.MessageBox('<27>زֹ<D8B2><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30>','<27><>ʾ',0);
Exit;
end;
if CDS_Main.Locate('Qty',0,[]) then
begin
Application.MessageBox('<27>زֳ<D8B2><D6B3>Ȳ<EFBFBD><C8B2><EFBFBD>Ϊ0<CEAA><30>','<27><>ʾ',0);
Exit;
end;
if CDS_Main.Locate('KgQty',null,[]) then
begin
Application.MessageBox('<27>زֹ<D8B2><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
if CDS_Main.Locate('Qty',null,[]) then
begin
Application.MessageBox('<27>زֳ<D8B2><D6B3>Ȳ<EFBFBD><C8B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
XJID.SetFocus;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_Main do
begin
First;
while not Eof do
begin
if GetLSNo(ADOQueryCmd,maxno,'HC','CK_BanCp_CR',4,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCp_CR where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('BCID').Value:=Trim(maxno);
FieldByName('CRID').Value:=CDS_Main.fieldbyname('CRID').Value;
FieldByName('CRTime').Value:=CDS_Main.fieldbyname('CRTime').Value;
FieldByName('KGQty').Value:=CDS_Main.fieldbyname('KGQty').Value;
FieldByName('Qty').Value:=CDS_Main.fieldbyname('Qty').Value;
FieldByName('QtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('MainID').Value:=CDS_Main.fieldbyname('MainID').Value;
FieldByName('SubID').Value:=CDS_Main.fieldbyname('SubID').Value;
FieldByName('APID').Value:=CDS_Main.fieldbyname('APID').Value;
FieldByName('MJID').Value:=CDS_Main.fieldbyname('MJID').Value;
FieldByName('CPType').Value:=CDS_Main.fieldbyname('CPType').Value;
FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
FieldByName('Filler').Value:=Trim(DName);
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('CRType').Value:='<27>ز<EFBFBD>';
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.Add('Update CK_BanCp_KC set KCKgQty='+cds_main.fieldbyname('KgQty').AsString);
SQL.Add(',KCQty='+cds_main.fieldbyname('Qty').AsString);
sql.Add(' where CRID='+CDS_Main.fieldbyname('CRID').AsString);
ExecSQL;
end;
Next;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
InitGrid();
Application.MessageBox('<27>زֳɹ<D6B3><C9B9><EFBFBD>','<27><>ʾ',0);
Exit;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27>ز<EFBFBD><D8B2><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
procedure TfrmBanCpHCSaoM.Button2Click(Sender: TObject);
begin
Close;
WriteCxGrid('<27><>Ʒ<EFBFBD>ز<EFBFBD>',Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
end;
end.