References Assignment, Study Guides, Projects, Research of Information Technology

All subjects in the course of studying Information Technology

Typology: Study Guides, Projects, Research

2016/2017

Uploaded on 02/26/2023

khoi-huynh
khoi-huynh 🇻🇳

2 documents

1 / 62

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Higher Nationals in Computing
Unit 20: Advanced Programming
ASSIGNMENT 2
Assessor name: LE NGOC THANH
Learner’s name: Hunh Đăng Khôi
ID: GCS200300
Class: GCS0905b
Subject code: 1651
Assignment due: Assignment submitted:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e

Partial preview of the text

Download References Assignment and more Study Guides, Projects, Research Information Technology in PDF only on Docsity!

Higher Nationals in Computing

Unit 20 : Advanced Programming

ASSIGNMENT 2

Assessor name: LE NGOC THANH

Learner’s name: Huỳnh Đăng Khôi

ID: GCS

Class: GCS0905b

Subject code: 1651

Assignment due: Assignment submitted:

ASSIGNMENT 2 BRIEF

Qualification BTEC Level 5 HND Diploma in Computing
Unit number and
title
Unit 2 : Advanced Programming
Assignment title Application development with class diagram and design patterns
Academic Year 2018 - 2019
Unit Tutor LE^ NGOC THANH
Issue date 30 April 2019 Submission date 11 May 2019
Submission Format:
Format: The submission is in the form of an individual written report. This should be written in a concise,
formal business style using single spacing and font size 12. You are required to make use of
headings, paragraphs and subsections as appropriate, and all work must be supported with
research and referenced using the Harvard referencing system. Please also provide a
bibliography using the Harvard referencing system.
Submission Students are compulsory to submit the assignment in due date and in a way requested by the
Tutors. The form of submission will be a soft copy in PDF posted on corresponding course of
http://cms.greenwich.edu.vn/ together with zipped project files.
Note: The Assignment must be your own work, and not copied by or from another student or from
books etc. If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you
must reference your sources, using the Harvard style. Make sure that you know how to reference properly,
and that understand the guidelines on plagiarism. If you do not, you definitely get fail
Assignment Brief and Guidance:
Scenario : (continued from Assignment 1) Your team has shown the efficient of UML diagrams in OOAD
and introduction of some Design Patterns in usages. The next tasks are giving a demonstration of using
OOAD and DP in a small problem, as well as advanced discussion of range of design patterns.
Tasks:
Your team is now separated and perform similar tasks in parallel. You will choose one of the real
scenarios that your team introduced about DP in previous phase, then implement that scenario based

Table Of Content

P3 Build an application derived from UML class diagrams.

