小编VAA*_*AAA的帖子

如何在SQL中执行运行总和(余额)

我有 2 个 SQL 表

单位交易 单位详细交易

(此处的表架构:http://sqlfiddle.com/#!3/ e3204/ 2)

这是表格及其示例数据

我需要的是执行 SQL 查询以生成包含余额的表。现在我有这个 SQL 查询,但它不能正常工作,因为当我有 2 个具有相同日期的交易时,余额计算不正确。

SELECT 
ft.transactionid,
ft.date,
ft.reference,
ft.transactiontype,
CASE ftd.isdebit WHEN 1 THEN MAX(ftd.debitaccountid) ELSE MAX(ftd.creditaccountid) END as financialaccountname,
CAST(COUNT(0) as tinyint) as totaldetailrecords,
ftd.isdebit,
SUM(ftd.amount) as amount,
balance.amount as balance
FROM unit_transaction_details ftd
JOIN unit_transactions ft ON ft.transactionid = ftd.transactionid
JOIN
(
    SELECT DISTINCT
    a.transactionid,
    SUM(CASE b.isdebit WHEN 1 THEN b.amount ELSE -ABS(b.amount) END) as amount
    --SUM(b.debit-b.credit) as amount
    FROM unit_transaction_details a
    JOIN unit_transactions …
Run Code Online (Sandbox Code Playgroud)

sql accounting

1
推荐指数
1
解决办法
8255
查看次数

C#5 Async Await .Task.Factory.StartNew取消

我有实现取消令牌的异步代码.它正在工作,但我不确定这是否是正确的方法,所以我只想要反馈.

这是实际的代码:

    /// <summary>
    /// 
    /// </summary>
    private async void SaveData() {

        if (GetActiveServiceRequest() != null)
        {
            var tokenSource = new System.Threading.CancellationTokenSource();


            this.ShowWizardPleaseWait("Saving data...");

            var someTask = System.Threading.Tasks.Task<bool>.Factory.StartNew(() =>
            {

                bool returnVal = false;

                // Set sleep of 7 seconds to test the 5 seconds timeout.
                System.Threading.Thread.Sleep(7000);

                if (!tokenSource.IsCancellationRequested)
                {
                    // if not cancelled then save data

                    App.Data.EmployeeWCF ws = new App.Data.EmployeeWCF ();
                    returnVal = ws.UpdateData(_employee.Data);
                    ws.Dispose();
                }

                return returnVal;

            }, tokenSource.Token);


            if (await System.Threading.Tasks.Task.WhenAny(someTask, System.Threading.Tasks.Task.Delay(5000)) == someTask)
            {
                // …
Run Code Online (Sandbox Code Playgroud)

c# task-parallel-library async-await

1
推荐指数
1
解决办法
3150
查看次数

Bootstrap文本字段按钮添加标签

我有以下引导代码用于显示带按钮的文本字段:

 <div class="form-group">
   <div class="input-group">
      <span class="input-group-btn">
      <button class="btn btn-default" type="button">Go!</button>
      </span>
      <label>Second Column</label>
      <input type="text" class="form-control" placeholder="Search for...">
   </div>
   <!-- /input-group -->
</div>
Run Code Online (Sandbox Code Playgroud)

我应该得到这样的东西:

在此输入图像描述

但我得到的是:

在此输入图像描述

我猜它是因为<label>标签.

关于如何解决这个问题的任何线索?

css css3 twitter-bootstrap twitter-bootstrap-3

1
推荐指数
1
解决办法
1119
查看次数

任务ContinuewWith等待返回错误

我有以下代码使用 System.Threading.Tasks

private async void UploadDocument(System.IO.FileInfo fileInfo)
{
    var someTask = await Task.Run<bool>(() =>
    {
        // open input stream
        using (System.IO.FileStream stream = new System.IO.FileStream(FileTextBox.Text, System.IO.FileMode.Open, System.IO.FileAccess.Read))
        {
            using (StreamWithProgress uploadStreamWithProgress = new StreamWithProgress(stream))
            {
                uploadStreamWithProgress.ProgressChanged += uploadStreamWithProgress_ProgressChanged;

                // start service client
                FileTransferWCF.FileTransferServiceClient client = new FileTransferWCF.FileTransferServiceClient();
                //FileTransferClient.FileTransferServiceClient client = new FileTransferClient.FileTransferServiceClient();

                // upload file
                client.UploadFile(fileInfo.Name, fileInfo.Length, uploadStreamWithProgress);

                // close service client
                client.Close();
            }
        }

        return true;

    }).ContinueWith(r =>{
        if(r.Result) LogText("Done!!");
    });

}
Run Code Online (Sandbox Code Playgroud)

如果我离开这个并尝试编译我得到:

"无法将void分配给隐式类型的局部变量"** var someTask

所以我var someTask …

c# task-parallel-library async-await

0
推荐指数
1
解决办法
1635
查看次数