Thursday, January 31, 2013

Dymisja w obraz przechwytywania

Budki zdj?cia s? jednym spo?ród w najwi?kszym stopniu uniwersalnych poj?? rozrywki w celu towarzyskich natomiast / b?d? innych wydarzeniach zwi?zanych spo?ród prac? albo korporacyjnych. Photo Booth jest nu?e odk?d d?u?szego czasu tudzie? koncepcji pozosta? w du?ej mierze takie same, jednak w tym momencie mamy mnogo?? w wy?szym stopniu zaawansowan? technologi?, która mia?a j? o chód nadal. Post?py serwisów spo?eczno?ciowych tak?e odegra?a wa?n? rol? w popularno?ci kabin fotograficznych, jak ca?a white seoistota pocz?wszy odk?d zasób wiedzy wideo a? do zdj?? mog? stanowi? udost?pniane wewn?trz po?rednictwem stron nader swobodnie, takich jak Facebook za? Twitter za pomoc? gospodarzy firm tudzie? osób spo?ród ich rodziny za? friends.The stare mokrej chemii Budki s? drogie do transportu i obs?ugi, tedy to najcz??ciej cyfrowe wersje, które s? u?ywane w tym celu. Firmy s? teraz dodatkowo oferuje wysoki obr?b us?ug gwoli klientów, w tym specjalnych ?rodowisk, sposobów zabarwienie a napis dodanej. Wynajmowanie Photo Booth na specjalne okazje, takie podczas gdy wesela sta?o si? wielce modne. Posiadanie Photo Booth na Pa?stwa wesele gwarantuje si? wielkim interaktywny procedura, ?eby przechwyci? te sporo bezcennych obrazów spo?ród tym szczególnym dniu. Warto wtr?ci?, i? zwi?zek ma??e?ski jest wydarzeniem, które zdarza si? cios w ?yciu danej osoby. Tote? pies z kulaw? nog? nie chce niech owo wypadek odpa?? na niepotrzebnie. Everyman chce, aby chwyta? ca?e wypadek a powi?zane uroczysto?ci w ramkach natomiast papierów. Stwarzane zdj?cia, naturalne zdj?cia, spontaniczne chwile, zabawne komplet happeningi musi dosta? przechwycone w ramkach. I a?eby owo byt wydarzy si? w optymalny dopuszczalny podej?cie, nie pozycja mog? istnie? porównywalne ze zdj?ciem booth.Adding zdj?ciem pomiar wynajmuj?c kiosk a? do ka?dym razie jest to ?atwe. Wolno je dostosowa? do ka?dego tematu.


Dymisja w obraz przechwytywania

Budki zdj?cia s? jednym z w najwy?szym stopniu rozrywki

Budki zdj?cia s? jednym spo?ród w najwi?kszym stopniu uniwersalnych poj?? rozrywki w celu towarzyskich a / lub innych wydarzeniach zwi?zanych z prac? albo korporacyjnych. Photo Booth jest nu?e od d?u?szego czasu za? koncepcji pozosta? w du?ej mierze takie same, przecie? obecnie mamy moc z wi?kszym nat??eniem zaawansowan? technologi?, która mia?a j? o chód nadal. Post?py serwisów spo?eczno?ciowych tak?e odegra?a wa?n? rol? w popularno?ci kabin fotograficznych, kiedy ca?a pozycjonowanieclou pocz?wszy od czasu zasób wiedzy wideo a? do zdj?? mog? egzystowa? udost?pniane w ci?gu po?rednictwem stron nader swobodnie, takich kiedy Facebook a Twitter z wykorzystaniem gospodarzy firm tudzie? osób z ich rodziny i friends.The stare mokrej chemii Budki s? drogie a? do transportu tudzie? obs?ugi, w nast?pstwie tego to z regu?y cyfrowe wersje, które s? u?ywane w tym celu. Firmy s? obecnie dodatkowo oferuje wielgachny zasi?g us?ug w celu klientów, w tym specjalnych ?rodowisk, sposobów kolor oraz nadruk dodanej. Wynajmowanie Photo Booth na specjalne okazje, takie kiedy wesela sta?o si? nies?ychanie modne. Dobrobyt Photo Booth na Pa?stwa uroczysto?ci weselne gwarantuje si? wielkim interakcyjny modus, i?by uchwyci? te masa bezcennych obrazów spo?ród tym szczególnym dniu. Warto zahaczy?, i? zwi?zek ma??e?ski jest wydarzeniem, które zdarza si? trafienie w ?yciu danej osoby. Wskutek tego nikt nie chce niech owo wypadek odlecie? na na pró?no. Everyman chce, by przechwyci? ca?e zdarzenie oraz powi?zane uroczysto?ci w ramkach natomiast papierów. Stwarzane zdj?cia, naturalne zdj?cia, spontaniczne chwile, zabawne ogó? happeningi musi uzyska? przechwycone w ramkach. A a?eby owo co? wydarzy si? w maksymalny mo?liwy tryb, nie lokalizacja mog? egzystowa? porównywalne ze zdj?ciem booth.Adding zdj?ciem eksperyment wynajmuj?c budka do ka?dym razie jest owo ?atwe. Mo?na je przykroi? a? do ka?dego tematu.


