2 queries - 1 SQL Server Agent Job - tsql

I have the following T-SQL job that I run - I need to pull invoices and credit notes into the one email - however, in two separate tables:
DECLARE #bodyMsg nvarchar(max)
DECLARE #subject nvarchar(max)
DECLARE #tableHTML nvarchar(max)
DECLARE #tableHTML2 nvarchar(max)
SET #subject = 'Invoices & Credits in Past Week'
SET #tableHTML =
N'<style type="text/css">
#box-table
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
text-align: center;
border-collapse: collapse;
border-top: 7px solid #9baff1;
border-bottom: 7px solid #9baff1;
border-spacing: 10px;
}
#box-table th
{
font-size: 13px;
font-weight: normal;
background: #b9c9fe;
border-right: 2px solid #9baff1;
border-left: 2px solid #9baff1;
border-bottom: 2px solid #9baff1;
color: #039;
border-spacing: 10px;
padding: 15px;
}
#box-table td
{
border-right: 1px solid #aabcfe;
border-left: 1px solid #aabcfe;
border-bottom: 1px solid #aabcfe;
color: #669;
border-spacing: 10px;
padding: 15px;
}
tr:nth-child(odd) { background-color:#eee; }
tr:nth-child(even) { background-color:#fff; }
</style>'+
N'<H3><font color="Red">Invoices from Past week</H3>' +
N'<table id="box-table" >' +
N'<tr>
<th>Invoice #</th>
<th>Date</th>
<th>Account #</th>
<th>Customer</th>
<th>ex GST</th>
</tr>' +
CAST ( (
SELECT
td = OINV.DocNum ,'',
td =CONVERT(VARCHAR(8), OINV.DocDate, 3) ,'',
td = OINV.CardCode ,'',
td = OINV.CardName ,'',
td = '$' + CONVERT(varchar, CONVERT(money, OINV.DocTotal-OINV.VatSum-OINV.TotalExpns), 1)
FROM OINV INNER JOIN OSLP ON OINV.SlpCode = OSLP.SlpCode
WHERE OSLP.SlpName = 'SALES REP' and OINV.DocDate > DATEADD(DAY, -7, GETDATE())
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) )
#tableHTML2 =
N'<style type="text/css">
#box-table
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
text-align: center;
border-collapse: collapse;
border-top: 7px solid #9baff1;
border-bottom: 7px solid #9baff1;
border-spacing: 10px;
}
#box-table th
{
font-size: 13px;
font-weight: normal;
background: #b9c9fe;
border-right: 2px solid #9baff1;
border-left: 2px solid #9baff1;
border-bottom: 2px solid #9baff1;
color: #039;
border-spacing: 10px;
padding: 15px;
}
#box-table td
{
border-right: 1px solid #aabcfe;
border-left: 1px solid #aabcfe;
border-bottom: 1px solid #aabcfe;
color: #669;
border-spacing: 10px;
padding: 15px;
}
tr:nth-child(odd) { background-color:#eee; }
tr:nth-child(even) { background-color:#fff; }
</style>'+
N'<H3><font color="Red">Credits from Past week</H3>' +
N'<table id="box-table" >' +
N'<tr>
<th>Credit #</th>
<th>Date</th>
<th>Account #</th>
<th>Customer</th>
<th>ex GST</th>
</tr>' +
CAST ( (
SELECT
td = ORIN.DocNum ,'',
td =CONVERT(VARCHAR(8), ORIN.DocDate, 3) ,'',
td = ORIN.CardCode ,'',
td = ORIN.CardName ,'',
td = '$' + CONVERT(varchar, CONVERT(money, ORIN.DocTotal-ORIN.VatSum-ORIN.TotalExpns), 1)
FROM ORIN INNER JOIN OSLP ON ORIN.SlpCode = OSLP.SlpCode
WHERE OSLP.SlpName = 'SALES REP' and ORIN.DocDate > DATEADD(DAY, -7, GETDATE())
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'</table>'
EXEC msdb.dbo.sp_send_dbmail #recipients='email#email.com',
#profile_name = 'SQL Alerts',
#subject = #subject,
#body = #tableHTML,
#body = #tableHTML2,
#body_format = 'HTML' ;
This T-SQL script runs when I only have #tableHTML in the query.
I need to find out why the above is erroring?
Any help appreciated!
Regards
Rick

Related

Possible to set the size and font of text of GtkButton with Glade?

is it possible to set the size and font of text of a GtkButton with Glade (Version 3.38.2) ?
If yes, how? :D
You can add "Style classes" under Common tab, Widget Attributes.
Then if you add "large" style class you can do css:
.large {
color: blue;
font-weight: bolder;
font-size:32px;
border-style: solid;
border-width: 2px 0 2px 2px;
padding: 8px;
}
Provide this to the GTK widget form:
css = b"""
.large {
color: blue;
font-weight: bolder;
font-size:32px;
border-style: solid;
border-width: 2px 0 2px 2px;
padding: 8px;
}"""
style_provider = Gtk.CssProvider()
style_provider.load_from_data(css)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
As in that example: https://gist.github.com/fcwu/5794494

Add image in select

I am using custom select box by "W3Schools" , from this link "https://www.w3schools.com/howto/howto_custom_select.asp" , but I want to modify this to allow inserting image on left side of the text , How to modify java script to add image near text ?
This is a selected option with image
Html:
<select class="vodiapicker">
<option value="en" class="test" data-thumbnail="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/LetterA.svg/2000px-LetterA.svg.png">English</option>
<option value="au" data-thumbnail="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/NYCS-bull-trans-B.svg/480px-NYCS-bull-trans-B.svg.png">Engllish (AU)</option>
<option value="uk" data-thumbnail="https://glot.io/static/img/c.svg?etag=ZaoLBh_p">Chinese (Simplified)</option>
<option value="cn" data-thumbnail="https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/NYCS-bull-trans-D.svg/2000px-NYCS-bull-trans-D.svg.png">German</option>
<option value="de" data-thumbnail="https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/MO-supp-E.svg/600px-MO-supp-E.svg.png">Danish</option>
<option value="dk" data-thumbnail="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/F_icon.svg/267px-F_icon.svg.png">French</option>
<option value="fr" data-thumbnail="https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Google_%22G%22_Logo.svg/2000px-Google_%22G%22_Logo.svg.png">Greek</option>
<option value="gr" data-thumbnail="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/4H_Emblem.svg/1000px-4H_Emblem.svg.png">Italian</option>
</select>
<div class="lang-select">
<button class="btn-select" value=""></button>
<div class="b">
<ul id="a"></ul>
</div>
</div>
CSS:
.vodiapicker{
display: none;
}
#a{
padding-left: 0px;
}
#a img, .btn-select img{
width: 12px;
}
#a li{
list-style: none;
padding-top: 5px;
padding-bottom: 5px;
}
#a li:hover{
background-color: #F4F3F3;
}
#a li img{
margin: 5px;
}
#a li span, .btn-select li span{
margin-left: 30px;
}
/* item list */
.b{
display: none;
width: 100%;
max-width: 350px;
box-shadow: 0 6px 12px rgba(0,0,0,.175);
border: 1px solid rgba(0,0,0,.15);
border-radius: 5px;
}
.open{
display: show !important;
}
.btn-select{
margin-top: 10px;
width: 100%;
max-width: 350px;
height: 34px;
border-radius: 5px;
background-color: #fff;
border: 1px solid #ccc;
}
.btn-select li{
list-style: none;
float: left;
padding-bottom: 0px;
}
.btn-select:hover li{
margin-left: 0px;
}
.btn-select:hover{
background-color: #F4F3F3;
border: 1px solid transparent;
box-shadow: inset 0 0px 0px 1px #ccc;
}
.btn-select:focus{
outline:none;
}
.lang-select{
margin-left: 50px;
}
JS:
//test for getting url value from attr
// var img1 = $('.test').attr("data-thumbnail");
// console.log(img1);
//test for iterating over child elements
var langArray = [];
$('.vodiapicker option').each(function(){
var img = $(this).attr("data-thumbnail");
var text = this.innerText;
var value = $(this).val();
var item = '<li><img src="'+ img +'" alt="" value="'+value+'"/><span>'+ text +'</span></li>';
langArray.push(item);
})
$('#a').html(langArray);
//Set the button value to the first el of the array
$('.btn-select').html(langArray[0]);
$('.btn-select').attr('value', 'en');
//change button stuff on click
$('#a li').click(function(){
var img = $(this).find('img').attr("src");
var value = $(this).find('img').attr('value');
var text = this.innerText;
var item = '<li><img src="'+ img +'" alt="" /><span>'+ text +'</span></li>';
$('.btn-select').html(item);
$('.btn-select').attr('value', value);
$(".b").toggle();
//console.log(value);
});
$(".btn-select").click(function(){
$(".b").toggle();
});
//check local storage for the lang
var sessionLang = localStorage.getItem('lang');
if (sessionLang){
//find an item with value of sessionLang
var langIndex = langArray.indexOf(sessionLang);
$('.btn-select').html(langArray[langIndex]);
$('.btn-select').attr('value', sessionLang);
} else {
var langIndex = langArray.indexOf('ch');
console.log(langIndex);
$('.btn-select').html(langArray[langIndex]);
//$('.btn-select').attr('value', 'en');
}

