在做销售录入界面时,如何使用dbgrid?(50分)
给你段源码看一看
用stringgird做得:
procedure Tfrmingoods.adddata ;
var
i:integer;
begin
for i:= to listgrid.RowCount - do
begin
if trim(listgrid.Cells[,i])=trim(goodsid.Text) then
begin
messagedlg('该种商品已输入!',mtWarning,[mbok],);
exit;
end;
end;
if goodsid.Text<>'' then
begin
if dm.commquery.Active then
dm.commquery.Active :=false;
dm.commquery.SQL.Clear ;
dm.commquery.SQL.Add('select * from goods where goodsid='+goodsid.Text+' and isdel=0');
try
dm.commquery.Open ;
if not dm.commquery.Eof then
begin
// currentrow:=cursorposition;
listgrid.Cells[,listgrid.RowCount-]:=dm.commquery.FieldValues['goodsid'];
listgrid.Cells[,listgrid.RowCount-]:=dm.commquery.FieldValues['goodsname'];
listgrid.Cells[,listgrid.RowCount-]:=dm.commquery.FieldValues['standard'];
listgrid.Cells[,listgrid.RowCount-]:=dm.commquery.FieldValues['unit'];
listgrid.Cells[,listgrid.RowCount-]:=trim(format('%8.2f',[dm.commquery.Fieldbyname('inprice').AsFloat]));
listgrid.RowCount :=listgrid.RowCount +;
listgrid.Col:=;
listgrid.Row:=listgrid.RowCount-;
listgrid.SetFocus ;
currentcursor(listgrid.RowCount-);
end
else
messagedlg('没有该种商品',mtWarning,[mbok],);
except
messagedlg('输入了非法字符!',mtWarning,[mbok],);
end;
end;
end;
下面是用query+dbgird做得:
procedure Tfrmoutgoods.goodsidKeyPress(Sender: TObject; var Key: Char);
begin
if key=# then
begin
if dm.commquery.Active then
dm.commquery.Active :=false;
dm.commquery.SQL.Clear ;
dm.commquery.SQL.Add('select goodsid,goodsname,standard,unit,redailprice from goods where goodsid='+goodsid.Text+' and isdel=0');
dm.commquery.Open;
if not dm.commquery.Eof then
begin
if not tempquery.Active then
tempquery.Open ;
if tempquery.Locate('goodsid',goodsid.Text,[loCaseInsensitive]) then
begin
application.MessageBox('该商品已经输入。','提示',mb_ok);
end
else
begin
tempquery.Append ;
tempquery.FieldValues['goodsid']:=dm.commquery.FieldValues['goodsid'];
tempquery.FieldValues['goodsname']:=dm.commquery.FieldValues['goodsname'];
tempquery.FieldValues['standard']:=dm.commquery.FieldValues['standard'];
tempquery.FieldValues['goodsunit']:=dm.commquery.FieldValues['unit'];
tempquery.FieldValues['goodsprice']:=dm.commquery.FieldValues['redailprice'];
tempquery.FieldValues['flage']:=;
end;
end //结束关于goods表的查询。
else
application.MessageBox('没有该商品。','提示',mb_ok);
end;
end; procedure Tfrmoutgoods.tempqueryCalcFields(DataSet: TDataSet);
begin
tempquerytotalprice.Value :=tempquerygoodscount.Value *tempquerygoodsprice.Value ;
end; procedure Tfrmoutgoods.tempquerygoodscountValidate(Sender: TField);
var
flage:integer; //定义商品的库存状态类别:0:有库存且满足所需;1:库存中该商品数量不足;2:库存中没有该商品;
begin
if (goodsid.Text<>'') and (trim(storname.Text)<>'') then
begin
flage:=;
if dm.commquery.Active then
dm.commquery.Active :=false;
dm.commquery.SQL.Clear ;
dm.commquery.SQL.Add('select sum(a.incount) as storecount from storagelist a,storehouse b where a.storehouseid=b.storehouseid and a.goodsid='+tempquery.FieldValues['goodsid']+' and b.storehousename='+#+trim(storname.Text)+#);
dm.commquery.Open;
if dm.commquery.Eof then
begin
messagedlg('该商品没有库存!',mtWarning,[mbok],);
flage:=;
end
else
begin
if dm.commquery.FieldValues['storecount']<sender.Value then
begin
messagedlg('该商品库存不足!',mtWarning,[mbok],);
flage:=;
end;
end;
dm.commquery.Close ;
case flage of
: tempquery.FieldValues['flage']:=;
: tempquery.FieldValues['flage']:=;
: tempquery.FieldValues['flage']:=;
end;
end
else
begin
application.MessageBox('请选择出货仓库。','提示',mb_ok);
end;
end;
用query+dbgrid需要一个临时表来做。
在做销售录入界面时,如何使用dbgrid?(50分)的更多相关文章
- 在做APP前端开发时应注意的一些问题
在做APP前端开发时应注意的一些问题 在整个app开发流程中,app前端开发是一个必不可少的环节,也是一个在app开发过程中重量级的角色.说到这,那么在app应用的前端开发中,又要注意什么问题呢?一. ...
- Android UI组件----用相对布局RelativeLayout做一个登陆界面
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...
- C正则库做DNS域名验证时的性能对比
C正则库做DNS域名验证时的性能对比 本文对C的正则库regex和pcre在做域名验证的场景下做评测. 验证DNS域名的正则表达式为: "^[0-9a-zA-Z_-]+(\\.[0-9a ...
- 通过navigationController跳转界面时隐藏navigationBar上的元素
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- 当list做gridview的数据源时,可以用泛型来对list进行排序
当list做gridview的数据源时,可以用泛型来对list进行排序 ,代码如下 var temps = from t in list orderby t.paymentAmount descend ...
- Mysql命令-以NULL做where条件过滤时应该写 IS NULL;
以NULL做where条件过滤时应该写 IS NULL;SELECT * FROM pet WHERE death IS NULL; SELECT * FROM pet WHERE death IS ...
- 【转载】 深度学习总结:用pytorch做dropout和Batch Normalization时需要注意的地方,用tensorflow做dropout和BN时需要注意的地方,
原文地址: https://blog.csdn.net/weixin_40759186/article/details/87547795 ------------------------------- ...
- tkinter如何设置界面消失 当制作一个登陆界面时,登陆成功之后,如何让登陆界面本身消失
tkinter如何设置界面消失 当制作一个登陆界面时,登陆成功之后,如何让登陆界面本身消失 if querySQL.checkAll():#用户名和密码都输入正确 self.root.withdraw ...
- 利用@keyframe及animation做一个页面Loading时的小动画
前言 利用@keyframe规则和animation常用属性做一个页面Loading时的小动画. 1 @keyframe规则简介 @keyframes定义关键帧,即动画每一帧执行什么. 要使用关键帧 ...
随机推荐
- 图、dfs、bfs
graphdfsbfs 1.clone graph2.copy list with random pointer3.topological sorting4.permutations5.subsets ...
- PAT A1130 Infix Expression (25 分)——中序遍历
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with pa ...
- ESP32 ADC
2个12位的ADC,共计18通道,ADC2比较特殊的一点就是:ADC2和wifi共用,wifi的优先级更高,所以ADC2只有在WIFI模块不用的情况下好使: 在读取ADC数据之前,必须先对ADC进行设 ...
- OOM异常的4种可能分析
OOM异常:OutOfMemoryError 1.JAVA堆溢出 JAVA堆用于存储对象实例,只要不断的创建对象,并且保证GC Roots到这些对象之间有路径可以来避免垃圾回收机制清除这些对象,那么在 ...
- IntelliJ IDEA 常用设置 (二)
一. 代码提示和补充功能有一个特性:区分大小写. 区分大小写的情况是这样的:比如我们在 Java 代码文件中输入 stringBuffer IntelliJ IDEA 是不会帮我们提示或是代码补充的, ...
- 自建mvc5项目里几个类图
AccoutController.cs AccountViewModels.cs IdentityModel.cs
- 05-Mirrorgate数据库信息
1.登录数据库 [root@node1 ~]# mongo localhost: > show dbs; admin .000GB dashboarddb .001GB local .000GB ...
- python3 installed 安装 pip3
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3
- Java Mongo 自定义序列化笔记
从insert方法入手 1. org.springframework.data.mongodb.repository.support.SimpleMongoRepository.java inse ...
- 编写脚本自动部署反向代理、web、nfs
服务器端 #!/bin/bash function nginx_install(){ if [[ -f /usr/sbin/nginx ]]; then echo 'Nginx has been in ...