Budki zdj?cia s? jednym z w najwy?szym stopniu rozrywki

Tuesday, January 22, 2013

[Share with Me] Looking Movie but Don't Understand ? Get The Subtitle Here...

Sometimes when we are looking a movie/film youd don’t understand what actually they talking about so you just thinking it what they mean by looking at the actor do. Or maybe you prefer looking a movie/film in your own language, so you’ll understand the story well. It’s such a painful thing right if you don’t understand what the story of the movie/film you’re looking at? Don’t worry, here I post some site that may help you to get subtitle of your favorite movie/film even some anime subtitle you’ll find here if you’re anime fans (like I do :) …..).

  1. Moviesubtitles.org

    You can find subtitles for not only the latest and hottest popular movies but also TV films. These subtitles offered are in multiple languages and for DivX/Xvid movies. The subtitles in this site are for free and are packed with WinZip, so if you have a Mac, you need install an unpacking tool to extract the subtitles. The common file format of these subtitles is srt.

  2. Subscene.com

    There are numerous subtitles in different languages including English, French, Spanish and more. It’s available for downloading subtitles, sharing your own subtitles and more.

  3. Download.hr/subtitles.html

    You can register the site to upload or download subtitles. As moviesubtitles.org, the subtitle files are packed with WinZip, so you need to unpack first.

  4. Subtitlesource.com

    You can find subtitles for more than 500 TV series and hot movies in 11 different languages here. The subtitles provided are for DivX videos and DVDs. But you can use iSkysoft iMedia Converter Deluxe for Mac to add subtitles to video in all popular formats and DVDs.

  5. Divxsubtitles.net

    The subtitles in this site are very comprehensive, and you can find the sub files for loads of movies. But the user experience is not as good as the subtitles here.


[Share with Me] Looking Movie but Don't Understand ? Get The Subtitle Here...

[Share with Me] Pelajaran Bersyukur dari Uang 10 Ribu Rupiah...

Sesungguhnya Allah mempunyai karunia terhadap manusia tetapi kebanyakan manusia tidak bersyukur. QS. Al Baqarah : 243

 Menjelang Ramadhan tahun ini ada seorang sahabat menuturkan kisahnya. Dia bernama Budiman. Sore itu ia menemani istri dan seorang putrinya berbelanja kebutuhan rumah tangga bulanan di sebuah toko swalayan.

Usai mereka membayar semua barang belanjaan. Tangan-tangan mereka sarat dengan tas plastik belanjaan. Baru saja mereka keluar dari toko swalayan, istri Budiman dihampiri seorang wanita pengemis yang saat itu bersama seorang putri kecilnya. Wanita pengemis itu berkata kepada istri Budiman, “Beri kami sedekah, Bu!”

Istri Budiman kemudian membuka dompetnya lalu ia menyodorkan selembar uang kertas berjumlah 1000 rupiah.

Wanita pengemis itu lalu menerimanya. Tatkala ia tahu jumlahnya dan ternyata itu tidak mencukup kebutuhannya, ia kemudian menguncupkan jari-jarinya dan ia arahkan kearah mulutnya, kemudian ia memegang kepala anaknya dan sekali lagi ia mengarahkan jari-jari yang terkuncup itu ke arah mulutnya. Seolah ia berkata dengan bahasa isyarat, “Aku dan anakku ini sudah berhari-hari tidak makan, tolong beri kami tambahan sedekah untuk bisa membeli makanan.”

Mendapati isyarat pengemis wanita itu, istri Budiman pun membalas isyarat dengan gerak tangannya seolah berkata, “Tidak… tidak, aku tidak akan menambahkan sedekah untukmu!”