1.Introduction
I mentioned in Lesson 1 that the current manual school Library management system is outdated and now I
have found a way to design a management software solution that replaces manual management. Managing
books with software will be more efficient. I was tasked with system design and UML diagramming for the
University of Greenwich Management Systems.
2. Scenario analysis
2.1. Scenario
In order to accomplish the above mentioned introduction, I need to write a program that is easy to use and
easily manages the amount of books in the library and the users (employees and students) who are registered
in the library. Here I will show the steps to do and explain it.
We must create connection diagrams (shown in the image) to identify and help identify the relationships of
the connected items a logic, and easy to govern, in order to link these things together in a logical sequence.
3. Implementation
3.1.Code
Form Login
Class dangnhap: This is a class with 2 methods: public and private
Public: then other classes can call and use it directly. Private , if the function or variable is declared private,
only the members of that class can use it.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication { public partial class dangnhap : Form { public dangnhap() { InitializeComponent(); } Themsuaxoa t = new Themsuaxoa(); string user = "admin"; string pass = "123"; private void button1_Click(object sender, EventArgs e) { if (taikhoan.Text == "") { MessageBox.Show("Bạn chưa nhập tài khoản"); taikhoan.Focus(); } else if (matkhau.Text == "") { MessageBox.Show("Bạn chưa nhập mật khẩu"); matkhau.Focus(); } else if (user.Equals(taikhoan.Text) && pass.Equals(matkhau.Text)) { MessageBox.Show("Đăng nhập thành công"); this.Hide(); Form f = new Formchinh(); f.Show();

} Themsuaxoa t = new Themsuaxoa(); private void loaddata() { DataTable dt = t.docdulieu("select * from sach"); if (dt != null) { luoi.DataSource = dt; } luoi.Columns[0].HeaderText = "Mã sách "; luoi.Columns[0].Width = 80; luoi.Columns[3].Width = 180; luoi.Columns[1].HeaderText = "Tên sách"; luoi.Columns[2].HeaderText = "Năm xuất bản"; luoi.Columns[3].HeaderText = "Mã nhà xuất bản"; luoi.Columns[4].HeaderText = "Mã thể loại"; luoi.Columns[5].HeaderText = "Mã tác giả"; //luoi.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); xoa.Enabled = true; sua.Text = "Sửa"; them.Enabled = true; sua.Enabled = true; xoa.Enabled = true; luu.Enabled = false; luoi.Enabled = true; } private void loadcombo() { DataTable dt = t.docdulieu("select * from nhaxb"); DataTable dt1 = t.docdulieu("select * from theloai"); DataTable dt2 = t.docdulieu("select * from tacgia"); comnhaxb.DataSource = dt; comnhaxb.DisplayMember = "tennxb"; comnhaxb.ValueMember = "manxb"; //comnhaxb.DisplayMember = "tennxb"; //comnhaxb.ValueMember = "manxb"; comtheloai.DataSource = dt1; comtheloai.DisplayMember = "tentheloai"; comtheloai.ValueMember = "matheloai"; commatacgia.DataSource = dt2; commatacgia.DisplayMember = "tentacgia"; commatacgia.ValueMember = "matacgia"; } private void txttimkiem_TextChanged(object sender, EventArgs e) { }

private void Formcapnhatsach_Load(object sender, EventArgs e) { loaddata(); } private void luoi_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void luoi_SelectionChanged(object sender, EventArgs e) { txtmasach.Text = luoi.CurrentRow.Cells[0].Value.ToString(); txttensach.Text = luoi.CurrentRow.Cells[1].Value.ToString(); txtnamxb.Text = luoi.CurrentRow.Cells[2].Value.ToString(); comnhaxb.Text = luoi.CurrentRow.Cells[3].Value.ToString(); comtheloai.Text = luoi.CurrentRow.Cells[4].Value.ToString(); commatacgia.Text = luoi.CurrentRow.Cells[5].Value.ToString(); } private void them_Click(object sender, EventArgs e) { txtmasach.Text = ""; txttensach.Text = ""; luu.Enabled = true; xoa.Enabled = false; sua.Text = "hủy"; them.Enabled = false; luoi.Enabled = false; loadcombo(); } private void luu_Click(object sender, EventArgs e) { if (txtmasach.Text == "") { MessageBox.Show("Chưa nhập mã sách"); txtmasach.Focus(); } else if (txttensach.Text == "") { MessageBox.Show("Chưa nhập tên sách"); txttensach.Focus(); } else if (txtnamxb.Text == "") { MessageBox.Show("Chưa nhập năm xuất bản");

txtmasach.Enabled = false; if (txttensach.Text == "") { txttensach.Focus(); } else if (txtnamxb.Text == "") { MessageBox.Show("Chưa nhập địa chỉ"); txtnamxb.Focus(); // else if (t.thucthidulieu("update SACH set tensach=N'" + txttensach.Text + "', namxb=N'" + txtnamxb.Text + "', manxb='" + comnhaxb.Text + "', matheloai='" + comtheloai.SelectedValue.ToString() + "', matacgia='" + commatacgia.SelectedValue.ToString() + "'where masach=N'" + txtmasach.Text + "'") == true) } else if (t.thucthidulieu("update SACH set tensach=N'" + txttensach.Text + "', namxb=N'" + txtnamxb.Text + "', manxb='" + comnhaxb.Text + "', matheloai='" + comtheloai.Text + "', matacgia='" + commatacgia.Text + "'where masach=N'" + txtmasach.Text + "'") == true) { MessageBox.Show("Cập nhật dữ liệu thành công"); loaddata(); txtmasach.Enabled = true; } else MessageBox.Show("Không thể cập nhật dữ liệu"); } } private void xoa_Click(object sender, EventArgs e) { if (xoa.Text == "hủy") { luu.Enabled = false; sua.Enabled = true; xoa.Enabled = true; xoa.Text = "Xóa"; sua.Text = "Sửa"; them.Enabled = true; loaddata(); luoi.Enabled = true; } else {

DialogResult chon = MessageBox.Show("Bạn có muốn xóa sách có mã số " + txtmasach.Text + "", "thông báo", MessageBoxButtons.YesNo); if (chon == DialogResult.Yes) { try { t.thucthidulieu("delete from sach where masach='" + txtmasach.Text + "'"); MessageBox.Show("Xóa thành Công", "Thông báo"); loaddata(); } catch (Exception) { MessageBox.Show("Không thể xóa", "Thông báo"); throw; } } else loaddata(); } } private void thoat_Click(object sender, EventArgs e) { this.Hide(); Form f = new Formchinh(); f.Show(); } private void button2_Click(object sender, EventArgs e) { DataTable dt5 = t.docdulieu("select * from sach where masach like '%" + txttimkiem.Text + "%'"); DataTable dt6 = t.docdulieu("select * from sach where tensach like '%" + txttimkiem.Text + "%'"); if (ramasach.Checked == true) { luoi.DataSource = dt5; } else luoi.DataSource = dt6; } } }

Form Search Book
Static to declare a static element.

{ luoi.DataSource = dt5; } else luoi.DataSource = dt6; } private void button1_Click(object sender, EventArgs e) { this.Hide(); Form f = new Formchinh(); f.Show(); } } }

