Tuesday, 15 January 2013

java - Not able to get this error message to work -



java - Not able to get this error message to work -

the code compiles , until come in 101 , shows grade is: . doing wrong?

public static void main(string args[]) { scanner sc = new scanner(system.in); int yourgrade; char grade = 0; system.out.print("enter grade (between 0 , 100 inclusive): "); yourgrade = sc.nextint(); if ((yourgrade>0) && (yourgrade<40)) { grade='f'; } else if ((yourgrade>39) && (yourgrade<55)) { grade='d'; } else if ((yourgrade>54) && (yourgrade<70)) { grade='c'; } else if ((yourgrade>69) && (yourgrade<85)) { grade='b'; } else if ((yourgrade>84) && (yourgrade<=100)) { grade='a'; } if ((yourgrade<0) && (yourgrade>100)) { system.out.println(" " + grade + " not valid grade."); system.out.println("please come in value between 0 , 100 inclusive."); } else { system.out.println("your grade is: " + grade); }

i tried adding lastly bit before final if statement yet, still not able display want to. please forgive me if doing wrong started , know how right.

if ((yourgrade<0) && (yourgrade>100))

these 2 conditions can't both true. if want check if 1 or other true, utilize or instead of and.

if (yourgrade<=0 || yourgrade>100)

also changed <0 <=0 since grade conditions f don't include zero.

you might notice in case, grade variable still set character zero, because that's how initialised it. printing

system.out.println(" " + grade + " not valid grade.");

won't create much sense.

java

sql - mysql | Getting Database error, Invalid Use of Group Function -



sql - mysql | Getting Database error, Invalid Use of Group Function -

i using ignited datatables. working fine except filter. when searching in it, error

invalid utilize of grouping function

i getting query in error result.

select `f`.`formid`, `f`.`formname`, `f`.`formcipath`, min(g.ismenulink) ismenulink, group_concat(distinct g.groupid order g.groupid) groupids (`sys_forms` f) inner bring together `sys_forms_in_groups` g on `g`.`formid` = `f`.`formid` `g`.`groupid` in ('1', '1') , (upper(f.formname) '%da%' or upper(f.formcipath) '%da%' or upper(min(g.ismenulink)) '%da%' ) grouping `f`.`formid` limit 25

what wrong query.??

the problem have aggregation functions in where clause:

select `f`.`formid`, `f`.`formname`, `f`.`formcipath`, min(g.ismenulink) ismenulink, group_concat(distinct g.groupid order g.groupid) groupids (`sys_forms` f) inner bring together `sys_forms_in_groups` g on `g`.`formid` = `f`.`formid` `g`.`groupid` in ('1', '1') , (upper(f.formname) '%da%' or upper(f.formcipath) '%da%' or upper(min(g.ismenulink)) '%da%' --------------^ ) grouping `f`.`formid` limit 25;

you can remove function, think:

where `g`.`groupid` in ('1', '1') , (upper(f.formname) '%da%' or upper(f.formcipath) '%da%' or upper(g.ismenulink) '%da%' )

or move having clause.

select `f`.`formid`, `f`.`formname`, `f`.`formcipath`, min(g.ismenulink) ismenulink, group_concat(distinct g.groupid order g.groupid) groupids (`sys_forms` f) inner bring together `sys_forms_in_groups` g on `g`.`formid` = `f`.`formid` `g`.`groupid` in ('1', '1') , (upper(f.formname) '%da%' or upper(f.formcipath) '%da%' ) grouping `f`.`formid` having upper(min(g.ismenulink)) '%da%' limit 25;

mysql sql

entity framework - How to search and update records with EF -



entity framework - How to search and update records with EF -

i trying find records contain text string in field/property , replace text string new text string , save update record.

i not sure way code belowis not working. have set break points , name variable have replaced text when @ record in database, field still have original value.

var vendors = db.vendor.where(c=> c.name.contains("corp.")); foreach( var vendor in vendors) { var name = vendor.name.replace("corp.", "corporation"); vendor.name = name; } db.savechanges();

update ended using hack now.

var vendors = db.vendor.where(c=> c.name.contains("corp.")); foreach( var vendor in vendors) { var v = db.vendor.find(vendor.id); var name = vendor.name.replace("corp.", "corporation"); v.name = name; } db.savechanges();

i think forgot mark entity's state modified, seek next code

var vendors = db.vendor.where(c=> c.name.contains("corp.")); foreach(var vendor in vendors) { var name = vendor.name.replace("corp.", "corporation"); vendor.name = name; db.entry(vendor).state = entitystate.modified; } db.savechanges();

entity-framework

c# - No Settings tab in Properties of XNA project in Visual Studio -



c# - No Settings tab in Properties of XNA project in Visual Studio -

when i've created windows forms projects have been able store variables utilize on relaunch of application creating them in settings tab in project properties. working on xna project , want similar save 'hi-score' in game. however, when in properties there no settings tab. thought if can access alternative in xna project?

right-click on project in solution explorer, select add together -> component, , find settings file.

c# visual-studio-2010 xna settings

javascript - Make menu dissappear on click anywhere screen -



javascript - Make menu dissappear on click anywhere screen -

hi have code works perfect other 1 time click anywhere on screen create dropdown menu content disappear can't reopen menu. heres code i'm using along jsfiddle demo below.

class="snippet-code-js lang-js prettyprint-override">$(document).click(function (e) { var container = $(".dropdown_content"); if (!container.is(e.target) && container.has(e.target).length === 0) { container.fadeout('slow'); } }); class="snippet-code-css lang-css prettyprint-override">.dropdown { display: block; display: inline-block; margin: 0px 3px; position: relative; } /* ===[ demonstration ]=== */ .dropdown { margin-top: 50px } /* ===[ end demonstration ]=== */ .dropdown .dropdown_button { cursor: pointer; width: auto; display: inline-block; padding: 4px 5px; font-weight: bold; color: #000; line-height: 16px; text-decoration: none !important; } .dropdown input[type="checkbox"]:checked + .dropdown_button { color: #000; padding: 4px 5px; } .dropdown input[type="checkbox"] + .dropdown_button .arrow { display: inline-block; width: 0px; height: 0px; border-top: 5px solid #fff; border-right: 5px solid transparent; border-left: 5px solid transparent; } .dropdown input[type="checkbox"]:checked + .dropdown_button .arrow { border-color: white transparent transparent transparent } .dropdown .dropdown_content { position: absolute; border: 1px solid #fff; padding: 0px; margin: 0; display: none; padding: 7px; -webkit-transition: 500ms ease-in-out; -moz-transition: 200ms ease-in-out; -o-transition: 500ms ease-in-out; -ms-transition: 500ms ease-in-out; transition: 500ms ease-in-out; -webkit-box-shadow: rgba(0, 0, 0, 0.58) 0px 12px 25px; -moz-box-shadow: rgba(0, 0, 0, 0.58) 0px 12px 25px; box-shadow: rgba(0, 0, 0, 0.58) 0px 12px 25px; background: #fff; font-size: 12px; -moz-border-radius: 0 0 4px 4px; -webkit-border-bottom-right-radius: 4px; -webkit-border-bottom-left-radius: 4px; border-radius: 0 0 4px 4px; min-width: 140px; } .dropdown .dropdown_content li { list-style: none; margin-left: 0px; line-height: 16px; border-top: 1px solid #fff; border-bottom: 1px solid #fff; margin-top: 2px; margin-bottom: 2px; -webkit-transition: 0.2s ease-in-out; -moz-transition: 0.2s ease-in-out; } .dropdown .dropdown_content li:hover { background: #d32d41; text-shadow: 1px 1px 0px #9e2635; -moz-background-clip: padding; -webkit-background-clip: padding-box; -webkit-box-shadow: inset 0 0 1px 1px #f14a5e; -moz-box-shadow: inset 0 0 1px 1px #f14a5e; box-shadow: inset 0 0 1px 1px #f14a5e; border: 1px solid #9e2635; color: #fff; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; } .dropdown .dropdown_content li { display: block; padding: 2px 7px; padding-right: 15px; color: black; text-decoration: none !important; white-space: nowrap; } .dropdown .dropdown_content li:hover { color: white; text-decoration: none !important; } .dropdown input[type="checkbox"]:checked ~ .dropdown_content { display: block } .dropdown input[type="checkbox"] { display: none } class="snippet-code-html lang-html prettyprint-override"><div class="dropdown" id="dropdown"> <input type="checkbox" id="drop1" /> <label for="drop1" class="dropdown_button">click here<span class="arrow"></span></label> <ul class="dropdown_content"> <li><a href="*">user panel</a></li> <li><a href="*">log out</a></li> <li><a href="*">edit profile</a></li> <li><a href="*">edit options</a></li> <li><a href="*">edit avatar</a></li> <li><a href="*">edit signature</a></li> <li><a href="#">buddy list</a></li> </ul> </div>

jsfiddle demo here

http://jsfiddle.net/andreas84x/x5wvnzt7/5/

it's because of the cascading order:

browser default external style sheet internal style sheet inline

when click outside dropdown it'll alter style attribute display: none. when trying alter display block/inline-block in css doesn't take effect, because still inline display: none have priority.

the solution: utilize fadein on button click (remove css fix) :)

javascript jquery html css drop-down-menu

printing - iOS 8 Safari print redirect doesn't stop javascript execution -



printing - iOS 8 Safari print redirect doesn't stop javascript execution -

i have need provide ability print label on successful save , after print redirect search page. works in chrome, firefox, ie, ios 6/7 safari, etc. however, seems ios 8 no longer stops execution of javascript when window.print() issued javascript.

if navigate this jsfiddle example ios 8 safari (connected computer can view console logs) , click print button see console.log trigger when print dialog up. if want print , navigate print wrong screen unless have delay gives plenty time nail print isn't acceptable in case.

i did artificial delay because in ios 6/7 seemed print dialog stop execution of javascript. in case 500ms plenty create work.

has else seen issue when doing similar thing in ios 8 safari? have introduced new event hear utilize this?

// illustration code window.print(); settimeout(function() { console.log('this should print after print issued in ios print dialog.'); }, 500);

you can utilize window.matchmedia (caniuse link), combined window.onbeforeprint , window.onafterprint (for before ie support). reference using matchmedia can found here , here.

to satisfy using matchmedia ios, utilize nested events. first, hear media type alter print. then, within callback, hear media alter screen.

if (window.matchmedia) { var printquery = window.matchmedia('print'); printquery.addlistener(function() { var screenquery = window.matchmedia('screen'); printquery.addlistener(function() { //actions after print dialog close here }); }); }

javascript printing ios8 mobile-safari

android - Keeping data after update sqlite version -



android - Keeping data after update sqlite version -

i had 1 table in sqlite database. changed database version 2 , add together table. user info first table disappeared. asking you: how can maintain user data?

public class database extends sqliteopenhelper { private static final long serialversionuid = 1l; static int databaseversion = 2; static string databasename = "dbinformation"; string table1 = "create table people ( " + "id integer primary key autoincrement, " + "name text, "+ "age integer )"; string table2 = "create table piece of furniture ( " + "id integer primary key autoincrement, " + "type text, "+ "price integer )"; public database(context context) { super(context, databasename, null, databaseversion); // todo auto-generated constructor stub } @override public void oncreate(sqlitedatabase db) { // todo auto-generated method stub db.execsql(table1); } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { // todo auto-generated method stub db.execsql(table2); db.execsql("drop table if exists people"); this.oncreate(db); } }

how can maintain user data?

don't drop people table. create furniture table:

@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { if (oldversion<2) { db.execsql(table2); } }

tomorrow, might bump schema version 3 , add together yet table:

@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { if (oldversion<2) { db.execsql(table2); } if (oldversion<3) { db.execsql(create_rutabaga_table_statement); } }

and on.

android sqlite