物资管理信息系统6 -- 材料信息界面

前端之家收集整理的这篇文章主要介绍了物资管理信息系统6 -- 材料信息界面前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//importwin.ui;
/*DSG{{*/
varwinform=..win.form(text="材料信息管理窗口";right=600;bottom=400;edge=1;parent=...)
winform.add(
button={cls="button";text="新增";left=396;top=271;right=469;bottom=302;group=1;z=12};
button2={cls="button";text="删除";left=498;top=271;right=571;bottom=302;group=1;z=13};
button3={cls="button";text="修改";left=398;top=336;right=471;bottom=367;group=1;z=14};
button4={cls="button";text="返回";left=495;top=334;right=568;bottom=365;group=1;z=2};
button5={cls="button";text="选择";left=131;top=339;right=212;bottom=369;z=16};
groupBox={cls="groupBox";left=370;top=11;right=589;bottom=385;cp=1;edge=1;group=1;z=15};
groupBox2={cls="groupBox";text="材料列表";left=7;top=12;right=361;bottom=387;edge=1;z=1};
name={cls="edit";left=461;top=90;right=573;bottom=115;edge=1;group=1;z=9};
showid={cls="edit";left=461;top=38;right=573;bottom=63;edge=1;group=1;readonly=1;z=8};
static1={cls="static";text="材料编码";left=393;top=41;right=445;bottom=66;group=1;transparent=1;z=3};
static2={cls="static";text="材料名称";left=393;top=92;right=445;bottom=117;group=1;transparent=1;z=4};
static3={cls="static";text="规格型号";left=393;top=144;right=445;bottom=169;group=1;transparent=1;z=5};
static4={cls="static";text="计量单位";left=393;top=196;right=445;bottom=221;group=1;transparent=1;z=6};
static5={cls="static";left=19;top=34;right=351;bottom=294;border=1;transparent=1;z=7};
tp={cls="edit";left=461;top=141;right=573;bottom=166;edge=1;group=1;z=10};
unit={cls="edit";left=462;top=193;right=573;bottom=218;edge=1;group=1;z=11}
)
/*}}*/

importcom;

vardb=sqlite("/store.db");
vardataGrid=winform.static5.createEmbed("MSFlexGridLib.MSFlexGrid.1");
vargd=dataGrid._object

withgd{
	Cols=4//列
	Rows=1//行
	setTextMatrix(0,"材料编码")
	setTextMatrix(0,1,"材料名称")
	setTextMatrix(0,2,"规格型号")
	setTextMatrix(0,3,"计量单位")
	AllowUserResizing=1
}

varshowData=function(id,na,tp,un){//列表显示数据
	withgd{
		Rows=gd.Rows+1
		row=gd.Rows-1
		col=0
		Text=id
		col=1
		Text=na
		col=2
		Text=tp
		col=3
		Text=un
	}
}

varnid=tostring(1000)
forid,name,unindb.each("SELECT*from[Goods]ORDERBYGoodsId"){//属性赋值写法
	showData(id,un)
	if(nid<id)nid=id	
}

winform.button2.disabled=1
winform.button3.disabled=1

dataGrid.DblClick=function(){//MSFlexGrid双击事件
	if(gd.Row=0)return;
	gd.col=0
	varrs=db.stepQuery("SELECT*FROM[Goods]",{GoodsId=gd.Text})
	if(rs){
		winform.showid.text=rs.GoodsId
		winform.name.text=rs.GoodsName
		winform.tp.text=rs.Type
		winform.unit.text=rs.Unit		
	}	
	winform.button2.disabled=0
	winform.button3.disabled=0	
}

assignment=function(){//文本框赋值
	varid=winform.showid.text
	varname=winform.name.text
	var	tp=winform.tp.text
	var	un=winform.unit.text	
	returnid,un;
}

winform.button5.oncommand=function(id,event){//选择;	
	dataGrid.DblClick(db)		
}

winform.button.oncommand=function(id,event){//新增;
	winform.showid.text=nid+1
	varid,un=assignment()
	winform.name.setFocus()
	if(!#name){
		winform.msgBox("请输入材料名称")
		winform.name.setFocus()
	}
	elseif(!#tp){
		winform.msgBox("请输入规格型号")
		winform.tp.setFocus()
	}
	elseif(!#un){
		winform.msgBox("请输入计量单位")
		winform.unit.setFocus()
	}
	else{
		varrs=db.stepQuery("SELECT*FROM[Goods]",{GoodsName=name;Unit=un;Type=tp})
		if(rs){
			winform.msgBox("已经存在此种材料的记录")
		}else{
			db.exec("insertinto[Goods]values(@GoodsId,@GoodsName,@Type,@Unit);",{GoodsId=id;GoodsName=name;Unit=un;Type=tp})
			showData(id,un)			
			nid=id
		}
	}
}

winform.button2.oncommand=function(id,event){//删除;	
	varid=assignment()
	varrs=db.stepQuery("SELECT*FROM[Goods]",{GoodsId=id})
	if(rs){	
		if(!winform.msgBoxTest("您确定要删除该纪录吗?,这可能会导致数据的丢失")){
			return;	
		}else{				
			db.exec("DELETEFROM[Goods]whereGoodsId=@gid;",{gid=id})
			gd.RemoveItem(gd.RowSel)									
		}	
	}
}

winform.button3.oncommand=function(id,event){//修改;	
	varid,un=assignment()
	if(!winform.msgBoxTest("您确定要修改该纪录吗?")){
		return;
	}
	else{
		varrs=db.stepQuery("SELECT*FROM[Goods]",{GoodsName=name;Unit=un;Type=tp})
			if(rs){
				winform.msgBox("已经存在此种材料的记录"+rs.GoodsId)
			}
			else{	
				db.exec("UPDATE[Goods]SETGoodsName=@name,Unit=@un,Type=@tpWHEREGoodsId=@id;",{id=id;name=name;un=un;tp=tp});		
		gd.col=1
				gd.Text=name
				gd.col=2
				gd.Text=tp
				gd.col=3
				gd.Text=un
			}
	}			
}

winform.button4.oncommand=function(id,event){//返回;	
	db.close();
	winform.close()	;
}

winform.show();
win.loopMessage();
returnwinform;
原文链接:https://www.f2er.com/sqlite/200729.html

猜你在找的Sqlite相关文章