Thứ Tư, 7 tháng 9, 2016

VB.NET Tutorial : How to Fillter DataGridView using Multiple CheckBox


VB.Net Tutorial - How we can fillter a DataGridView using Multiple CheckBox where data storing from a database (MySQL) database. In preiews Lessons, we have learn about how to filltering DataGridview from a textBox, read How to Filter DataGridView Using TextBox and MySQL Database and How to Search/Fillter Items in a ListBox.

Fillter DataGridView using Multiple CheckBox

in your visual studio, create new project and rename it with "FillterDataGridView" and at the form1.vb add one DataGridView, Two GroupBox, and five CheckBox, see images below :

How to Fillter DataGridView using Multiple CheckBox

Next, Add new Module, called "ModuleConnection.vb" for our connection to database using ODBC class, or you can crate using ADO.NET.

Source Code ModuleConnection.vb

Imports System.Data.Odbc ' we can use ODBC class to create a connection
Module ModuleConnections
    ' first you must have a database,
    ' and we will connect it using ODBC connection.
    ' i have a database (MySQL database) and has create ODBC connection
    Public connection As OdbcConnection
    Public Sub connect()
        Try
            connection = New OdbcConnection("DSN=k13new;MultipleActiveResultSets=True")
            If connection.State = ConnectionState.Closed Then
                ' open connection
                connection.Open()
            End If
        Catch ex As Exception
            MsgBox("Connection failed!")
        End Try
    End Sub
End Module

Source Code Fillter Data (Form1.vb)

Imports System.Data.Odbc
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' open connection
        connect()
        Dim da As New OdbcDataAdapter("SELECT * FROM siswa", connection)
        Dim ds As New DataSet ' we will use dataset
        da.Fill(ds, "siswa")
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = "siswa"
        da.Dispose()
        connection.Close()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim query As String = ""
        Dim query2 As String = ""
        Dim c1check As Boolean
        Dim c2check As Boolean

        Dim myList As New List(Of String)
        For Each cb As CheckBox In GroupBox1.Controls.OfType(Of CheckBox)
            ' we can know if checkbox in GroupBox1 is checked or not
            If cb.Checked Then
                c1check = True
                ' get the text of checkbox that checked by user
                myList.Add(cb.Text)
            End If
        Next

        ' now , add the same function to get value from groupbox 2
        Dim myList2 As New List(Of String)
        For Each cb2 As CheckBox In GroupBox2.Controls.OfType(Of CheckBox)
            ' we can know if checkbox in GroupBox2 is checked or not
            If cb2.Checked Then
                c2check = True
                ' get the text of checkbox that checked by user
                myList2.Add(cb2.Text)
            End If
        Next

        If c1check Then
            ' if checkbox in groupbox1 is checked, we will create this query to our database
            query = "SELECT * FROM siswa WHERE kelas='" & String.Join("' or kelas=" + "'", myList) + "'"
        End If
        If c2check Then
            ' if checkbox in groupbox2 is checked, we will create this query to our database
            query = "SELECT * FROM siswa WHERE jeniskelamin='" & String.Join("' or jeniskelamin=" + "'", myList2) + "'"
        End If
        If c1check And c2check Then
            ' if checkbox in GorupBox 1 and 2 is checked, we will create this query to our database
            query = "SELECT * FROM siswa WHERE (kelas='" & String.Join("' or kelas=" + "'", myList) + "') AND (jeniskelamin='" & String.Join("' or jeniskelamin=" + "'", myList2) + "')"

        End If

        ' open connection
        connect()
        Dim da As New OdbcDataAdapter(query, connection)
        Dim ds As New DataSet

        da.Fill(ds, "siswa")
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = "siswa"
        da.Dispose()
        connection.Close()
    End Sub
End Class

Video tutorial How to Fillter DataGridView using Multiple CheckBox



Download Project http://bit.ly/2ckFI2r

Thứ Ba, 6 tháng 9, 2016

Laravel 5 Tutorial : Forms & HTML Class in laravel 5.3


Laravel 5 Tutorial - How to solved Html and Form class not found in Laravel 5.3? to add class HTML & FORM in Laravel 5.3 you need three simple steps. that because By default in Laravel 5.3, Html and Form are not embedded anymore.

at the previews lessons, we have learn about Http Session Method in Laravel 5.3 and How to Create localization for Multiple languages in laravel 5.3.

HTML & Form Class Installation

Add the following lines laravelcollective/html": "5.3.* in the require section of your composer.json file and run composer update.

"require": {
. . . .
    "laravelcollective/html": "5.3.*"
. . . .
}

than RUN "compser update" on your terminal.

composer update

Next, we need to Register the service provider by default stored on config/app.php by adding the following value into the providers array:

'providers' => [
    // ...
    Collective\Html\HtmlServiceProvider::class,
    // ...
  ],

Register facades by adding these two lines in the aliases array on config/app.php :

'aliases' => [
    // ...
      'Form' => Collective\Html\FormFacade::class,
      'Html' => Collective\Html\HtmlFacade::class,
    // ...
  ],

Now, you can add Form and Html class in your Laravel project.
Laravel 5 Tutorial : Forms & HTML Class in laravel 5.3

Create Form & HTML Class Example

First, create new Views file stored in resources\views\newformpage.blade.php

newformpage.blade.php

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>FORM & HTML</title>
  </head>
  <body>
<?php
  echo Form::open(['url' => 'foo/bar']);
    echo Form::text('username','username');
    echo '<br/>';
    echo Form::text('email','yourmail@here.com');
    echo '<br/>';
    echo Form::password('password');
    echo '<br/>';
    echo Form::checkbox('name','value');
    echo '<br/>';
    echo Form::radio('name','value');
    echo '<br/>';
    echo Form::file('image');
    echo '<br/>';
    echo Form::select('Gender',['P'=>'perempuan','L'=> 'Laki-laki']);
    echo '<br/>';
    echo Form::submit('Register Now');
  echo Form::close(); ?>
  </body>
</html>

Create new routes on routes\web.php

web.php

Route::get('/form', function () {
    return view('newformpage');
});

Now, try to access your new page by following this url : http://localhost:8080/form

Video tutorial Forms & HTML Class in laravel 5.3



See you next Lessons More method can use in Form & Html Class

Thứ Hai, 5 tháng 9, 2016

Laravel 5 Tutorial : Get() Put() Remove() Method HTTP Session in laravel 5.3


Laravel 5 Tutorial - How we can use Get() method in HTTP Session, Put() method and Remove() Method HTTP Session in laravel 5.3? in the previews lessons, we have learn about Create localization for Multiple languages and Authentication Login & Registration Form + Bootstrap

Get() method in HTTP Session

Get() method in HTTP Session is used for Accessing Session Data, we need an instance of session which can be accessed via HTTP request.

Put() method in HTTP Session

Put() can use for Storing Session Data, The put() method will take with two arguments, the "key" and the "value".

Forget() method in HTTP Session

forget() method use for Deleting Session Data, more detail about Http Session following Laravel Document https://laravel.com/docs/5.3/session#storing-data

Example Laravel Project (Http Session)

At your laravel project, we need to create new Controller, create new controller using Artisan command following by :

php artisan make:controller SessionController

Your SessionController.php will created and stored on App\Http\Controllers
Just create all function for Get() Put() Remove() Method int your controller,
Get() Put() Remove() Method HTTP Session in laravel 5.3

SessionController.php

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class SessionController extends Controller
{
    //we will create function to get accessing session Data
    // that is with get() method
    public function getSession(Request $request){
      if($request->session()->has('session_name'))
        echo $request->session()->get('session_name');
      else {
        echo 'no data in the session';
      }
    }
    // create new function for put method
    public function putSession(Request $request){
      $request->session()->put('session_name','www.hc-kr.com');
      echo 'a data hasbeen added to the session';
    }
    // create new function to delete session
    public function forgetSession(Request $request){
      $request->session()->forget('session_name');
      echo "data hasbeen removed from the session";
    }
}


After all done, just create new routes in your route file (\routes\web.php for Laravel 5.3)

web.php

Route::get('session/get', 'SessionController@getSession');
Route::get('session/put', 'SessionController@putSession');
Route::get('session/forget', 'SessionController@forgetSession');

Try to access your route in your browser following this command

http://localhost:8080/session/get
http://localhost:8080/session/put
http://localhost:8080/session/forget

Video Tutorial Get() Put() Remove() Method HTTP Session


See you next Lessons ....

Laravel 5 Tutorial : How to Create localization for Multiple languages in laravel 5.3


Laravel 5 Tutorials - in Laravel PHP Framework Localization used for handle multiple languages on your laravel apps. Default installations in Laravel 5.3 is stored on resources\lang\ folders. In previews lessons, we have learn about Authentication Login & Registration Form + Bootstrap in laravel 5.3 and Adding Bootstrap Theme to Laravel 5.3.

In this lessons, we will create simple page that use two different languages,

First, we will create new Controller and will strode on App\Http\Controllers

Use Artisan command >> php artisan make:controller LanguageController

LanguageController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class LanguageController extends Controller
{
    // we will create new method
    public function index(Request $request, $locale){
        // set application Locale
        app()->setlocale($locale);
        // get the translated message and show it
        echo trans('language.message');

    }
}

Create new routes

Web.php