I need to know how to change the text color in my contact form

I have a contact form and I have it set exactly the way I like it, however the text is white, so when you type in it you cant see it. When you highlight it it is there so it is working, however people can't see what they are typing. I have it hosted here www.trutattoo.amdesigns.studio.com
and this is my CSS
form label,
form .label {
display: block;
margin-bottom: 20px;
}
input,
textarea {
margin-top: 20px;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
font-weight: 800;
font-color: #000000;
border: 1px solid #000000;
outline: none;
-webkit-transition: border-color 0.2s;
-moz-transition: border-color 0.2s;
-ms-transition: border-color 0.2s;
-o-transition: border-color 0.2s;
transition: border-color 0.2s;
}
input[type="text"],
textarea {
padding: 10px;
width: 100%;
}
input[type="text"]:focus,
textarea:focus {
border-color: #161616;
}
input[type="checkbox"] {
display: none;
}
textarea {
margin-top: 20px;
height: 200px;
}
Just change
font-color: #000000;
border: 1px solid #000000;
000000 to any color you want.
Example change to #ff0000 is you want RED.
Hope it helps!

Adding a dropdown or toggle button to DataGrid

Is there a way to add a dropdown button or toggle button to the CellTable or DataGrid?
The documentation only demonstrates using a regular button (ButtonCell).
To add a ToggleButton to a grid, the only way I found is to place the button in another panel (like a FlowPanel) then add this panel in the grid.
To found this type of button, you can visit the showcase of gwt :
http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwCustomButton
here my code to have your button in a FlowPanel :
RootLayoutPanel rp = RootLayoutPanel.get();
FlowPanel togglePanel = new FlowPanel();
ToggleButton toggle = new ToggleButton("Coucou");
toggle.setWidth("100px");
togglePanel.add(toggle);
rp.add(togglePanel);
css :
.gwt-ToggleButton-up,
.gwt-ToggleButton-up-hovering,
.gwt-ToggleButton-up-disabled,
.gwt-ToggleButton-down,
.gwt-ToggleButton-down-hovering,
.gwt-ToggleButton-down-disabled {
margin: 0;
text-decoration: none;
background: url("images/hborder.png") repeat-x 0px -27px;
-moz-border-radius: 2px;
border-radius: 2px;
}
.gwt-ToggleButton-up,
.gwt-ToggleButton-up-hovering,
.gwt-ToggleButton-up-disabled {
padding: 3px 5px 3px 5px;
}
.gwt-ToggleButton-up {
border:1px solid #bbb;
border-bottom: 1px solid #a0a0a0;
cursor: pointer;
cursor: hand;
}
.gwt-ToggleButton-up-hovering {
border: 1px solid;
border-color: #939393;
cursor: pointer;
cursor: hand;
}
.gwt-ToggleButton-up-disabled {
border: 1px solid #bbb;
cursor: default;
opacity: .5;
zoom: 1;
filter: alpha(opacity=45);
}
.gwt-ToggleButton-down,
.gwt-ToggleButton-down-hovering,
.gwt-ToggleButton-down-disabled {
padding: 4px 4px 2px 6px;
}
.gwt-ToggleButton-down {
background-position: 0 -513px;
border: 1px inset #666;
cursor: pointer;
cursor: hand;
}
.gwt-ToggleButton-down-hovering {
background-position: 0 -513px;
border: 1px inset;
border-color: #9cf #69e #69e #7af;
cursor: pointer;
cursor: hand;
}
.gwt-ToggleButton-down-disabled {
background-position: 0 -513px;
border: 1px inset #ccc;
cursor: default;
opacity: .5;
zoom: 1;
filter: alpha(opacity=45);
}
It is the basic css i took on the showcase. You should modify it.

