493 lines
13 KiB
ObjectPascal
493 lines
13 KiB
ObjectPascal
unit U_CPAddPN;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
||
cxEdit, DB, cxDBData, ADODB, DBClient, cxGridLevel, cxGridCustomTableView,
|
||
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
|
||
cxGrid, ComCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, cxTextEdit,
|
||
cxButtonEdit, StdCtrls, ExtCtrls, cxCurrencyEdit, BtnEdit;
|
||
|
||
type
|
||
TfrmCPAddPN = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
ToolButton1: TToolButton;
|
||
TBClose: TToolButton;
|
||
CDS_Sub: TClientDataSet;
|
||
ADOQueryMain: TADOQuery;
|
||
DataSource2: TDataSource;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
ScrollBox1: TScrollBox;
|
||
Label1: TLabel;
|
||
Label7: TLabel;
|
||
CYNo: TEdit;
|
||
CYNote: TMemo;
|
||
Label5: TLabel;
|
||
CYName: TEdit;
|
||
Label11: TLabel;
|
||
CYCF: TEdit;
|
||
Label15: TLabel;
|
||
CYMF: TEdit;
|
||
Label22: TLabel;
|
||
CYKZ: TEdit;
|
||
Label23: TLabel;
|
||
Label2: TLabel;
|
||
CYColor: TEdit;
|
||
Label10: TLabel;
|
||
CYID: TEdit;
|
||
Label3: TLabel;
|
||
CYSpec: TMemo;
|
||
CYPrice: TEdit;
|
||
cxGrid1: TcxGrid;
|
||
TV1: TcxGridDBTableView;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
cxGridDBColumn4: TcxGridDBColumn;
|
||
cxGridLevel2: TcxGridLevel;
|
||
Label4: TLabel;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
cxGridDBColumn5: TcxGridDBColumn;
|
||
cxGridDBColumn6: TcxGridDBColumn;
|
||
cxGridDBColumn7: TcxGridDBColumn;
|
||
cxGridDBColumn8: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
Label6: TLabel;
|
||
Y_Note_PLJ: TMemo;
|
||
Label8: TLabel;
|
||
Y_Note_PLW: TMemo;
|
||
Label9: TLabel;
|
||
DS_YarnJX: TDataSource;
|
||
CDS_YarnJX: TClientDataSet;
|
||
CDS_YarnWX: TClientDataSet;
|
||
DS_YarnWX: TDataSource;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure CYColorKeyPress(Sender: TObject; var Key: Char);
|
||
procedure CYKZExit(Sender: TObject);
|
||
procedure CYMFExit(Sender: TObject);
|
||
private
|
||
canshu1: string;
|
||
Fint: Integer;
|
||
procedure InitSubGrid();
|
||
function SaveData(): Boolean;
|
||
{ Private declarations }
|
||
public
|
||
FCYID, FCYCode, FCPID, FCPNO, FCPName: string;
|
||
CopyInt,PState: Integer;
|
||
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmCPAddPN: TfrmCPAddPN;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun, U_iniParam, U_ZDYHelp, U_ZdyAttachGYS, U_FileUp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmCPAddPN.InitSubGrid();
|
||
var
|
||
FXHInt: Integer;
|
||
begin
|
||
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select * from CP_YDang where CYID=''' + Trim(FCYID) + '''');
|
||
Open;
|
||
end;
|
||
SCSHDataNew(ADOQueryMain, ScrollBox1, 2);
|
||
SCSHDataNew(ADOQueryMain, ScrollBox1, 0);
|
||
|
||
/////////////////ˢ<>¾<EFBFBD>˿/////////////////////////
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CP_Plan_Yarn where PYType=''<27><>˿'' and Y_CYID=''' + Trim(FCYID) + '''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, CDS_YarnJX);
|
||
SInitCDSData20(ADOQueryTemp, CDS_YarnJX);
|
||
Y_Note_PLJ.Text := Trim(ADOQueryTemp.FieldByName('Y_Note_PL').AsString);
|
||
if (CopyInt = 0) and (PState<>1) then
|
||
begin
|
||
with CDS_YarnJX do
|
||
begin
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><EFBFBD>';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27>Ҿ<EFBFBD>';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><><EFBFBD><EFBFBD>';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><><EFBFBD><EFBFBD>';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27>쾭';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><><EFBFBD><EFBFBD>';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><><EFBFBD><EFBFBD>';
|
||
Post;
|
||
end;
|
||
end;
|
||
/////////////////ˢ<>¾<EFBFBD>˿/////////////////////////
|
||
|
||
/////////////////ˢ<><CBA2>γ˿/////////////////////////
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CP_Plan_Yarn where PYType=''γ˿'' and Y_CYID=''' + Trim(FCYID) + '''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, CDS_YarnWX);
|
||
SInitCDSData20(ADOQueryTemp, CDS_YarnWX);
|
||
Y_Note_PLW.Text := Trim(ADOQueryTemp.FieldByName('Y_Note_PL').AsString);
|
||
if (CopyInt = 0) and (PState<>1) then
|
||
begin
|
||
with CDS_YarnWX do
|
||
begin
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><>γ';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><>γ';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><>γ';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><>γ';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><>γ';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><>γ';
|
||
Post;
|
||
Append;
|
||
FieldByName('PYXH').Value := '<27><>γ';
|
||
Post;
|
||
end;
|
||
end;
|
||
/////////////////ˢ<><CBA2>γ˿/////////////////////////
|
||
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmCPAddPN.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid(Trim(self.Caption), Tv1, '<27><>Ʒ¼<C6B7>뾭˿');
|
||
ReadCxGrid(Trim(self.Caption), Tv2, '<27><>Ʒ¼<C6B7><C2BC>γ˿');
|
||
InitSubGrid();
|
||
if CopyInt = 1 then
|
||
begin
|
||
FCYID := '';
|
||
CYID.text := '';
|
||
CYNo.Text :='';
|
||
/////////////////<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>ID/////////////////////////
|
||
CDS_YarnJX.DisableControls;
|
||
with CDS_YarnJX do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
Edit;
|
||
FieldByName('Y_CYID').Value := '';
|
||
FieldByName('PYId').Value := '';
|
||
Post;
|
||
Next;
|
||
end;
|
||
end;
|
||
CDS_YarnJX.EnableControls;
|
||
|
||
CDS_YarnWX.DisableControls;
|
||
with CDS_YarnWX do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
Edit;
|
||
FieldByName('PYId').Value := '';
|
||
FieldByName('Y_CYID').Value := '';
|
||
Post;
|
||
Next;
|
||
end;
|
||
end;
|
||
CDS_YarnWX.EnableControls;
|
||
/////////////////<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>ID/////////////////////////
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPAddPN.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Trim(self.Caption), Tv1, '<27><>Ʒ¼<C6B7>뾭˿');
|
||
WriteCxGrid(Trim(self.Caption), Tv2, '<27><>Ʒ¼<C6B7><C2BC>γ˿');
|
||
Close;
|
||
end;
|
||
|
||
function TfrmCPAddPN.SaveData(): Boolean;
|
||
var
|
||
maxId, FCYNo,maxpbno: string;
|
||
begin
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
if Trim(FCYID) = '' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, maxId, 'Y', 'CP_YDang', 4, 1) = False then
|
||
begin
|
||
Result := False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
CYID.Text := trim(maxId);
|
||
end
|
||
else
|
||
begin
|
||
maxId := Trim(FCYID);
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from CP_YDang where CYID=''' + Trim(FCYID) + '''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if Trim(FCYID) = '' then
|
||
begin
|
||
Append;
|
||
FieldByName('CYType').Value := Trim(FCPID);
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
FieldByName('FillCode').Value := Trim(DCode);
|
||
FieldByName('Filler').Value := SGetServerDateTime(ADOQueryTemp);
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value := Trim(DName);
|
||
FieldByName('EditCode').Value := Trim(DCode);
|
||
FieldByName('Editer').Value := SGetServerDateTime(ADOQueryTemp);
|
||
end;
|
||
FieldByName('CYID').Value := Trim(maxId);
|
||
if trim(CYNo.Text) = '' then
|
||
CYNo.Text := Trim(maxId);
|
||
SSetsaveSqlNew(ADOQueryCmd, 'CP_YDang', ScrollBox1, 2);
|
||
Post;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select count(*) as AA from CP_YDang where CYNo=''' + Trim(CYNo.Text) + '''');
|
||
Open;
|
||
if FieldByName('AA').AsInteger > 1 then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Result := False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
///////////////////////////////////<2F><>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>//////////////////////////////
|
||
with CDS_YarnJX do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Trim(CDS_YarnJX.fieldbyname('PYId').AsString) = '' then
|
||
begin
|
||
if GetLSNo(ADOQueryTemp, maxpbno, 'PY', 'CP_Plan_Yarn', 4, 1) = False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
maxpbno := Trim(CDS_YarnJX.fieldbyname('PYId').AsString);
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from CP_Plan_Yarn where ');
|
||
sql.Add(' PYId=''' + Trim(maxpbno) + '''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if Trim(CDS_YarnJX.fieldbyname('PYId').AsString) = '' then
|
||
begin
|
||
Append;
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp);
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value := Trim(DName);
|
||
FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp);
|
||
end;
|
||
FieldByName('PYType').Value := '<27><>˿';
|
||
FieldByName('PYID').Value := Trim(maxpbno);
|
||
FieldByName('Y_CYID').Value := Trim(maxId);
|
||
FieldByName('Y_Note_PL').Value := Trim(Y_Note_PLJ.Text);
|
||
RTSetSaveDataCDS(ADOQueryCmd, Tv1, CDS_YarnJX, 'CP_Plan_Yarn', 0);
|
||
Post;
|
||
end;
|
||
CDS_YarnJX.Edit;
|
||
CDS_YarnJX.FieldByName('PYId').Value := Trim(maxpbno);
|
||
Next;
|
||
end;
|
||
end;
|
||
///////////////////////////////////<2F><>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>//////////////////////////////
|
||
|
||
///////////////////////////////////γ˿<CEB3><CBBF><EFBFBD><EFBFBD>//////////////////////////////
|
||
with CDS_YarnWX do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Trim(CDS_YarnWX.fieldbyname('PYId').AsString) = '' then
|
||
begin
|
||
if GetLSNo(ADOQueryTemp, maxpbno, 'PY', 'CP_Plan_Yarn', 4, 1) = False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('γ˿<CEB3><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
maxpbno := Trim(CDS_YarnWX.fieldbyname('PYId').AsString);
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from CP_Plan_Yarn where ');
|
||
sql.Add(' PYId=''' + Trim(maxpbno) + '''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if Trim(CDS_YarnWX.fieldbyname('PYId').AsString) = '' then
|
||
begin
|
||
Append;
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp);
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value := Trim(DName);
|
||
FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp);
|
||
end;
|
||
FieldByName('PYType').Value := 'γ˿';
|
||
FieldByName('PYID').Value := Trim(maxpbno);
|
||
FieldByName('Y_CYID').Value := Trim(maxId);
|
||
FieldByName('Y_Note_PL').Value := Trim(Y_Note_PLW.Text);
|
||
RTSetSaveDataCDS(ADOQueryCmd, Tv2, CDS_YarnWX, 'CP_Plan_Yarn', 0);
|
||
Post;
|
||
end;
|
||
CDS_YarnJX.Edit;
|
||
CDS_YarnJX.FieldByName('PYId').Value := Trim(maxpbno);
|
||
Next;
|
||
end;
|
||
end;
|
||
///////////////////////////////////γ˿<CEB3><CBBF><EFBFBD><EFBFBD>//////////////////////////////
|
||
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
FCYID := maxId;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPAddPN.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if CYNo.Text = '' then
|
||
begin
|
||
Application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if CYName.Text = '' then
|
||
begin
|
||
// Application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
|
||
// Exit;
|
||
CYName.Text := CYNo.Text;
|
||
end;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
|
||
ModalResult := 1;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPAddPN.CYColorKeyPress(Sender: TObject; var Key: Char);
|
||
var
|
||
c: Integer;
|
||
begin
|
||
if Key = '.' then
|
||
begin
|
||
for c := 1 to length(TEdit(Sender).text) do
|
||
begin
|
||
if Tedit(Sender).text[c] = '.' then
|
||
Key := #0;
|
||
end;
|
||
end
|
||
else if Key = #13 then
|
||
PerForm(WM_NEXTDLGCTL, 0, 0)
|
||
else if Key = #8 then
|
||
Key := #8
|
||
else if (Key < '0') or (Key > '9') then
|
||
Key := #0;
|
||
end;
|
||
|
||
procedure TfrmCPAddPN.CYKZExit(Sender: TObject);
|
||
begin
|
||
if pos('GSM', trim(CYKZ.Text)) = 0 then
|
||
CYKZ.Text := trim(CYKZ.Text) + 'GSM';
|
||
end;
|
||
|
||
procedure TfrmCPAddPN.CYMFExit(Sender: TObject);
|
||
begin
|
||
if pos('CM', trim(CYMF.Text)) = 0 then
|
||
CYMF.Text := trim(CYMF.Text) + 'CM';
|
||
end;
|
||
|
||
end.
|
||
|