📄 u_goodsoutstock.~pas
字号:
i : Integer;
begin
if LvMain.Items.Count<1 then
begin
if messagebox(getactivewindow(),'没有可选项,不可选择!','提示',MB_ICONINFORMATION+mb_ok)=IDOK then
exit;
end;
if lvMain.SelCount<1 then
begin
Application.MessageBox('请选择记录','警告',MB_OK);
InitEdt;
Exit;
end;
ItemsID := lvMain.Selected.Index;
if ItemsID>=0 then
begin
lvMain.Items.Item[ItemsID].Delete;
InitEdt;
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
else
begin
Total := 0;
edtTotal.Text := FloatToStr(Total);
end;
end;
end;
procedure TfrmGoodsOutStock.btnOKClick(Sender: TObject);
var
Success,i : Integer;
Check : Tadoquery ;
begin
if (lvMain.Items.Count<1) and (edtTotal.Text = '0') then
begin
Application.MessageBox('请输入商品信息','警告',MB_OK);
edtGoodsBH.SetFocus;
Exit;
end;
{
if edtPayMent.Text = '' then
begin
Application.MessageBox('请输入收款金额','警告',MB_OK);
edtPayMent.SetFocus;
Exit;
end;
if IsNumeric(edtPayMent.Text)= False then
begin
Application.MessageBox('收款金额输入有误','警告',MB_OK);
edtPayMent.SetFocus;
Exit;
end;
if (StrToFloat(edtPayMent.Text)<0) then
begin
Application.MessageBox('付款金额不可为负','警告',MB_OK);
edtPayMent.SetFocus;
Exit;
end;
}
if CusSupply.Text = '' then
begin
Application.MessageBox('请输入客户名称','警告',MB_OK);
CusSupply.SetFocus;
Exit;
end;
//如果是试用版的话,记录控制在20条
if Not IsJXCAvailable then
begin
Check := Tadoquery.Create(self);
Check.Connection := frmDataCtrl.ADOConn;
Check.Close;
Check.SQL.Clear;
Check.SQL.Add('select count(*) as Rec from tb_GoodsOutMaster');
try
Check.Active := true ;
if Check.FieldByName('Rec').AsInteger >=20 then
begin
Application.MessageBox('试用版只能输入20条入库单,请你使用正式版!','警告',MB_OK);
Exit;
end;
except
end;
end;
with pipGoodsOutMaster do
begin
Parameters.ParamByName('@OutBH').Value := EdtGoodsOutBH.Text;
Parameters.ParamByName('@CusName').Value := CusSupply.Text;
Parameters.ParamByName('@OutUser').Value := 'FCU';
Parameters.ParamByName('@OutTotal').Value := edtTotal.Text;
Parameters.ParamByName('@OutPayMon').Value := edtPayMent.Text;
if edtInVoice.Text = '' then
Parameters.ParamByName('@InvoiceMon').Value := '0'
else
Parameters.ParamByName('@InvoiceMon').Value := edtInVoice.Text;
if ChkCheck.Checked then
Parameters.ParamByName('@btCheck').Value := 1
else
Parameters.ParamByName('@btCheck').Value := 0;
ExecProc;
Success := Parameters.ParamByName('@RETURN_VALUE').Value;
end;
if Success = 1 then
begin
with pipGoodsOutDetail do
begin
for i := 0 to lvMain.Items.Count-1 do
begin
with LvMain.Items do
begin
Parameters.ParamByName('@OutBH').Value := EdtGoodsOutBH.Text;
Parameters.ParamByName('@CusName').Value := CusSupply.Text;
Parameters.ParamByName('@GoodsBH').Value := Item[i].Caption;
Parameters.ParamByName('@GoodsSpec').Value := Item[i].SubItems.Strings[1];
Parameters.ParamByName('@GoodsModel').Value := Item[i].SubItems.Strings[2];
Parameters.ParamByName('@GoodsOutSum').Value := Item[i].SubItems.Strings[4];
Parameters.ParamByName('@GoodsOutPrice').Value := Item[i].SubItems.Strings[3];
ExecProc;
Success := Parameters.ParamByName('@RETURN_VALUE').Value;
end;
end;
end;
if StrtoFloat(edtPayMent.Text)>0 then
begin
with pipCusAccount do
begin
Parameters.ParamByName('@CusName').Value := CusSupply.Text;
Parameters.ParamByName('@CusSummary').Value := CusSupply.Text+'付款';
Parameters.ParamByName('@GoodsOutSum').Value := IntToStr(0);
Parameters.ParamByName('@GoodsOutPrice').Value := IntToStr(0);
Parameters.ParamByName('@OutDH').Value := edtGoodsOutBH.Text;
Parameters.ParamByName('@PayMent').Value := edtPayMent.Text;
ExecProc;
Success := Parameters.ParamByName('@RETURN_VALUE').Value;
end;
end;
if Success = 1 then
begin
Application.MessageBox('商品出库成功','提示',MB_OK);
//打印报表
if chkPrint.Checked then
begin
frmGoodsInRep.edtInDate.Caption := edtDate.Text;
frmGoodsInRep.edtInBH.Caption:= edtGoodsInBH.Text;
InRepQry.Close;
InRepQry.SQL.Clear;
InRepQry.SQL.Text:='select * from vw_GoodsInDetail where InBH='+QuotedStr(edtGoodsInBH.Text);
try
InRepQry.Open;
frmGoodsInRep.InReport.Preview;
except
end;
end;
//结束
edtTotal.Clear;
edtPayMent.Clear;
lvMain.Items.Clear;
BtnAdd.Click;
CusSupply.SetFocus;
with popGetGoodsOutBH do
begin
Close;
ExecProc;
EdtGoodsOutBH.Text := Parameters.ParamByName('@billcode').Value;
end;
end;
end;
end;
procedure TfrmGoodsOutStock.btnCancelClick(Sender: TObject);
begin
BtnAdd.Click;
end;
procedure TfrmGoodsOutStock.edtInVoiceKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (key = VK_RETURN) and (Length(edtInVoice.Text)>0) then
begin
if IsNumeric(edtInVoice.Text)= False then
begin
Application.MessageBox('开票价格输入有误','警告',MB_OK);
edtInVoice.SetFocus;
Exit;
end
else
btnOK.SetFocus;
end;
end;
procedure TfrmGoodsOutStock.edtGoodsPriceKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (key = VK_RETURN) and (Length(edtGoodsPrice.Text)>0) then
begin
if IsNumeric(edtGoodsPrice.Text)= False then
begin
Application.MessageBox('单价输入有误','警告',MB_OK);
edtGoodsPrice.SetFocus;
Exit;
end
else
edtGoodsAmount.SetFocus;
end;
end;
procedure TfrmGoodsOutStock.btnAbandonClick(Sender: TObject);
begin
if Application.MessageBox('您确定要放弃吗?','警告',MB_OKCANCEL)=1 then
begin
btnAdd.Click;
lvMain.Items.Clear;
edtTotal.Clear;
edtPayMent.Clear;
end;
end;
procedure TfrmGoodsOutStock.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := Cafree ;
end;
procedure TfrmGoodsOutStock.pmDelClick(Sender: TObject);
begin
btnDelete.Click;
end;
procedure TfrmGoodsOutStock.InitShowADD();
begin
BtnAdd.Show;
BtnEdit.Show;
BtnSave.Hide;
BtnCancel.Hide;
edtGoodsBh.SetFocus;
end;
procedure TfrmGoodsOutStock.InitShowSave();
begin
BtnAdd.Hide;
BtnEdit.Hide;
BtnSave.Show;
BtnCancel.Show;
edtGoodsBh.SetFocus;
end;
procedure TfrmGoodsOutStock.edtGoodsBHExit(Sender: TObject);
var
TempSql : String;
TempQuery : TADOQuery;
begin
if trim(edtGoodsBH.Text)<>'' then
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;
procedure TfrmGoodsOutStock.CusSupplyDblClick(Sender: TObject);
begin
frmCusSearch.CusQry.Close;
frmCusSearch.CusQry.Open;
frmCusSearch.ShowModal;
end;
procedure TfrmGoodsOutStock.CusSupplyExit(Sender: TObject);
var
Check : Tadoquery ;
AddQry: Tadoquery ;
begin
if length(trim(CusSupply.Text))>0 then
begin
Check := Tadoquery.Create(self);
Check.Connection := frmDataCtrl.ADOConn;
Check.Close;
Check.SQL.Clear;
Check.SQL.Add('select * from tb_Customer where CusSName='+QuotedStr(CusSupply.Text));
try
check.Active := true ;
if Check.RecordCount<1 then
if Application.MessageBox('没有此客户,是否增加此客户?','询问',MB_YesNo)=IDYes then
begin
AddCus;
edtGoodsBH.SetFocus;
end
else
begin
CusSupply.Text := '';
CusSupply.SetFocus;
end
else
edtGoodsBH.SetFocus;
except
end;
end;
end;
procedure TfrmGoodsOutStock.AddCus();
var
Check : Tadoquery ;
CusNo : String ;
begin
with sp_GetCusNo do
begin
Close;
ExecProc;
CusNo := Parameters.ParamByName('@billcode').Value;
end;
Check := Tadoquery.Create(self);
Check.Connection := frmDataCtrl.ADOConn;
Check.Close;
Check.SQL.Clear;
Check.SQL.Add(' EXEC pip_Customer '+QuotedStr(CusNo)+','+QuotedStr(CusSupply.Text)+',');
Check.SQL.Add(QuotedStr('')+','+QuotedStr('')+','+QuotedStr('')+','+QuotedStr('')+',');
Check.SQL.Add(QuotedStr('')+','+QuotedStr('')+','+QuotedStr('')+','+QuotedStr('')+',');
Check.SQL.Add(QuotedStr('')+','+'2,'+QuotedStr(''));
try
Check.ExecSQL;
except
showmessage('数据库操作失败!');
end;
end;
procedure TfrmGoodsOutStock.edtPayMentKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if key = vk_Return then
edtInVoice.SetFocus;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -