691 lines
18 KiB
ObjectPascal
691 lines
18 KiB
ObjectPascal
unit U_ItemizedListQtyInPut;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
System.Types, 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, dxDateRanges, dxBarBuiltInMenu, U_BaseInput, System.ImageList,
|
||
Vcl.ImgList, ComObj, dxScrollbarAnnotations, cxContainer, dxCore, cxDateUtils,
|
||
cxMaskEdit, cxImageList, cxCurrencyEdit, Vcl.Menus, Clipbrd;
|
||
|
||
type
|
||
TfrmItemizedListQtyInPut = class(TfrmBaseInput)
|
||
DataSource3: TDataSource;
|
||
CDS_Sub: TClientDataSet;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
GPM_1: TcxGridPopupMenu;
|
||
CDS_LM: TClientDataSet;
|
||
OpenDialog1: TOpenDialog;
|
||
pnl1: TPanel;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
tlb1: TToolBar;
|
||
btnAdd: TToolButton;
|
||
btn3: TToolButton;
|
||
btn4: TToolButton;
|
||
pnl2: TPanel;
|
||
inPiece: TcxCurrencyEdit;
|
||
Label9: TLabel;
|
||
inQty: TcxCurrencyEdit;
|
||
Label13: TLabel;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
Tv1Column5: TcxGridDBColumn;
|
||
btndaoru: TToolButton;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
ToolButton2: TToolButton;
|
||
TBSave: TToolButton;
|
||
TBClose: TToolButton;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
ADOQueryBatch: TADOQuery;
|
||
Label1: TLabel;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure FromCoNameDblClick(Sender: TObject);
|
||
procedure inQtyKeyPress(Sender: TObject; var Key: Char);
|
||
procedure btndaoruClick(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
procedure btnAddClick(Sender: TObject);
|
||
procedure Tv1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||
private
|
||
{ Private declarations }
|
||
function SaveData(): Boolean;
|
||
|
||
procedure NianTie();
|
||
function Split(const s: string; Separator: char): TStringDynArray;
|
||
public
|
||
{ Public declarations }
|
||
FTIMId, FTISId, FQtyUnit: string;
|
||
FName, FColor, FColorNo: string;
|
||
end;
|
||
|
||
var
|
||
frmItemizedListQtyInPut: TfrmItemizedListQtyInPut;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_RPFun;
|
||
|
||
{$R *.dfm}
|
||
|
||
// <20>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
function TfrmItemizedListQtyInPut.Split(const s: string; Separator: char): TStringDynArray;
|
||
var
|
||
i, ItemIndex: Integer;
|
||
len: Integer;
|
||
SeparatorCount: Integer;
|
||
Start: Integer;
|
||
begin
|
||
len := Length(s);
|
||
if len = 0 then
|
||
begin
|
||
Result := nil;
|
||
Exit;
|
||
end;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
SeparatorCount := 0;
|
||
for i := 1 to len do
|
||
if s[i] = Separator then
|
||
Inc(SeparatorCount);
|
||
|
||
SetLength(Result, SeparatorCount + 1);
|
||
ItemIndex := 0;
|
||
Start := 1;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||
for i := 1 to len do
|
||
begin
|
||
if s[i] = Separator then
|
||
begin
|
||
Result[ItemIndex] := Copy(s, Start, i - Start);
|
||
Inc(ItemIndex);
|
||
Start := i + 1;
|
||
end;
|
||
end;
|
||
|
||
Result[ItemIndex] := Copy(s, Start, len - Start + 1);
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.N1Click(Sender: TObject);
|
||
var
|
||
hmem: THandle;
|
||
ClipboardText: PChar;
|
||
Lines: TStringDynArray;
|
||
Cells: TStringDynArray;
|
||
i: Integer;
|
||
begin
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ClipboardText<78><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
OpenClipboard(0);
|
||
hmem := GetClipboardData(CF_TEXT);
|
||
|
||
ClipboardText := GlobalLock(hmem);
|
||
|
||
// <20><><EFBFBD>Ȱ<EFBFBD><C8B0><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>
|
||
Lines := Split(ClipboardText, #13); // Windowsϵͳ<CFB5>л<EFBFBD><D0BB>з<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>#13#10
|
||
|
||
// <20><><EFBFBD><EFBFBD>ÿһ<C3BF><D2BB>
|
||
for i := 0 to Length(Lines) - 1 do
|
||
begin
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2>ֳɵ<D6B3>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
Cells := Split(Lines[i], ',');
|
||
|
||
// <20><>ʱCells<6C><73><EFBFBD><EFBFBD><EFBFBD>оʹ洢<CDB4><E6B4A2>ÿһ<C3BF>еĵ<D0B5>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>в<EFBFBD><D0B2>ֺ<EFBFBD><D6BA><EFBFBD>Cells[0]='<27><><EFBFBD><EFBFBD>'<27><>Cells[1]='<27><><EFBFBD><EFBFBD>'<27><>Cells[2]='<27>Ա<EFBFBD>'
|
||
// <20><><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD>ݵ<EFBFBD><DDB5>뵽cxGrid<69><64>
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.NianTie();
|
||
var
|
||
hmem: THandle;
|
||
pstr: PChar;
|
||
ArrStr: TStringList;
|
||
i, x, h, Row, Z: Integer;
|
||
FColumn: string;
|
||
begin
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if IsClipboardFormatAvailable(CF_TEXT) then
|
||
begin
|
||
OpenClipboard(0);
|
||
hmem := GetClipboardData(CF_TEXT);
|
||
pstr := GlobalLock(hmem);
|
||
// Memo1.Text := pstr;
|
||
pstr := PChar(StringReplace(pstr, #$A, #$A#$3F, [rfReplaceAll]));
|
||
// pstr := PAnsiChar(StringReplace(pstr, #$D#$A#$D, #$D#$A#$20#$D, [rfReplaceAll]));
|
||
ArrStr := TStringList.Create;
|
||
ArrStr.Clear;
|
||
ExtractStrings([#13], [], PChar(pstr), ArrStr);
|
||
GlobalUnlock(hmem);
|
||
CloseClipboard;
|
||
end;
|
||
ArrStr.Delete(ArrStr.Count - 1);
|
||
|
||
Row := Tv1.Controller.FocusedRowIndex;
|
||
|
||
CDS_Sub.Locate('xhno', Row + 1, []);
|
||
|
||
x := (Tv1.DataController.RowCount - (Row + 1));
|
||
|
||
// showmessage(ArrStr.Text);
|
||
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
||
if x < ArrStr.count then
|
||
begin
|
||
for i := x to ArrStr.count - 2 do
|
||
begin
|
||
if VarIsNull(Tv1.DataController.Summary.FooterSummaryValues[0]) = True then
|
||
begin
|
||
h := 0;
|
||
end
|
||
else
|
||
h := Tv1.DataController.Summary.FooterSummaryValues[0];
|
||
h := h + 1;
|
||
with CDS_Sub do
|
||
begin
|
||
Append;
|
||
FieldByName('XHNO').Value := IntToStr(h);
|
||
Post;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
CDS_Sub.Locate('xhno', Row + 1, []);
|
||
i := 0;
|
||
Z := 0;
|
||
|
||
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
||
|
||
with CDS_Sub do
|
||
begin
|
||
DisableControls;
|
||
while not Eof do
|
||
begin
|
||
edit;
|
||
if ArrStr.Count > i then
|
||
begin
|
||
CDS_Sub.FieldByName(FColumn).Value := StringReplace(ArrStr[i], '?', '', [rfReplaceAll]);
|
||
end
|
||
else
|
||
Break;
|
||
i := i + 1;
|
||
Post;
|
||
Next;
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.btnAddClick(Sender: TObject);
|
||
begin
|
||
if CDS_Sub.IsEmpty = False then
|
||
begin
|
||
CopyAddRowCDS(CDS_Sub);
|
||
with CDS_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('BCIOID').Value := null;
|
||
FieldByName('StkCoNo').Value := '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>';
|
||
FieldByName('StkCoName').Value := '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>';
|
||
post;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
with CDS_Sub do
|
||
begin
|
||
Append;
|
||
FieldByName('IOTime').Value := Trim(FormatDateTime('yyyy-MM-dd', Now));
|
||
FieldByName('StkCoNo').Value := '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>';
|
||
FieldByName('StkCoName').Value := '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>';
|
||
FieldByName('QtyUnit').Value := 'M';
|
||
Post;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.btndaoruClick(Sender: TObject);
|
||
var
|
||
excelApp, WorkBook: Variant;
|
||
i, j, k, LX, ExcelRowCount: integer;
|
||
maxId, FCPID, FCPName, t1, t2, t3, FFID: string;
|
||
begin
|
||
|
||
try
|
||
excelApp := CreateOleObject('Excel.Application');
|
||
openDialog1.Filter := '*.CSV;*.xls';
|
||
if opendialog1.Execute then
|
||
begin
|
||
WorkBook := excelApp.WorkBooks.Open(OpenDialog1.FileName);
|
||
end
|
||
else
|
||
exit;
|
||
excelApp.Visible := false;
|
||
ExcelRowCount := WorkBook.WorkSheets[1].UsedRange.Rows.Count;
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>EXCEL<45><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
|
||
CDS_LM.EmptyDataSet;
|
||
|
||
for j := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
with CDS_LM do
|
||
begin
|
||
Append;
|
||
FieldByName('LCode').Value := trim(Tv1.Columns[j].DataBinding.FieldName);
|
||
FieldByName('LName').Value := trim(Tv1.Columns[j].Caption);
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
try
|
||
for i := 1 to 50 do
|
||
begin
|
||
if trim(WorkBook.WorkSheets[1].Cells[1, i].value) = '' then
|
||
continue;
|
||
if CDS_LM.Locate('LName', trim(WorkBook.WorkSheets[1].Cells[1, i].value), []) then
|
||
begin
|
||
with CDS_LM do
|
||
begin
|
||
Edit;
|
||
FieldByName('LXH').Value := i;
|
||
Post;
|
||
end;
|
||
end;
|
||
end;
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
|
||
try
|
||
for i := 2 to ExcelRowCount do
|
||
begin
|
||
with CDS_Sub do
|
||
begin
|
||
Append;
|
||
CDS_LM.First;
|
||
while not CDS_LM.Eof do
|
||
begin
|
||
if CDS_LM.FieldByName('LXH').AsInteger > 0 then
|
||
CDS_Sub.fieldbyname(CDS_LM.FieldByName('LCode').AsString).Value := WorkBook.WorkSheets[1].Cells[i, CDS_LM.FieldByName('LXH').AsInteger].Value;
|
||
CDS_LM.Next;
|
||
end;
|
||
Post;
|
||
end;
|
||
end;
|
||
WorkBook.Close;
|
||
excelApp.Quit;
|
||
excelApp := Unassigned;
|
||
WorkBook := Unassigned;
|
||
except
|
||
WorkBook.Close;
|
||
excelApp.Quit;
|
||
excelApp := Unassigned;
|
||
WorkBook := Unassigned;
|
||
exit;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
function TfrmItemizedListQtyInPut.SaveData(): Boolean;
|
||
var
|
||
Maxno, MBCIOID: string;
|
||
begin
|
||
try
|
||
ADOQueryBatch.Connection.BeginTrans;
|
||
CDS_Sub.DisableControls;
|
||
with CDS_Sub do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from BS_Cloth_IO where BCIOID=''' + Trim(CDS_Sub.fieldbyname('BCIOID').AsString) + '''');
|
||
open;
|
||
end;
|
||
MBCIOID := Trim(ADOQueryTemp.fieldbyname('BCIOID').AsString);
|
||
if Trim(MBCIOID) = '' then
|
||
begin
|
||
if not GetLSNo(ADOQueryBatch, Maxno, 'MR', 'BS_Cloth_IO', 4, 1) then
|
||
raise Exception.Create('ȡȾɫ<C8BE><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
||
end
|
||
else
|
||
begin
|
||
Maxno := Trim(MBCIOID);
|
||
end;
|
||
with ADOQueryBatch do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from BS_Cloth_IO where BCIOID=''' + Trim(Maxno) + '''');
|
||
Open;
|
||
end;
|
||
with ADOQueryBatch do
|
||
begin
|
||
if Trim(MBCIOID) = '' then
|
||
begin
|
||
Append;
|
||
FieldByName('Fillid').Value := Trim(Dcode);
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
FieldByName('BCIOID').Value := Trim(Maxno);
|
||
FieldByName('STKID').Value := Trim(Maxno);
|
||
FieldByName('CIID').Value := Trim(Maxno);
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editid').Value := Trim(Dcode);
|
||
FieldByName('Editer').Value := Trim(DName);
|
||
FieldByName('EditTime').Value := SGetServerDate(ADOQueryTemp);
|
||
end;
|
||
RTSetSaveDataCDS(ADOQueryBatch, Tv1, CDS_Sub, 'BS_Cloth_IO', 0);
|
||
FieldByName('STKName').Value := 'ó<>ײ<EFBFBD>ƥ';
|
||
FieldByName('IOFlag').Value := '<27><><EFBFBD><EFBFBD>';
|
||
FieldByName('IOQtyFlag').Value := 1;
|
||
FieldByName('Piece').Value := 1;
|
||
FieldByName('Qty').Value := CDS_Sub.FieldByName('Qty').Value;
|
||
FieldByName('TIMId').Value := FTIMId;
|
||
FieldByName('TISId').Value := FTISId;
|
||
FieldByName('QtyUnit').Value := FQtyUnit;
|
||
Post;
|
||
end;
|
||
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
CDS_Sub.EnableControls;
|
||
with ADOQueryBatch do
|
||
begin
|
||
Close;
|
||
Sql.Clear;
|
||
|
||
Sql.Add('exec P_BS_Cloth_UpdateByItemizedList ');
|
||
Sql.Add(' @TIMId=' + quotedstr(Trim(FTIMId)));
|
||
Sql.Add(',@DCode=' + quotedstr(Trim(DCode)));
|
||
Sql.Add(',@DName=' + quotedstr(Trim(DName)));
|
||
Open;
|
||
end;
|
||
if ADOQueryBatch.FieldByName('intReturn').AsInteger = -1 then
|
||
raise Exception.Create(pchar(trim(ADOQueryBatch.FieldByName('ShowMsg').AsString)));
|
||
// ADOQueryBatch.UpdateBatch;
|
||
ADOQueryBatch.Connection.CommitTrans;
|
||
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
ADOQueryBatch.Connection.RollbackTrans;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ReadCxGrid('<27>뵥<EFBFBD>Ǽ<EFBFBD>', Tv1, 'ó<><EFBFBD><D7BB>ֿܲ<DCB2>');
|
||
Label1.Caption := 'ɫ<><C9AB><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>' + FName + ' <20><>ɫ<EFBFBD><C9AB>' + FColor + ' ɫ<>ţ<EFBFBD>' + FColorNo;
|
||
with CDS_LM do
|
||
begin
|
||
FieldDefs.Clear;
|
||
FieldDefs.Add('LXH', ftInteger, 0);
|
||
FieldDefs.Add('lCode', ftString, 40);
|
||
FieldDefs.Add('LName', ftString, 40);
|
||
close;
|
||
CreateDataSet;
|
||
end;
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ');
|
||
sql.Add(' from BS_Cloth_IO A');
|
||
sql.Add(' where ioflag=''<27><><EFBFBD><EFBFBD>'' and TISId=''' + Trim(FTISId) + '''');
|
||
sql.Add(' order by qty desc ');
|
||
Open;
|
||
end;
|
||
|
||
SCreateCDS(ADOQueryTemp, CDS_Sub);
|
||
SInitCDSData(ADOQueryTemp, CDS_Sub);
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.FromCoNameDblClick(Sender: TObject);
|
||
begin
|
||
TcxButtonEdit(Sender).Text := '';
|
||
TcxButtonEdit(Sender).Properties.LookupItems.Text := '';
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.inQtyKeyPress(Sender: TObject; var Key: Char);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
if Key = #13 then
|
||
begin
|
||
with CDS_Sub do
|
||
begin
|
||
DisableControls;
|
||
for i := 1 to StrToIntDef(inPiece.Text, 1) do
|
||
begin
|
||
Append;
|
||
|
||
if FQtyUnit = 'M' then
|
||
begin
|
||
FieldByName('Meter').Value := StrTofloatDef(inQty.Text, 0);
|
||
end
|
||
else if FQtyUnit = 'Y' then
|
||
begin
|
||
FieldByName('Yardage').Value := StrTofloatDef(inQty.Text, 0);
|
||
end
|
||
else
|
||
begin
|
||
FieldByName('NetWeight').Value := StrTofloatDef(inQty.Text, 0);
|
||
end;
|
||
|
||
Post;
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
inPiece.Text := '1';
|
||
inQty.Text := '';
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_Sub.IsEmpty then
|
||
Exit;
|
||
if Trim(CDS_Sub.fieldbyname('BCIOID').AsString) <> '' then
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_Fin_Flow_Judge ');
|
||
Sql.Add(' @FFIDS=' + quotedstr(Trim(CDS_Sub.fieldbyname('BCIOID').AsString)));
|
||
Sql.Add(',@DCode=' + quotedstr(Trim(DCode)));
|
||
Sql.Add(',@DName=' + quotedstr(Trim(DName)));
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('intReturn').AsInteger = -1 then
|
||
begin
|
||
Application.MessageBox(PChar(ADOQueryTemp.fieldbyname('ShowMsg').AsString), '<27><>ʾ', 0);
|
||
exit;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
Sql.Clear;
|
||
sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails) ');
|
||
sql.Add('values(''ó<><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
||
sql.Add(',' + quotedstr(Trim(CDS_Sub.fieldbyname('BCIOID').AsString)));
|
||
sql.Add(',''ɾ<><C9BE>'' ');
|
||
sql.Add(',' + quotedstr(DName));
|
||
sql.Add(',' + quotedstr(trim(self.Caption)));
|
||
sql.Add(',' + quotedstr(Trim(CDS_Sub.fieldbyname('BCIOID').AsString)));
|
||
sql.Add(') ');
|
||
|
||
Sql.Add('exec P_BS_Cloth_In_Del ');
|
||
Sql.Add(' @BCIOIDS=' + quotedstr(Trim(CDS_Sub.fieldbyname('BCIOID').AsString)));
|
||
Sql.Add(',@DCode=' + quotedstr(Trim(DCode)));
|
||
Sql.Add(',@DName=' + quotedstr(Trim(DName)));
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
|
||
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
CDS_Sub.Delete;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
CDS_Sub.Delete;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.TBSaveClick(Sender: TObject);
|
||
var
|
||
Maxno: string;
|
||
begin
|
||
if CDS_Sub.IsEmpty then
|
||
Exit;
|
||
with CDS_Sub do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
|
||
Edit;
|
||
if FQtyUnit = 'M' then
|
||
begin
|
||
FieldByName('Qty').Value := FieldByName('Meter').Value;
|
||
end
|
||
else if FQtyUnit = 'Y' then
|
||
begin
|
||
FieldByName('Qty').Value := FieldByName('Yardage').Value;
|
||
end
|
||
else
|
||
begin
|
||
FieldByName('Qty').Value := FieldByName('NetWeight').Value;
|
||
end;
|
||
|
||
Post;
|
||
Next;
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
if CDS_Sub.Locate('Qty', null, []) = True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if CDS_Sub.Locate('Qty', 0, []) = True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
||
ModalResult := 1;
|
||
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.ToolButton2Click(Sender: TObject);
|
||
var
|
||
MFiltration: string;
|
||
MPrintJson: string;
|
||
begin
|
||
if CDS_sub.IsEmpty then
|
||
Exit;
|
||
|
||
if CDS_Sub.Locate('BCIOID', '', []) = True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if CDS_Sub.Locate('BCIOID', null, []) = True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
MFiltration := '';
|
||
with CDS_sub do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
MFiltration := MFiltration + ',' + CDS_sub.FieldByName('BCIOID').AsString;
|
||
next;
|
||
end;
|
||
end;
|
||
|
||
MPrintJson := ' {"LMType": "TradeFinishClothInPrt1" ';
|
||
MPrintJson := MPrintJson + ' ,"PreviewPrint": true ';
|
||
MPrintJson := MPrintJson + ' ,"PrtArgs": [ { "IsSql": false, "Filtration":" ' + MFiltration + '" }, ';
|
||
MPrintJson := MPrintJson + ' { "IsSql": false, "Filtration":" ' + MFiltration + '" }, ';
|
||
MPrintJson := MPrintJson + ' { "IsSql": false, "Filtration":" ' + MFiltration + '" }, ';
|
||
MPrintJson := MPrintJson + ' { "IsSql": false, "Filtration":" ' + MFiltration + '" }, ';
|
||
MPrintJson := MPrintJson + ' { "IsSql": false, "Filtration":" ' + MFiltration + '" } ] } ';
|
||
FromPrintFr3(Application, PChar(DConString), PChar(MPrintJson));
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.ToolButton5Click(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmItemizedListQtyInPut.Tv1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||
begin
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> Ctrl+V
|
||
if (Key = Ord('V')) and (Shift = [ssCtrl]) then
|
||
begin
|
||
pasteDatatTocxGrid(Tv1);
|
||
|
||
end;
|
||
|
||
end;
|
||
|
||
end.
|
||
|