Monday, December 31, 2012

User: Manage, Profile in ASP.NET, visual studio 2008, sql server 2005

User: Manage, Profile in ASP.NET, visual studio 2008, sql server 2005
[youtube=http://youtu.be/Qt0B7poAsjg]

Wednesday, December 26, 2012

Hướng dẫn tạo trang giỏ hàng đơn giản với jsp

Chúng ta cùng nhau xây dựng chức năng giỏ hàng một cách đơn giản nhất trong jsp như sau:

[caption id="attachment_859" align="alignnone" width="300"]Trang chọn sản phẩm Trang chọn sản phẩm[/caption]

Sau khi chọn sản phẩm sẽ chuyển sang trang giỏ hàng

[caption id="attachment_860" align="alignnone" width="300"]Giỏ hàng Giỏ hàng[/caption]

Các bạn có thể tham khảo bên dưới

Trang sản phẩm
[sourcecode language="html"]
<%--
Document : index
Created on : Dec 25, 2012, 3:08:22 PM
Author : Ngo Tuong Dan
--%>

<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
h1
{
color: yellowgreen;
font-style: italic;
}
div
{
margin-left: auto;
margin-right: auto;
width: 300px;
}
input[type=text]
{
width:150px;
text-align:left;
border:thin solid gray;
padding: 2px 5px 2px 5px;
border-radius: 3px 3px 3px 3px;
}
input[type=submit]
{
width:75px;
text-align:center;
border:thin solid gray;
padding: 3px 5px 3px 5px;
border-radius: 3px 3px 3px 3px;
background-color: orange;
}
input[type=submit]:hover
{
width:75px;
text-align:center;
border:thin solid gray;
padding: 3px 5px 3px 5px;
border-radius: 3px 3px 3px 3px;
background-color: yellowgreen;
}
</style>

<title>JSP Page</title>
</head>
<body>
<div>
<h1>Shopping card demo</h1>
<%
if (request.getParameter("btnOK") != null) {
codes.item item = new codes.item();

item.setId(Integer.parseInt(request.getParameter("txtID")));
item.setPrice(Integer.parseInt(request.getParameter("txtPrice")));
item.setQuantity(Integer.parseInt(request.getParameter("txtQuantity")));
java.util.ArrayList orders = new ArrayList();
if (session.getAttribute("Orders") != null) {
orders = ((java.util.ArrayList) session.getAttribute("Orders"));
}
orders.add(item);
session.setAttribute("Orders", orders);

response.sendRedirect("list.jsp");
}
%>

<form method="post">
<table>
<tr>
<td>
ID</td>
<td>
<input type="text" name="txtID" />
</td>
</tr>
<tr>
<td>
Price
</td>
<td>
<input type="text" name="txtPrice"/>
</td>
</tr>
<tr>
<td>
Quantity
</td>
<td>
<input type="text" name="txtQuantity"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit"value="OK" name="btnOK"/>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>

[/sourcecode]

Trang giỏ hàng

[sourcecode language="html"]
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<style>
h1
{
color: yellowgreen;
font-style: italic;
}
div
{
margin-left: auto;
margin-right: auto;
width: 300px;
}

table
{
border: 1px solid gray;
padding: 3px 3px 3px 3px;
}

th
{
color: brown;
}
.back
{
width:75px;
text-align:center;
border:thin solid gray;
padding: 2px 5px 2px 5px;
border-radius: 3px 3px 3px 3px;
background-color: orange;
}
.back:hover
{
width:75px;
text-align:center;
border:thin solid gray;
padding: 3px 5px 3px 5px;
border-radius: 3px 3px 3px 3px;
background-color: yellowgreen;
}
</style>
</head>
<body>
<div>
<h1>Your card</h1>
<table>
<tr>
<th>ID</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
<th>Operator</th>
</tr>
<%
java.util.ArrayList orders = new ArrayList();
codes.item item = new codes.item();
if (session.getAttribute("Orders") != null) {
orders = ((java.util.ArrayList) session.getAttribute("Orders"));
}

int count = orders.size() - 1;
while (count > 0) {
item = (codes.item) orders.get(count);

if (request.getParameter("id") != null) {
if (item.getId() == Integer.parseInt(request.getParameter("id"))) {
orders.remove(item);
count--;
continue;
}
}

out.print("<tr>");
out.print("<td>" + item.getId() + "</td>");
out.print("<td>" + item.getPrice() + "</td>");
out.print("<td>" + item.getQuantity() + "</td>");
out.print("<td>" + item.getQuantity() * item.getPrice() + "</td>");
out.print("<td> <a href='?id=" + item.getId() + "'>Delete</a></td>");
count--;
out.print("</tr>");
}
%>
</table>
<br/>
<a class="back" href="index.jsp">continue</a>
</div>
</body>
</html>
[/sourcecode]

JSP Expression language with static function

http://youtu.be/PnCEZrbnb8I

JSP Expression language with static function

Saturday, December 22, 2012

Java script

Một ví dụ nho nhỏ

js

[sourcecode language="html"]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Java script</title>
<style>
input[type=text]
{
width:50px;
text-align:center;
border:thin solid gray;
padding: 2px 5px 2px 5px;
border-radius: 3px 3px 3px 3px;
}
#result
{
width:60px;
background:#33CC66;
color: #FFFFFF;
font-weight:bold;
}

</style>
<script>
function show()
{
var f = document.getElementById("f");
var s = document.getElementById("s");
var r = document.getElementById("result");

r.value = new Number(f.value) + new Number(s.value);
}
</script>
</head>
<body>
<input type="text" id="f" onkeyup="show();"/>+<input type="text" id="s" onkeyup="show();"/>
<input type="text" id="result" readonly="true" />
</body>
</html>

[/sourcecode]

Friday, December 21, 2012

Sử dụng builtin attribute và tạo attribute mới trong C#

[sourcecode language="csharp"]
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Reflection;

namespace ACS_Lab01
{
class Program
{
DateTime date = DateTime.Now;

/// <summary>
/// Tach ham tu thu vien he thong
/// </summary>
/// <param name="c"></param>
/// <param name="text">Noi dung hien thi</param>
/// <param name="caption">Tieu de hop thoai</param>
/// <param name="type">Kieu hop thoai</param>
/// <returns></returns>
[DllImport("User32.dll")]
public static extern int MessageBox(int c, string text, string caption, int type);

static void Main(string[] args)
{
Program objPro = new Program();
objPro.add(3, 5);

Console.WriteLine("*****************************************");
// doc thong tin cac phuong thuc cua lop program
MethodInfo[] methods = typeof(Program).GetMethods();
object[] attributes = null;
for (int i = 0, l = methods.GetLength(0); i < l; i++)
{
MethodInfo mi = methods[i];
// chi lay ve cac custom attribute
attributes = mi.GetCustomAttributes(true);
foreach (Attribute attribute in attributes)
{
if (attribute is Author)
{
Console.WriteLine("Thong tin lien quan phuong thuc " + mi.Name);
Author author = (Author)attribute;
System.Console.WriteLine("Ten tac gia: {0} ,ghi chu: {1} , tao vao : {2}", author.FullName, author.Comment, author.CreateDate.ToShortDateString());
}
}
}

Console.ReadLine();
}

// [Obsolete("Do not use this method")]
[Conditional("DEBUG")]
public void add(int a, int b)
{
Console.WriteLine("Ket qua: " + (a + b));

MessageBox(0, "Ket qua: " + (a + b), "Thong tin", 0);
}

[Author("Nguyen Van Mit", "Very easy")]
[Author("Tran Thi Chom Chom", "Sai giai thuat")]
public int Add(int a, int b)
{
return a + b;
}
}
}
[/sourcecode]

Author attribute
[sourcecode language="csharp"]
using System;
using System.Collections.Generic;
using System.Text;

namespace ACS_Lab01
{
/// <summary>
///
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple=true)]
class Author: System.Attribute
{
/// <summary>
/// Ham khoi tao su dung de cung cap thong tin cho cac thuoc tinh
/// </summary>
/// He ten tac gia
/// Ngay tao ra
public Author(string FullName, string Comment)
{
this.FullName = FullName;
this.CreateDate = DateTime.Now;
this.Comment = Comment;
}

private string _comment;
/// <summary>
/// Ghi chu
/// </summary>
public string Comment
{
get { return _comment; }
set { _comment = value; }
}


private string _name;
/// <summary>
/// Ho ten tac gia
/// </summary>
public string FullName
{
get { return _name; }
set { _name = value; }
}

private DateTime _create;
/// <summary>
/// Ngay toa ra
/// </summary>
public DateTime CreateDate
{
get { return _create; }
set { _create = value; }
}

}
}
[/sourcecode]