Ironisnya meski ia tidak menambahkan sedekahnya malah istri dan putrinya Budiman menuju ke sebuah gerobak gorengan untuk membeli cemilan. Pada kesempatan yang sama Budiman berjalan ke arah ATM center guna mengecek saldo rekeningnya. Saat itu memang adalah tanggal dimana ia menerima gajian dari perusahaannya, karenanya Budiman ingin mengecek saldo rekeningnya.

Ia sudah berada di depan ATM. Ia masukkan kartu ke dalam mesin tersebut. Ia tekan langsung tombol INFORMASI SALDO. Sesaat kemudian muncullah beberapa digit angka yang membuat Budiman menyunggingkan senyum kecil dari mulutnya. Ya, uang gajiannya sudah masuk ke dalam rekening.

Budiman menarik sejumlah uang dalam bilangan jutaan rupiah dari ATM. Pecahan ratusan ribu berwarna merah kini sudah menyesaki dompetnya. Lalu ada satu lembar uang berwarna merah juga, namun kali ini bernilai 10 ribu yang ia tarik dari dompet. Kemudian uang itu ia lipat menjadi kecil dan ia berniat untuk berbagi dengan wanita pengemis yang tadi meminta tambahan sedekah.

Budiman memberikan uang itu. Lalu saat sang wanita melihat nilai uang yang ia terima betapa girangnya dia. Ia berucap syukur kepada Allah dan berterima kasih kepada Budiman dengan kalimat-kalimat penuh kesungguhan:

“Alhamdulillah… Alhamdulillah… Alhamdulillah… Terima kasih tuan! Semoga Allah memberikan rezeki berlipat untuk tuan dan keluarga. Semoga Allah memberi kebahagiaan lahir dan batin untuk tuan dan keluarga. Diberikan karunia keluarga sakinah, mawaddah wa rahmah. Rumah tangga harmonis dan anak-anak yang shaleh dan shalehah. Semoga tuan dan keluarga juga diberi kedudukan yang terhormat kelak nanti di surga…!”

Budiman tidak menyangka ia akan mendengar respon yang begitu mengharukan. Budiman mengira bahwa pengemis tadi hanya akan berucap terima kasih saja. Namun, apa yang diucapkan oleh wanita pengemis tadi sungguh membuat Budiman terpukau dan membisu. Apalagi tatkala sekali lagi ia dengar wanita itu berkata kepada putri kecilnya, “Dik, Alhamdulillah akhirnya kita bisa makan juga….!”

Deggg…!!! Hati Budiman tergedor dengan begitu kencang. Rupanya wanita tadi sungguh berharap tambahan sedekah agar ia dan putrinya bisa makan. Sejurus kemudian mata Budiman membuntuti kepergian mereka berdua yang berlari menyeberang jalan, lalu masuk ke sebuah warung tegal untuk makan di sana.

Budiman masih terdiam dan terpana di tempat itu. Hingga istri dan putrinya kembali lagi dan keduanya menyapa Budiman. Mata Budiman kini mulai berkaca-kaca dan istrinya pun mengetahui itu. “Ada apa Pak?” Istrinya bertanya.

Dengan suara yang agak berat dan terbata Budiman menjelaskan:

“Aku baru saja menambahkan sedekah kepada wanita tadi sebanyak 10 ribu rupiah!”

Awalnya istri Budiman hampir tidak setuju tatkala Budiman menyatakan bahwa ia memberi tambahan sedekah kepada wanita pengemis, namun Budiman melanjutkan kalimatnya:

“Bu…, aku memberi sedekah kepadanya sebanyak itu. Saat menerimanya, ia berucap hamdalah berkali-kali seraya bersyukur kepada Allah. Tidak itu saja, ia mendoakan aku, mendoakan dirimu, anak-anak dan keluarga kita. Panjaaaang sekali ia berdoa!

Uang 10 Ribu Rupiah

Uang 10 Ribu Rupiah

Dia hanya menerima karunia dari Allah Swt sebesar 10 ribu saja sudah sedemikian hebatnya bersyukur. Padahal aku sebelumnya melihat di ATM saat aku mengecek saldo dan ternyata di sana ada jumlah yang mungkin ratusan bahkan ribuan kali lipat dari 10 ribu rupiah. Saat melihat saldo itu, aku hanya mengangguk-angguk dan tersenyum. Aku terlupa bersyukur, dan aku lupa berucap hamdalah.

