在做销售录入界面时,如何使用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定义关键帧,即动画每一帧执行什么. 要使用关键帧 ...
随机推荐
- zabbix学习-如何部署一个agent客户端
1. 部署一个agent客户端很简单,比如监控服务器本身 yum install zabbix-agent -y 2.配置文件位置: vim /etc/zabbix/zabbix-agendt.con ...
- 我是怎样和Linux系统结缘并通过红帽RHCE认证的
我高考完当时就是选择的计算机科学与技术专业,上大学以后联想到的和计算机相关的就只有写代码,开发,网站,网页设计,就没有其他的了,当时学习写代码也都是在Windows上,什么C#.C++之类的?大约在大 ...
- springzuul实现限流
限流描述 https://www.cnblogs.com/LBSer/p/4083131.html 第一步添加pom文件 <!--限流--> <dependency> < ...
- SQL 公用表达式CTE
一 基本用法 with mywith as(select * from Student ) select * from mywith 二 递归调用 with mywith as( select ID, ...
- Linux DNS原理简介及配置
Linux DNS原理简介及配置 DNS简介 DNS原理 域名解析的过程 资源记录 DNS BIND安装配置 一.简介 一般来讲域名比IP地址更加的有含义.也更容易记住,所以通常用户更习惯输入域名来访 ...
- 解决Skyline6.5多球对比时,自动运行TerraExplorer软件的问题
如果你的操作系统是Win7 64位,在运行Skyline6.5提供的ITE3DWindowEx控件实现多球对比时,启动程序调试运行时,却自动运行了TerraExplorer软件, 这时候你会发现for ...
- 16-(基础入门篇)GPRS(Air202)关于多个文件中的变量调用和定时器
https://www.cnblogs.com/yangfengwu/p/9968405.html 因为自己看到好多问多个文件调用的,感觉这个应该说一说 对了大家有没有知道这个是干什么的 大家有没有看 ...
- docker[caffe&&pycaffe]
0 引言 今天花了一天,完成了整个caffe的dockerfile编写,其支持python3.6.6,这里主要的注意点是protobuf的版本(在3.6.0之后,只支持c11),还有在制作镜像的时候注 ...
- (原创)odoo11.0 如何运行python单元测试
官方文档中运行单元测试有三个条件 1.为模块创建tests的子包,建立测试用例 2.将配置项test_enable设置为true,命令行通过--test-enable选项 3.当模块安装或者更新时,测 ...
- 手机端@media的屏幕适配
@media only screen and (width: 320px) { html { font-size: 16px; }} @media only screen and (width: 36 ...