766 lines
21 KiB
ObjectPascal
766 lines
21 KiB
ObjectPascal
unit U_finishSalesConInput;
|
||
|
||
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, dxSkinsCore, dxSkinsDefaultPainters, cxNavigator,
|
||
dxDateRanges, dxBarBuiltInMenu, dxDateTimeWheelPicker, dxGDIPlusClasses,
|
||
Vcl.Menus, MovePanel, cxCheckBox, cxImage, cxDBEdit, Vcl.DBCtrls, U_BaseInput,
|
||
System.ImageList, Vcl.ImgList, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, IdExplicitTLSClientServerBase, IdFTP, ShellAPI,
|
||
dxSkinOffice2013White, dxSkinSharpPlus, dxSkinWXI, dxScrollbarAnnotations,
|
||
dxCore, cxDateUtils, cxImageList, cxCurrencyEdit;
|
||
|
||
type
|
||
TfrmfinishSalesConInput = class(TfrmBaseInput)
|
||
ToolBar1: TToolBar;
|
||
TBSave: TToolButton;
|
||
TBClose: TToolButton;
|
||
ScrollBox1: TScrollBox;
|
||
Label3: TLabel;
|
||
ToolBar2: TToolBar;
|
||
ToolButton1: TToolButton;
|
||
ToolButton2: TToolButton;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
ADOTemp: TADOQuery;
|
||
ADOCmd: TADOQuery;
|
||
DS_1: TDataSource;
|
||
Order_Sub: TClientDataSet;
|
||
v1PRTOrderQty: TcxGridDBColumn;
|
||
Label10: TLabel;
|
||
ConNo: TcxTextEdit;
|
||
Label14: TLabel;
|
||
v1XHNo: TcxGridDBColumn;
|
||
v1OrderUnit: TcxGridDBColumn;
|
||
Label6: TLabel;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
VC_SCSCode: TcxGridDBColumn;
|
||
cxgrdpmn1: TcxGridPopupMenu;
|
||
v1Column1: TcxGridDBColumn;
|
||
pm_sub: TPopupMenu;
|
||
N1: TMenuItem;
|
||
Tv1Column7: TcxGridDBColumn;
|
||
DataSource1: TDataSource;
|
||
ADOQueryImage: TADOQuery;
|
||
DS_ImgHX: TDataSource;
|
||
Qry_ImgHX: TADOQuery;
|
||
IdFTP1: TIdFTP;
|
||
Label15: TLabel;
|
||
Label16: TLabel;
|
||
PackSeal: TBtnEditC;
|
||
Label17: TLabel;
|
||
N2: TMenuItem;
|
||
DlyNote: TcxTextEdit;
|
||
ToolButton3: TToolButton;
|
||
lblSalesId: TLabel;
|
||
Label25: TLabel;
|
||
SalesId: TcxTextEdit;
|
||
TallyId: TcxTextEdit;
|
||
BuyName: TcxButtonEdit;
|
||
QtyNote: TcxButtonEdit;
|
||
ConDate: TcxDateEdit;
|
||
ToolButton4: TToolButton;
|
||
Label1: TLabel;
|
||
DlyDate: TcxDateEdit;
|
||
Tv1density: TcxGridDBColumn;
|
||
Tv1C_WidthUnit: TcxGridDBColumn;
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
|
||
procedure N1Click(Sender: TObject);
|
||
procedure Pic_Image1DblClick(Sender: TObject);
|
||
|
||
procedure N2Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
private
|
||
FLeft, FTop: Integer;
|
||
fuserName, Fstatus: string;
|
||
procedure JSMoney();
|
||
procedure InitData();
|
||
function TestData(): Boolean;
|
||
function SaveData(): Boolean;
|
||
procedure SetXH();
|
||
procedure LookImage(FileName: string);
|
||
{ Private declarations }
|
||
public
|
||
CopyInt: Integer;
|
||
PState: string;
|
||
fFlileFlag: string;
|
||
FConMId: string;
|
||
FAuthority, FGSTT: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmfinishSalesConInput: TfrmfinishSalesConInput;
|
||
newh: hwnd;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp, U_CompanySel, U_ClothInfoSel,
|
||
U_PictureUpload11, U_TatClothInfoSel, U_BankSel;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmfinishSalesConInput.SetXH();
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with Order_Sub do
|
||
begin
|
||
First;
|
||
i := 1;
|
||
while not Eof do
|
||
begin
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('XHNoTemp').Value := i;
|
||
Post;
|
||
end;
|
||
i := i + 1;
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
with Order_Sub do
|
||
begin
|
||
Order_Sub.IndexFieldNames := '';
|
||
First;
|
||
i := 1;
|
||
while not Eof do
|
||
begin
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('SerialNo').Value := FieldByName('XHNoTemp').AsInteger;
|
||
Post;
|
||
end;
|
||
i := i + 1;
|
||
Next;
|
||
end;
|
||
Order_Sub.IndexFieldNames := 'SerialNo';
|
||
end;
|
||
|
||
end;
|
||
|
||
|
||
procedure TfrmfinishSalesConInput.JSMoney();
|
||
var
|
||
FConQty, FConPrice, FC_Money: Double;
|
||
begin
|
||
with Order_Sub do
|
||
begin
|
||
FConQty := Fieldbyname('ConQty').AsFloat;
|
||
FConPrice := Fieldbyname('ConPrice').AsFloat;
|
||
end;
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEA3AC><EFBFBD><EFBFBD>2λС<CEBB><D0A1>
|
||
FC_Money := RoundFloat(FConQty * FConPrice, 2);
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('ConTotalAmount').Value := FC_Money;
|
||
Post;
|
||
end;
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
function TfrmfinishSalesConInput.TestData(): Boolean;
|
||
begin
|
||
try
|
||
if Trim(ConNo.Text) = '' then
|
||
raise Exception.Create('<27><>ͬ<EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
|
||
if Order_Sub.Locate('C_Code', null, []) then
|
||
raise Exception.Create('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
if Order_Sub.Locate('C_Code', '', []) then
|
||
raise Exception.Create('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
if Order_Sub.Locate('C_Name', null, []) then
|
||
raise Exception.Create('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
if Order_Sub.Locate('C_Name', '', []) then
|
||
raise Exception.Create('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
// if Order_Sub.Locate('C_Color', null, []) then
|
||
// raise Exception.Create('<27><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
// if Order_Sub.Locate('C_Color', '', []) then
|
||
// raise Exception.Create('<27><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
|
||
|
||
|
||
// if Order_Sub.Locate('C_MF', null, []) then
|
||
// raise Exception.Create('<27>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
// if Order_Sub.Locate('C_MF', '', []) then
|
||
// raise Exception.Create('<27>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
// if Order_Sub.Locate('C_KZ', null, []) then
|
||
// raise Exception.Create('<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
// if Order_Sub.Locate('C_KZ', '', []) then
|
||
// raise Exception.Create('<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
if Order_Sub.Locate('ConQty', null, []) then
|
||
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
if Order_Sub.Locate('ConQty', 0, []) then
|
||
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30>');
|
||
if Order_Sub.Locate('ConUnit', null, []) then
|
||
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
if Order_Sub.Locate('ConUnit', '', []) then
|
||
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
Result := True;
|
||
except
|
||
Result := false;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.ToolButton1Click(Sender: TObject); //<2F><><EFBFBD><EFBFBD>
|
||
var
|
||
i: Integer;
|
||
maxno: string;
|
||
begin
|
||
if GetLSNo(ADOCmd, maxno, 'CPCS', 'CP_Contract_Sub', 4, 1) = False then
|
||
begin
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if Trim(ConNo.Text) = '' then
|
||
begin
|
||
Application.MessageBox('<27><>ͬ<EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
i := Order_Sub.RecordCount; //<2F><>ǰ<EFBFBD><C7B0>dataset<65>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>м<EFBFBD>¼
|
||
i := i + 1;
|
||
CopyAddRow(Tv1, Order_Sub);
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('SSEL').Value := FALSE;
|
||
FieldByName('SerialNo').Value := i;
|
||
FieldByName('ConSId').Value := maxno;
|
||
FieldByName('ConQty').Value := null;
|
||
FieldByName('ConUnit').Value := 'M';
|
||
Post;
|
||
end;
|
||
SetXH();
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if Order_Sub.IsEmpty then
|
||
Exit;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
while Order_Sub.Locate('SSel', True, []) do
|
||
begin
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Trade_Plan_Sub where ConSId=''' + Trim(Order_Sub.fieldbyname('ConSId').AsString) + '''');
|
||
open;
|
||
end;
|
||
if ADOTemp.IsEmpty = false then
|
||
begin
|
||
exit;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ϸ<EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
end;
|
||
if Trim(Order_Sub.fieldbyname('ConSId').AsString) <> '' then
|
||
begin
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete CP_Contract_Sub where ConSId=''' + Trim(Order_Sub.fieldbyname('ConSId').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
Order_Sub.Delete;
|
||
end;
|
||
SetXH();
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.ToolButton4Click(Sender: TObject);
|
||
var
|
||
i: Integer;
|
||
maxno: string;
|
||
MCYNo: string;
|
||
begin
|
||
|
||
if Trim(ConNo.Text) = '' then
|
||
begin
|
||
Application.MessageBox('<27><>ͬ<EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
|
||
i := Order_Sub.RecordCount; //<2F><>ǰ<EFBFBD><C7B0>dataset<65>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>м<EFBFBD>¼
|
||
|
||
|
||
frmTatClothInfoSel := TfrmTatClothInfoSel.Create(self);
|
||
with frmTatClothInfoSel do
|
||
begin
|
||
if showmodal = 1 then
|
||
begin
|
||
|
||
with CDS_1 do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if CDS_1.fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
|
||
if GetLSNo(ADOCmd, maxno, 'CPCS', 'CP_Contract_Sub', 4, 1) = False then
|
||
begin
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
|
||
with Self.Order_Sub do
|
||
begin
|
||
append;
|
||
|
||
Order_Sub.fieldbyname('C_Code').Value := frmTatClothInfoSel.CDS_1.fieldbyname('C_Code').asstring;
|
||
Order_Sub.fieldbyname('C_Name').Value := frmTatClothInfoSel.CDS_1.fieldbyname('C_Name').asstring;
|
||
|
||
Order_Sub.fieldbyname('C_Spec').Value := frmTatClothInfoSel.CDS_1.fieldbyname('C_Spec').asstring;
|
||
Order_Sub.fieldbyname('C_Composition').Value := frmTatClothInfoSel.CDS_1.fieldbyname('C_Composition').asstring;
|
||
|
||
Order_Sub.fieldbyname('C_Width').Value := frmTatClothInfoSel.CDS_1.fieldbyname('C_Width').asstring;
|
||
// Order_Sub.fieldbyname('BBNO').Value := frmTatClothInfoSel.CDS_1.fieldbyname('BBNO').asstring;
|
||
|
||
FieldByName('SSEL').Value := FALSE;
|
||
FieldByName('SerialNo').Value := i;
|
||
FieldByName('ConSId').Value := maxno;
|
||
FieldByName('ConQty').Value := null;
|
||
// FieldByName('ConTotalAmount').Value := null;
|
||
FieldByName('ConUnit').Value := 'M';
|
||
end;
|
||
end;
|
||
Next;
|
||
i := i + 1;
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
|
||
end;
|
||
free;
|
||
end;
|
||
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
SetXH();
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.TBCloseClick(Sender: TObject);
|
||
begin
|
||
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.TBSaveClick(Sender: TObject);
|
||
begin
|
||
ConDate.SetFocus;
|
||
|
||
if TestData() = false then
|
||
exit;
|
||
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.InitData();
|
||
var
|
||
maxno: string;
|
||
begin
|
||
//ˢ<>²<EFBFBD>Ʒ<EFBFBD><C6B7>Ϣ
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select * from CP_Contract_Sub ');
|
||
sql.Add('where ConMId=''' + Trim(FConMId) + '''');
|
||
sql.Add(' order by SerialNo ');
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOTemp, Order_Sub);
|
||
SInitCDSData(ADOTemp, Order_Sub);
|
||
//ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CP_Contract_Main where ConMId=''' + Trim(FConMId) + '''');
|
||
Open;
|
||
end;
|
||
SCSHData(ADOTemp, ScrollBox1, 2);
|
||
|
||
BuyName.Properties.LookupItems.Text := Trim(ADOTemp.FieldByName('BuyNo').AsString);
|
||
|
||
Fstatus := Trim(ADOTemp.FieldByName('status').AsString);
|
||
|
||
if PState = '<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
ConDate.Date := SGetServerDateTime(ADOTemp);
|
||
DlyDate.Date := ConDate.Date;
|
||
ConNo.Text := '<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
|
||
SalesID.Text := trim(DCode);
|
||
end;
|
||
|
||
if PState = '<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
|
||
PState := '<27><><EFBFBD><EFBFBD>';
|
||
FConMId := '';
|
||
ConNo.Text := '<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
|
||
with Order_Sub do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if GetLSNo(ADOCmd, maxno, 'CPSCS', 'CP_Contract_Sub', 4, 1) = False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
Edit;
|
||
FieldByName('ConMId').Value := '';
|
||
FieldByName('ConSId').Value := maxno;
|
||
Post;
|
||
Next;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.N1Click(Sender: TObject);
|
||
var
|
||
FValue, FFValue, FColumn, FFColumn, MHXSID: string;
|
||
MXHNO: Integer;
|
||
begin
|
||
if Fstatus = '1' then
|
||
begin
|
||
application.MessageBox('<27><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
exit;
|
||
end;
|
||
MXHNO := Order_Sub.FieldByName('XHNo').ASInteger;
|
||
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
||
FValue := Trim(Order_Sub.fieldbyname(FColumn).AsString);
|
||
MHXSID := Trim(Order_Sub.fieldbyname('HXSID').AsString);
|
||
with Order_Sub do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if FieldByName('SSel').AsBoolean then
|
||
begin
|
||
Edit;
|
||
|
||
if FValue = '' then
|
||
begin
|
||
Order_Sub.FieldByName(FColumn).Value := null;
|
||
end
|
||
else
|
||
begin
|
||
Order_Sub.FieldByName(FColumn).Value := FValue;
|
||
end;
|
||
if FColumn = 'C_HX' then
|
||
begin
|
||
Order_Sub.FieldByName('HXSID').Value := MHXSID;
|
||
end;
|
||
Post;
|
||
JSMoney();
|
||
end;
|
||
Next;
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
Order_Sub.Locate('XHNO', MXHNO, []);
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.N2Click(Sender: TObject);
|
||
var
|
||
FValue, MC_Code, MC_Craft, MC_Name, MC_Spec, MC_CF, MC_Color, MC_MF, MC_KZ, MC_Note, MC_Unit, MGcHuaNo, MSuoLv, MC_EName: string;
|
||
MXHNO: Integer;
|
||
begin
|
||
if Fstatus = '1' then
|
||
begin
|
||
application.MessageBox('<27><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
exit;
|
||
end;
|
||
|
||
MXHNO := Order_Sub.FieldByName('XHNo').ASInteger;
|
||
MC_Code := Order_Sub.fieldbyname('C_Code').AsString;
|
||
MC_Craft := Order_Sub.fieldbyname('C_Craft').AsString;
|
||
MC_Name := Order_Sub.fieldbyname('C_Name').AsString;
|
||
MC_Spec := Order_Sub.fieldbyname('C_Spec').AsString;
|
||
MC_CF := Order_Sub.fieldbyname('C_CF').AsString;
|
||
MC_Color := Order_Sub.fieldbyname('C_Color').AsString;
|
||
MC_MF := Order_Sub.fieldbyname('C_MF').AsString;
|
||
MC_KZ := Order_Sub.fieldbyname('C_KZ').AsString;
|
||
MC_Note := Order_Sub.fieldbyname('C_Note').AsString;
|
||
MC_Unit := Order_Sub.fieldbyname('C_Unit').AsString;
|
||
MSuoLv := Order_Sub.fieldbyname('SuoLv').AsString;
|
||
MGcHuaNo := Order_Sub.fieldbyname('GcHuaNo').AsString;
|
||
MC_EName := Order_Sub.fieldbyname('C_EName').AsString;
|
||
|
||
with Order_Sub do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if FieldByName('SSel').AsBoolean then
|
||
begin
|
||
Edit;
|
||
Order_Sub.fieldbyname('C_Code').Value := MC_Code;
|
||
Order_Sub.fieldbyname('C_Craft').Value := MC_Craft;
|
||
Order_Sub.fieldbyname('C_Name').Value := MC_Name;
|
||
Order_Sub.fieldbyname('C_Spec').Value := MC_Spec;
|
||
Order_Sub.fieldbyname('C_CF').Value := MC_CF;
|
||
Order_Sub.fieldbyname('C_Color').Value := MC_Color;
|
||
Order_Sub.fieldbyname('C_MF').Value := MC_MF;
|
||
Order_Sub.fieldbyname('C_KZ').Value := MC_KZ;
|
||
Order_Sub.fieldbyname('C_Note').Value := MC_Note;
|
||
Order_Sub.fieldbyname('C_Unit').Value := MC_Unit;
|
||
Order_Sub.fieldbyname('SuoLv').Value := MSuoLv;
|
||
Order_Sub.fieldbyname('GcHuaNo').Value := MGcHuaNo;
|
||
Order_Sub.fieldbyname('C_EName').Value := MC_EName;
|
||
Post;
|
||
|
||
end;
|
||
Next;
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
Order_Sub.Locate('XHNO', MXHNO, []);
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.Pic_Image1DblClick(Sender: TObject);
|
||
begin
|
||
if TcxDBImage(Sender).Picture.Height = 0 then
|
||
exit;
|
||
|
||
LookImage(ADOQueryImage.fieldbyname(TcxDBImage(Sender).Hint).asstring);
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.LookImage(FileName: string);
|
||
var
|
||
sFieldName: string;
|
||
begin
|
||
sFieldName := leftbstr(ExtractFilePath(Application.ExeName), 1) + ':\ͼƬ<CDBC>鿴';
|
||
if not DirectoryExists(pchar(sFieldName)) then
|
||
CreateDirectory(pchar(sFieldName), nil);
|
||
sFieldName := sFieldName + '\' + trim(FileName);
|
||
try
|
||
IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI', 'SERVER', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ', '127.0.0.1');
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
;
|
||
end;
|
||
|
||
if IdFTP1.Connected then
|
||
begin
|
||
try
|
||
IdFTP1.Get(fFlileFlag + '\' + Trim(FileName), sFieldName, true, false);
|
||
except
|
||
Application.MessageBox('<27>ͻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox('<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
if IdFTP1.Connected then
|
||
IdFTP1.Quit;
|
||
ShellExecute(Handle, 'open', PChar(sFieldName), '', '', SW_SHOWNORMAL);
|
||
end;
|
||
|
||
procedure TfrmfinishSalesConInput.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
readCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD>ۺ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>');
|
||
fFlileFlag := UserDataFlag + 'HX';
|
||
InitData();
|
||
end;
|
||
|
||
function TfrmfinishSalesConInput.SaveData(): Boolean;
|
||
var
|
||
maxno, ZiMu: string;
|
||
fconNO, fmxType, fDate, YueRi: string;
|
||
begin
|
||
try
|
||
ADOCmd.Connection.BeginTrans;
|
||
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //////////////////////
|
||
if Trim(FConMId) = '' then
|
||
begin
|
||
if GetLSNo(ADOTemp, maxno, 'CPCM', 'CP_Contract_Main', 3, 1) = False then
|
||
raise Exception.Create('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
||
|
||
fDate := FormatDateTime('yy', SGetServerDate(ADOTemp));
|
||
YueRi := FormatDateTime('MMDD', SGetServerDate(ADOTemp));
|
||
|
||
if trim(ConNo.Text) = '<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>' then
|
||
begin
|
||
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select ZiMu = dbo.GetPinYin(''' + Trim(BuyName.text) + ''')');
|
||
Open;
|
||
end;
|
||
ZiMu := Trim(ADOTemp.fieldbyname('ZiMu').AsString);
|
||
|
||
if GetLSNo(ADOTemp, fconNO, fDate, 'CP_Contract_Main', 4, 0) = False then
|
||
raise Exception.Create('ȡ<><C8A1><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
||
//
|
||
//// fconNO := Copy(fconNO, 1, 4) + YueRi + Copy(fconNO, 5, 4);
|
||
// if ConType.Text = '<27><><EFBFBD><EFBFBD>' then
|
||
// fconNO := 'N' + fconNO
|
||
// else
|
||
// fconNO := 'W' + fconNO;
|
||
ConNo.Text := fconNO;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
maxno := Trim(FConMId);
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select * from CP_Contract_Main where ConMId=''' + Trim(FConMId) + '''');
|
||
Open;
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
if Trim(FConMId) = '' then
|
||
begin
|
||
Append;
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
FieldByName('status').Value := '0';
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value := Trim(DName);
|
||
FieldByName('EditTime').Value := SGetServerDateTime(ADOTemp);
|
||
end;
|
||
FieldByName('ConMId').Value := Trim(maxno);
|
||
RTSetsavedata(ADOCmd, 'CP_Contract_Main', ScrollBox1, 2);
|
||
// ShowMessage(self.BuyName.Properties.LookupItems[0]+'hh');
|
||
// ShowMessage(self.Sellname.Properties.LookupItems[0]+'hh');
|
||
// ShowMessage(self.MiddleName.Properties.LookupItems.Text+'hh');
|
||
// if Trim(BuyName.Properties.LookupItems.text) = '' then
|
||
// begin
|
||
// FieldByName('BuyNo').Value := Trim(BuyName.Properties.LookupItems[0]);
|
||
// end
|
||
// else
|
||
// begin
|
||
// FieldByName('BuyNo').Value := Trim(BuyName.Properties.LookupItems[0]);
|
||
// end;
|
||
|
||
Post;
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CP_Contract_Main where ConNo=''' + Trim(ConNo.Text) + '''');
|
||
Open;
|
||
end;
|
||
if ADOCmd.RecordCount > 1 then
|
||
raise Exception.Create('<27><>ͬ<EFBFBD><CDAC><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>');
|
||
|
||
FConMId := Trim(maxno);
|
||
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //////////////////////
|
||
///
|
||
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD> //////////////////////
|
||
with Order_Sub do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
maxno := Trim(Order_Sub.fieldbyname('ConSId').AsString);
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from CP_Contract_Sub where ConSId=''' + Trim(maxno) + '''');
|
||
Open;
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
if ADOCmd.IsEmpty then
|
||
Append
|
||
else
|
||
Edit;
|
||
RTSetSaveDataCDS(ADOCmd, Tv1, Order_Sub, 'CP_Contract_Sub', 0);
|
||
FieldByName('ConMId').Value := Trim(FConMId);
|
||
FieldByName('ConSId').Value := Trim(maxno);
|
||
|
||
Post;
|
||
end;
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('ConSId').Value := Trim(maxno);
|
||
Post;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD> //////////////////////
|
||
///
|
||
//////////////// <20><><EFBFBD>º<EFBFBD>ͬ //////////////////////
|
||
// with ADOCmd do
|
||
// begin
|
||
// close;
|
||
// sql.Clear;
|
||
// sql.Add('EXEC P_Con_Up_PiQty ');
|
||
// sql.Add('@DataID=' + quotedstr(Trim(FConMId)));
|
||
// execsql;
|
||
// end;
|
||
//////////////// <20><><EFBFBD>º<EFBFBD>ͬ //////////////////////
|
||
|
||
ADOCmd.Connection.CommitTrans;
|
||
Result := True;
|
||
except
|
||
|
||
ADOCmd.Connection.RollbackTrans;
|
||
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
|
||
Result := False;
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|