RTFormwork/项目代码/RTBasicsV1/D03针织坯布仓库/U_KnitDRQuickInPut.pas

207 lines
5.0 KiB
ObjectPascal
Raw Normal View History

2024-07-07 09:35:27 +08:00
unit U_KnitDRQuickInPut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo,
cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit,
StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxCalendar, StrUtils,
cxDropDownEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels,
cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters,
dxDateRanges, dxBarBuiltInMenu, U_BaseList;
type
TfrmKnitDRQuickInPut = class(Tform)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
ScrollBox1: TScrollBox;
ADOTemp: TADOQuery;
ADOCmd: TADOQuery;
ADOQuery1: TADOQuery;
Label1: TLabel;
OutType: TComboBox;
Note: TEdit;
Label12: TLabel;
Label11: TLabel;
ToCoName: TBtnEditC;
cxStyleRepository1: TcxStyleRepository;
dazi1: TcxStyle;
Label2: TLabel;
DlyDate: TDateTimePicker;
Label27: TLabel;
QtyUnit: TComboBox;
Label5: TLabel;
DRAddWet: TEdit;
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure ToCoNameBtnUpClick(Sender: TObject);
procedure ToCoNameBtnDnClick(Sender: TObject);
private
fuserName: string;
procedure InitData();
function SaveData(): Boolean;
{ Private declarations }
public
PState, CopyInt: Integer;
FDRMID: string;
{ Public declarations }
end;
var
frmKnitDRQuickInPut: TfrmKnitDRQuickInPut;
newh: hwnd;
implementation
uses
U_DataLink, U_ZDYHelp, U_RTFun, U_CompanySel;
{$R *.dfm}
procedure TfrmKnitDRQuickInPut.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmKnitDRQuickInPut.InitData();
var
fsj: string;
begin
if PState = 0 then
begin
DlyDate.DateTime := strtodatetime(Trim(FormatDateTime('yyyy-MM-dd', Now)));
end;
with ADOQuery1 do
begin
Close;
sql.Clear;
sql.Add('select A.* ');
sql.Add(' from Knit_Cloth_DR_Main A');
sql.Add(' where DRMID=''' + Trim(FDRMID) + ''' ');
Open;
end;
SCSHData(ADOQuery1, ScrollBox1, 1);
ToCoName.TxtCode := ADOQuery1.FieldByName('ToCoNo').asstring;
end;
procedure TfrmKnitDRQuickInPut.FormShow(Sender: TObject);
begin
InitData();
end;
function TfrmKnitDRQuickInPut.SaveData(): Boolean;
var
MaxMid, MaxSid: string;
begin
try
ADOCmd.Connection.BeginTrans;
///////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> /////////////////
if Trim(FDRMID) = '' then
begin
if GetLSNo(ADOCmd, MaxMid, 'DM', 'Knit_Cloth_DR_Main', 4, 1) = False then
raise Exception.Create(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
begin
MaxMid := Trim(FDRMID);
end;
with ADOCmd do
begin
Close;
sql.Clear;
SQL.Add('select * from Knit_Cloth_DR_Main where DRMID=''' + Trim(MaxMid) + '''');
Open;
end;
with ADOCmd do
begin
if Trim(FDRMID) = '' 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(ADOTemp);
end;
RTSetsavedata(ADOCmd, 'Knit_Cloth_DR_Main', ScrollBox1, 1);
FieldByName('DRMID').Value := Trim(MaxMid);
FieldByName('ToCoNo').Value := Trim(ToCoName.TxtCode);
FieldByName('Status').Value := '9';
Post;
end;
///////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> /////////////////
FDRMID := Trim(MaxMid);
ADOCmd.Connection.CommitTrans;
Result := True;
except
ADOCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
Result := False;
end;
end;
procedure TfrmKnitDRQuickInPut.TBSaveClick(Sender: TObject);
var
Freal: Double;
begin
ToolBar1.SetFocus;
if Trim(OutType.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
if Trim(ToCoName.Text) = '' then
begin
Application.MessageBox('<27>ջ<EFBFBD><D5BB><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
ModalResult := 1;
end;
end;
procedure TfrmKnitDRQuickInPut.ToCoNameBtnUpClick(Sender: TObject);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27>ͻ<EFBFBD>';
if ShowModal = 1 then
begin
self.ToCoName.TxtCode := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString);
self.ToCoName.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString);
end;
end;
finally
frmCompanySel.Free;
end;
end;
procedure TfrmKnitDRQuickInPut.ToCoNameBtnDnClick(Sender: TObject);
begin
ToCoName.Text := '';
end;
end.