D10myBiaoqi/A02基础产品管理/U_TatClothInfoInput.pas

352 lines
8.2 KiB
ObjectPascal
Raw Permalink Normal View History

2024-07-04 16:01:24 +08:00
unit U_TatClothInfoInput;
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, dxSkinsCore, dxSkinsDefaultPainters,
cxNavigator, dxDateRanges, dxBarBuiltInMenu;
type
TfrmTatClothInfoInput = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
TBClose: TToolButton;
ADOQueryMain: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryTemp: TADOQuery;
ScrollBox1: TScrollBox;
Label1: TLabel;
Label5: TLabel;
Label15: TLabel;
Label22: TLabel;
Label2: TLabel;
Label4: TLabel;
Label3: TLabel;
C_Code: TEdit;
C_Name: TEdit;
C_YarnQty: TEdit;
C_FinishLatitudeDensity: TEdit;
C_Width: TBtnEditC;
C_GramWeight: TBtnEditC;
Label12: TLabel;
C_FinishLongitudeDensity: TEdit;
ToolButton6: TToolButton;
BCIID: TEdit;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
C_LatitudeSpec: TEdit;
C_LongitudeSpec: TEdit;
C_ReedNo: TEdit;
Label9: TLabel;
C_Spec: TEdit;
Label10: TLabel;
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);
procedure FormCreate(Sender: TObject);
procedure CYJGGYBtnDnClick(Sender: TObject);
procedure C_WidthBtnDnClick(Sender: TObject);
procedure C_WidthBtnUpClick(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
private
canshu1: string;
Fint: Integer;
procedure InitGrid();
function SaveData(): Boolean;
{ Private declarations }
public
FBCIID, FCTID, FCTName: string;
CopyInt: Integer;
{ Public declarations }
end;
var
frmTatClothInfoInput: TfrmTatClothInfoInput;
implementation
uses
U_DataLink, U_RTFun, U_iniParam, U_ZDYHelp, U_AttachmentUpload;
{$R *.dfm}
procedure TfrmTatClothInfoInput.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
SQL.Clear;
SQL.Add('select * from BS_Cloth_Info where BCIID=''' + Trim(FBCIID) + '''');
Open;
end;
SCSHData(ADOQueryMain, ScrollBox1, 2);
SCSHData(ADOQueryMain, ScrollBox1, 0);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmTatClothInfoInput.FormShow(Sender: TObject);
begin
InitGrid();
if CopyInt = 1 then
begin
FBCIID := '';
BCIID.text := '';
C_Code.text := '';
end;
// if C_Code.text = '' then
// begin
// with ADOQueryTemp do
// begin
// Close;
// sql.Clear;
// sql.Add(' exec P_YP_Get_CPBH ');
// sql.Add('@CTID=' + quotedstr(Trim(FCTID)));
//
// Open;
// end;
// end;
// if trim(C_Code.Text) = '' then
// begin
// with ADOQueryTemp do
// begin
// Close;
// sql.Clear;
// sql.Add(' exec P_YP_Get_No @Str=''CP'' ');
// Open;
// end;
// C_Code.Text := trim(ADOQueryTemp.FieldByName('NewC_Code').asstring);
// end;
// if FCPName = '<27><>֯' then
// begin
// CYPUnit.text := 'KG';
// end;
// if FCPName = '<27><>֯' then
// begin
// CYPUnit.text := 'M';
// end;
end;
procedure TfrmTatClothInfoInput.TBCloseClick(Sender: TObject);
begin
Close;
end;
function TfrmTatClothInfoInput.SaveData(): Boolean;
var
maxId, maxno: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FBCIID) = '' then
begin
if GetLSNo(ADOQueryCmd, maxId, '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(maxId);
end
else
begin
maxId := Trim(FBCIID);
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(maxId);
if trim(C_Code.Text) = '' then
C_Code.Text := Trim(maxId);
RTSetsavedata(ADOQueryCmd, 'BS_Cloth_Info', ScrollBox1, 2);
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;
ADOQueryCmd.Connection.CommitTrans;
FBCIID := maxId;
Result := True;
except
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
end;
end;
procedure TfrmTatClothInfoInput.CYJGGYBtnDnClick(Sender: TObject);
begin
TBtnEditC(Sender).Text := '';
end;
procedure TfrmTatClothInfoInput.ToolButton1Click(Sender: TObject);
var
MC_Code: string;
begin
if C_Name.Text = '' then
begin
Application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ʋ<EFBFBD><C6B2><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 TfrmTatClothInfoInput.CYColorKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
SelectNext(ActiveControl as TWinControl, True, True);
end;
end;
procedure TfrmTatClothInfoInput.CYKZExit(Sender: TObject);
begin
// if pos('G/M2', trim(CYKZ.Text)) = 0 then
// begin
// if pos('G/M', trim(CYKZ.Text)) = 0 then
// begin
// CYKZ.Text := trim(CYKZ.Text) + 'G/M2';
// end;
// end;
end;
procedure TfrmTatClothInfoInput.C_WidthBtnDnClick(Sender: TObject);
begin
TBtnEditC(Sender).Text := '';
TBtnEditC(Sender).TxtCode := '';
end;
procedure TfrmTatClothInfoInput.C_WidthBtnUpClick(Sender: TObject);
var
fsj: string;
FWZ: Integer;
begin
fsj := Trim(TEdit(Sender).Hint);
FWZ := Pos('/', fsj);
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := Copy(fsj, 1, FWZ - 1);
flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
if ShowModal = 1 then
begin
TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmTatClothInfoInput.CYMFExit(Sender: TObject);
begin
// if pos('"', trim(CYMF.Text)) = 0 then
// begin
// if pos('CM', trim(CYMF.Text)) = 0 then
// CYMF.Text := trim(CYMF.Text) + 'CM';
// end;
end;
procedure TfrmTatClothInfoInput.FormCreate(Sender: TObject);
begin
// LaYangDate.DateTime := SGetServerDateTime(ADOQueryTemp);
end;
procedure TfrmTatClothInfoInput.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><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
end;
end;
finally
frmAttachmentUpload.Free;
end;
end;
end.