D10xhGemei/A02基础产品管理/U_ClothInfoInput1.pas
“ddf” 56b1ef408f 1
2024-12-14 17:23:12 +08:00

447 lines
12 KiB
ObjectPascal
Raw Permalink 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_ClothInfoInput1;
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, U_BaseList,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxDateRanges,
dxBarBuiltInMenu, cxCheckBox, cxDropDownEdit, cxContainer, cxMaskEdit,
dxScrollbarAnnotations, cxMemo, dxCore, cxDateUtils, cxCalendar, dxSkinsCore,
dxSkinsDefaultPainters;
type
TfrmClothInfoInput1 = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
TBClose: TToolButton;
ADOQueryCmd: TADOQuery;
ADOQueryTemp: TADOQuery;
ScrollBox1: TScrollBox;
Label1: TLabel;
Label3: TLabel;
C_Code: TcxTextEdit;
ToolButton6: TToolButton;
BCIID: TcxTextEdit;
Label9: TLabel;
C_FromName: TcxButtonEdit;
C_DBNote1: TcxMemo;
Label18: TLabel;
Label19: TLabel;
FtyNo: TcxTextEdit;
FtyName: TcxTextEdit;
Label2: TLabel;
C_DBNote2: TcxMemo;
Label4: TLabel;
C_DBNote3: TcxMemo;
lbl5: TLabel;
CodeDate: TcxDateEdit;
Label5: TLabel;
LSNo: TcxTextEdit;
Label20: TLabel;
C_Texture: TcxButtonEdit;
ADOQueryTemp1: TADOQuery;
procedure FormShow(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure CYColorKeyPress(Sender: TObject; var Key: Char);
procedure CYJGGYBtnDnClick(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure C_GramWeightDblClick(Sender: TObject);
procedure C_FromNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure C_TexturePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
private
canshu1, TempPre, TempLSNo: string;
Fint: Integer;
procedure InitGrid();
function SaveData(): Boolean;
{ Private declarations }
public
FBCIID, FCTID: string;
TempCTName: string;
TypeInt: Integer; //0<><30><EFBFBD><EFBFBD>_1<5F><31><EFBFBD><EFBFBD>_2<5F>޸<EFBFBD>
{ Public declarations }
end;
var
frmClothInfoInput1: TfrmClothInfoInput1;
implementation
uses
U_DataLink, U_RTFun, U_iniParam, U_ZDYHelp, U_AttachmentUpload, U_ClothInfoSel;
{$R *.dfm}
procedure TfrmClothInfoInput1.InitGrid();
begin
with ADOQueryTemp do
begin
Close;
SQL.Clear;
SQL.Add('select * from V_BS_Cloth_Info where BCIID=''' + Trim(FBCIID) + '''');
Open;
end;
SCSHData(ADOQueryTemp, ScrollBox1, 2);
// SCSHData(ADOQueryTemp, ScrollBox1, 0);
C_FromName.Properties.LookupItems.Text := Trim(ADOQueryTemp.fieldbyname('FromBCIID').AsString); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
C_FromName.Text := Trim(ADOQueryTemp.fieldbyname('C_FromName').AsString); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
end;
procedure TfrmClothInfoInput1.C_FromNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmClothInfoSel := TfrmClothInfoSel.Create(Application);
with frmClothInfoSel do
begin
FCTType := '<27><><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
C_FromName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('BCIID').AsString);
C_FromName.Text := Trim(CDS_1.fieldbyname('C_Name').AsString);
end;
end;
finally
frmClothInfoSel.Free;
end;
end;
procedure TfrmClothInfoInput1.C_GramWeightDblClick(Sender: TObject);
var
TempNo: Integer;
begin
TcxButtonEdit(Sender).Text := '';
TcxButtonEdit(Sender).Properties.LookupItems.Text := '';
TempPre := 'P';
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select BHNo from SY_MaxBH where BHStr=''' + Trim(TempPre) + ''' and BHType=''BS_Cloth_Info''');
ExecSQL;
Open;
end;
TempNo := 1;
if ADOQueryTemp.RecordCount > 0 then
begin
TempNo := ADOQueryTemp.FieldByName('BHNo').AsInteger + 1;
end;
LSNo.Text := TempPre + Format('%.3d', [TempNo]);
TempLSNo := LSNo.Text;
end;
procedure TfrmClothInfoInput1.C_TexturePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
var
fsj: string;
FWZ: Integer;
TempNo: Integer;
begin
fsj := Trim(TcxButtonEdit(Sender).Hint);
FWZ := Pos('/', fsj);
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
MainType := 'ClothInfo';
flag := Copy(fsj, 1, FWZ - 1);
flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
fnote := True;
if ShowModal = 1 then
begin
TcxButtonEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
if Trim(ClientDataSet1.fieldbyname('Note').AsString) <> '' then
begin
TcxButtonEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
if Trim(ClientDataSet1.fieldbyname('Note').AsString) <> '' then
begin
TempPre := Trim(ClientDataSet1.fieldbyname('Note').AsString);
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select BHNo from SY_MaxBH where BHStr=''' + Trim(TempPre) + ''' and BHType=''BS_Cloth_Info''');
ExecSQL;
Open;
end;
TempNo := 1;
if ADOQueryTemp.RecordCount > 0 then
begin
TempNo := ADOQueryTemp.FieldByName('BHNo').AsInteger + 1;
end;
LSNo.Text := TempPre + Format('%.3d', [TempNo]);
TempLSNo := LSNo.Text;
end;
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmClothInfoInput1.FormShow(Sender: TObject);
var
TempNo: Integer;
begin
InitGrid();
if TypeInt = 1 then
begin
FBCIID := '';
BCIID.text := '';
C_Code.text := '';
LSNo.Text := '';
C_Texture.Text := '';
end;
if TempCTName = '<27><><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
Label5.Caption := <><D3A1><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>';
Label5.Visible := True;
LSNo.Visible := True;
C_Texture.Visible := True;
Label20.Visible := True;
TempPre := 'P';
end;
if TempCTName = '<27><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
Label5.Caption := <><D1B9><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>';
Label5.Visible := True;
LSNo.Visible := True;
TempPre := 'E';
end;
if TypeInt = 2 then
begin
C_Texture.Enabled := false;
end
else
begin
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select BHNo from SY_MaxBH where BHStr=''' + Trim(TempPre) + ''' and BHType=''BS_Cloth_Info''');
ExecSQL;
Open;
end;
TempNo := 1;
if ADOQueryTemp.RecordCount > 0 then
begin
TempNo := ADOQueryTemp.FieldByName('BHNo').AsInteger + 1;
end;
LSNo.Text := TempPre + Format('%.3d', [TempNo]);
TempLSNo := LSNo.Text;
end;
end;
procedure TfrmClothInfoInput1.TBCloseClick(Sender: TObject);
begin
Close;
end;
function TfrmClothInfoInput1.SaveData(): Boolean;
var
MaxBCIID, MaxBCPID, MaxLSNo: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //////////////////////
if Trim(FBCIID) = '' then
begin
if GetLSNo(ADOQueryCmd, MaxBCIID, 'Y', 'BS_Cloth_Info', 4, 1) = False then
begin
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
BCIID.Text := trim(MaxBCIID);
end
else
begin
MaxBCIID := Trim(FBCIID);
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('update BS_Cloth_Info set DelId=' + quotedstr(DCode) + ',Deler=' + quotedstr(DName) + ',Deltime=GETDATE() where BCIID=''' + Trim(MaxBCIID) + '''');
sql.Add('insert into Bs_Cloth_Info_Log select * from BS_Cloth_Info where BCIID=''' + Trim(MaxBCIID) + '''');
sql.Add('update BS_Cloth_Info set DelId=null,Deler=null,Deltime=null where BCIID=''' + Trim(MaxBCIID) + '''');
ExecSQL;
end;
end;
if TypeInt <> 2 then
begin
if GetLSNo(ADOQueryCmd, MaxLSNo, TempPre, 'BS_Cloth_Info', 3, 0) = False then
begin
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
LSNo.Text := MaxLSNo;
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from BS_Cloth_Info where BCIID=''' + Trim(FBCIID) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FBCIID) = '' then
begin
Append;
FieldByName('CTID').Value := Trim(FCTID);
FieldByName('FILLID').Value := Trim(DCode);
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('BCIID').Value := Trim(MaxBCIID);
if trim(C_Code.Text) = '' then
C_Code.Text := Trim(MaxBCIID);
RTSetsavedata(ADOQueryCmd, 'BS_Cloth_Info', ScrollBox1, 2);
Post;
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('delete BS_Cloth_Info_Link where ToID=''' + Trim(MaxBCIID) + '''');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from BS_Cloth_Info_Link where 1=2');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('ToID').Value := Trim(MaxBCIID);
FieldByName('FromID').Value := Trim(C_FromName.Properties.LookupItems.Text); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select count(*) as AA from BS_Cloth_Info where C_Code=''' + Trim(C_Code.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;
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //////////////////////
///
///
ADOQueryCmd.Connection.CommitTrans;
if TempLSNo <> MaxLSNo then
begin
Application.MessageBox(PChar('<27><>ˮ<EFBFBD><CBAE>' + TempLSNo + '<27>ѱ<EFBFBD>ռ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>Ϊ' + MaxLSNo), '<27><>ʾ', 0);
end;
FBCIID := MaxBCIID;
Result := True;
except
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmClothInfoInput1.CYJGGYBtnDnClick(Sender: TObject);
begin
TBtnEditC(Sender).Text := '';
end;
procedure TfrmClothInfoInput1.ToolButton1Click(Sender: TObject);
var
MC_Code: string;
begin
if LSno.Text = '' then
begin
Application.MessageBox('<27><>ˮ<EFBFBD>Ż<EFBFBD>ȡʧ<C8A1>ܣ<EFBFBD><DCA3><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD>Ӧǰ׺', '<27><>ʾ', 0);
Exit;
end;
if trim(C_Code.Text) = '' then
begin
if GetLSNo(ADOQueryCmd, MC_Code, 'C', 'BS_Cloth_Info', 4, 0) = False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
C_Code.Text := MC_Code;
end;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
ModalResult := 1;
end;
end;
procedure TfrmClothInfoInput1.CYColorKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
SelectNext(ActiveControl as TWinControl, True, True);
end;
end;
procedure TfrmClothInfoInput1.ToolButton6Click(Sender: TObject);
begin
if trim(C_Code.Text) = '' then
Exit;
try
frmAttachmentUpload := TfrmAttachmentUpload.Create(Application);
with frmAttachmentUpload do
begin
FEditAuthority := True;
fkeyNO := trim(C_Code.Text);
fType := '<27><>ƷƷ<C6B7><C6B7><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
end;
end;
finally
frmAttachmentUpload.Free;
end;
end;
end.