How to read in a Bit field to create a checkbox - asp.net

I have a field in my SQL database that is a BIT field.
I want to read in that field. If 1 then checkbox is true, else false.
I started off with this code, but getting error. Any advice on how to do this?
If (MyReader["TArchive"] == 1) then
Regards
Tea

Try this:
myCheckbox.Checked = Convert.ToBoolean(MyReader["TArchive"]);

Try this
If (MyReader.GetBoolean("TArchive")) // returns true if value is 1
{
// checkbox true
}
else
{
// checkbox false
}
Not tested but GetBoolean does this automatically.

Related

Endless loop validating NSTableViewRow

So I tried this code in both shouldSelectRow notification as well as selectionShouldChange function
I've just entered data in a row and trying to validate it. If invalid want to ask user if want to continue editing or let the selected row change, at which point I will refresh to keep the last (i.e. "new") row of my table blank. Problem is if I say "Yes" it keeps asking me question again and again because the method gets called again and again. Why?
let isNew = //lastRowInTable
if isNew {
let check = validateRowAt(tableView.selectedRow)
if check.error {
let keep = shouldContinueEditing(check.message)
if !keep {
tableView.reloadData()
}
else {
tableView.editColumn(Column.description.hashValue, row: tableView.selectedRow, with: nil, select: true)
}
return keep ? false : true
}
}

onEditCell issue with dhtmlxGrid

I'm using dhtmlxGrid and as I've found in the docs (https://docs.dhtmlx.com/api__dhtmlxgrid_oneditcell_event.html) returning "true" confirms the edit, while a value (for example newValue) sets the value.
I've tried both methods, but neither of them works! I can't confirm the edit by "true" nor set the value by "newValue".
Here is my code:
myGrid.attachEvent("onEditCell", function(stage,rId,cInd,nValue,oValue){
doOnEdit(stage,rId,cInd,nValue,oValue)
});
...
function doOnEdit(stage,rId,cInd,nValue,oValue){
if (cInd==0 && nValue=="100")
return false
return true
}
Can anybody explain my mistake or is there a bug?
Please, try to use the following solution:
myGrid.attachEvent("onEditCell", doOnEdit);
...
function doOnEdit(stage,rId,cInd,nValue,oValue){
if (cInd==0 && nValue=="100")
return false
return true
}

How do I determine, if Observable has never received anything?

How do I determine, if the Observable is "empty"?
Better, that it has never received anything.
My code looks like this:
spots: Observable<Spot[]>;
And I've tried several things I found on Google like:
spots.isEmpty();
spots.length;
spots.length();
spots().length;
spots.first();
But none of them works like I want..
I need this functionality, to fill a list in Ionic2 with No items found until the first item is loaded.
This is how I solve it in my code:
if ( arrayOfItems && arrayOfItems.length > 0 ) {
// display the list
return arrayOfItems.map((item) => { return item; })
} else {
// show a message that nothing was found
return "Nothing to see here...";
}
This will check that the variable has some sort of positive value (ie. it is not null, false or undefined) and that the array has at least one value. If that is not the case then display a message that nothing was found.
I solved it like this:
I have an variable let isEmpty=true; and set it to false when I receive the first Object in the Observable:
spots.subscribe(() => {
this.empty = false;
...
});

meteor autoform: how to ignore simple schema key during insert or update

I have following simple schema keys:
isParent: {
type: String
,optional: true
,custom: function(){
if( !this.isSet ){
console.log('IsParent value: ',this.field.value);
return 'required';
}
}
},
parentId: {
type: Number
,optional: true
,custom: function(){
if( (this.field('isParent').value === 'false') && !this.isSet ){
console.log(this.field('isParent').value);
console.log('ParentId value: ', this.value);
return 'required';
}
}
I don't want to insert/update 'isParent' key in db. I only want to use it as trigger point to enable/disable the 'parentId' key in html form and in schema.
If I don't use 'isParent' key in insert process, then meteor error is generated.
Can some one guide me how to ignore insertion or updation of 'isParent' key during validation upon insert or update.
Not sure if I got what you're asking, but what's the point in storing the value of this isParent boolean? Simply makes it a JavaScript trigger but don't save it into dB. Then you can just check the parentId to know if someone's has or not parents.
Being more straightforward, you can set up a checkbox (for example) that is not attached to the schema (use autoform instead of quickform) and surround the parentId part of the form by a if clause reactively triggered by the event of clicking or not the checkbox.

Dynamics AX: how to filter a report?

I need to add a filter to a report in Dynamics AX 2009. Msdn tell me to filter using Fetch event. So i've added the following code into the fetch.
DateFromDialog and DateToDialog are variable declared into ClassDeclaration.
qrun = new QueryRun(element);
_vendInvoiceJour = qrun.get(TableNum(VendInvoiceJour));
if( _vendInvoiceJour.InvoiceDate <= DateFromDialog.value() || _vendInvoiceJour.InvoiceDate >=DateToDialog.value() ) {
// Exclude record, don't print it
return false;
}
Is it correct to return false if the record must not printed ?
Thanks
No, it is not. If your your first record is to be excluded, the fetch method return false without sending a single record and nothing is printed.
You can return false in the send method. That works but is a poor choice for performance reasons.
The correct way is to add the date range as a query range:
SysQuery::findOrAddRange(element.queryrun().query().findDatasource(tableNum(VendInvoiceJour), fieldNum(VendInvoiceJour,InvoiceDate)).value(queryRange(DateFromDialog.value(), DateToDialog.value()));
I have not tested the code.

Resources