在做销售录入界面时,如何使用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定义关键帧,即动画每一帧执行什么. 要使用关键帧 ...
随机推荐
- SpringMVC+Swagger详细整合
一.新建maven工程导入正确的pom文件 还是那句话,包导入正确就成功了80%.剩下的20%慢慢攻克吧. <project xmlns="http://maven.apache.or ...
- java算法----排序----(4)快速排序
package log; public class Test4 { /** * java算法---快速排序 * * @param args */ public static void main(Str ...
- UOJ219 NOI2016 优秀的拆分 二分、字符串哈希
传送门 题目可以转化为求\(AA\)的数量,设\(cnt1_x\)表示左端点为\(x\)的\(AA\)的数量,\(cnt2_x\)表示右端点为\(x\)的\(AA\)的数量,那么答案就是\(\sum ...
- HTTP-从输入url到请求回数据发生了什么
- HBase最佳实践-管好你的操作系统
本文由 网易云发布. 作者:范欣欣 本篇文章仅限本站分享,如需转载,请联系网易获取授权. 操作系统这个话题其实很早就想拿出来和大家分享,拖到现在一方面是因为对其中各种理论理解并不十分透彻,怕讲不好: ...
- C#_委托与事件
委托: 把方法当作参数进行传递 public delegate void AddDelegate(string name); public class Ad{ //addDelegate就是委托的一个 ...
- CSS 表格实例
CSS 表格实例CSS 表格属性可以帮助您极大地改善表格的外观.CSS Table 属性属性 描述border-collapse 设置是否把表格边框合并为单一的边框.border-spacing 设置 ...
- Ubuntu16.04下安装QQ的完整操作记录(经验证可用)
本机安装了Ubuntu16.04系统,用于日常运维办公.打算在Ubuntu上安装QQ,如下操作记录也使用于Ubuntu18.04: 1)先下载特制的QQ程序包(其实就是基于Wine容器做了一些封装,程 ...
- C. A Mist of Florescence
链接 [http://codeforces.com/contest/989/problem/C] 题意 给定A B C D四个字符个数,让你构造一个矩阵使得他们的个数恰好那么多,联通块算一块 分析 构 ...
- 关于dreamweaver的软件测评
最近在用javascript编写程序,于是便用到了dreamweaver .所以,想写一个关于dreamweaver的软件测评. 学生本人使用的是dreamweaver 8.首先,谈谈本人使用感受,打 ...