want to send data from one table to another on button click - c#-4.0

In the below code i used label and text box to send data to sql . but instead of using label and textbox i want to send data from one table to another on button click . please let me know the shortest path .
SqlConnection con1 = new SqlConnection(strcon);
con1.Open();
SqlCommand com = new SqlCommand("update coupon set status =('" + Label2.Text + "'),macaddress =('" + mac.Text + "') where accode =('" + usename.Text + "')", con1);
com.ExecuteNonQuery();
con1.Close();
AddNewUserToNomadix();

Related

How to return value from database in Spotfire?

Do you have any ideas how value which was writeback from SF to database could be returned from data base again to Spotfire input field.
(No just any value, what is mechanism stay behind it?)
If I need to make changes in this record ?
We writeback to DB with IronPython scripting assigning document properties.
Piece of code....
sqlIns = "INSERT INTO SCHEMA.TABLE_NAME (FIELD, WELL, WELLBORE, WELLTYPE) \n\
VALUES \n\
('" + Document.Properties["IFIELD"] + "', \n\
'" + Document.Properties["IWell"] + "', \n\
'" + Document.Properties["IWellBore"] + "', \n\
'" + Document.Properties["IWellType"] + "')"
print sqlIns
dbsettings = DatabaseDataSourceSettings( "System.Data.OracleClient","Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server)(PORT=****))(CONNECT_DATA=(SERVICE_NAME=****)));User Id=;Password=",sqlIns)
ds = DatabaseDataSource(dbsettings)
newDataTable = Document.Data.Tables.Add("temp",ds)
Document.Data.Tables.Remove(newDataTable)
The problem is that before updating into the database the record, this record needs somehow modify. I insert the data through input or drop-down field in the text area, then press the Submit button to insert it into the database. It recorded there and appeared in the table which I add on the same page in SF.
My thoughts that it should be workflow like: highlight record you want to change (it happened in a table connected to SF)
-> once you choose the record, it appears in the input screen (input screen - text area where you enter all these values for the first time or another input screen only for data modification)
-> make required changes
-> re-write/update data to DB (with replacement initial record.)
The python script just sends an sql command. That command can be changed to do an update instead of an insert.
Post an example of code that you are using for the insert and people can assist on how to change to an update statement.
You'll need to have a primary key or other identifier for the update statement.
If you "wrote back to a database" to read the data into a input Field or table you'd have to query the database (a normal query to pull data into spotfire)

Access field in a column in a Lotus Notes view

