ก COE2005 - 20 ก 453041042-6 453040701-7 กกก 4 กก ก ก ก
����������ก������ � COE2005 - 20 ������
����ก����� ����������� �����
��������� ���
���
���������� ����� !�" ��# 453041042-6
�����()� #*��+��� ��# 453040701-7
�������-.�/0������� �������ก�������ก12ก3���.�/45-� 4 62���#���/0�#�7��2��8�
�ก#*"�7�17ก���1�#"�+�� !�"
���7���7�17ก������)�7�"��+
� 97�17ก���1�#"�+ ��7�5�� �����:ก��
Project Report No. COE2005-20 Title
Carparts Database Network System By
Mr. Apidecha Nabundit I.D. 453041042-6 Mr. Danupon Soonrach I.D. 453040701-7
This is the report of fourth year project assignment submitted in partial fulfillment of the requirement for the Degree of Bachelor of Engineering
Department of Computer Engineering Faculty of Engineering Khon Kaen University
������
����ก����� ����������� �����
��������� ���
�,� ���������� ����� !�" ��# 453041042-6
�����()� #*��+��� ��# 453040701-7
-��./01��2ก3���4ก�
....................................... (��.������ �( ��7)
-��.5����6������7���4ก�
1. ........................................ (a1.��.7���� :ก����ก�1) 2. ........................................ (�.���""+ �b��#ก( )
/�9����a 7��5-� 17 ก(���)��c+ ).1. 2549
ก
�/��,��
�/e�����������ก���-. b��5f��2.��)���/�9����+8�ก��b��ก��ก���9��g���h��* "���i����h���9j � : 9���#����k�f�j//����/ -���8�hก���h���h�"���i5-��-ก��8�h�9��g���h��* 8�ก��b��ก���9��g���h��* 5-��-����8l�ij�h 62��g���h��* �k��"+#�7�8l�b9�-ก��:�ก/�9��5�7��*�5-� �ก �����j7h m9��.�"h���-ก��b��ก��5-����9#� b�ก5-����j�h12ก3�k2��7��"h��ก��5��ก���h�����9j ��k��"+���j�h5���7��ก���h����/�9��5�-.bf��/0�"h���-ก��b��ก��ก���h��* #�7�"���i5-��-�7��6��6h��: 9�(����ก8�ก��"�7b#��8h#����k5f�j�h�����2.� ������b98�h�7���*h8�#�7��-. 5f�ก��b��ก��g���h��* 8ha*h8�h#����k�*: : 9�7��(�j�h������-/�9#�5c���)�����2.� 62��a*h8�h#����k8�h�/�:ก���-.8�ก���/�-���5-������#���h�5-��-�ก��"���ก��8�� ���กn�#���h��)���ก��"��#��8b"���ij�h ��กb�ก�-.����-op����ก+#f����ก���h���h��* 8ha*h8�h#����k"�7b#��� ��#���h�j�h�-ก�h7� 62��ก��ก�95f�"���i�-.#����k5f�j�ha���5�� User Interface 5-�k*ก��ก:����8h8�h��� : 9��h�8bj�h�����-ก�h7�
�
Abstract
The goal of this project is to develop a database management for a car-part business. The difference of this business from another is that it requires a big inventory system. This is because variety types of bands, models, manufactures of each type of car. In order to deal with the complexity, we are studying the requirement of users in this project. Then, we use this knowledge to implement our database management system. Using our system can be used as inventory control. Also, to provide benefits for a user, the system provides price comparison among difference grades of each part of car and provides simplicity search functionality. By providing the graphical user interface, this program is easy to use and able to support as needed in this business.
�
����:
�5������ ก Abstract � #����l � #����l�*/��) b #����l"���� m �55-� 1 �5�f� 1
1.1 �7���/0���: 9�7��#f���l�������ก�� 1 1.2 7�"k(/�9#��+ 1 1.3 �����"�������ก�� 1 1.4 :a�ก���f�������� 2 1.5 a 5-����7��b9j�h��� 2
�55-� 2 �7���*h���.��"h� 3 2.1 �7���*h���.��"h��ก-��7ก����3� C++ 3 2.2 �7���*h���.��"h��ก-��7ก�� SQL Database 3 �55-� 3 ก����ก:��g���h��* : 9)�x���/�:ก�� 6 3.1 ก����ก:��g���h��* 6 3.2 ก��)�x���/�:ก�� 6 �55-� 4 ก��8�h����/�:ก�� 12 4.1 ���* �ก 12 4.2 ���*���� 13 4.2.1 Insert Product 13 4.2.2 Company 16 4.2.3 Dealer 18 4.2.4 Customer 19 4.2.5 Update 19 4.2.6 Comparison 22 4.2.7 All Products 23 4.2.8 Print 24 �55-� 5 �5#�(/: 9�h��#��:�9 26
�
���a�7ก ก 7�c-ก��"��"�.��/�:ก�� 27 ���a�7ก � jo +5-�8�h8��/�:ก�� 30 ��� ��(ก�� 31
b
����:���;<
�*/5-� 3.1 ER Diagram 7�*/5-� 3.2 :#��ก�9�7�ก�� Transaction 8 �*/5-� 3.3 :#��"����g���h��* ���a*h6�.� (Customer) ����/�:ก�� SQL Administrator 8 �*/5-� 3.4 :#���h��* Database 8�#�7����a*h��� (Dealer) ����/�:ก�� SQL Administrator 9 �*/5-� 3.5 :#���h��* Database 8�#�7�������3�5 (Company) ����/�:ก�� SQL Administrator 9 �*/5-� 3.6 :#���h��* Database 8�#�7�����k��"+ (Cars) ����/�:ก�� SQL Administrator 9 �*/5-� 3.7 :#���h��* Database 8�#�7�����-�h�����9j � (Carparts Series) 10 �*/5-� 3.8 :#���h��* Database 8�#�7�����h��* �9j � (Carparts main) 10 �*/5-� 3.9 :#���h��* Database 8�#�7����/�9��5����9j � (Carparts category) 10 �*/5-� 3.10 :#���h��* Database 8�#�7�����-�h��9j � (Carparts brand) 11 �*/5-� 4.1 �h�"��� ���* �ก 12 �*/5-� 4.2 �h�"���:#�� Insert Product 13 �*/5-� 4.3 �h�"��� Category 14 �*/5-� 4.4 �h�"���#f�����)����(������9j � ( Carparts Series ) 15 �*/5-� 4.5 �h�"���#f�����)����-�h�����9j � ( Carparts Brand ) 15 �*/5-� 4.6 �h�"���#f�����)�����������k5-�8�hก���9j � ( Car Brand ) 16 �*/5-� 4.8 �h�"���#f�����)������ 9��-�����)��ก������ ( Dealer ) 18 �*/5-� 4.9 �h�"���#f�����)������ 9��-�����a*h6�.� ( Customer ) 20 �*/5-� 4.10 �h�"���:�ก#f����ก��:กhj��h��* ( Update ) 20 �*/5-� 4.11 :#���h�"���/���/�(�bf��7�#���h� 21 �*/5-� 4.12 :#���h�"���/���/�(�����#���h� 21 �*/5-� 4.13 :#���h�"����)����/�-���5-������h���h7�"�7��ก3� T 22 �*/5-� 4.14 :#���h�"��� Search Product �)����h��#���h� 23 �*/5-� 4.15 :#���h�"��� Delete Product �)��� �#���h� 24 �*/5-� 4.16 :#���h�"���)��)+ (Print) 25 �*/5-� ก.1 ��.�"��ก��"��"�.��/:ก�� Microsoft Visual Studio .NET 27 �*/5-� �. 1 :#��jo +5-�k*ก�h��k2� 30 �*/5-� �. 2 :#��jo +��h������� 30 �*/5-� �. 3 :#��jo +��h�ก����ก:�� (design) 30
m
����:=�4 "����5-� 1.1 �9�9�7 �:a�ก���f�������� 2
1
�//01 1 �/�
1.1 �6�����:���/01�� 4���4ก�
8�/pbb(����-ก��8�h�k��"+ ���)��9 "���i��ก�2.� :�h7��b9j�h ���a ก�95�b�ก�����.f����5-�#*��2.�กn"�� :"�������b�ก:a�ก��)�x���1�3gก�b /�9ก���h7��������8�ก��8�h�k��"+ ����� 5f�8h���3�5a*ha �"�-ก���f���h��k��"+�(��8�� 8��-�h�"���i ��ก�����h���8�/�9�51 ��กb�ก�-./�9��ก�#�7�8l��-ก��8�h�k��"+�/0��9�9�7 �������j���-ก��5f� �� 5f�8hbf��7��k��"+8�/�9�51�-/���� #*��2.� 8�#�7����ก��6����f��(� ������k��"+�-�9�9�7 �8�ก��8�h�����ก�2.� กn�����-ก��#2ก�� �f��(� �#-���m9��.�ก���*: ��ก3��k��"+�)���8h�k�-/�9#�5c���)�5���������#*��2.� b2��/0�#���5-�a*h������"h��ก���9j ��k��"+b2��/0�#���bf��/0�#f����ก��6����f��(����/���:"���)����7��)2�)�8b���a*h������ :"�8�/pbb(����k��"+"���i�-��ก�2.�j��7��b9�/0��-�h��(��"���i b2�5f�8h�9j �����k��"+�-��ก��� ������ ก��b9��h��* b2���b5f�8h f���ก���j��#9�7ก m9��.�b2��7��-ก��b��ก��ก��/pl�"���-. database b2��/0�#�7�5-�#f���l8�ก��b��ก���h��* �9j ��k��"+ ก����ก:�� database �/0�#�7�#f���l#�7��2�����ก�� �7��7��h��* ������-/�9#�5c���) ก��5-��-�h��* ����8l���b5f�8hก���h�� : 9:กhj� f���ก m9��.�ก����ก:�� database 5-��-b2��/0�#�7�#f���l��ก 62��kh�ก���กn��h��* 8� database ��ก:����j���- /�9ก��ก��ก����� user interface 5-��- กnb95f�8h�/�:ก��j���-/�9#�5c���): 9j��j�h����7������ ก��b9�f� database ��8�hก���9j ��k��"+5-��- ���7��*� �����3�5 ���(�� ก���h���(/ก� +5-�"��"���7��"h��ก����� *ก�h���b5f�j�h f���ก ก��#�h���/�:ก��5-�:#�� user interface : 9�- database 5-��-b2�#����k��7��)����7����n7 �7��#9�7ก8�ก���h�� : 9ก��"�7b#��bf��7��9j �j�h�-�2.� 62��b9��7�8hc(�ก�b�-/�9#�5c���)��ก�2.�
1.2 6�=AB����4�. - #����k��ก:���)����กn��h��* ����8l�j�h - �-ก��b���7��*�5-��-�)��� ��7��"h��ก��8�ก��b���กn� - #����k��ก:���/�:ก������f��2�k2��7��"h��ก�����a*h8�h�/0� �ก 1.3 � ���=� 4���4ก� - )�x���9�� database network 5-�#����k8�hj�h8��9�����������b��� - )�x���9��: 95f�ก��5�#���9����� server ��� MySQL ���9��/{���"�ก��7����7#+ - 8�h��3� Visual C++ .net 8�ก��)�x��
2
1.4 �5ก�,��74 1. 12ก3� visual C++ ก��8�h��� visual studio .net : 9�7��7� Tool "���i 5-�b9�f���8�h���
2. ��ก:������#�h��g���h��* ���.��"h� : 97��a���/�:ก�����.��"h� 3. /���:"��g���h��* : 9a���/�:ก��8h���9#�
4. ��-���/�:ก��: 9g���h��* ���.��"h� 5. ��-��g���h��* : 9�/�:ก�� 6. 12ก3�ก��8�h���8��9����������� 7. ��-���/�:ก���)���8h#����k8�h���8��9�����������j�h 8. 5� ��8�h: 9/���/�(��/�:ก�� 9. b��5f��*����ก��8�h�/�:ก��: 9��-��������m���#��*� +
"����5-� 1.1 "����:#���9�9�7 �:a�ก���f��������
��.�"��5-� ��.�. ก.�. #.�. ก.�. ".�. ).�. c.�. �.�.
1.
2.
3.
4.
5.
6.
7.
8.
9.
1.5 5�/01�,6�-��,����
�/�:ก��b��ก��g���h��* : 9�*: �9��8��h���9j � ���9�����������
3
�//01 2 �6�������F 4=�
2.1 �6�������F 4=��ก01�6ก��;3 C++ H7,�� ��� 8�ก����-���/�:ก�����)�7�"��+ �h7���3� C/C++ b9"h��กf��������h��* 8hก��"�7:/�ก��� 5-�b9�f�"�7:/���.���8�h �h��* "�������ก��b9�-�( #���"� : 9ก��8�h���"���ก�� 8�5-��-.b9j�hก ��7k2���� 9��-����������h��* "���i ��3�6-�-�����h��* ����-. - �h��* ����51���� 9��-��#���5�� (double precision floating point) - �h��* ����bf��7��"n� (integer type) �h��* �����-.j�h:ก�"�7� �62��j���-51���� ���� 35, 20 �/0�"h� - �h��* ����51���� (floating point type) �h��* �����-.j�h:ก�"�7� �5-��-����/0�51���� ���� 10.5, 20.8 - �h��* ����"�7��ก3� (character type) �h��* �����-.j�h:ก�"�7��ก3� A-Z, � � 0-9 : 9#�l �ก3 +"���i "�7:/�5-�กf����/0�����"�7��ก3�b9���"�7��ก3�j�h�)-�� 1 "�7�5����.� : 9#����k����h��* bf��7��"n�62���-����97��� ~128 k2� 127 62��#����k�f�j/�f��7 5��� �"1�#"�+j�h �h��* �����-.b98�h 8 ��"8�ก���กn�"�7��ก3� 1 "�7 ก��กf����h��* �����-.8hก��"�7:/�"h���9�(�h7� char - �h��* ����j���-��� (valueless type) "�7�9�(�/0�����5-�k*ก"�.��2.��)���8�h"�7:/�, �����5-�, op�ก+���, � �# : 9����i /�9ก���h7�"�7��ก3�: 9"�7� � :"�"h���2.�"h��h7�"�7��ก3� /ก"�b9#����k"�.�����j�h��7k2� 32 "�7��ก3�:"�����9��/{���"�ก��#����k"�.�����j�h��7ก7����.� #f���� C : 9 C++ ก����-������"�7�9�(�h7�"�78l�: 9"�7� nกb98h�7������/0��� 9"�7�9�(ก�� k2�:�h7��b9������-�7ก�� ( Case Sensitive ) Pointer 8� C++ �-"�7:/��-ก�����2����-�ก7�� Pointer "�7:/� Pointer b9�กn� Address ���"�7:/� :5�5-�b9�กn��h��* "���i �����"�7:/���������i b�ก�( #���"���� "�7:/����� Pointer b2�����*�����ก�� "�7�-. ��� )���+�"��+ 62���-.j/5-� Address ���"�7:/�
2.2 �6�������F 4=��ก01�6ก�� SQL Database
��3� SQL (#����k������ก�#-��j�h 2 :�� ��� ���#��7:� � (SQL) ��� �6-��7 � (Sequel)) �����b�ก Structured Query Language �����3�8�ก��#��k���h��* �/0���3�5���h��g���h��* 5-�#����k#�h��: 9/{���"�ก��ก��g���h��* :��#��)��c+ (relational database) ����m)�9 : 9�/0���3�5-��- �ก3 9� h��ก����3����ก�3 ��3� SQLk*ก)�x���2.�b�ก:�7������ relational calculus : 9 relationalalgebra �/0� �ก ��3� SQL �����)�x�����.�:�ก��� Almaden research center ������3�5
4
IBM ����-���������:�ก7�� �6-��7 � (Sequel) "����j�h�/ -��������/0����#��7:� � (SQL) ��b�ก��.���3� SQL j�hk*ก�f���)�x�����a*ha �"6�o:7�+�h���9��b��ก��g���h��* ����#��)��c+b��/0�5-�����ก�������:)�� ��8�/pbb(������a*ha �":"� 9���กn)�����5-�b9)�x���9��b��ก��g���h��* ���"�8h�- �ก3 9�����m)�9�2.��� 5f�8h�*/:��ก��8�h�f�#��� SQL �-�*/:��5-�:"ก"���ก��j/�h�� ���� ORACLE, ACCESS, SQL Base ��� Sybase Ingress ��� SQL Server ��� Microsoft �/0�"h� �����.�8�/4 �.1. 1986 5���h�� American National Standards Institute (ANSI) b2�j�hกf�����"�g����� SQL �2.� �����j�กn�- �/�:ก��g���h��* 5-����8�5h��" �� j�h���� SQL ��กj/b��ก���h�กf������ ANSI ����)����( #���"�����i 5-����7���/0�/�9����+��h�j/�-ก:"���� �ก5��7j/: h7กn���/{���"�"����"�g����� ANSI 8�ก���c�����f�#���"���i�����3� SQL 2.2.1 ����;/� 4����14� 4;3 SQL
��3� SQL �/0���3�5-�8�h���j�h"�.�:"��9�������������)�7�"��+#�7��(�� )-6-j/b�k2��9�������o�� /�9��5����f�#���8���3� SQL (The subdivision of sql) :�����ก�/0� 3 /�9��5 ���
1. ��3�#f����ก��������h��* (Data Definition Language : DDL) /�9ก���h7��f�#���5-�8�h8�ก��กf�������#�h���h��* 7���-�� ���+�9j� :"� 9�� ���+�กn��h��* /�9��58� �7�k2�ก���)����� ���+ ก��กf�������- ก��กf���7�7���"�����#�������a*h8�h �/0�"h�
2. ��3�#f����ก��b��ก���h��* (Data Manipulation Language : DML) /�9ก���h7��f�#���5-�8�h8�ก����-�ก8�h�h��* ก���/ -���:/ ��h��* ก���)������ ��h��* �/0�"h�
3. ��3��7��(� (Data Control Language : DCL) : /�9ก���h7��f�#���5-�8�h8�ก���7��(� ก���ก����79)�h��ก�� ���ก��/e��ก��ก���ก���"(ก�� +5-�a*h8�h ������-�ก8�h�h��* )�h��ก�� : 9�f�#���5-��ก-��7�h��ก��ก���7��(��7��/ ���������h��* �h7�ก��กf���#�5c����a*h8�h5-�:"ก"���ก�� �/0�"h� 2.2.2 H7,� 4�� ���/01NH�N;3 SQL
8���3� SQL ก�����b(�h��* �8��� ���+"��� i ���"����b9"h��กf�����������h��* (data type) 8h:"� 9�� ���+ ��������h��* �-.b9:#������������5-���*�8��� ���+ ���5(ก���8��� ���+5-�กf���b9"h���/0�������-�7ก�� ���� 8�"���� *ก�h��� ���+5-��/0�������� *ก�h� b9"h���/0�"�7���#�� 8�� 95-��� ���+bf��7�����5-� *ก�h�6�.�#���h��/0�"�7� �
��������h��* ���:"� 9�� ���+b9�2.�ก�� �ก3 9����h��* :"� 9�� ���+ 62��:���j�h����-.�����h��* )�.�g��8���3� SQL ����-. "�7���#�� (character) 8���3� SQL b98�h
- "�7���#��:���7����7��5-� (fixed-length character) b98�h char (n) ��� character(n) :5�/�9��5����h��* 5-��/0�"�7���#��8�i5-��-�7����7����h��* ��5-�����-�7����7 n "�7 ���#��/�9��5�-.b9�-ก��b�����.�5-�"���7����75-���5-�"��5-�กf���j7h ��������h��* /�9��5�-.b9�กn��7����7���
5
�h��* j�h��ก5-�#(�j�h 255 "�7��ก3� - "�7���#��:���7����7j����5-� (variable-length character) b98�h varchar (n) :5�
/�9��5����h��* 5-��/0�"�7���#��8�i5-��-�7����7����h��* j����5-� ����-�7����7 n "�7���#��/�9��5�-.b9�-ก��b�����.�5-�"���7����7����h��* ��������h��* /�9��5�-.b9�กn��7����7����h��* j�h��ก5-�#(�j�h 4000 "�7��ก3� bf��7�� � (numeric)
- bf��7�� �5-��-b(�51���� (decimal) 8���3� SQL b98�h dec(m,n) ��� decimal(m,n)
�/0�/�9��5�h��* 5-��/0�bf��7�� �5-��-b(�51������� m ���bf��7�"�7� �5�.��� (�7�b(�51����) : 9 n ���bf��7�"�7� � ��b(�51����
- bf��7�� �5-�j���-b(�51����8���3� SQL b98�h int ��� integer �/0�� �bf��7��"n� �7ก��� �����8l� �/0�"�7� � 10 �ก 5-��-���"�.�:"� ~2,147,483,648 k2� +2,147,483,647 : 98���3� SQL b98�h smallint �/0�/�9��5�h��* 5-��/0�� �bf��7��"n��7ก��� ������ nก�/0�"�7� � 5 �ก 5-��-���"�.�:"� ~ 32,768 k2� + 32,767 "�7� �bf��7��"n�/�9��5�-.b9�-ก��b�����.�5-��h��ก7��:�� integer
- � �bf��7�b��� 8���3� SQL ��b8�h number (n) :5�bf��7�� �5-�j���-b(�51����: 9bf��7�� �5-��-b(�51���� �h��* 8� �ก3 9����i
- 7��5-�: 9�7 � (Date/Time) �/0�����7��5-�����7 �8���3� SQL b98�h date �/0��h��* 7��5-� 62��b9�- ���*/:��8h� ��ก8�h ���� yyyy-mm-dd (1999-10-31) dd.mm.yyyy(31. 10.1999) ��� dd/mm/yyyy (31/10/1999)
6
�//01 3 ก� ก������ ������<�X����ก��
3.1 ก� ก������ ��� 8�#�7��-.j�h5f�ก����ก:�� Database �h��* ��� �9j ��k��"+"��#��)�7������n����a*h )�x���*/:�� Database �-.�/0�#�7�5-�bf��/0�#f�����h���h�a*h8h���ก���(/ก� +�k��"+62��b9�-"�����h��* �ก�5��5-�bf��/0���� �9j ��k��"+, *ก�h�5-�8�h���ก��, )��ก���8��h��, ���3�55-�a �"�9j ��k��"+ : 9�-�h��k��"+5-�5���h���-�9j �bf����� ����-:a���) ER ����*/5-� 3.1
3.2 ก�<�X����ก��
ก��)�x���/�:ก��j�h5f�op�ก+���"���i �)���������ก��8�h���"���i #����k�c����j�h����-. 1. Insert Product #f�����)���#���h�8�#"n�ก 2. Company #f����ก��ก��� 9��-�����3�5a*ha �" 3. Dealer #f�����)���: 9 ��������)��ก������ 4. Customer #f����b���กn��h��* ��� *ก�h� 5. Update #f����/���/�(���� 9��-��"���i���#���h� 6. Comparison �5-�������97����9j �:5h: 9�9j �/ �� 7. All Product #f�����h����� 9��-��"���i ���#���h� 8. Print #f����)��)+���ก���9j �: 9���� 9. Exit #f������กb�ก�/�:ก�� ก��5f�ก��"��"��#���#��a����9����������� j�h5f�ก��������"�����8�h MySQL Server �/0�"�7
b��ก���6�o�7��+ a���5�� )��+5 3306 ����-��������6�o�7��+5-��- IP �/0� 192.168.8.9 ก��"��"��ก�� MySQL Database 8�hก��"��"��a���5�� ODBC : 9�-ก��5f� transaction �)���ก��ก��a��) ��8�ก��#���h��* : 9:กh/pl� Deadlock
ก��5f� Transaction ���:"� 9 Process �)���:กhj�ก��"����� (Deadlock Resolution) 8�ก� -5-��ก��ก��:���ก����h�k2��h��* b�5f�8h�9��j��#����k5f����"��j/j�h �9��b��ก��g���h��* b9"h��5f�ก��:5�ก:6�: 9�ก� �กก��5f�������������ก���)���8h�9������7�#����k5f����"��j�h : 9�)���ก��8�h���8���������� 8h#����k8�h���j�h8��7 ���-�7ก�� �-��.�"�� ����*/5-� 3.2 62�� Process 5-�5f� Transaction ��� ก���)���#���h� ��� 9��-�����3�5a*ha �" a*h��� : 9 �h��* *ก�h�
7
�*/5-� 3.1 ER Diagram #f����g���h��*
M
N
N
N
1
1
Company
CO
fax
CA
bra
nd
CA
_id
CA
serr
ies
Buy
1
Sale
Dn
ame
Dfn
ame
Dln
ame
Dte
l D
_id
Dsa
l
Dse
x
Dag
e
Dp
assw
Du
ser
DA
dd
r
Dealer
Make
CO
nam
e
CO
add
r
CO
pro
du
ct
CO
tel
Company
CO
fax
Car
Drive
Cte
l C
nam
e Customer
Cfn
ame
Cln
ame
Cad
dr
Cbu
y
C_id
Cse
x
CA
_id
Carparts
Pq
ual
ity
Pb
rand
P_
id
Pn
ame P
pic
Pfo
rcar
Pco
st
CA
serr
ies
N
7
8
�*/5-� 3.2 :#��ก�9�7�ก�� Transaction
g���h��* 8��/�:ก���-ก��:#�����"�7:/� ���� : 9�( #���"�"���i ���"�7:/� ���8�h MySQL
Administrator 8�ก��:#��: 9b��ก��g���h��* 62��j�h:#��g���h��* :"� 9"��������*/5-� 3.3 ~ 3.8 ��)ก��8�h���ก����ก:��g���h��* ����/�:ก�� SQL Administrator �- �ก3 9����*/"��j/�-.
�*/5-� 3.3 :#��"����g���h��* ���a*h6�.� (Customer) ����/�:ก�� SQL Administrator
Rollback �-�h�a��) ��
�����ก��5f� Transaction
5f�ก�� Queries
�����5f����
Commit
MyConnection.Open( )
MyTransaction = MyConnect.BeginTransaction( )
MyCommand1.Transaction = MyTransaction
MyCommand2.Transaction = MyTransaction
Try
MyCommand1.ExecuteNonQuery( )
MyCommand1.ExecuteNonQuery( )
MyTransaction.Commit( )
Catch
MyTransaction.Rollback( )
Finally
MyConnection.Close( )
End Try
9
�*/5-� 3.4 :#���h��* Database 8�#�7����a*h��� (Dealer) ����/�:ก�� SQL Administrator
�*/5-� 3.5 :#���h��* Database 8�#�7�������3�5 (Company) ����/�:ก�� SQL Administrator
�*/5-� 3.6 :#���h��* Database 8�#�7�����k��"+ (Cars) ����/�:ก�� SQL Administrator
10
�*/5-� 3.7 :#���h��* Database 8�#�7�����-�h�����9j � (Carparts Series)
�*/5-� 3.8 :#���h��* Database 8�#�7�����h��* �9j � (Carparts main)
�*/5-� 3.9 :#���h��* Database 8�#�7����/�9��5����9j � (Carparts category)
11
�*/5-� 3.10 :#���h��* Database 8�#�7�����-�h��9j � (Carparts brand)
12
�//01 4 ก�NH�4����ก��
8�ก����ก:���/�:ก��/�9�(ก"+�9��g���h��* �9j � ���8�h Visual Studio .NET 2003 5-���ก:�������3� C++ �*/:�� windows form �-ก��8�h���8��*/:���f�#���"���i ��� ก���)��� ก�� � ก��/���/�(��h��* ก���h���h��* : 9�-ก��8�h Crystal Report �/0� plug in �)���5f�ก��)��)+ 4.1 ������ก
�h�"���b9�- �ก3 9����*/5-� 4.1
�*/5-� 4.1 �h�"��� ���* �ก �h�"������* �กb9#����k��h�j/8�h���j�h 9 ���*���� ��� 1. Insert Product #f�����)���#���h�8�#"n�ก 2. Company #f����ก��ก��� 9��-�����3�5 3. Dealer #f�����)���: 9 ��������)��ก������ 4. Customer #f����b���กn��h��* ��� *ก�h�
13
5. Update #f����/���/�(���� 9��-��"���i���#���h� 6. Comparision �5-�������97����9j �:5h: 9�9j �/ �� 7. All Product #f�����h����� 9��-��"���i ���#���h� 8. Print #f����)��)+���ก���9j �: 9���� 9. Exit #f������กb�ก�/�:ก��
4.2 ����� � 4.2.1 Insert Product
#f�����)���#���h�8�#"n�ก b9�-�h�"������ 9��-����� �*/5-� 4.2
�*/5-� 4.2 �h�"���:#�� Insert Product
Insert Product b9�- �ก3 9ก���)���#���h����8hก��ก��� 9��-��"���i ��� - Carparts ID �- �ก3 9�)���8h8#��h��* 5-��/0� Varchar ���#����k8#�j�h5�.�"�7� �: 9"�7��ก3� ���8h8#���� ID 8��*/:�� /�9��5/��#/�ก�� ���� ����k��"+ T001A ����*��� 9��-������ b�ก/(��5-��-#�l �ก3 + �h�� �����o� �+ �)�����h�op�ก+����h��
14
- Carparts Category �- �ก3 9�)���8h8#��h��* 5-��/0� Varchar #f����8#�/�9��5����9j � ���� ����k��"+ ��� Tire 62���ก�-/�9��58��b2��)���8�#�7� �h�� �����o� �+62���- �h�"��� �ก3 9����*/5-� 4.3 - Carpart Series �- �ก3 9�)���8h8#��h��* 5-��/0� Varchar #f����8#��(������9j � ���� ��� �k��"+ �(�� fly hock 62���ก�-�(��8��i b2��)���8�#�7� �h�� �����o� �+62���-�h� "��� �ก3 9����*/5-� 4.4 - Carparts Brand �- �ก3 9�)���8h8#��h��* 5-��/0� Varchar #f����8#��-�h�����9j � ���� ��� �k��"+ �-�h� Goodyear 62���ก�-/�9��58��b2��)���8�#�7� �h�� �����o� �+62�� �-�h�"��� �ก3 9����*/5-� 4.5
- Car brand �- �ก3 9�)���8h8#��h��* 5-��/0� Varchar #f����8#�/�9��5����k��"+5-��9j � ������.�#����k8#�j�h ���� pickup sedan van ���8#�j�hก��5(ก����8h8#� ALL 62���ก�- /�9��58��b2��)���8�#�7� �h�� �����o� �+ 62���-�h�"��� �ก3 9����*/5-� 4.6
- Date �- �ก3 9�h��* �/0� 7��5-� ���8h8#�8��*/:����� /4/�����/7�� ���� 2006/02/21 - Grade �- �ก3 9�h��* �/0� Varchar #f����8#��( ��)����9j � ���� ���:5h 8#� A ��� �5-��������- B ����5-��5��7j/ C �/0�"h� ( �/0� not null "h��8#���� ) - Amount �- �ก3 9�/0� Integers #f����8#�bf��7�����9j �������.�5-������h���8��h�� - Price �- �ก3 9�/0� Integers #f����8#���������9j �������.�"���2����7� - /(�� OK #f����ก��)����)����h��* #���k8�h/(�� Enter 8�:/e�)��)+j�h �ก8#�j�����b9�2.��"��� - /(�� Main #f����ก ��j/����h� �ก �*/5-� 4.3 �h�"��� Category
15
�*/5-� 4.4 �h�"���#f�����)����(������9j � ( Carparts Series )
�*/5-� 4.5 �h�"���#f�����)����-�h�����9j � ( Carparts Brand )
16
�*/5-� 4.6 �h�"���#f�����)�����������k5-�8�hก���9j � ( Car Brand ) 4.2.2 Company
#f�����)����h��* ������3�5a*ha �" b9�-�h�"������ 9��-����� �*/5-� 4.7 Company b9�- �ก3 9ก���)������ 9��-��������3�5a*ha �"�9j � ���8hก��ก��� 9��-��"���i ��� - Company ID #f����ก��ก��#������3�5a*ha �" - Company Name #f����ก��ก����������3�5a*ha �" - Company Address #f����ก��ก5-���*�������3�5a*ha �" - Telephone #f����ก��ก����+�5�1�)5+������3�5a*ha �" ���j��"h��8#��-� - Fax #f����ก��ก����+�5�#��������3�5a*ha �" ���j��"h��8#��-� - E-mail #f����ก��ก5-���*��-�� ������3�5a*ha �"
- Product #f����ก��ก�����9j �5-�a*ha �"bf����� �กa �" ������� 8h8#����������� comma ( , ) ��.�
- /(�� Submit #f����ก��)����)����h��* �8�g���h��* #���k8�h/(�� Enter 8�:/e�)��)+j�h �ก 8#�j�����b9�2.��"��� - /(�� Del Company #f���� ����3�5 ���8h8#� ID 5-�"h��ก��b9 �8� Company ID �)-������ ��-�7: h7ก�/(�� Del Company - /(�� Main #f����ก ��j/����h� �ก - /(�� Refresh �)�����-�ก�h��* ��#(�b�กg���h��* ����7+8�"����
17
�*/5-� 4.7 �h�"���#f�����)������ 9��-��������3�5a*ha �" ( Company )
4.2.3 Dealer #f�����)����h��* ���)��ก������ b9�-�h�"������ 9��-����� �*/5-� 4.8
Dealer b9�- �ก3 9ก���)������ 9��-�����)��ก������ ���8hก��ก��� 9��-��"���i ��� - Dealer ID #f����ก��ก��#���)��ก������ - Name #f����ก��ก�������)��ก������ - SurnName #f����ก��ก���#ก( ���)��ก������
- Age #f����ก��ก���(���)��ก������ - Sex #f����ก��ก�)1���)��ก������ - Salary #f����ก��ก������������)��ก������ - Address #f����ก��ก5-���*����)��ก������ - Province #f����ก��กb��7��5-�)��ก�������ก�� - Telephone #f����ก��ก����+�5�1�)5+���)��ก������ ���j��"h��8#��-�
18
- Fax #f����ก��ก����+�5�#�����)��ก������ ���j��"h��8#��-� - E-mail #f����ก��ก5-���*��-�� ���)��ก������
- /(�� Submit #f����ก��)����)����h��* �8�g���h��* #���k8�h/(�� Enter 8�:/e�)��)+j�h �ก 8#�j�����b9�2.��"��� - /(�� Del Dealer #f���� ����3�5 ���8h8#� ID 5-�"h��ก��b9 �8� Dealer ID �)-������ ��-�7: h7ก�/(�� Del Dealer - /(�� Main #f����ก ��j/����h� �ก - /(�� Refresh �)�����-�ก�h��* ��#(�b�กg���h��* ����7+8�"����
�*/5-� 4.8 �h�"���#f�����)������ 9��-�����)��ก������ ( Dealer )
19
4.2.4 Customer #f�����)����h��* ���a*h6�.� b9�-�h�"������ 9��-����� �*/5-� 4.9
Customer b9�- �ก3 9ก���)������ 9��-�����a*h6�.� ���8hก��ก��� 9��-��"���i ��� - Customer ID #f����ก��ก��#���a*h6�.� - Name #f����ก��ก�������a*h6�.� - Sure Name #f����ก��ก���#ก( ���a*h6�.�
- Age #f����ก��ก���(���a*h6�.� - Sex #f����ก��ก�)1���a*h6�.� - Salary #f����ก��ก������������a*h6�.� - Address #f����ก��ก5-���*����a*h6�.� - Province #f����ก��กb��7��5-�a*h6�.��ก�� - Telephone #f����ก��ก����+�5�1�)5+���a*h6�.� ���j��"h��8#��-� - Fax #f����ก��ก����+�5�#�����a*h6�.� ���j��"h��8#��-� - E-mail #f����ก��ก5-���*��-�� ���a*h6�.�
- /(�� Submit #f����ก��)����)����h��* �8�g���h��* #���k8�h/(�� Enter 8�:/e�)��)+j�h �ก 8#�j�����b9�2.��"��� - /(�� Del Customer #f���� ����3�5 ���8h8#� ID 5-�"h��ก��b9 �8� Customer ID �)-������ ��-�7: h7ก�/(�� Del Customer - /(�� Main #f����ก ��j/����h� �ก - /(�� Refresh �)�����-�ก�h��* ��#(�b�กg���h��* ����7+8�"����
4.2.5 Update #f����:กhj��h��* bf��7�: 9�������#���h� b9�-�h�"���:�ก62���- 2 /(��8h� ��ก ��� �*/5-� 4.10
- /(�� Amount Update 8�h#f����ก��:กhj��h��* bf��7�����9j � �����ก�b9�-�h�"���#f����/���/�(�bf��7� ���ก�
5-�/(�� Refresh �)����*�h��* ��#(�5-��- �����"h��ก��/���/�(��h��* 8hก��ก ID : 98#�bf��7�5-�b9/���/�(� ����*/5-� 4.11 - /(�� Price Update
8�h#f����ก��:กhj���������9j � �����ก�b9�-�h�"���#f����/���/�(����� ���ก�5-�/(�� Refresh �)����*�h��* ��#(�5-��- �����"h��ก��/���/�(��h��* 8hก��ก ID : 98#�����5-�b9/���/�(� ��� �*/5-� 4.12
20
�*/5-� 4.9 �h�"���#f�����)������ 9��-�����a*h6�.� ( Customer )
�*/5-� 4.10 �h�"���:�ก#f����ก��:กhj��h��* ( Update )
21
�*/5-� 4.11 :#���h�"���/���/�(�bf��7�#���h�
�*/5-� 4.12 :#���h�"���/���/�(�����#���h�
22
4.2.6 Comparison #f�����/�-���5-���������#���h�62��#����k�h��#���h�5-�"h��ก���)����f����/�-���5-�� �-
�ก3 9����*/5-� 4.13 - ���� Search #f����8#��f������ก3��)����h��#���h�5-�"h��ก�� ���j��8#� �)����h��5(ก���� - /(�� Submit �����ก�/(��b95f�ก���h���)����f���:#���/�-���5-�� ���� b�ก�*/5-� 4.13 b9�n�
7���h���h7�"�7��ก3� T b2��h��5-�"�7��ก3� T )� Tire �������k #����k�/�-���5-������ ����k�-�h� YOKOHAMA ���:5h�ก�� A ก������5-���ก�� B j�h 62.�b9:#����� 9��-����� ID ����9j ���.� ��������9j � �-�h��9j � �( ��)����9j � : 9��������9j �
- /(�� Main �)���ก ��#*����* �ก
�*/5-� 4.13 :#���h�"����)����/�-���5-������h���h7�"�7��ก3� T
23
4.2.7 All Product #f�����h��#���h�: 9��� 9��-��"���i 62��#����k�h�����ก��กf���/�9��5ก���h�� ���
�h��b�ก5(ก����� �h��b�ก/�9��5 ���� �(�� �-�h� : 9������� �k��"+5-�8�hj�h �-ก5�.�#����k�h���h7� �f� ��� "�7��ก3�j�h ���:#��8��*/5-� 4.14
- ���� Search #f����8#��f������ก3��)����h��#���h�5-�"h��ก�� ���j��8#� �)����h��5(ก����
- ���� By ���ก���h�����/�9��5 ���� ��� ���� �(�� �-�h� �����������k - /(�� Search �)���5f�ก���h�� - /(�� Refresh �)����*�h��* ��#(� - /(�� Del Product �����ก�b9�-�h�"�������*/5-� 4.15 �)��� �#���h� ���8#� ID 8�o� �+�)���5f�ก��
�#���h�
�*/5-� 4.14 :#���h�"��� Search Product �)����h��#���h�
24
�*/5-� 4.15 :#���h�"��� Delete Product �)��� �#���h�
4.2.8 Print #f����)��)+�h��* 8�g���h��* ��ก��:#��a ���8�h Crystal Report ����*/5-� 4.16 - ���� � 1 �)���)��)+��ก5���������)��)+ - ���� � 2 �)���/���/�(��h��* 8h8��5-�#(� - ���� � 3 �)���#����ก8��*/:��"���i ���� .pdf .doc .xls .rtf - ���� � 4 �)���� ��ก�*b�กก (���h�5-�"h��ก��b9)��)+ ������-�h�5-�"h��ก��)��)+��กi
- ���� � 5 �)������� ��� �����8�ก��"�7b#��ก���)��)+ - ���� � 6 �)����h���f� ���"�7��ก3����8���ก#��)��)+
25
�*/5-� 4.16 :#���h�"���)��)+ (Print)
26
�//01 5 �/��B������ �� ��
ก����ก:�� Database �/0�#�7�#f���l#�7��2�����ก�� �7��7��h��* ������-/�9#�5c���) ก��5-��-�h��* ����8l���b5f�8hก���h�� : 9:กhj� f���ก m9��.�ก����ก:�� Database 5-��-b2��/0�#�7�#f���l��ก 62��kh�ก���กn��h��* 8� Database ��ก:����j���- /�9ก��ก��ก����� user interface 5-��- กnb95f�8h�/�:ก��j���-/�9#�5c���): 9j��j�h����7������ ก��b9�f� Database ��8�hก���9j ��k��"+5-��- ���7��*� �����3�5 ���(�� ก���h���(/ก� +5-�"��"���7��"h��ก����� *ก�h���b5f�j�h f���ก ก��#�h���/�:ก��5-�:#�� User interface : 9�- Database 5-��-#����k��7��)����7���7���n7 �7��#9�7ก8�ก���h�� : 9ก��"�7b#��bf��7��9j �j�h�-�2.� b9��7�8hc(�ก�b�-/�9#�5c���)��ก�2.� #f����"�7�/�:ก��#����k8�h���j�h�-:"���bj��"��ก���7��"h��ก�����a*h8�h���b��� ������b�กj��j�h�-ก��#��k���7��"h��ก�����a*h8�h���b��� "�7�/�:ก��b��5f��2.��)���12ก3�: 9)�x��ก��5f����8��9����������� ก��)�x��"��j/b2�:�9�f�8h#��k���7��"h��ก��b�กa*h8�h���b��� 62��b9#����k5f�8h)�x��j�h"��ก���7��"h��ก�����a*h8�h���b���
27
;�56ก ก 67`0ก�=7,=�F4 Microsoft Visual Studio .NET
#f������.�"��ก��"��"�.� Microsoft Visual Studio .NET �-����-. 1.8#�:a���/�:ก�� Visual Studio.NETb9j�h����*/5-� ก.1(ก) 2.� �ก� ��ก Windows Component Update ����*/5-� ก.1(�) 3. � ��ก I accept the agreement b�ก��.�� ��ก Continue ����*/5-� ก.1(�) b�ก��.�� ��ก Continue �)���j/��.�"��"��j/ 4. � �ก� ��ก Continue ����*/5-� ก.1(�) 5. 8#���#a������������� : 9b�ก��.�� ��ก Install Now! ����*/5-� ก.1(b) �/�:ก��b9�f�����ก��"��"�.��������*/5-� ก.1(m) 6. � �ก� ��ก Done ����*/5-� ก.1(�) 7. � �ก� ��ก Visual Studio.NET ����*/5-� ก.1(6) 8. 8#�:a���/�:ก�� "��5-��9�( ����*/5-� ก.1(�) 9. � �ก� ��ก I accept the agreement b�ก��.�8#� CD Key : h7ก� Continue ����*/5-� ก.1(�) 10. � �ก� ��ก Install Now! ����*/5-� ก.1({) 11. �/�:ก��b95f�ก��"��"�.���������"����"� ����*/5-� ก.1(g) 12. �������k2���.�"���-.8h� ��ก Exit ��กj/j�h� � j��"h�� � Service Releases ����*/5-� ก.1(!)
(ก)
(�) �*/5-� ก.1 ��.�"��ก��"��"�.��/:ก�� Microsoft Visual Studio .NET
28
(�) (�)
(b) (m)
(�) (6)
(�) (�)
�*/5-� ก.1 ("��)
29
({) (g)
(!)
�*/5-� ก.1 ("��)
30
;�56ก � �f�.=�4g N����ก��
�*/5-� �. 1 :#��jo +5-�k*ก�h��k2�
�*/5-� �. 2 :#��jo +��h�������
�*/5-� �. 3 :#��jo +��h�ก����ก:�� (design)
31
���hBก��
�ก3�#��"+ )� ��ก��. C++ : 9 �กก����� OOP m��������"h�. 6-��n��*������ bf�ก��, ก�(��5)����� �(l�5c�� ก*h�ก-��"�ก( . 2542. �9��g���h��* (Database System). )��)+���.�5-�2.� 97�17ก���1�#"�+
��7�5�� �����:ก��,���:ก�� /�-�� �.�k7��. ��3� C++ �)���ก��8�h���. 6-��n��*������ bf�ก��, ก�(��5)����� #�ก���"+ 5��#7���. My SQL �9��g���h��* #f��������5��+��".6-��n��*������ bf�ก��, ก�(��5)����� http://ads2.exhedra.com �h��7h������7��5-� 8 c��7��� 2548 http://msdn.microsoft.com �h��7h������7��5-� 8 c��7��� 2548 http://sot.swu.ac.th �h��7h������7��5-� 20 )�1b�ก��� 2548 http://www.codepedia.com/1/startpage �h��7h������7��5-� 8 c��7��� 2548 http://www.codeproject.com �h��7h������7��5-� 3 c��7��� 2548 http://www.dms.moph.go.th/ict/Train_Docs/Train_DB/mysql/mysql-client.html �h��7h������7��5-� 8
c��7��� 2548 http://www.thai-programmer.com �h��7h������7��5-� 7 c��7��� 2548