Form Readers
The Form Reader is a child of the Form dangnhap class. Form Reader has many new features: reader code,
first and last name, date of birth,
As in the parent class also use 2 methods Private void() and InputInfo()

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication { public partial class Formdocgia : Form { public Formdocgia() { InitializeComponent(); } Themsuaxoa t = new Themsuaxoa(); private void Formdocgia_Load(object sender, EventArgs e) { loaddata(); } private void thoat_Click(object sender, EventArgs e) { this.Hide(); Form f = new Formchinh(); f.Show(); } private void loaddata()

{ DataTable dt = t.docdulieu("Logged in successfully"); l.Text = dt.Rows.Count.ToString(); if (dt != null) { luoi.DataSource = dt; } luoi.Columns[0].HeaderText = "Mã độc giả"; luoi.Columns[1].HeaderText = "Họ và tên"; luoi.Columns[2].HeaderText = "Ngày sinh"; luoi.Columns[3].HeaderText = "Giới tính"; luoi.Columns[4].HeaderText = "Lớp"; luoi.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); xoa.Enabled = true; sua.Text = "Sửa"; them.Enabled = true; sua.Enabled = true; xoa.Enabled = true; luu.Enabled = false; luoi.Enabled = true; } private void luoi_SelectionChanged(object sender, EventArgs e) { txtmadocgia.Text = luoi.CurrentRow.Cells[0].Value.ToString(); txttendocgia.Text = luoi.CurrentRow.Cells[1].Value.ToString(); ngaysinh.Text = luoi.CurrentRow.Cells[2].Value.ToString(); comgioitinh.Text = luoi.CurrentRow.Cells[3].Value.ToString(); txtlop.Text = luoi.CurrentRow.Cells[4].Value.ToString(); } private void them_Click(object sender, EventArgs e) { txtmadocgia.Text = ""; txttendocgia.Text = ""; luu.Enabled = true; //sua.Enabled = false; xoa.Enabled = false; sua.Text = "hủy"; them.Enabled = false; luoi.Enabled = false; } private void luu_Click(object sender, EventArgs e) { string ngayhh = ngaysinh.Value.ToString("yyyy/MM/dd"); if (txtmadocgia.Text == "")

} else { if (txttendocgia.Text == "") { txttendocgia.Focus(); } else if (txtlop.Text == "") { MessageBox.Show("Chưa nhập địa chỉ"); txtlop.Focus(); } else if (t.thucthidulieu("update docgia set hoten=N'" + txttendocgia.Text + "', ngaysinh=N'" + ngayhh + "', gioitinh=N'" + comgioitinh.Text + "', thongtin='" + txtlop.Text + "'where madocgia=N'" + txtmadocgia.Text + "'") == true) { MessageBox.Show("Cập nhật dữ liệu thành công"); loaddata(); } else MessageBox.Show("Không thể cập nhật dữ liệu"); } } private void xoa_Click(object sender, EventArgs e) { if (xoa.Text == "hủy") { luu.Enabled = false; sua.Enabled = true; xoa.Enabled = true; xoa.Text = "Xóa"; sua.Text = "Sửa"; them.Enabled = true; loaddata(); luoi.Enabled = true; } else { DialogResult chon = MessageBox.Show("Bạn có muốn xóa độc giả có mã số " + txtmadocgia.Text + "", "thông báo", MessageBoxButtons.YesNo); if (chon == DialogResult.Yes)

{ try { if (t.thucthidulieu("delete from docgia where madocgia='" + txtmadocgia.Text + "'") == true) MessageBox.Show("Xóa thành Công", "Thông báo"); else MessageBox.Show("Lỗi không thể xóa dữ liệu", "Thông báo"); loaddata(); } catch (Exception) { MessageBox.Show("Không thể xóa", "Thông báo"); throw; } } else loaddata(); } } } }

Form borrowing and returning books
Form borrowing and returning books are children of the Form dangnhap class. Form borrowing and returning
books has many new features: add, delete, save, return books, renew....
As in the parent class, also use 2 methods Private void() and InputInfo()

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;