RTFormwork/项目代码/RTBasicsV1/B02基础纱线仓库/U_YarnInfoInPut.pas

239 lines
6.6 KiB
ObjectPascal
Raw Normal View History

2024-07-07 09:35:27 +08:00
unit U_YarnInfoInPut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit, ComCtrls, ToolWin,
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxClasses, cxControls, cxGridCustomView, cxGrid, cxGridCustomPopupMenu,
cxGridPopupMenu, ADODB, DBClient, cxButtonEdit, cxTextEdit, StdCtrls, ExtCtrls,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseInput,
2024-07-07 19:26:56 +08:00
U_BaseList, System.ImageList, Vcl.ImgList, cxContainer, dxSkinWXI, cxMaskEdit,
cxMemo, dxSkinBasic, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel,
dxSkinCoffee, dxSkinDarkroom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinOffice2016Colorful,
dxSkinOffice2016Dark, dxSkinOffice2019Black, dxSkinOffice2019Colorful,
dxSkinOffice2019DarkGray, dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven,
dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
dxSkinSpringtime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
dxSkinTheBezier, dxSkinValentine, dxSkinVisualStudio2013Blue,
dxSkinVisualStudio2013Dark, dxSkinVisualStudio2013Light, dxSkinVS2010,
dxSkinWhiteprint, dxSkinXmas2008Blue, cxImageList;
2024-07-07 09:35:27 +08:00
type
TfrmYarnInfoInPut = class(TfrmBaseInput)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
ToolButton1: TToolButton;
ScrollBox1: TScrollBox;
Label2: TLabel;
Label6: TLabel;
Label7: TLabel;
Label1: TLabel;
2024-07-07 19:26:56 +08:00
Brand: TcxTextEdit;
Y_Name: TcxTextEdit;
2024-07-07 09:35:27 +08:00
Label3: TLabel;
2024-07-07 19:26:56 +08:00
Y_Code: TcxTextEdit;
2024-07-07 09:35:27 +08:00
Label4: TLabel;
Label8: TLabel;
2024-07-07 19:26:56 +08:00
Denier: TcxTextEdit;
Y_Spec: TcxTextEdit;
2024-07-07 09:35:27 +08:00
Label9: TLabel;
2024-07-07 19:26:56 +08:00
Y_Color: TcxTextEdit;
Note: TcxMemo;
Y_Type: TcxComboBox;
Y_Composition: TcxTextEdit;
Label5: TLabel;
ADOConnection1: TADOConnection;
cxImageList_bar: TcxImageList;
2024-07-07 09:35:27 +08:00
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
2024-07-07 19:26:56 +08:00
procedure FormCreate(Sender: TObject);
2024-07-07 09:35:27 +08:00
private
{ Private declarations }
function SaveData(): Boolean;
public
{ Public declarations }
FBYIID, FSTKName: string;
end;
var
frmYarnInfoInPut: TfrmYarnInfoInPut;
implementation
uses
2024-07-07 19:26:56 +08:00
U_DataLink, U_RTFun, U_ZDYHelp; //, U_ProductInfoSel
2024-07-07 09:35:27 +08:00
{$R *.dfm}
procedure TfrmYarnInfoInPut.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
function TfrmYarnInfoInPut.SaveData(): Boolean;
var
MaxNo, MaxPRID: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FBYIID) = '' then
begin
if GetLSNo(ADOQueryCmd, MaxNo, 'P', 'BS_Yarn_Info', 4, 0) = False then
raise Exception.Create(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
2024-07-07 19:26:56 +08:00
Y_Code.Text := MaxNo;
2024-07-07 09:35:27 +08:00
end
else
begin
MaxNo := Trim(FBYIID);
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from BS_Yarn_Info where BYIID=''' + Trim(MaxNo) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FBYIID) = '' then
begin
Append;
FieldByName('FillId').Value := Trim(DCode);
FieldByName('Filler').Value := Trim(DName);
end
else
begin
Edit;
FieldByName('EditId').Value := Trim(DCode);
FieldByName('Editer').Value := Trim(DName);
FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp);
end;
FieldByName('BYIID').Value := Trim(MaxNo);
RTSetsavedata(ADOQueryCmd, 'BS_Yarn_Info', ScrollBox1, 2);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from BS_Yarn_Info where Y_Code=' + quotedstr(trim(Y_Code.Text)));
Open;
end;
if ADOQueryCmd.RecordCount > 1 then
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!');
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from BS_Yarn_Info where Y_Name=' + quotedstr(trim(Y_Name.Text)));
Open;
end;
if ADOQueryCmd.RecordCount > 1 then
raise Exception.Create('Ʒ<><C6B7><EFBFBD>ظ<EFBFBD>!');
ADOQueryCmd.Connection.CommitTrans;
Result := True;
except
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmYarnInfoInPut.TBCloseClick(Sender: TObject);
begin
Close;
end;
2024-07-07 19:26:56 +08:00
procedure TfrmYarnInfoInPut.FormCreate(Sender: TObject);
begin
inherited;
try
with ADOConnection1 do
begin
Connected := false;
ConnectionString := DConString;
Connected := true;
end;
ADOQueryBaseCmd.Connection := ADOConnection1;
ADOQueryBaseTemp.Connection := ADOConnection1;
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
end;
end;
2024-07-07 09:35:27 +08:00
procedure TfrmYarnInfoInPut.FormShow(Sender: TObject);
var
fsj: string;
begin
inherited;
fsj := ' select Code=ZDYNo,Name=ZDYName from KH_ZDY where Type=''YType'' and MainType='<>ߵ<EFBFBD><DFB5><EFBFBD>'' ';
2024-07-07 19:26:56 +08:00
SInitTcxComBoxBySql(ADOQueryTemp, Y_Type, TRUE, fsj);
2024-07-07 09:35:27 +08:00
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add(' select * from BS_Yarn_Info ');
sql.Add(' where BYIID=''' + Trim(FBYIID) + '''');
Open;
end;
SCSHData(ADOQueryTemp, ScrollBox1, 2);
end;
procedure TfrmYarnInfoInPut.TBSaveClick(Sender: TObject);
begin
2024-07-07 19:26:56 +08:00
// if Trim(Y_Code.Text) = '' then
// begin
// Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
// Exit;
// end;
2024-07-07 09:35:27 +08:00
if Trim(Y_Name.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
2024-07-07 19:26:56 +08:00
if Trim(Denier.Text) <> '' then
begin
if StrToFloatdef(Denier.Text, 0) = 0 then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>D<EFBFBD><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
end;
2024-07-07 09:35:27 +08:00
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
ModalResult := 1;
Exit;
end;
end;
end.