protected void OnBtnGoClicked(object sender, EventArgs e) { if (!datStartDate.SelectedDate.HasValue || !datEndDate.SelectedDate.HasValue) { string message = ResourceManager.GetString("messageInvalidDateTurnover"); string script = "<script type=\"text/javascript\">"; script += " alert(\"" + message + "\");"; script += " </script>"; if (!ClientScript.IsClientScriptBlockRegistered("ttt")) ClientScript.RegisterStartupScript(this.GetType(), "ttt", script); } else { InvoicesRepository repo = new InvoicesRepository(); double? iAmount = repo.GetSumAmountNotVAT("I", datStartDate.SelectedDate, datEndDate.SelectedDate); double? cAmount = repo.GetSumAmountNotVAT("C", datStartDate.SelectedDate, datEndDate.SelectedDate); double result = (iAmount.HasValue ? iAmount.Value : 0) - (cAmount.HasValue ? cAmount.Value : 0); txtResult.Text = result.ToString(); } }