📄 u_goodsoutstock.~pas
字号:
unit u_GoodsOutStock;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ADODB, DB, StdCtrls, Buttons, ComCtrls, ExtCtrls, Menus;
type
TfrmGoodsOutStock = class(TForm)
Panel1: TPanel;
edtDate: TLabeledEdit;
EdtGoodsOutBH: TLabeledEdit;
lvMain: TListView;
Panel2: TPanel;
btnCancel: TBitBtn;
btnSave: TBitBtn;
edtGoodsBH: TLabeledEdit;
edtGoodsName: TLabeledEdit;
edtGoodsSpec: TLabeledEdit;
edtGoodsModel: TLabeledEdit;
edtGoodsPrice: TLabeledEdit;
edtGoodsAmount: TLabeledEdit;
btnAdd: TBitBtn;
btnDelete: TBitBtn;
btnEdit: TBitBtn;
Panel3: TPanel;
Label2: TLabel;
Label3: TLabel;
edtTotal: TEdit;
edtPayMent: TEdit;
btnOK: TBitBtn;
BitBtn4: TBitBtn;
popGetSysTime: TADOStoredProc;
popGetGoodsOutBH: TADOStoredProc;
pipGoodsOutMaster: TADOStoredProc;
pipCusAccount: TADOStoredProc;
pipGoodsOutDetail: TADOStoredProc;
btnAbandon: TBitBtn;
PMDb: TPopupMenu;
pmDel: TMenuItem;
CusSupply: TLabeledEdit;
sp_GetCusNo: TADOStoredProc;
edtInVoice: TLabeledEdit;
chkCheck: TCheckBox;
OutRepQry: TADOQuery;
chkPrint: TCheckBox;
procedure InitEdt();
procedure InitShowADD();
procedure InitShowSave();
function CheckEdt() :Boolean;
procedure BitBtn4Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CusSupplyKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edtGoodsBHKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edtGoodsAmountKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edtGoodsBHDblClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure lvMainDblClick(Sender: TObject);
procedure lvMainSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
procedure btnEditClick(Sender: TObject);
procedure btnAddClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure edtInVoiceKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edtGoodsPriceKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btnAbandonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure pmDelClick(Sender: TObject);
procedure edtGoodsBHExit(Sender: TObject);
procedure CusSupplyDblClick(Sender: TObject);
procedure CusSupplyExit(Sender: TObject);
procedure AddCus();
procedure edtPayMentKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
Flag : Integer;
ItemsID : Integer;
Total : Real;
end;
var
frmGoodsOutStock: TfrmGoodsOutStock;
function CheckInt(Data : String) : Boolean;
implementation
uses u_DataCtrl, Math, u_ChooseGoodsOut, u_ShareFun, u_CusSearch,
u_GoodsOutRep;
{$R *.dfm}
function CheckInt(Data : String) : Boolean;
var
code : Integer;
r : Integer;
begin
Val(Data,r,code);
if code = 0 then
Result := True
else
Result := False;
end;
procedure TfrmGoodsOutStock.InitEdt;
begin
edtGoodsBH.Clear;
edtGoodsName.Clear;
edtGoodsSpec.Clear;
edtGoodsModel.Clear;
edtGoodsPrice.Clear;
edtInVoice.Clear;
edtGoodsAmount.Clear;
end;
procedure TfrmGoodsOutStock.BitBtn4Click(Sender: TObject);
begin
Close;
end;
procedure TfrmGoodsOutStock.FormShow(Sender: TObject);
begin
Total := 0;
edtTotal.Text := '0';
with popGetSysTime do
begin
Close;
ExecProc;
edtDate.Text := Parameters.ParamByName('@billcode').Value;
end;
with popGetGoodsOutBH do
begin
Close;
ExecProc;
EdtGoodsOutBH.Text := Parameters.ParamByName('@billcode').Value;
end;
BtnAdd.Click;
CusSupply.SetFocus;
end;
procedure TfrmGoodsOutStock.CusSupplyKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (key = VK_RETURN) and (length(trim(CusSupply.Text))>0) then
frmGoodsOutStock.CusSupplyExit(self);
end;
procedure TfrmGoodsOutStock.edtGoodsBHKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
var
TempSql : String;
TempQuery : TADOQuery;
begin
if key = VK_RETURN then
begin
if edtGoodsBH.Text = '' then
begin
Application.MessageBox('请输入编码','警告',MB_OK);
Exit;
end
else
begin
TempSql := 'select * from vw_GoodsInfo where GoodsBH='+QuotedStr(edtGoodsBH.Text);
TempQuery := frmDataCtrl.ReturnQuery(TempSql);
if TempQuery.RecordCount > 0 then
begin
edtGoodsName.Text := TempQuery.FieldValues['GoodsName'];
edtGoodsSpec.Text := TempQuery.FieldValues['GoodsSpec'];
edtGoodsModel.Text := TempQuery.FieldValues['GoodsModel'];
edtGoodsPrice.Text := TempQuery.fieldbyname('GoodsOutPrice').AsString ;
TempQuery.Free;
edtGoodsPrice.SetFocus;
end
else
begin
showmessage('没有此商品,请重新输入!');
edtGoodsBH.SetFocus;
exit;
end;
end;
end;
end;
procedure TfrmGoodsOutStock.edtGoodsAmountKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (key = VK_RETURN) and (not CheckInt(edtGoodsAmount.Text) ) then
begin
Application.MessageBox('数量输入有误','警告',MB_OK);
edtGoodsAmount.SetFocus;
Exit;
end;
if (key = VK_RETURN) and CheckInt(edtGoodsAmount.Text) then
begin
btnSave.SetFocus;
end;
end;
procedure TfrmGoodsOutStock.edtGoodsBHDblClick(Sender: TObject);
begin
frmChooseGoods.ShowModal;
end;
function TfrmGoodsOutStock.CheckEdt: Boolean;
begin
if edtGoodsBH.Text = '' then
begin
Application.MessageBox('请输入商品编码','警告',MB_OK);
edtGoodsBH.SetFocus;
Result := False;
Exit;
end;
if edtGoodsName.Text = '' then
begin
Application.MessageBox('名称不可为空','警告',MB_OK);
Result := False;
Exit;
end ;
if Not IsNumeric(edtGoodsPrice.Text) then
begin
Application.MessageBox('单价输入有误,请重新输入!','警告',MB_OK);
edtGoodsPrice.SetFocus;
Result :=False;
Exit;
end;
if Not CheckInt(edtGoodsAmount.Text) then
begin
Application.MessageBox('数量输入有误,请重新输入','警告',MB_OK);
edtGoodsAmount.SetFocus;
Result :=False;
Exit;
end
else
Result := True;
end;
procedure TfrmGoodsOutStock.btnSaveClick(Sender: TObject);
var
i : Integer;
begin
if CheckEdt()= False then
Exit;
if Flag = 1 then
begin
with lvMain.Items.Insert(0) do
begin
Caption := edtGoodsBH.Text;
SubItems.Add(edtGoodsName.Text);
SubItems.Add(edtGoodsSpec.Text);
SubItems.Add(edtGoodsModel.Text);
SubItems.Add(edtGoodsPrice.Text);
SubItems.Add(edtGoodsAmount.Text);
SubItems.Add(FloatToStr(StrToFloat(edtGoodsPrice.Text) * StrToInt(edtGoodsAmount.Text)));
end;
BtnAdd.Click;
end;
if Flag = 2 then
begin
i := ItemsID;
with lvMain.Items do
begin
Item[i].Caption := edtGoodsBH.Text;
Item[i].SubItems.Strings[0] := edtGoodsName.Text;
Item[i].SubItems.Strings[1] := edtGoodsSpec.Text;
Item[i].SubItems.Strings[2] := edtGoodsModel.Text;
Item[i].SubItems.Strings[3] := edtGoodsPrice.Text;
Item[i].SubItems.Strings[4] := edtGoodsAmount.Text;
Item[i].SubItems.Strings[5] := FloatToStr(StrToFloat(edtGoodsPrice.Text)*StrToInt(edtGoodsAmount.Text));
end;
BtnAdd.Click;
end;
Total:=0;
with lvMain.Items do
begin
if count>0 then
begin
for i:=0 to count-1 do
Total:=Total+strtofloat(Item[i].SubItems.Strings[5]);
edtTotal.Text := FloatToStr(Total);
end;
end;
end;
procedure TfrmGoodsOutStock.lvMainDblClick(Sender: TObject);
var
i : Integer;
begin
if lvMain.Items.Count<1 then
begin
Application.MessageBox('没有可选项,不可选择!','提示',MB_OK);
Exit;
end;
if lvMain.SelCount<1 then
begin
Application.MessageBox('请选择记录','提示',MB_OK);
InitEdt;
Exit;
end;
with lvMain.Items do
begin
Flag := 2;
ItemsID := lvMain.Selected.Index;
i := ItemsID;
edtGoodsBH.Text := Item[i].Caption;
edtGoodsName.Text := Item[i].SubItems.Strings[0];
edtGoodsSpec.Text := Item[i].SubItems.Strings[1];
edtGoodsModel.Text := Item[i].SubItems.Strings[2];
edtGoodsPrice.Text := Item[i].SubItems.Strings[3];
edtGoodsAmount.Text := Item[i].SubItems.Strings[4];
edtInVoice.Text := Item[i].SubItems.Strings[5];
end;
InitShowSave;
end;
procedure TfrmGoodsOutStock.lvMainSelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
InitEdt;
InitShowAdd;
end;
procedure TfrmGoodsOutStock.btnEditClick(Sender: TObject);
var
i : Integer;
begin
i := lvMain.SelCount;
if i<0 then
begin
Application.MessageBox('请选择记录','提示',MB_OK);
Exit;
end;
ItemsID := lvMain.Selected.Index;
lvMain.OnDblClick(self);
Flag := 2;
end;
procedure TfrmGoodsOutStock.btnAddClick(Sender: TObject);
begin
Flag := 1;
InitEdt;
InitShowSave;
end;
procedure TfrmGoodsOutStock.btnDeleteClick(Sender: TObject);
var
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -