<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>仓库</title>
<link href="css/mainnone.css" rel="stylesheet" type="text/css"/>
<link href="css/table.css" rel="stylesheet" type="text/css"/>
<script language="javascript" src="js/util.js"></script>
<script language="javascript" src="js/db.js"></script>
<script language="javascript" src="js/setday.js"></script>
<script language="javascript">
/****************查询数据************/
function readdb()
{
deleteRows();//清楚旧数据
var idx = 0,zlrDors = 0,zsrDors = 0,zzcDors = 0;
var conn = new ActiveXObject("ADODB.Connection");
conn.Open("DBQ="+dbpath +";DRIVER={Microsoft Access Driver (*.mdb)};");
var rs = new ActiveXObject("ADODB.Recordset");
var stime = $v("searchtime");
if("查当天记录" == $v("searchtime") || $v("searchtime").length == 0)
{
stime = getMyTime(null,"yyyy-MM-dd");
}
var sql="select * from shouru where createtime >=#"+stime+"# order by createtime";
//alert(sql);
rs.open(sql,conn);
var obj = $('portTbl');
while(!rs.EOF)
{
var new_row = obj.insertRow(1);//增加第rows行
for (var i = 0; i < 4 ;i++)
{
var dor = parseFloat(rs("jine"));
var new_cell = new_row.insertCell(i);
new_cell.height = "25px";
new_cell.align="center";
if (i==0) new_cell.innerText = parseInt(idx)+1;
if (i==1) new_cell.innerHTML = rs("xiangmu");
if (i==2) new_cell.innerHTML = dor;
if (i==3) new_cell.innerHTML = getMyTime(rs("createtime"));
}
rs.moveNext;
idx++;
zlrDors += dor;
if(dor > 0)
{
zsrDors += dor;
}else
{
zzcDors += dor;
}
}
rs.close();
rs = null;
conn.close();
conn = null;
$("zlr").value = "¥" + zlrDors;//总利润
$("zsr").value = "¥" + zsrDors;//总收入
$("zzc").value = "¥" + zzcDors;//总支出
$('hid').value = parseInt(idx) + 1;
$("myflghid").value = 0;
}
/*******数据录入*****************/
function writedb()
{
if(0 == $v("myflghid"))
{
alert("请录入数据!");
return;
}
var sqls = new Array();
var rows = $v('hid');
for(var i = 1 ;i<rows ; i++)
{
if(0 == $v("srzc"+i))
{
continue;
}
sqls[i-1] = "insert into shouru(xiangmu,jine,createtime) "
+ "values('"+$v("xmmc"+i)+"','"+$v("srzc"+i)+"','"+$v("mydatetime"+i)+"')"; // alert(sqls[i-1]);
}
var myFlg = runsqls(sqls); //执行多条语句;runsql执行单条语句; // true != myFlg ? alert("数据录入失败!") : window.location.reload(ture);
if(myFlg)
{
alert("数据录入成功!");
window.location.reload(true);
}else
{
alert("数据录入失败!");
}
}
/**********添加数据行*******/
function addRow()
{
if(0 == $v("myflghid")){deleteRows();}
var obj = $('portTbl');
var rows = $v('hid');
var new_row = obj.insertRow(rows);//增加第rows行
for (var i = 0; i < 4 ;i++)
{
var new_cell = new_row.insertCell(i);
new_cell.align="center";
if (i==0) new_cell.innerText = rows;
if (i==1) new_cell.innerHTML = "<input id='xmmc"+rows+"' size='85%' type='text' value='"+ rows +"'/>";
if (i==2) new_cell.innerHTML = "<input id='srzc"+rows+"' maxLength='10' size='20%' type='text' value='0' onkeypress='return event.keyCode>=4&&event.keyCode<=57' "
+ "onfocus=\" this.style.imeMode=\'disabled\'\"\/>";
if (i==3) new_cell.innerHTML = "<input id='mydatetime"+rows+"' size='20%' type='text' value='" + getMyTime()+"'"
+ "onclick='SelectDate(this)' readOnly/>";
}
$('hid').value = parseInt(rows) + 1;
}
/************删除数据行************************/
function deleteRows()
{
var obj = $('portTbl');
var rowNum=obj.rows.length;
for (i = 1;i < rowNum; i++)
{
obj.deleteRow(i);
rowNum = rowNum-1;
i=i-1;
}
$('hid').value = 1;
$("myflghid").value = true;
}
</script>
</head>
<body>
<input type="hidden" value="1" id="hid">
<input type="hidden" value="0" id="myflghid">
<input type="button" id="ck" name="ck" value="查 询" onclick="readdb();">
<input type="text" id="searchtime" name="searchtime" value="查当天记录" class="txtReadOnly" size="23" onclick="SelectDate(this,'yyyy-MM-dd')" readonly>
当前时间:<table
width="100%" cellspacing="0" cellpadding="0" id="portTbl" height="26" bordercolor="#949494" border="1" style="border-collapse: collapse">
<tr>
<td width="8%" align="center" bgcolor="#619EF2" height="26">
<font color="#FFFFFF">序号</font></td>
<td width="53%" align="center" bgcolor="#619EF2" height="26">
<font color="#FFFFFF">项目名称</font></td>
<td width="14%" align="center" bgcolor="#619EF2" height="26">
<font color="#FFFFFF">+收入/支出-</font></td>
<td width="15%" align="center" bgcolor="#619EF2" height="26">
<font color="#FFFFFF">当前时间</font></td>
<td width="9%" align="center" bgcolor="#619EF2" height="26">
<font color="#FFFFFF">操 作</font></td>
</tr></table>
<input type="button" id="ck1" name="ck1" value="增加项目" onclick="addRow();">
<input type="button" id="ck0" name="ck0" value="确定录入" onclick="writedb();">
总利润<input type="text" id="zlr" size="15" readonly> = 总收入 <input type="text" id="zsr" size="15" readonly>
+ 总支出<input type="text" id="zzc" size="15" readonly>
</body>
</html>
评论0