418 lines
11 KiB
ObjectPascal
418 lines
11 KiB
ObjectPascal
unit U_TatInspEdit;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
||
cxEdit, DB, cxDBData, cxTextEdit, DBClient, ADODB, cxGridLevel,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
|
||
cxControls, cxGridCustomView, cxGrid, StdCtrls, ExtCtrls, ComCtrls, ToolWin,
|
||
cxButtonEdit, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
|
||
dxSkinsDefaultPainters, dxDateRanges;
|
||
|
||
type
|
||
TfrmTatInspEdit = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
ToolButton2: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
CIID: TEdit;
|
||
ADOTmp: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOCmd: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
Order_MJ: TClientDataSet;
|
||
ToolButton1: TToolButton;
|
||
ToolButton3: TToolButton;
|
||
Label2: TLabel;
|
||
GrossWeight: TEdit;
|
||
Label4: TLabel;
|
||
Label6: TLabel;
|
||
Meter: TEdit;
|
||
RadioGroup1: TRadioGroup;
|
||
Ma: TLabel;
|
||
Label7: TLabel;
|
||
MJQty1: TEdit;
|
||
Label5: TLabel;
|
||
Label10: TLabel;
|
||
Label12: TLabel;
|
||
Label14: TLabel;
|
||
NetWeight: TEdit;
|
||
PieceNo: TEdit;
|
||
Label15: TLabel;
|
||
Label11: TLabel;
|
||
Yardage: TEdit;
|
||
ToolButton4: TToolButton;
|
||
cxGrid1: TcxGrid;
|
||
TV1: TcxGridDBTableView;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
cxGridDBColumn4: TcxGridDBColumn;
|
||
cxGridDBColumn5: TcxGridDBColumn;
|
||
cxGridDBColumn6: TcxGridDBColumn;
|
||
cxGridDBColumn7: TcxGridDBColumn;
|
||
cxGridDBColumn8: TcxGridDBColumn;
|
||
cxGridDBColumn9: TcxGridDBColumn;
|
||
cxGridLevel3: TcxGridLevel;
|
||
TV1Column1: TcxGridDBColumn;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure tv2CDWZPropertiesEditValueChanged(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure cxGridDBColumn3PropertiesEditValueChanged(Sender: TObject);
|
||
procedure TV1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
private
|
||
{ Private declarations }
|
||
function SaveData(): Boolean;
|
||
procedure GetJYXK(FJYIP: string);
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmTatInspEdit: TfrmTatInspEdit;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_RTFun, U_ZDYHelp, U_DataLink;
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmTatInspEdit.GetJYXK(FJYIP: string);
|
||
begin
|
||
with ADOTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select A.* from Tat_Cloth_Inspect A ');
|
||
sql.Add(' where A.CIID=''' + Trim(FJYIP) + '''');
|
||
Open;
|
||
end;
|
||
if ADOTmp.IsEmpty then
|
||
begin
|
||
CIID.Text := '';
|
||
Label2.Caption := '';
|
||
Label2.Visible := False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
PieceNo.Text := Trim(ADOTmp.fieldbyname('PieceNo').AsString);
|
||
|
||
GrossWeight.Text := Trim(ADOTmp.fieldbyname('GrossWeight').AsString);
|
||
NetWeight.Text := Trim(ADOTmp.fieldbyname('NetWeight').AsString);
|
||
Meter.Text := Trim(ADOTmp.fieldbyname('Meter').AsString);
|
||
Yardage.Text := Trim(ADOTmp.fieldbyname('Yardage').AsString);
|
||
|
||
if Trim(Trim(ADOTmp.fieldbyname('Grade').AsString)) = '<27><>Ʒ' then
|
||
begin
|
||
RadioGroup1.ItemIndex := 0
|
||
end
|
||
else if Trim(Trim(ADOTmp.fieldbyname('Grade').AsString)) = '<27><>Ʒ' then
|
||
begin
|
||
RadioGroup1.ItemIndex := 1;
|
||
end;
|
||
with ADOTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select * from Tat_Cloth_Inspect_Flaw A where A.CIID=''' + Trim(CIID.Text) + '''');
|
||
Open;
|
||
end;
|
||
Label2.Caption := Trim(CIID.Text);
|
||
Label2.Visible := True;
|
||
CIID.Text := '';
|
||
SCreateCDS(ADOTmp, Order_MJ);
|
||
SInitCDSData(ADOTmp, Order_MJ);
|
||
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.cxGridDBColumn3PropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue, CIFbeg, CIFEnd: string;
|
||
FFReal: Double;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
with Order_MJ do
|
||
begin
|
||
Edit;
|
||
FieldByName('CIFEnd').Value := mvalue;
|
||
Post;
|
||
end;
|
||
CIFbeg := Trim(Order_MJ.fieldbyname('CIFbeg').AsString);
|
||
CIFEnd := Trim(Order_MJ.fieldbyname('CIFEnd').AsString);
|
||
if (Trim(CIFbeg) <> '') and (Trim(CIFEnd) <> '') then
|
||
begin
|
||
if TryStrToFloat(CIFbeg, FFReal) and TryStrToFloat(CIFbeg, FFReal) then
|
||
begin
|
||
if StrToFloat(CIFEnd) < StrToFloat(CIFbeg) then
|
||
begin
|
||
Application.MessageBox('<27><>ֹλ<D6B9><CEBB>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ʼλ<CABC><CEBB>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
with Order_MJ do
|
||
begin
|
||
Edit;
|
||
FieldByName('CDQty').Value := StrToFloat(CIFEnd) - StrToFloat(CIFbeg);
|
||
Post;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox('<27>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmTatInspEdit := nil;
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.tv2CDWZPropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue, CIFbeg, CIFEnd: string;
|
||
FFReal: Double;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
with Order_MJ do
|
||
begin
|
||
Edit;
|
||
FieldByName('CIFbeg').Value := mvalue;
|
||
Post;
|
||
end;
|
||
CIFbeg := Trim(Order_MJ.fieldbyname('CIFbeg').AsString);
|
||
CIFEnd := Trim(Order_MJ.fieldbyname('CIFEnd').AsString);
|
||
if (Trim(CIFbeg) <> '') and (Trim(CIFEnd) <> '') then
|
||
begin
|
||
if TryStrToFloat(CIFbeg, FFReal) and TryStrToFloat(CIFbeg, FFReal) then
|
||
begin
|
||
if StrToFloat(CIFEnd) < StrToFloat(CIFbeg) then
|
||
begin
|
||
Application.MessageBox('<27><>ֹλ<D6B9><CEBB>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ʼλ<CABC><CEBB>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
with Order_MJ do
|
||
begin
|
||
Edit;
|
||
FieldByName('CIFQty').Value := StrToFloat(CIFEnd) - StrToFloat(CIFbeg);
|
||
Post;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox('<27>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if Trim(Label2.Caption) = '' then
|
||
Exit;
|
||
Order_MJ.Append;
|
||
Order_MJ.Post;
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
if Trim(Label2.Caption) = '' then
|
||
Exit;
|
||
if Order_MJ.IsEmpty then
|
||
Exit;
|
||
if Trim(Order_MJ.fieldbyname('CIFID').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 Tat_Cloth_Inspect_Flaw where CIFID=''' + Trim(Order_MJ.fieldbyname('CIFID').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
Order_MJ.Delete;
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(Self.Caption), Tv1, 'ӡȾ<D3A1><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.TV1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag := 'WFBCD';
|
||
flagname := '<27>õ<EFBFBD>';
|
||
if ShowModal = 1 then
|
||
begin
|
||
Self.Order_MJ.Edit;
|
||
Self.Order_MJ.FieldByName('CIFName').value := Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
function TfrmTatInspEdit.SaveData(): Boolean;
|
||
var
|
||
maxno: string;
|
||
FFreal: Double;
|
||
begin
|
||
try
|
||
ADOCmd.Connection.BeginTrans;
|
||
///<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>
|
||
with Order_MJ do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if trim(Order_MJ.FieldByName('CIFName').AsString) = '' then
|
||
raise Exception.Create(pchar('<27>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>'));
|
||
|
||
if Trim(Order_MJ.fieldbyname('CIFID').AsString) = '' then
|
||
begin
|
||
if GetLSNo(ADOTmp, maxno, 'JC', 'Tat_Cloth_Inspect_Flaw', 5, 1) = False then
|
||
raise Exception.Create(pchar('ȡ<><C8A1><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>'));
|
||
end
|
||
else
|
||
begin
|
||
maxno := Trim(Order_MJ.fieldbyname('CIFID').AsString);
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select * from Tat_Cloth_Inspect_Flaw ');
|
||
sql.Add(' where CIFID=''' + Trim(maxno) + ''' ');
|
||
Open;
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
if Trim(Order_MJ.fieldbyname('CIFID').AsString) = '' then
|
||
Append
|
||
else
|
||
Edit;
|
||
FieldByName('CIID').Value := Trim(Label2.Caption);
|
||
FieldByName('CIFID').Value := Trim(maxno);
|
||
RTSetSaveDataCDS(ADOCmd, Tv1, Order_MJ, 'Tat_Cloth_Inspect_Flaw', 0);
|
||
Post;
|
||
end;
|
||
|
||
Order_MJ.Edit;
|
||
Order_MJ.FieldByName('CIFID').Value := Trim(maxno);
|
||
Order_MJ.FieldByName('CIID').Value := Trim(Label2.Caption);
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' UPdate Tat_Cloth_Inspect Set ');
|
||
sql.Add(' PieceNo=''' + Trim(PieceNo.Text) + ''' ');
|
||
sql.Add(',GrossWeight=' + FloatToStr(Strtofloatdef(GrossWeight.Text, 0)));
|
||
sql.Add(',NetWeight=' + FloatToStr(Strtofloatdef(NetWeight.Text, 0)));
|
||
sql.Add(',Meter=' + FloatToStr(Strtofloatdef(Meter.Text, 0)));
|
||
sql.Add(',Yardage=' + FloatToStr(Strtofloatdef(Yardage.Text, 0)));
|
||
|
||
if RadioGroup1.ItemIndex = 0 then
|
||
begin
|
||
sql.Add(',Grade=''<27><>Ʒ'' ');
|
||
end
|
||
else if RadioGroup1.ItemIndex = 1 then
|
||
begin
|
||
sql.Add(',Grade=''<27><>Ʒ'' ');
|
||
end;
|
||
sql.Add(' where CIID=''' + Trim(Label2.Caption) + '''');
|
||
ExecSQL;
|
||
end;
|
||
////////////////// <20><><EFBFBD>¾<EFBFBD><C2BE>Ŵõ<C5B4><C3B5><EFBFBD>Ϣ //////////////////
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_Tat_Insp_Up @CIID=''' + Trim(Label2.Caption) + '''');
|
||
sql.Add(',@InspType=' + QuotedStr('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'));
|
||
execsql;
|
||
end;
|
||
////////////////// <20><><EFBFBD>¾<EFBFBD><C2BE>Ŵõ<C5B4><C3B5><EFBFBD>Ϣ //////////////////
|
||
///
|
||
////////////////// <20><><EFBFBD><EFBFBD><EFBFBD>⼰<EFBFBD><E2BCB0><EFBFBD><EFBFBD> //////////////////
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_Tat_Insp_In_Stk @CIID=''' + Trim(Label2.Caption) + '''');
|
||
execsql;
|
||
end;
|
||
////////////////// <20><><EFBFBD><EFBFBD><EFBFBD>⼰<EFBFBD><E2BCB0><EFBFBD><EFBFBD> //////////////////
|
||
///
|
||
////////////////// <20><><EFBFBD>½<EFBFBD><C2BD><EFBFBD> //////////////////
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('insert into Tat_Need_Up(UOperation,UType,UDataId) values(''<27><><EFBFBD><EFBFBD>'',''<27><><EFBFBD><EFBFBD><EFBFBD>༭'',' + quotedstr(Trim(Label2.Caption)) + ') ');
|
||
execsql;
|
||
end;
|
||
////////////////// <20><><EFBFBD>½<EFBFBD><C2BD><EFBFBD> //////////////////
|
||
///
|
||
ADOCmd.Connection.CommitTrans;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
ADOCmd.Connection.RollbackTrans;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if Trim(Label2.Caption) = '' then
|
||
Exit;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatInspEdit.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid(trim(Self.Caption), Tv1, 'ӡȾ<D3A1><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
if CIID.Text <> '' then
|
||
begin
|
||
GetJYXK(CIID.Text);
|
||
end;
|
||
|
||
end;
|
||
|
||
end.
|
||
|