📄 billedit.pas
字号:
unit BillEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
BaseBillEdit, StdCtrls, ExtCtrls, dxCntner, dxTL, dxDBCtrl, dxDBGrid,
Buttons, Db, DBTables, ImgList, dxEdLib, dxDBELib, dxEditor, dxExEdtr,
DBCtrls, dxGrClms, dxDBTLCl, DBData, ADODB, Menus, DBGrids, dxBar,
KsSkinForms, KsSkinButtons, KsSkinLabels, KsSkinPanels, sncCurrency,
sncDBCurrency, Grids, Provider, se_controls;
type
TfrmBillEdit = class(TfrmBaseBillEdit)
edtMemo: TdxDBEdit;
Label3: TSeSkinLabel;
lblMemo: TSeSkinLabel;
lblBillDate: TSeSkinLabel;
edtBillDate: TdxDBDateEdit;
lblUserCode: TSeSkinLabel;
edtUserCode: TdxDBEdit;
lblUnit: TSeSkinLabel;
lblEmploye: TSeSkinLabel;
lblAddress: TSeSkinLabel;
edtAddress: TdxDBEdit;
lblDepot: TSeSkinLabel;
lblInvoice: TSeSkinLabel;
edtInvoice: TdxDBPickEdit;
chkFinish: TdxDBCheckEdit;
lblToDate: TSeSkinLabel;
edtToDate: TdxDBDateEdit;
edtUnit: TdxButtonEdit;
edtEmploye: TdxButtonEdit;
lblBillNum: TSeSkinLabel;
edtBillNum: TdxDBEdit;
lblPayment: TSeSkinLabel;
edtPayment: TdxDBButtonEdit;
edtDepot: TdxButtonEdit;
bbSelect: TSeSkinButton;
lblMoney: TSeSkinLabel;
edtMoney: TdxDBCurrencyEdit;
bbAutoAssign: TSeSkinButton;
pnlPOS: TSeSkinPanel;
SeSkinLabel8: TSeSkinLabel;
edtPosAll1: TdxEdit;
SeSkinLabel1: TSeSkinLabel;
edtReceipt: TdxEdit;
SeSkinLabel2: TSeSkinLabel;
edtGive: TdxEdit;
SeSkinLabel3: TSeSkinLabel;
edtPosDime: TdxEdit;
SeSkinLabel4: TSeSkinLabel;
edtPosAll2: TdxEdit;
SeSkinLabel5: TSeSkinLabel;
edtMoneySub: TdxButtonEdit;
SeSkinLabel6: TSeSkinLabel;
edtMoneyTotal: TdxDBCurrencyEdit;
procedure edtUnitButtonClick(Sender: TObject; AbsoluteIndex: Integer);
procedure edtEmployeButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
procedure bbOkClick(Sender: TObject);
procedure edtDepotButtonClick(Sender: TObject; AbsoluteIndex: Integer);
procedure edtPaymentButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure mnPrintInitClick(Sender: TObject);
procedure bbSetupClick(Sender: TObject);
procedure bbPrevClick(Sender: TObject);
procedure bbNextClick(Sender: TObject);
procedure edtToDateKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edtBillDateKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure gridMainChangeColumn(Sender: TObject; Node: TdxTreeListNode;
Column: Integer);
procedure bbSelectClick(Sender: TObject);
procedure bbAutoAssignClick(Sender: TObject);
procedure edtPosDimeChange(Sender: TObject);
procedure edtReceiptChange(Sender: TObject);
procedure edtPosAll1Change(Sender: TObject);
procedure pbbPrintClick(Sender: TObject);
procedure pbbPrintViewClick(Sender: TObject);
procedure pbbPrintCustomClick(Sender: TObject);
procedure pbbPrintInitClick(Sender: TObject);
procedure ADOSetListBeforeScroll(DataSet: TDataSet);
procedure edtUnitExit(Sender: TObject);
procedure edtEmployeExit(Sender: TObject);
procedure edtDepotExit(Sender: TObject);
procedure edtMoneySubButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
private
{ Private declarations }
lPubType: Integer;
sReturn: string;
sUniqueTable: string;
bSavePrint, bPriceCan0, bCanMinusWare: Boolean;
function ReturnSQL(lType, lMode, lBillID: Integer): string;
procedure ToolShow;
procedure BillRowSummary;
// procedure CalcRowFinish;
procedure EditShow;
procedure FieldToEdit;
procedure LoadGrid;
procedure LoadData;
function CheckSavePrint: Boolean; //保存单据才能打印
function LoadOrderBill(lOrderID: Integer): Boolean;
procedure SaveData(lType: Integer);
function CheckMsg: Boolean;
procedure MoneySelectUnit(lUID, lMMode: Integer);
procedure MainShow;
public
{ Public declarations }
end;
function BillEditShow(l1Mode, l1ID: Integer): string;
implementation
uses SysPublic;
{$R *.DFM}
function BillEditShow(l1Mode, l1ID: Integer): string;
var
frmBillEdit: TfrmBillEdit;
begin
frmBillEdit := TfrmBillEdit.Create(Application);
with frmBillEdit do
begin
lMode := l1Mode;
lID := l1ID;
MainShow;
Result := sReturn;
Free;
end;
end;
procedure TfrmBillEdit.MainShow;
begin
if lMode = 0 then
Exit;
if CheckUnRegister then
Exit; //如果未注册并过期
InitialBillSetup(lMode);
LoadGrid;
EditShow;
LoadData;
ToolShow;
ShowModal;
end;
procedure TfrmBillEdit.LoadGrid;
var
btnColumn: TdxDBGridButtonColumn;
sFieldName, sCaption, sWidth, sNoDisPlay, sReadOnly: string;
begin
sReturn := '';
sUniqueTable := '';
Caption := 'XXXX 单据';
lSelectMode := 0;
lOneRet := 0;
sFieldName := 'Field';
sCaption := 'TopName';
sWidth := 'Width';
sNoDisPlay := 'Display';
sReadOnly := 'Read';
bSavePrint := StrToBool2(GetIniValue(frmData.ADOConnet, 'BillSavePrint'));
bPriceCan0 := StrToBool2(GetIniValue(frmData.ADOConnet, 'BillPriceCan0'));
bCanMinusWare := StrToBool2(GetIniValue(frmData.ADOConnet, 'CanMinusWare'));
GetDataField(sFieldName, sCaption, sWidth, sNoDisPlay, sReadOnly);
StrToGridField(gridMain, sFieldName, sCaption, sWidth);
SetBillDisPlay(sNoDisPlay);
SetBillReadOnly(sReadOnly);
case lMode of
STOCK_ORDER_EDIT, STOCK_FORMAL_EDIT, STOCK_BACK_EDIT, SALE_ORDER_EDIT,
SALE_BACK_EDIT, SALE_FORMAL_EDIT, SALE_READY_EDIT, SALE_POS_EDIT:
begin
//设置[编号列]为Button方式,并对应单击事件.
ChangColumnType(gridMain, gridMain.ColumnByFieldName('WareCode'), TdxDBGridButtonColumn);
btnColumn := TdxDBGridButtonColumn(gridMain.ColumnByFieldName('WareCode'));
btnColumn.OnButtonClick := GridButtonClick;
btnColumn.ClickKey := VK_RETURN;
//设置[商品名称列]为Button方式,并对应单击事件.
ChangColumnType(gridMain, gridMain.ColumnByFieldName('WareName'), TdxDBGridButtonColumn);
btnColumn := TdxDBGridButtonColumn(gridMain.ColumnByFieldName('WareName'));
btnColumn.OnButtonClick := GridButtonClick;
btnColumn.ClickKey := VK_RETURN;
//设置[商品单价列]为Button方式,并对应单击事件.
ChangColumnType(gridMain, gridMain.ColumnByFieldName('Price'), TdxDBGridButtonColumn);
btnColumn := TdxDBGridButtonColumn(gridMain.ColumnByFieldName('Price'));
btnColumn.OnButtonClick := GridSelectPrice;
//设置[商品金额列]为Currency方式.
ChangColumnType(gridMain, gridMain.ColumnByFieldName('Total'), TdxDBGridCurrencyColumn);
end;
end;
case lMode of
STOCK_ORDER_EDIT:
begin
Caption := '进货订单';
SetGridSummary(gridMain, 'WareName,Number,Total,ToNumber');
end;
STOCK_FORMAL_EDIT:
begin
Caption := '进货单';
SetGridSummary(gridMain, 'WareName,Number,Total,UnNumber');
end;
STOCK_MONEY_EDIT:
begin
Caption := '进货付款单';
SetGridSummary(gridMain,
'UserCode,Date,Number,ToNumber,UnNumber,Total,Finish');
end;
STOCK_BACK_EDIT:
begin
Caption := '进货退货单';
SetGridSummary(gridMain, 'WareName,Number,Total');
end;
SALE_ORDER_EDIT:
begin
Caption := '销售订单';
SetGridSummary(gridMain, 'WareName,Number,Total,ToNumber');
lSelectMode := 1;
end;
SALE_FORMAL_EDIT:
begin
Caption := '销售单';
SetGridSummary(gridMain, 'WareName,Number,Total,UnNumber');
lSelectMode := 1;
end;
SALE_MONEY_EDIT:
begin
Caption := '销售收款单';
SetGridSummary(gridMain, 'UserCode,Date,Number,ToNumber,UnNumber,Total,Finish');
end;
SALE_POS_EDIT:
begin
Caption := '零售单(POS)';
SetGridSummary(gridMain, 'WareName,Number,Total,UnNumber');
lSelectMode := 1;
lOneRet := 1;
end;
SALE_READY_EDIT:
begin
Caption := '现款销售单';
SetGridSummary(gridMain, 'WareName,Number,Total,UnNumber');
lSelectMode := 1;
end;
SALE_BACK_EDIT:
begin
Caption := '销售退货单';
SetGridSummary(gridMain, 'WareName,Number,Total');
end;
else
ShowMsg('内部参数出错,请与开发商联系!');
end;
lblCaption.Caption := Caption;
SetDrawGridSummary(gridMain);
edtInvoice.Items.Text := GetBaseInvoiceType;
end;
procedure TfrmBillEdit.ToolShow;
begin
if (lID > 0) and ((lPubType = 2) or (lPubType = 5)) then //如果是已保存的单据
begin //11
case lMode of//case1
STOCK_ORDER_EDIT, SALE_ORDER_EDIT: ;
else
begin
bbIns.Enabled := False;
bbDel.Enabled := False;
bbOk.Enabled := False;
SetEditRead(Self, True);
gridMain.Enabled := False;
end;
end;//case1
end
else//11
begin
case lMode of //case2
STOCK_ORDER_EDIT, SALE_ORDER_EDIT: ;
else
begin
bbIns.Enabled := True;
bbDel.Enabled := True;
bbOk.Enabled := True;
SetEditRead(Self, False);
gridMain.Enabled := True;
end;
end //case2
end; //11
end;
procedure TfrmBillEdit.EditShow;
begin
case lMode of
STOCK_ORDER_EDIT:
begin
lblUnit.Visible := True;
edtUnit.Visible := True;
lblUnit.Caption := '供 货 商:';
lblEmploye.Visible := True;
edtEmploye.Visible := True;
lblEmploye.Caption := '经 手 人:';
lblToDate.Visible := True;
edtToDate.Visible := True;
lblToDate.Caption := '收货日期:';
lblAddress.Visible := True;
edtAddress.Visible := True;
lblAddress.Caption := '收货地址:';
lblMemo.Visible := True;
edtMemo.Visible := True;
lblMemo.Caption := '备 注:';
end;
STOCK_FORMAL_EDIT:
begin
lblUnit.Visible := True;
edtUnit.Visible := True;
lblUnit.Caption := '供 货 商:';
lblEmploye.Visible := True;
edtEmploye.Visible := True;
lblEmploye.Caption := '经 手 人:';
lblDepot.Visible := true;
edtDepot.Visible := True;
lblDepot.Caption := '仓 库:';
//lblInvoice.Visible := true; edtInvoice.Visible := True; lblInvoice.Caption := '发票类型:';
lblMemo.Visible := True;
edtMemo.Visible := True;
lblMemo.Caption := '备 注:';
lblMemo.Left := lblAddress.Left;
edtMemo.Left := edtAddress.Left;
edtMemo.Width := edtMemo.Width * 2;
bbSelect.Caption := '选择订单';
bbSelect.Visible := True;
end;
STOCK_MONEY_EDIT:
begin
lblUnit.Visible := True;
edtUnit.Visible := True;
lblUnit.Caption := '供 货 商:';
lblEmploye.Visible := True;
edtEmploye.Visible := True;
lblEmploye.Caption := '经 手 人:';
lblPayment.Visible := True;
edtPayment.Visible := True;
lblPayment.Caption := '付款方式:';
lblBillNum.Visible := True;
edtBillNum.Visible := True;
lblBillNum.Caption := '票 号:';
lblInvoice.Visible := true;
edtInvoice.Visible := True;
lblInvoice.Caption := '发票类型:';
lblMoney.Visible := True;
edtMoney.Visible := True;
lblMoney.Caption := '付款金额:';
lblMemo.Visible := True;
edtMemo.Visible := True;
lblMemo.Caption := '备 注:';
lblMemo.Left := lblAddress.Left;
edtMemo.Left := edtAddress.Left;
edtMemo.Width := edtMemo.Width * 2;
bbAutoAssign.Visible := True;
end;
STOCK_BACK_EDIT:
begin
lblUnit.Visible := True;
edtUnit.Visible := True;
lblUnit.Caption := '供 货 商:';
lblEmploye.Visible := True;
edtEmploye.Visible := True;
lblEmploye.Caption := '经 手 人:';
lblDepot.Visible := true;
edtDepot.Visible := True;
lblDepot.Caption := '仓 库:';
//lblInvoice.Visible := true; edtInvoice.Visible := True; lblInvoice.Caption := '发票类型:';
lblMemo.Visible := True;
edtMemo.Visible := True;
lblMemo.Caption := '备 注:';
lblMemo.Left := lblAddress.Left;
edtMemo.Left := edtAddress.Left;
edtMemo.Width := edtMemo.Width * 2;
end;
SALE_ORDER_EDIT:
begin
lblUnit.Visible := True;
edtUnit.Visible := True;
lblUnit.Caption := '客 户:';
lblEmploye.Visible := True;
edtEmploye.Visible := True;
lblEmploye.Caption := '经 手 人:';
lblToDate.Visible := True;
edtToDate.Visible := True;
lblToDate.Caption := '交货日期:';
lblAddress.Visible := True;
edtAddress.Visible := True;
lblAddress.Caption := '交货地址:';
lblMemo.Visible := True;
edtMemo.Visible := True;
lblMemo.Caption := '备 注:';
end;
SALE_FORMAL_EDIT:
begin
lblUnit.Visible := True;
edtUnit.Visible := True;
lblUnit.Caption := '客 户:';
lblEmploye.Visible := True;
edtEmploye.Visible := True;
lblEmploye.Caption := '经 手 人:';
lblDepot.Visible := true;
edtDepot.Visible := True;
lblDepot.Caption := '仓 库:';
//lblInvoice.Visible := true; edtInvoice.Visible := True; lblInvoice.Caption := '发票类型:';
lblMemo.Visible := True;
edtMemo.Visible := True;
lblMemo.Caption := '备 注:';
lblMemo.Left := lblAddress.Left;
edtMemo.Left := edtAddress.Left;
edtMemo.Width := edtMemo.Width * 2;
bbSelect.Caption := '选择订单';
bbSelect.Visible := True;
end;
SALE_MONEY_EDIT:
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -