RTFormwork/项目代码/RTBasicsV1/B02基础纱线仓库/U_YarnInfoInPut.pas
“ddf” 719cdbc141 1
2024-07-07 19:26:56 +08:00

239 lines
6.6 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_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,
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;
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;
Brand: TcxTextEdit;
Y_Name: TcxTextEdit;
Label3: TLabel;
Y_Code: TcxTextEdit;
Label4: TLabel;
Label8: TLabel;
Denier: TcxTextEdit;
Y_Spec: TcxTextEdit;
Label9: TLabel;
Y_Color: TcxTextEdit;
Note: TcxMemo;
Y_Type: TcxComboBox;
Y_Composition: TcxTextEdit;
Label5: TLabel;
ADOConnection1: TADOConnection;
cxImageList_bar: TcxImageList;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
function SaveData(): Boolean;
public
{ Public declarations }
FBYIID, FSTKName: string;
end;
var
frmYarnInfoInPut: TfrmYarnInfoInPut;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp; //, U_ProductInfoSel
{$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>');
Y_Code.Text := MaxNo;
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;
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;
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>'' ';
SInitTcxComBoxBySql(ADOQueryTemp, Y_Type, TRUE, fsj);
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
// if Trim(Y_Code.Text) = '' then
// begin
// Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
// Exit;
// end;
if Trim(Y_Name.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
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;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
ModalResult := 1;
Exit;
end;
end;
end.