我有一个数据库,我正在尝试为其创建网页摘要小部件。我正在使用 MS Webmatrix 和剃须刀。
我有几个选择查询设置为变量,然后我的 html 将它们的值作为字符串询问并显示它们。到目前为止,一切都很好。
现在我想将两个结果相加,然后减去第三个。EG:添加今天处理的订单(我称之为 itotl)和今天部分处理的订单(ppr)并减去今天的信用(ctotl)。
因此,我想要 (itotl + ppr) - ctotl。
如果我尝试通过在我的 html 中输入 @itotl 和 @ppr 变量等来执行此操作,则会失败。
将有一个简单的行业最佳实践方法来做到这一点,但我只是在学习,而且很难!
有什么建议么?如果有帮助,我可以在这里粘贴整个代码。这里:
@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "SCOREBOARD";
var db = Database.Open("data");
var itot = db.QueryValue("SELECT SUM(SUBTOTAL) from dbo.DR_TRANS where TRANSDATE = 41192 and SUBTOTAL >0");
var isum = db.QueryValue("SELECT COUNT(subtotal) from dbo.DR_TRANS where TRANSDATE = 41192 and Subtotal >0");
var qsum = db.QueryValue("SELECT COUNT(subtotal) from dbo.SALESORD_HDR where ORDERDATE = 41192 and Subtotal >0");
var ppr = db.QueryValue("select sum(subtotal) from dbo.SALESORD_HDR where ORDERDATE = 41192 and SUBTOTAL >0 and status = 1");
var psum = db.QueryValue("SELECT COUNT(subtotal) from dbo.SALESORD_HDR where ORDERDATE = 41192 and Status =1");
var qtot = db.QueryValue("SELECT SUM(SUBTOTAL) FROM dbo.SALESORD_HDR where ORDERDATE = 41192 and SUBTOTAL >0");
var ctot = db.QueryValue("SELECT SUM(SUBTOTAL) from dbo.DR_TRANS where TRANSDATE = 41192 and TRANSTYPE = 1 and SUBTOTAL <0");
var csum = db.QueryValue("SELECT COUNT(SUBTOTAL) from dbo.DR_TRANS where TRANSDATE = 41192 and TRANSTYPE = 1 and SUBTOTAL <0");
<META HTTP-EQUIV="REFRESH" CONTENT="15"></META>;
}<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<style>
.column1 {color: blue; font-weight: bold; font-size: 1.6em;}
.column2 {color: red;}
</style>
</head>
<body>
<p>@qsum.ToString() Quotes:
<span class=@(qtot > 20000 ? "column1" : "column2")>@qtot.ToString("C")</span>
</p>
<p>@psum.ToString() Partly Processed:
<span class=@(ppr > 18000 ? "column1" : "column2")>@ppr.ToString("C")</span>
</p>
<p>@isum.ToString() Invoices:
<span class=@(itot > 18000 ? "column1" : "column2")>@itot.ToString("C")</span>
</p>
<p>@csum.ToString() Credits:
<span class=@(ctot > 18000 ? "column1" : "column2")>@ctot.ToString("C")</span>
</p>
<p>Nett Sales:</p>
</body>
</html>
如何让我的标记整齐地显示在堆栈中?这使得阅读有点困难!