In Lotus Notes, I have view which has got a column say PolicyNum. Requirement is while double clicking on the document to open, which will open the attachment in the form in the view, it has to be validated against a computed field say SecureDoc which contains either Yes or No.
For client version this is easy as in the queryopen in the form it is validated and exited if the condition doesn't meet with proper messagebox.
But for the web version the column is appeared as a link and the messagebox has to appeared as alertbox in JS. In the PolicyNum column I have tried to use #GetField("SecureDoc") which will get the value of the field for that particular document.
Column Formula:
furl:="javascript:alert('Document not available');return false";
OpenDisp:="[" + PolicyNumber + "]";
secDoc:=#GetField("SecureDoc");
#If(att = "" ; OpenDoc ;secDoc="Yes";OpenDisp;OpenAttach)
Here OpenDoc and OpenAttach are different string which will open the document and attachment respectively depending on the att, which checks for the attachment.#GetField("SecureDoc") return "". So if I write #If(att = "" ; OpenDoc ;secDoc="";OpenDisp;OpenAttach) it is showing the alert box and is working fine.
So the requirement is to get the handle of the field value for the particular doc which is to be clicked on web and check for the condition.
Also webqueryopen is not working..
Note: On opening the document it is opening the attachment in the form and not the form itself.
Column Value :
view := "0";
att := #AttachmentNames;
WebName := #WebDbName ;
url := "'/" + WebName + "/" + view + "/" + #Text(#DocumentUniqueID) + "/$File/" + att + "?OpenElement'";
url := "window.open(" + url + ");" ;
url := #Implode(url; ";");
url := "javascript:" + url + " return false;\" href=\"javascript:void(0);";
furl:="javascript:alert('Document not available');return false";
OpenAttach := "[<TABLE><TR><TD NOWRAP><a target=_blank onClick=\"" + url + "\">" + PolicyNumber + "</a></TD></TR></TABLE>]";
OpenDoc := "[<TABLE><TR><TD NOWRAP>" + PolicyNumber + "</TD></TR></TABLE>]";
OpenDisp:="[<TABLE><TR><TD NOWRAP><a target=_blank onClick=\"" + furl + "\">" + PolicyNumber + "</a></TD></TR></TABLE>]";
secDoc:=#GetField("prevSecDoc");
#If(att = "" ; OpenDoc ;secDoc="Yes";OpenDisp;OpenAttach)
I have tried with both #If(att = "" ; OpenDoc ;secDoc="Yes";OpenDisp;OpenAttach) and #If(att = "" ; OpenDoc ;prevSecDoc="Yes";OpenDisp;OpenAttach) but it is not getting the value as "Yes". Though when I open the document through URL giving the docid it ha the value as "Yes"
Quick back to basics : a document is a record in a database, a form is, well, a form, which determines how data are input by the user and controls display.
Allow me to rephrase your question. If the document contains a field named "SecureDoc", and if said field holds the value "NO", then a click on the link must not open the document and present the user with a JavaScript alert.
One could question why display the document in the view in the first place, and then why have a link with no other effect than telling it has no effect.
OK, not my place to question the requirements.
My suggestion would be that the content of the column displayed for web access be a computed hyperlink :
href := #If( SecureDoc = "NO";
"javascript:alert('nope')";
"normal url for opening the doc"
);
"" + "the title of the doc or whatever" + ""

Send details to email on click of a button

I am developing an android app and i have a few edit texts and a submit button.
On click of the submit button all the fields in the edit texts entered by the user should be sent to a particular email id.
Could anyone please suggest me how it can be done?
String s = editText.getText().toString();
in button's onClickListner() method use this
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, s);
//emailIntent.putExtra(Intent.EXTRA_HTML_TEXT, body); //If you are using HTML in your body text
startActivity(Intent.createChooser(emailIntent, "Send Email via"));
Already answered Here
As you are working with multiple editTexts you can do this,
String s = (editText1.getText().toString() + "\n" + editText2.getText().toString() + "\n"+editText3.getText().toString() + "\n" + editText4.getText().toString() + "\n" + editText5.getText().toString() + "\n" + editText6.getText().toString() + "\n");
and then use same snippet as above.
If you want to know how send email without prior user interaction then see this answer
see this code snippet here also : https://github.com/enrichman/androidmail
There is also an API available named mandrillapp:
Read this blog for full code : https://www.mindstick.com/Articles/1673/sending-mail-without-user-interaction-in-android

Create an iconNote Document in a new database