EditorFor Template for boolean type

How can we access the model's property name when using EditorFor() with a template for value types, for instance like the one below for bool type?
It seems that the MVC somehow pulls out the property name because it correctly renders the checkbox (or textbox, if used) with the correct property name, but where does MVC get it?
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<bool>" %>
<fieldset>
<legend>insert boolean property name here or the value of DisplayName attribute??</legend>
<div class="clear">
<p>
<%: Html.CheckBox("", Model) %>
<span>insert boolean property name here or the value of DisplayName attribute??</span>
</p>
</div>
</fieldset>
Example of a Boolean type for EditorTemplates using MVC3, Jquery 1.7 and CSS3
EditorTemplates Boolean.cshtml
#model bool
#{
string propertyName = Html.ViewData.ModelMetadata.PropertyName;
}
<div class="field switch">
#if (#Model == true)
{
<label class="cb-enable selected">
<span>Yes</span></label>
<label class="cb-disable">
<span>No</span></label>
<input type="checkbox" id="#propertyName" class="checkbox" name="#propertyName" value="true" checked=checked />
}
else
{
<label class="cb-enable">
<span>Yes</span></label>
<label class="cb-disable selected">
<span>No</span></label>
<input type="checkbox" id="#propertyName" class="checkbox" name="#propertyName" value="false" />
}
</div>
<script>
$(document).ready(function () {
$(".cb-enable").click(function () {
var parent = $(this).parents('.switch');
$('.cb-disable', parent).removeClass('selected');
$(this).addClass('selected');
$('.checkbox', parent).attr('checked', true);
$('.checkbox', parent).attr('value', true);
});
$(".cb-disable").click(function () {
var parent = $(this).parents('.switch');
$('.cb-enable', parent).removeClass('selected');
$(this).addClass('selected');
$('.checkbox', parent).attr('checked', false);
$('.checkbox', parent).attr('value', false);
});
});
</script>
CSS
.cb-enable, .cb-disable, .cb-enable span, .cb-disable span
{
display: block; float: left;
}
.cb-enable {
display: block;
float: left;
border: 1px solid #EEE;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 0px;
-webkit-border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 0px;
-moz-border-radius-bottomright: 0;
-moz-border-radius-bottomleft: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 5px;
}
.cb-disable
{
display: block; float: left; border: 1px solid #EEE;
.roundedCorners(0px,5px,0px,5px);
}
.cb-enable span, .cb-disable span
{
line-height: 30px; display: block; background-repeat: no-repeat;
}
.cb-enable span { padding: 0 10px; }
.cb-disable span { padding: 0 10px; }
.cb-disable.selected
{
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, transparent), color-stop(100%, rgba(0, 0, 0, 0.25))),#D5D5D5;
background: -webkit-linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#D5D5D5;
background: -moz-linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#D5D5D5;
background: -o-linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#D5D5D5;
background: -ms-linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#D5D5D5;
background: linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#D5D5D5;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 0px;
-webkit-border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 0px;
-moz-border-radius-bottomright: 0;
-moz-border-radius-bottomleft: 5px;
-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.4);
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.4);
-o-box-shadow: 0 1px 2px rgba(0,0,0,0.4);
box-shadow: 0 1px 2px rgba(0,0,0,0.4);
text-shadow: rgba(0, 0, 0, 0.2) 0 -1px 1px;
color: white;
}
.cb-disable.selected span { color: #fff; }
.cb-enable.selected
{
background: #129EE8;
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, transparent), color-stop(100%, rgba(0, 0, 0, 0.25))),#129EE8;
background: -webkit-linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#129EE8;
background: -moz-linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#129EE8;
background: -o-linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#129EE8;
background: -ms-linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#129EE8;
background: linear-gradient(top, transparent,rgba(0, 0, 0, 0.25)),#129EE8;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 0px;
-webkit-border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 0px;
-moz-border-radius-bottomright: 0;
-moz-border-radius-bottomleft: 5px;
-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.4);
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.4);
-o-box-shadow: 0 1px 2px rgba(0,0,0,0.4);
box-shadow: 0 1px 2px rgba(0,0,0,0.4);
text-shadow: rgba(0, 0, 0, 0.2) 0 -1px 1px;
}
.cb-enable.selected span { color: #fff; }
.switch label { cursor: pointer; }
.switch input { display: none; }
<%: ViewData.ModelMetadata.PropertyName %>
or:
<%: ViewData.ModelMetadata.DisplayName %>
UPDATE:
Example of resource localized display attribute:
public class LocalizedDisplayNameAttribute : DisplayNameAttribute
{
public LocalizedDisplayNameAttribute(string name)
: base(GetValueFromResource(name))
{ }
private static string GetValueFromResource(string name)
{
// TODO: fetch the display name from wherever you want
throw new NotImplementedException();
}
}