Route::get('{locale}', 'LanguageController@index');


Create files for our language,
at the resources\lang\id\ folder, create new file "language.php"

language.php

<?php
  return [
    'message'=>'Hallo semuanya, nama saya adalah Harison Matondang'    
  ];


at the resources\lang\en\ folder, create new file "language.php"

language.php

<?php
  return [
    'message'=>'hello all, my name is Harison Matondang'
  ];

How to Create localization for Multiple languages in laravel 5.3

Video Tutorial localization in Laravel 5.3


see you next lessons ....

Chủ Nhật, 4 tháng 9, 2016

VB.NET Tutorial : How to Search/Fillter Items in a ListBox


Vb.NET tutorial for beginners - How we can add some values / items into a ListBox component and then search or fillter it using a TextBox in vb.net programming languages? we can create simple application that contains the match will be selected at the Listbox.

At your visual studio, create new project and at the form1.vb add some component like a TextBox, Button and a ListBox component.

Write all source code serach items in a ListBox below

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' Add items into ListBox
        With ListBox1.Items
            .Add("Harison Matondang") ' add more string
            .Add("www.hc-kr.com") ' add more string
            .Add("budi") ' add more string
            .Add("beni") ' add more string
            .Add("Indonesia") ' add more string
        End With
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim search As String
        ' doing loops here
        For x As Integer = 0 To ListBox1.Items.Count - 1
            search = ListBox1.Items.Item(x)
            If InStr(search.ToLower, TextBox1.Text.ToLower) Then
                ' show the result here
                ListBox1.SelectedItem = search
            End If
        Next
    End Sub
End Class

How to Search/Fillter Items in a ListBox

Video Tutorial serach items in a ListBox below



Download full source code here http://bit.ly/2bXq21d

VB.NET Tutorial : Check if String is a Letter, Number, Digit


Vb.NET Tutorial - How we can check if String is a Letter, check if String is a Number, check if String is a Digit in VB.NET? Char.IsNumber() functions is to checks if a string entered is a number (hex 0 - 9 - A - F), Char.IsLetter() checks if a string entered is a letter (a - z), Char.IsDigit() to check a string entered is a digit.

at the previews lessons, we have learned about String Equals() CopyTo() Copy() Contains() and String Length() Insert() IndexOf() function in vb.net

Check if String is a Number (hex 0 - 9 - A - F)

If Char.IsNumber(number.Text.Chars(number.TextLength - 1)) = True Then
 MsgBox("its a Numbers")
Else
 MsgBox("Please insert a Number")
End If

Check if String is a Letters (a-z)

If Char.IsLetter(Letters.Text.Chars(Letters.TextLength - 1)) = True Then
 MsgBox("it's Letters")
Else
 MsgBox("Please enter a Letter")
End If

Check if String is a Letter, Number, Digit

Check if String is a Digit

If Char.IsDigit(Digits.Text.Chars(Digits.TextLength - 1)) = True Then
 MsgBox("its a Digit")
Else
 MsgBox("please enter a Digit")
End If

See you Next Lessons ....

Thứ Bảy, 3 tháng 9, 2016

Laravel 5 Tutorial : Authentication Login & Registration Form + Bootstrap in laravel 5.3


Implementing Authentication Login form, Registration and Password reset in laravel 5.3 is very simple. That will be located on config\auth.php folder. How to create Authentication Login & Registration Form in Laravel 5.3? we can use simple Artisan command "php artisan make:auth" and then just crate new migrate, please read How to Database Migration & Schema in Laravel 5.3.

Authentication Defaults in laravel 5.3

'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

Authentication Guards

'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],
    ],

User Providers

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => AppUser::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

Resetting Passwords

'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
    ],

Create Login & Registration Form + Bootstrap in laravel 5.3

First, after following this tutorial, you must have an database before and connect with your Laravel project, read How to Connect Database in laravel 5.3

Authentication Login & Registration Form + Bootstrap in laravel 5.3

At your laravel project, we will create Register, Login and new routes into your laravel project just by following this artisan command :

php artisan make:auth

Than, please see on resources\views\auth folder, you will got login and register with blading templates.

Now, following this command to migrate new tables into our database.

php artisan migrate

To know more about migrate please read How to Database Migration & Schema in Laravel 5.3

In your database, you will get new tables where table name is "users". Just try to access your login and register form by following this command

http://localhost:8080/register ->> to register new user
http://localhost:8080/login - >> to login

How to add Bootsrtap Theme in Login and Registration Form?

please read How to Adding Bootstrap Theme to Laravel 5.3 or just watch video tutorial below.

Video Tutorial

How to make Authentication Login & Registration Form + Bootstrap in laravel 5.3


See you next Lessons...............