This is a more explicite extension on my previous question.
From an button on an XPage I create a new database
targetDB = dir.createDatabase(fileName);
I then copy a bunch of stuff into the targetDB from the sourceDB. I then want to set the launch properties in the targetDB which is where the problem comes.
I know that I can get the iconNote = targetDB.getDocumentByID("FFFF0010") except there is no iconDoc in the target. Does anyone have a way to create this doc with the specific NoteID?
I tried copying the iconNote document from the sourceDB to the targetDB but that does not work. Changes the UNID and noteID. Can't find any database method to create an icon Note.
Found lots of stuff on how to change the settings in the iconNote, but nothing on how to create one if there is not one in the database.
Thanks to Jesse I took his code and changed it to SSJS and it works fine.
var dir:NotesDbDirectory = session.getDbDirectory("Development");
var newDB:NotesDatabase = dir.createDatabase("XPages/install/created.nsf");
var importer:NotesDxlImporter = session.createDxlImporter();
importer.setDesignImportOption(6);
var dxl:String = "<?xml version='1.0'?>\n" +
"<note default='true' class='icon'>\n" +
" <item name='$TITLE'>\n" +
" <text>Test Title</text>\n" +
" </item>\n" +
" <item name='$Flags'>\n" +
" <text>J7NZq?!</text>\n" +
" </item>\n" +
"</note>\n";
importer.importDxl(dxl, newDB);
var iconNote = newDB.getDocumentByID("FFFF0010");
iconNote.replaceItemValue("$DefaultXPage", "xpWFSDemo.xsp");
iconNote.replaceItemValue("$DefaultClientXPage", "xpWFSDemo.xsp");
iconNote.save();
dBar.info(iconNote.getItemValueString("$Flags"));
Something like this oughta do it:
DbDirectory dir = session.getDbDirectory(null);
Database newDB = dir.createDatabase("tests/created.nsf");
DxlImporter importer = session.createDxlImporter();
importer.setDesignImportOption(DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_CREATE);
String dxl = "<?xml version='1.0'?>\n" +
"<note default='true' class='icon'>\n" +
" <item name='$TITLE'>\n" +
" <text>Some DB Title</text>\n" +
" </item>\n" +
" <item name='$Flags'>\n" +
" <text>J7NZq?!</text>\n" +
" </item>\n" +
"</note>\n";
importer.importDxl(dxl, newDB);
That's with the two "open XPage" options set already - you could also include the two XPage name items the same way, and it may be a good idea to export the icon note from an existing DB (database.getDocumentByID("FFFF0010").generateXML()) and paste in the actual icon item as well, since this DXL will result in an icon-less database. Nonetheless, it seems to work in my testing as a basis.
And after that point, you'll be able to fetch the icon note using the usual "FFFF0010" pseudo-ID and replace item values the same way I mentioned before.

How do I filter a dojo grid on an xpage?

How do we filter the dojo grid (extlib component) that gets its data from the REST service component? I have the grid loaded with data from the view correctly from the REST service component. I also have on the xpage a dropdown where users can select a value that's a dbcolumn of one of the columns in the same view. I've tried setting the REST service keys value to viewScope.filterCat01 (which is the variable for the combo box), and I've also tried setting the filter in a button (BY is the field/column name) but nothing seems to filter it. Any ideas? In the button when I check grid properties, it does work, so I know the grid object is valid - but the filter just doesn't seem to be doing anything. I've also tried doing a grid._refresh() as well as setting the Keys in the REST service component with no luck. Is there a special way to trigger the filter?
var filterValue = XSP.getElementById("#{id:comboBox2}").value;
var grid = dijit.byId("#{id:djxDataGrid1}");
grid.filter({ By: filterValue});
This is definitely one of those things that you need to piece together a thousand cryptic clues to work it out (Domino - never!). Anyway, I had to work this one out last year. Here's an example 'search' button:
var searchText = dojo.byId('#{id:searchText}').value.replace(/"/g, '|"');
if (searchText) {
var ftSearchText = '[Title] CONTAINS "' + searchText + '" OR [Description] CONTAINS "' + searchText + '" OR [URL] CONTAINS "' + searchText + '"';
dijit.byId('#{id:grid}').filter('?search=(' + ftSearchText + ')', false);
} else {
dojo.byId('#{id:reset}').click();
}
As you can see, it's doing an ft search when a filter is applied. The key is to put "?search=" on to the beginning of the filter string.
and here's the 'reset' button example:
dojo.byId('#{id:searchText}').value="";
var grid = dijit.byId('#{id:grid}');
grid.filter("",true);
grid.store.close();
grid._refresh();
This was developed with 8.5.2. There might be some cleaner ways to do things in 8.5.3 with dojo 1.6.1.
Enjoy!

Resources