在做销售录入界面时,如何使用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定义关键帧,即动画每一帧执行什么. 要使用关键帧 ...
随机推荐
- WebSocket原理与实践(四)--生成数据帧
WebSocket原理与实践(四)--生成数据帧 从服务器发往客户端的数据也是同样的数据帧,但是从服务器发送到客户端的数据帧不需要掩码的.我们自己需要去生成数据帧,解析数据帧的时候我们需要分片. 消息 ...
- 谈高清显示接口HDMI、RGB、LVDS、MIPI、eDP、mini-LVDS、V-By-One
近年来随着电子产业的高速发展,智能显示设备也取得了辉煌的成就,高清显示得到了消费者的青睐.目前高清显示协议接口有RGB.LVDS.MIPI.eDP.HDMI.miniLVDS.V-by-One等,由于 ...
- VS诊断工具打开失败
使用管理员模式打开cmd,输入以下命令~ C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -iC:\Windows\Micros ...
- 大话设计模式:代理模式 C#
学无止境,精益求精 十年河东,十年河西,莫欺少年穷 学历代表你的过去,能力代表你的现在,学习代表你的将来 所谓代理模式就是你去委托一个人帮你干一件事!例如:你委托我帮你谈恋爱,你委托我帮你陪你媳妇儿逛 ...
- [Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子:
[Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子: mydf001=sqlContext.read.format("jdbc").o ...
- TensorFlow入门(五)多层 LSTM 通俗易懂版
欢迎转载,但请务必注明原文出处及作者信息. @author: huangyongye @creat_date: 2017-03-09 前言: 根据我本人学习 TensorFlow 实现 LSTM 的经 ...
- Scala学习(四)---映射和元组
映射和元组 摘要: 一个经典的程序员名言是:"如果只能有一种数据结构,那就用哈希表吧".哈希表或者更笼统地说映射,是最灵活多变的数据结构之一.映射是键/值对偶的集合.Scala有一个通用的叫法:元组, ...
- nginx解决前端跨域配置
在nginx.conf文件中 添加如上配置: 在ajax中将原来的 url:http://192.168.1.127:8905/findItem 改成:'http://localhost/findIt ...
- 我的devops实践经验分享一二
前言 随着系统越来越大,开发人员.站点.服务器越来越多,微服务化推进,......等等原因,实现自动化的devops越来越有必要. 当然,真实的原因是,在团队组建之初就预见到了这些问题,所以从一开始就 ...
- spring-session-data-redis包冲突
包冲突 spring 的包很容易冲突, 因为写软件的人在兼容性上处理的不够,一般不检测重复加载. spring-session-data-redis 引用后, 一定要把 spring-session ...