Bu…, aku malu kepada Allah! Dia terima hanya 10 ribu begitu bersyukurnya dia kepada Allah dan berterimakasih kepadaku. Kalau memang demikian, siapakah yang pantas masuk ke dalam surga Allah, apakah dia yang menerima 10 ribu dengan syukur yang luar biasa, ataukah aku yang menerima jumlah lebih banyak dari itu namun sedikitpun aku tak berucap hamdalah.

Budiman mengakhiri kalimatnya dengan suara yang terbata-bata dan beberapa bulir air mata yang menetes. Istrinya pun menjadi lemas setelah menyadari betapa selama ini kurang bersyukur sebagai hamba.

Ya Allah, ampunilah kami para hamba-Mu yang suka lalai atas segala nikmat-Mu!

Disadur dari Eramuslim


[Share with Me] Pelajaran Bersyukur dari Uang 10 Ribu Rupiah...

Monday, January 21, 2013

[Share with Me] New Zealand ASEAN Scholar Awards

The New Zealand-ASEAN Scholar Awards recognise New Zealand’s close cultural, economic, and geographic ties with Southeast Asia. They seek to empower individuals with the knowledge, skills and qualifications to contribute to the economic, social, and political development of their region.

Awards for students from Myanmar, Cambodia, Indonesia, Lao PDR, Malaysia, the Philippines, Thailand and Vietnam are managed by the New Zealand Ministry of Foreign Affairs and Trade.

Awards for Brunei and Singapore are managed by the awarding institution, Victoria University of Wellington.

Information for applicants for awards managed by the New Zealand Ministry of Foreign Affairs and Trade

Information on this page applies to applicants from Myanmar, Cambodia, Indonesia, Lao PDR, Malaysia, the Philippines, Thailand and Vietnam.

Criteria for awards for Brunei and Singapore are set by Victoria University of Wellington and differ from those set out below. Please click the country page for Brunei and Singapore for details.

What the scholarship offers

New Zealand has first-rate education institutions that offer world-recognised qualifications. Successful applicants will have access to excellent academic knowledge in quality facilities.

Scholarships include financial support for tuition, living costs while in New Zealand, an establishment allowance on arrival in New Zealand, and return airfares.

The partners of students are eligible for a work visa that allows them to live and work in New Zealand for the duration of their partner’s study.

Eligible countries

Applications for New Zealand-ASEAN Scholar Awards are welcome from the following countries. For more information about priority sectors, follow the links to the scholarship information page for your country.

Brunei  I  Cambodia  I Indonesia  I  Lao PDR  I  Myanmar  I   Malaysia  I Philippines  I  Singapore  I  Thailand  I  Vietnam

For more information on the new Victoria ASEAN PhD Scholarships for Singapore and Brunei click here.

For further information on the Young Business Leaders initiative managed by the Asia New Zealand foundation click here.

General eligibility criteria

The New Zealand-ASEAN Scholars Awards are open to candidates from the public and private sector including civil society, university lecturers, development-focused organisations and charitable foundations.

To be eligible, you must:

  • be a citizen of one of the eligible countries and have resided in that country for at least two years at the time of application
  • not have citizenship/permanent residence status for New Zealand or Australia
  • not be married or engaged to be married to a person who holds New Zealand or Australian citizenship or permanent residence status
  • not hold or have held a New Zealand Government or Australian Government scholarship in the preceding 24 months at the time of application
  • not be seeking support for a degree programme already commenced
  • not hold a qualification at a similar level or in a similar field of study at similar level (this means holders of bachelor degrees should apply for Masters or PhD and Masters graduates should apply for PhD study)
  • be available to take up the scholarships in the calendar year for which the scholarship is offered
  • hold a bachelor degree of strong academic merit that is relevant to the proposed post graduate qualification
  • have a minimum IELTS (academic) results of 5.5 overall, with no band less than 5.0 and results to be no older than 24 months at time of application
  • satisfy the admission requirements of the New Zealand institution in which the degree programme is to be undertaken, including that institution’s English language criteria.

Preference will be given to applicants whose study focuses on the priority sectors identified by each country. Please see country information pages listed above for more information about these priorities.

Preference will also be given to applicants under 40 years of age.

English language requirements