Nếu cần demo ban gửi mail cho tôi

Sunday, December 16, 2012

Video hướng dẫn từng bước xây dựng ứng dựng với C# SqlServer

Do một số bạn không có điều kiện đến lớp tôi sẽ post một loạt video hướng dẫn xây dựng một ứng dụng quản lý đơn giản nhằm giúp các bạn ôn tập tốt hơn môn học Window form with C# chương trình ACCP.

Nội dung môn học WFC#

  1. Thiết kế giao diện từ Session 01 ->06

  2. Thao tác với CSDL Session 07-10

  3. Nhóm bài hỗ trợ


Xây dựng phần mềm quản lý hồ sơ sinh viên

-         SinhVien(masv, hoten, ngay,gioitinh)

-         DiemDanh(masv,ngayhoc,vang)

Yêu cầu chức năng

-         Viết CT tạo sinh viên mới

-         Tìm sinh viên theo mã số

-         Hiển thị ds sinh viên (edit,delete)

-         Điểm danh theo sinh viên tham gia lớp học theo từng ngày

-         Báo cáo:

  • In ra ds sinh viên

  • Thống kê tỉ lệ tham gia lớp học của sinh viên

  • Đóng gói, triển khai và cập nhật phần mềm thông qua hệ thống mạng


Tôi sẽ sớm upload để các bạn tham khảo.

Tổng quan và giao diện

http://www.youtube.com/watch?v=OYV9xsZSFgA

Giao diện

http://www.youtube.com/watch?v=0upGEc3Ij1k

Kết nối dữ liệu

http://www.youtube.com/watch?v=kG3qahrmhOU
Đọc dữ liệu

http://www.youtube.com/watch?v=YMZ5gYc9g3o

Thao tác dữ liệu

http://www.youtube.com/watch?v=S778YynB308
Báo cáo

http://www.youtube.com/watch?v=WSYD-XUr1a8

Đóng gói

http://www.youtube.com/watch?v=XgNE9zkCjog

Custom control

http://www.youtube.com/watch?v=6isPeiXcFx4

Login

http://www.youtube.com/watch?v=p4T5UmUvGD8

Các bạn tham khảo nguồn tại đây.

Sunday, December 9, 2012

Create first jsp and servlet

http://youtu.be/eOuT4IepggU

Create first jsp and servlet netbean 7.2

Translate