Chủ Nhật, 12 tháng 1, 2014

Basic1_ Tạo button trong C# và tạo sự kiện

Tạo một Form như sau:

  • button 1 có tên là button1
  • textbox có tên là textbox1
Yêu cầu:
  • Nhập vào textbox 1 số n và click vào nút button1, kết quả sẽ hiện ra các button từ 1 đến n có name là btn1, btn2, btn3,...
  • Khi click vào nút btn2 hiện ra messagebox "bạn đã chọn vào btn2".

private void button1_Click(object sender, EventArgs e)
        {
            string x=textBox1.Text;
            for (int i = 0; i <= int.Parse(x); i++)
            {
                Button nut = new Button();
                nut.Text = "Nut thu" + i;
                nut.Name = "nut" + i;
                nut.Location = new Point(200, 50+30 * i);
                this.Controls.Add(nut);
                nut.Click += new EventHandler(nut_Click);
            }

        }


Viết sự kiện nut_Click khi click vào nút.
void nut_Click(object sender, EventArgs e)
        {
            string x = ((Button)sender).Text;
            string n = ((Button)sender).Name;
            if(n=="nut1")
            MessageBox.Show("Ban vua click vao" + x);


        }


Thứ Sáu, 27 tháng 12, 2013

4_ Viết chức năng thêm sửa xóa trong window form

Thiết kê 1 form quản lý sinh viên bao gồm 2 textbox, 4 btn thêm ,sửa , xóa, hiển thị, và 1 datagirdview như hình bên dưới

3_ Thao tác trên cơ sở dữ liệu sử dụng dataset,dataadapter,datatable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;


2_Thực thi câu truy vấn SQL trên C#

1. Lấy ra họ tên và mã số sinh viên từ table sinh viên

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

1_ Kiểm tra Kết nối cơ sở dữ liệu trong C#

Để kết nối với cở sở dữ liệu,  Phải khai báo namespace "System.Data.SqlClient".

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient; //namespace de thao tac voi CSDL

Thứ Hai, 5 tháng 8, 2013

Hướng dẫn định tuyến IS-IS


Cấu hình trên R1:

Current configuration : 930 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
ip cef
!
!
!
no ip domain lookup
ip domain name lab.local
ip audit po max-events 100
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 172.16.2.1 255.255.255.255
 ip router isis
!
interface FastEthernet0/0
 ip address 172.16.1.3 255.255.255.0
 ip router isis
 duplex auto
 speed auto
 isis circuit-type level-1
!
interface FastEthernet0/1
 no ip address
 shutdown
 duplex auto
 speed auto
!
router isis
 net 49.0001.1720.1600.2001.00
 is-type level-1
!
ip classless
!
no ip http server
no ip http secure-server
!
!
!
!
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line vty 0 4
 login
!
end


Cấu hình trên router R2


Current configuration : 975 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
ip cef
!
!
!
no ip domain lookup
ip domain name lab.local
ip audit po max-events 100
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 172.16.3.1 255.255.255.255
 ip router isis
!
interface FastEthernet0/0
 ip address 172.16.1.4 255.255.255.0
 ip router isis
 duplex auto
 speed auto
 isis circuit-type level-1
!
interface FastEthernet0/1
 ip address 192.168.1.4 255.255.255.0
 ip router isis
 duplex auto
 speed auto
 isis circuit-type level-2-only
!
router isis
 net 49.0001.1720.1600.3001.00
!
ip classless
!
no ip http server
no ip http secure-server
!
!
!
!
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line vty 0 4
 login
!
end

Cấu hình trên router 3

Building configuration...

Current configuration : 920 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R3
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
ip cef
!
!
!
no ip domain lookup
ip domain name lab.local
ip audit po max-events 100
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 192.168.2.1 255.255.255.255
 ip router isis
!
interface FastEthernet0/0
 ip address 192.168.1.5 255.255.255.0
 ip router isis
 duplex auto
 speed auto
 isis circuit-type level-2-only
!
interface FastEthernet0/1
 no ip address
 shutdown
 duplex auto
 speed auto
!
router isis
 net 49.0002.1921.6800.2001.00
!
ip classless
!
no ip http server
no ip http secure-server
!
!
!
!
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line vty 0 4
 login
!
end


Chủ Nhật, 21 tháng 7, 2013

1. Hướng dẫn cài đặt python,python mysql, django làm web

1. Cài đặt python
Hôm nay viết bài làm web với python trên framework python. Đầu tiên các bạn download python về đã. Phiên bản mới nhất là 3.3, những mình xài 2.7 quen rồi nên download 2.7 xài. Với lại 3.3 chưa có gói hỗ trợ mysql . Ai thích 3.3 thì cứ phang thôi :D

Link download http://www.python.org/download/.

Sau khi cài đặt xong, thì thư mục chứ python mặc định sẽ là C:\python27.
Click chuột phải vào Mycomputer\Chọn Properties\Change Settings \Tab Advanced.Click vào Environment Variables... Dưới ô System variables chọn varialbes là path,click vào nút Edit,thêm vào
;C:\Python27;C:\Python27\Scripts;C:\Python27\Lib\site-packages\django\bin


Click ok để hoàn thành.

2. Cài đặt python mysql.
Download tại đây http://sourceforge.net/projects/mysql-python/ , sau khi download nháy đúp vào cài chạy bình thường.Next next finish là xong :V

3. Cài đặt Django Framework
Ai mà code web python chay,ko xài framework thì không cần cài thằng này .Download tại đây .
Sau khi download về giải nén, ở đây mình giải nén trong ổ đĩa C, thay đổi tên thư mục thành Django cho dễ nhìn.Cấu trúc thư mục ta sẽ có như sau

Tiếp theo vào Cmd của Windows, truy cập vào thư mục django và gõ lệnh
cd C:\Django
C:\>python setup.py install

Đợi xí là nó báo cài xong. Ok
Sau khi chạy xong bà đã hoàn tất cài đặt framework django. Bài sau sẽ hướng dẫn các bạn cấu hình vào xây dựng ứng dụng đơn giản trên framework django sử dụng cơ sở dữ liệu mysql