New Zealand tertiary education institutions set their own admission requirements for English language proficiency. All applicants should check the IELTS (International English Language Testing System, academic stream) or TOEFL (Testing of English as a Foreign Language) score required for admission to their selected New Zealand education institution. As a guide, most New Zealand education institutions require a minimum IELTS score of 6.5, with no band less than 6.0, for postgraduate level study. Some postgraduate qualifications may require a higher score.

Candidates must provide the original copy of their IELTS or TOEFL exam result as a pre-condition of placement. Results must be no older than 24 months at the time of the scholarship start date.

Candidates who show particularly strong developmental relevance and applicability may be able to receive three months’ English language training in New Zealand prior to starting their main academic qualification. Candidates with IELTS of 6.0 overall, with no band less than 5.5, should therefore still consider applying.

Application process

Download the New Zealand-ASEAN Scholar Awards application form (pdf 159kb)

Application processes and timelines can vary depending on the country. For information about the application process please see the scholarship information page for your home country.

Terms and conditions

All applicants who are offered a New Zealand-ASEAN Scholars Awards will be required to sign a contract with the New Zealand Government declaring they will comply with the terms and conditions of the scholarship.

All awardees are required to return to their home country for a minimum period of two years following completion of their scholarship in order to contribute to their country’s economic and social development.

source : New Zealand Scholar Awards


[Share with Me] New Zealand ASEAN Scholar Awards

[Share with Me] What You Need to Know About Flood in Jakarta, Indonesia

Like we know in the 3-4 days ago Jakarta, Indonesia was fill by water due the weather condition that almost in 4 days rain never stop. It cause Jakarta flooding in most of it’s city. Due to it’s special condition in Indonesia, Google as a company that holding a branch take action and make kind of flood crisis center to help people get in touch with information about Jakarta flood. It shows place with various water depth so if people see it, hopefully they will not pass that way. Below is some link that may be useful for you when you visit or stay in Jakarta. (I get this information from detik.com)


[Share with Me] What You Need to Know About Flood in Jakarta, Indonesia

[Share with Me] Create a Facebook Share Button Dinamically Using PHP (2)

After searching in the internet, i’ve found this method. You can try this if you want. Found this in this forum.

Another way to create your share button is using this script. When using this kind of method, simply just replace <;url> with your own link.

Hopefully this will help you all.

Text link:

<script>function fbs_click() {u=location.href;t=document.title;window.open ('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script> <a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank">Share on Facebook</a>

Small icon and text:

<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_link { padding:2px 0 0 20px; height:16px; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top left; }</style> <a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank">Share on Facebook</a>

Icon only:

<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_button { display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; } html .fb_share_button:hover { color:#fff; border-color:#295582; background:#3b5998 url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; text-decoration:none; } </style> <a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a>

 

Sources: http://www.facebook.com/share_partners.php


[Share with Me] Create a Facebook Share Button Dinamically Using PHP (2)

Sunday, January 20, 2013

[Share with Me] Create a Facebook Share Button Dinamically Using PHP

Facebook social plugins are widely used to promote websites, blog posts etc. In this post I am going to tell you how to dynamically create a Facebook share button in PHP and how to populate and open the Facebook share popup so the user can stay on the same page while sharing to Facebook. Meta tags will be used to populate this.

Let’s get on with it then

Lets start with the Facebook share button. To create a Facebook share button you need two things, first is the share button image and second is the unique URL that is used by facebook to fetch the data from. For a unique URL we’ll use fbsharepage.php with the query string parameter that is the id to make it unique, the id can be a number or a string and if you’re using a database then you can use a primary key as an id as it’s always unique.

Here is the URL

$url = $_SERVER['HTTP_HOST']."/demo/fbshare/fbsharepage.php?id=1";

 

Javascript is used to create a popup for share. Window.open is used to open a share popup where the first parameter is the page URL you want to display in the popup, second parameter is the name of the popup and the thrid is the list of options you can set to window. Please note that in second parameter i.e the popup name, do not use space and – characters as IE doesn’t allow these characters.

Here is the JavaScript function to open a share popup

function fbshare() { window.open ("http://www.facebook.com/share.php?u=<;?php echo $url?>", "Facebook_Share","menubar=1,resizable=1,width=900,height=500"); }

 

And the Facebook Share Button

<a href="javascript:fbshare()"> <img src="images/Share.png" /> </a>

And here is the complete code of the Facebook share page saved as php-create-fb-share-button.php

<div style="font-weight: bold;font-size:12px;"> PHP how to dynamically create facebook share button </div> <?php $url = $_SERVER['HTTP_HOST']."/demo/fbshare/fbsharepage.php?id=1"; //$url = "http://".$_SERVER['HTTP_HOST']."/php-create-fb-share-button/fbsharepage.php?id=1"; ?> <script type="text/javascript"> function fbshare() { window.open ("http://www.facebook.com/share.php?u=<;?php echo $url?>", "Facebook_Share","menubar=1,resizable=1,width=900,height=500"); //window.open("http://www.javascript-coder.com","mywindow","menubar=1,resizable=1,width=900,height=500"); } </script> <a href="javascript:fbshare()"> <img src="images/Share.png" /> </a>

 

Now create a folder in the same place as images and copy the Share.png in the folder

Lets move to fbsharepage.php

As we are using fbsharepage.php as the share URL so Facebook uses this page to fetch the data using meta tags. This page is also used to redirect the user to the post page once they click on the shared link on Facebook feed.

Here is the redirection code

//if user come from facebook by clicking on the link, we can redirect user to the post page. 
//Referer address is the address where user comes from by clicking on the link in this case facebook is the referer.
if(isset($_SERVER['HTTP_REFERER']))
{
//a regular expression to match the facebook address from the referer address
if(preg_match("/www.facebook.com/",$_SERVER['HTTP_REFERER']))
{
$url = $_SERVER['HTTP_HOST']."/demo/php-create-fb-share-button.php";
?>
<SCRIPT type="text/javascript">
window.location="php-create-fb-share-button.php";
</SCRIPT>
<?php
}
}

Here is the meta tags. You can use the query string id that we have passed to dynamically create the meta tags. I’m just using static meta tags for this example

<?php
?>
<meta property="og:title" content="How to dynamically create facebook share button in PHP" />
<meta property="og:image" content="<?php echo $imageURL;?>" />
<meta property="og:description" content="In this post I am going to tell you how to dynamically create
facebook share button and how facebook fetch data from the provided link on like to automatically
share on facebook using page meta tags." />

And here is the complete code for the fbsharepage.php page

<meta property="og:image" content="" />

Click here to download the full source code.


[Share with Me] Create a Facebook Share Button Dinamically Using PHP

Register


Register

[Share with Me] Data Binding in Visual Basic.Net

Q : How can I get the most out of data binding in the applications I write in Visual Basic® .NET?
A : As I mentioned in last month’s installment of Advanced Basics, data binding is alive and well in the Microsoft® .NET Framework and it’s a great technology that makes dealing with data more useful in many types of applications. Let’s pick up where I left off and look at some practical applications of data binding.
A As I mentioned in last month’s installment of Advanced Basics, data binding is alive and well in the Microsoft® .NET Framework and it’s a great technology that makes dealing with data more useful in many types of applications. Let’s pick up where I left off and look at some practical applications of data binding.
First, let’s discuss architecture for a moment. Figure 1 shows an overview of a common way of using data binding with a data source. The data is pulled from the source by way of a data library and placed in an untyped DataSet. The untyped DataSet is used in order to enable the use of a generic data access library. This lets you call a single function that returns any DataSet. You can now take this untyped DataSet and merge it with a typed DataSet by using two matching tables. Finally, you can bind controls to the typed DataSet.

Figure 1 Binding 
You might wonder why I didn’t bind directly to the untyped DataSet. Well, the typed DataSet provides features such as early binding of fields. This enables you to use .CustomerName as a member of the DataSet instead of referencing the Items collection with the value “CustomerName,” making the process of accessing data much more straightforward. This early binding also gives you automatic support for data binding at design time. This enables you to select fields in the editor and even access custom properties in certain controls.
Now let’s look at data binding in the real world. Take a look at the following function from my July 2003 column that pulls data from SQL Server and returns a DataSet:

[sourcecode language="vb"]

Function RetrieveCustomerContacts() As DataSet Dim ds As DataSet Try ds = RunSQLWithDataSet("Select CustomerID, " & _ "CompanyName, ContactName, NoOfCustomerVisits " & _ "from customers", ConnectionString, "Customers") Catch ex As Exception ds = Nothing End Try Return ds End Function

[/sourcecode]

 

Next, consider a typed DataSet named Customers with the following fields that I’ve added to the project as dsCustomers.xsd (part of the XSD has been omitted to conserve space):

 <xs:sequence> <xs:element name="CustomerID" type="xs:string" /> <xs:element name="CompanyName" type="xs:string" /> <xs:element name="ContactName" type="xs:string" minOccurs="0" /> <xs:element name="NoOfCustomerVisits" type="xs:int" minOccurs="0" /> </xs:sequence>
In Visual Studio® .NET, you can wire up this data to a DataSet by dragging a DataSet component from the toolbox and dropping it onto your form, then associating it with the typed DataSet named Customers. Now you can use the properties window of a DataGrid control to select the new DataSet as the DataSource and the Customers table as the DataMember.

You can complete the process by adding the following code in the form’s Load event:

 Dim ds As DataSet Dim oClass As New SomeComponent.Class1 Try ds = oClass.RetrieveCustomerContacts dsCustomers.Merge(ds) Catch ex As Exception sbarmain.Text = ex.Message End Try

This code calls the RetrieveCustomerContacts class to retrieve the DataSet and merge it into the typed DataSet for your form. Of course, you can also perform this type of data binding with other controls such as the listbox and combobox controls. There is another cool feature that comes into play. The same code I just showed can be used to cause the typed DataSet to be loaded into your combobox. Then you can extract the chosen value with just a single line of code in the SelectedIndexChanged event:

txtSelectedID.Text = ComboBox1.SelectedValue

Of course, if you are binding the txtSelectedID control to a class or structure where the property is called CustomerID, you could do this instead of putting the data directly into the control:

CustomerContacts.CustomerID = ComboBox1.SelectedValue

This would update the class’s CustomerID field and the data binding would update the value shown in the bound textbox.

Let’s take a look at another way data binding makes your data-driven application more user-friendly. Say, for example, you have an application that has to show data in three textboxes from a DataSet or other bindable object. The CurrencyManager can be used to navigate through these controls and provide other features. I looked at several examples using the CurrencyManager and they were fairly obtuse, so I borrowed a concept from a sample in the MSDN® Library and made a more practical example. The interface to this form is shown in Figure 2.

Figure 2 Currency Manager Interface 
This form allows you to scroll through a DataSet and make changes to the data as you go. Each time you change a value and move to another record, the change is persisted to the DataSet. That’s pretty much how the data binding worked in Visual Basic 6.0 and before. It’s more flexible now with Visual Basic .NET because you have access to the low-level features of data binding.
Let’s take a look at the code in Figure 3 so I can share a couple of things I learned. The code is pretty straightforward, but requires a bit of explanation. I will skip the mundane parts such as the class that pulls the data from SQL Server and returns it, but the complete code is in the download for this column.
 Figure 3 Key Code Elements For Data Binding
Private WithEvents thisCurrencyManager As CurrencyManager 'Variable defs go here 'Form Load builds the dataset, merges it with CustomerInfo1, 'then binds the controls by calling BindControls Private Sub BindControls(ByVal thisDataTable As DataTable) ' Bind a TextBox control to a DataTable column 'in a DataSet. txtCompany.DataBindings.Add("Text", thisDataTable, "CompanyName") txtName.DataBindings.Add("Text", thisDataTable, "ContactName") txtCity.DataBindings.Add("Text", thisDataTable, "City") txtCustomerID.DataBindings.Add("Text", thisDataTable, "CustomerID") ' Specify the CurrencyManager for the DataTable. thisCurrencyManager = _ CType(Me.BindingContext(thisDataTable), CurrencyManager) ' Set the initial Position of the control. thisCurrencyManager.Position = 0 End Sub Private Sub MoveNext(ByVal thisCurrencyManager As CurrencyManager) If thisCurrencyManager.Position = thisCurrencyManager.Count - 1 Then MessageBox.Show("You're at end of the records") Else thisCurrencyManager.Position += 1 CheckChanges() End If End Sub Private Sub MoveFirst(ByVal thisCurrencyManager As CurrencyManager) thisCurrencyManager.Position = 0 CheckChanges() End Sub Private Sub MovePrevious(ByVal thisCurrencyManager As CurrencyManager) If thisCurrencyManager.Position = 0 Then MessageBox.Show( _ "You're at the beginning of the records.") Else thisCurrencyManager.Position -= 1 CheckChanges() End If End Sub Private Sub MoveLast(ByVal thisCurrencyManager As CurrencyManager) thisCurrencyManager.Position = thisCurrencyManager.Count - 1 CheckChanges() End Sub 'Button click events go here Private Sub txtName_TextChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles txtName.TextChanged 'Exit if starting up If IsNothing(thisCurrencyManager) Then Exit Sub End If StartEditMode() End Sub Private Sub txtCompany_TextChanged(ByVal sender As _ System.Object,ByVal e As System.EventArgs) _ Handles txtCompany.TextChanged StartEditMode() End Sub Private Sub txtCity_TextChanged(ByVal sender As _ System.Object, ByVal e As System.EventArgs) _ Handles txtCity.TextChanged StartEditMode() End Sub Sub StartEditMode() cmdSaveChanges.Enabled = True End Sub Sub EndEditMode() Me.BindingContext(CustomerInfo1.Customers).EndCurrentEdit() End Sub Private Sub thisCurrencyManager_PositionChanged( _ ByVal sender As Object, _ ByVal e As System.EventArgs) _ Handles thisCurrencyManager.PositionChanged cmdSaveChanges.Enabled = False End Sub Private Sub cmdNew_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles cmdNew.Click thisCurrencyManager.AddNew() End Sub 'Other subs go here

The first line of code in Figure 3 defines the CurrencyManager for my application. It’s defined with WithEvents to allow the use of its events if I need them:

Private WithEvents thisCurrencyManager As CurrencyManager
The code in the frmBinder2_Load event is pretty standard. It calls a method that returns a DataSet, then merges that DataSet into a typed DataSet. The typed DataSet’s Customers table is passed to the BindControls method, which performs the binding.

The BindControls method is where you see the CurrencyManager in action. The first few lines bind four fields from the DataSet to the Text property of the controls:

txtCompany.DataBindings.Add("Text", thisDataTable, "CompanyName") txtName.DataBindings.Add("Text", thisDataTable, "ContactName") txtCity.DataBindings.Add("Text", thisDataTable, "City") txtCustomerID.DataBindings.Add("Text", thisDataTable, "CustomerID")

The last two lines of BindControls actually use the CurrencyManager. The first of these lines sets the CurrencyManager to the BindingContext of the data source (a DataTable in this case):

thisCurrencyManager = CType(Me.BindingContext(thisDataTable), _ CurrencyManager)

The next line sets the initial position to 0 (the first record):

thisCurrencyManager.Position = 0

Now, I can proceed to the CurrencyManager. The Move methods all change the position within the DataSet by using the CurrencyManager. For instance, the MoveNext method moves the current element pointer forward in the data source as long as the current position is not the last element:

If thisCurrencyManager.Position = _ thisCurrencyManager.Count - 1 Then MessageBox.Show("You're at end of the records") Else thisCurrencyManager.Position += 1 CheckChanges() End If

The CheckChanges method is called each time the position changes to determine if the DataSet has any changes.

As I built this sample application, I struggled with one small problem for hours. I could scroll through the records fine and changing the data worked as long as I changed to another row in the data. However, when I used the Save button to save the changes, the GetChanges method was not properly indicating that changes had occurred. I checked the code per the MSDN documentation and the online samples and after a bit of sleuthing, I figured it out.

I was using a DataTable as the data source. The EndCurrentEdit method was being fired by the EndEditMode procedure with the following line of code:

Me.BindingContext(CustomerInfo1, "Customers").EndCurrentEdit()

This did not work; the DataSet showed no changes even though the data did, in fact, change. Finally, I realized I was using the wrong context. The following context worked just fine:

Me.BindingContext(CustomerInfo1.Customers).EndCurrentEdit()

In this case, I am passing only the DataTable which is indeed the data source for the controls. The funny thing is, the original code didn’t generate any errors when it executed; it just didn’t work. I’m sure the line did actually execute because when I changed the table name (Customers) to CustomersX, the line generated a runtime error. As I said, the code was executing, it was just pointing to the wrong data source.

The other code in this form is pretty straightforward as it implements calls to the move methods and otherwise handles interactions with the CurrencyManager.
The cmdAddNew_Click event is noteworthy because it causes a new row to be added to the data. This clears the form and allows you to enter data into the new row. You can see the changes are automatically saved by moving off the row and back.
The thisCurrencyManager_PositionChanged event is fired when the position is changed. This event is used to reset the state of the SaveChanges button.

Test Post from Share with Me

Test Post from Share with Me http://mwindriyanto.web.id