Git Product home page Git Product logo

qlhv's Introduction

KenDzz 👋

🌐Socials

Facebook KenDzz LinkedIn

💻Tech Stack

CSS3 HTML5 JavaScript PHP Bootstrap Laravel CakePHP NodeJS React Jquery Web3 JS Python



qlhv's People

Watchers

 avatar  avatar  avatar

qlhv's Issues

test.java

package GUI1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.text.Segment;

import com.sun.jdi.connect.spi.Connection;

import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Window.Type;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JLayeredPane;
import javax.swing.JRadioButton;
import javax.swing.ListSelectionModel;
import javax.swing.JMenuBar;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

public class test extends JFrame {

private JPanel scrolldislay;
private JTextField tfhoten;
private JTextField tfmaSV;
private JTextField tfngaySinh;
private JTextField tfqueQuan;
private JTextField tfmaLop;
private JTable tbdislay;
Object[] columHeader = {"MaSV","TenSV","GioiTinh","NgaySinh","QueQuan","TenMH","HocKy","GiuaKy","BaiTap"};	
DefaultTableModel model = new DefaultTableModel(columHeader,0);  

/**
 * Launch the application.
 */
public static void main(String[] args) {
	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				test frame = new test();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}



/**
 * Create the frame.
 */
public test() {
	setTitle("Ph\u1EA7n m\u1EC1m qu\u1EA3n l\u00FD H\u1ECCC VI\u00CAN - KenDzz");
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 1078, 513);
	scrolldislay = new JPanel();
	scrolldislay.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(scrolldislay);
	scrolldislay.setLayout(null);
	
	JLabel lbltitle = new JLabel("QU\u1EA2N L\u00DD H\u1ECCC VI\u00CAN");
	lbltitle.setFont(new Font("Tahoma", Font.PLAIN, 30));
	lbltitle.setBounds(433, 0, 272, 54);
	scrolldislay.add(lbltitle);
	
	JLabel lblhoten = new JLabel("H\u1ECC V\u00C0 T\u00CAN");
	lblhoten.setFont(new Font("Tahoma", Font.BOLD, 13));
	lblhoten.setBounds(10, 70, 75, 21);
	scrolldislay.add(lblhoten);
	
	tfhoten = new JTextField();
	tfhoten.setBounds(95, 71, 144, 20);
	scrolldislay.add(tfhoten);
	tfhoten.setColumns(10);
	
	JLabel lblmaSV = new JLabel("M\u00E3 SV");
	lblmaSV.setFont(new Font("Tahoma", Font.BOLD, 13));
	lblmaSV.setBounds(10, 114, 75, 19);
	scrolldislay.add(lblmaSV);
	
	tfmaSV = new JTextField();
	tfmaSV.setBounds(95, 113, 144, 20);
	scrolldislay.add(tfmaSV);
	tfmaSV.setColumns(10);
	
	JLabel lblgioitinh = new JLabel("Gi\u1EDBi T\u00EDnh");
	lblgioitinh.setFont(new Font("Tahoma", Font.BOLD, 13));
	lblgioitinh.setBounds(10, 158, 75, 20);
	scrolldislay.add(lblgioitinh);
	
	JLabel lblngaySinh = new JLabel("Ng\u00E0y Sinh");
	lblngaySinh.setFont(new Font("Tahoma", Font.BOLD, 13));
	lblngaySinh.setBounds(10, 207, 75, 21);
	scrolldislay.add(lblngaySinh);
	
	tfngaySinh = new JTextField();
	tfngaySinh.setText("(yyyy-MM-dd)");
	tfngaySinh.setBounds(95, 208, 144, 20);
	scrolldislay.add(tfngaySinh);
	tfngaySinh.setColumns(10);
	
	JLabel lblqueQuan = new JLabel("Qu\u00EA Qu\u00E1n");
	lblqueQuan.setFont(new Font("Tahoma", Font.BOLD, 13));
	lblqueQuan.setBounds(10, 254, 75, 21);
	scrolldislay.add(lblqueQuan);
	
	tfqueQuan = new JTextField();
	tfqueQuan.setBounds(95, 255, 144, 20);
	scrolldislay.add(tfqueQuan);
	tfqueQuan.setColumns(10);
	
	JLabel lbmaLop = new JLabel("M\u00E3 L\u1EDBp");
	lbmaLop.setFont(new Font("Tahoma", Font.BOLD, 13));
	lbmaLop.setBounds(10, 300, 75, 21);
	scrolldislay.add(lbmaLop);
	
	tfmaLop = new JTextField();
	tfmaLop.setBounds(95, 301, 144, 20);
	scrolldislay.add(tfmaLop);
	tfmaLop.setColumns(10);
	
	JButton btnthem = new JButton("Thêm");
	btnthem.setFont(new Font("Tahoma", Font.PLAIN, 13));
	btnthem.setBounds(10, 367, 144, 33);
	scrolldislay.add(btnthem);
	
	tbdislay = new JTable();
	tbdislay.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
	tbdislay.setBounds(307, 74, 722, 256);
	scrolldislay.add(tbdislay);
	
	JScrollPane scrollPane = new JScrollPane(tbdislay);
	scrollPane.setBounds(293, 70, 742, 262);
	scrolldislay.add(scrollPane);
	
	JButton btnupdate = new JButton("C\u1EADp Nh\u1EADt H\u1ED2 S\u01A0");
	btnupdate.setFont(new Font("Tahoma", Font.PLAIN, 13));
	btnupdate.setBounds(381, 367, 144, 33);
	scrolldislay.add(btnupdate);
	
	JButton btnupdatediem = new JButton("C\u1EADp Nh\u1EADt \u0110i\u1EC3m");
	btnupdatediem.setFont(new Font("Tahoma", Font.PLAIN, 13));
	btnupdatediem.setBounds(549, 367, 144, 33);
	scrolldislay.add(btnupdatediem);
	
	JButton btndelete = new JButton("X\u00F3a");
	btndelete.setBounds(719, 368, 144, 33);
	scrolldislay.add(btndelete);
	
	JButton btndislay = new JButton("Hi\u1EC3n Th\u1ECB Th\u00F4ng Tin");
	btndislay.setBounds(891, 368, 144, 33);
	scrolldislay.add(btndislay);
	
	JRadioButton rdbtnNam = new JRadioButton("Nam");
	rdbtnNam.setBounds(95, 158, 60, 23);
	scrolldislay.add(rdbtnNam);
	
	JRadioButton rdbtnNu = new JRadioButton("N\u1EEF");
	rdbtnNu.setBounds(174, 158, 65, 23);
	scrolldislay.add(rdbtnNu);
	
	JButton btnupdateinfo = new JButton("Cập Nhật MHọc, Lớp");
	btnupdateinfo.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		}
	});
	btnupdateinfo.setBounds(186, 368, 160, 33);
	scrolldislay.add(btnupdateinfo);
	
	JButton btntimKiem = new JButton("Tìm Kiếm");
	btntimKiem.setBounds(483, 434, 111, 37);
	scrolldislay.add(btntimKiem);
	
	JButton btnsapxep = new JButton("Sắp Xếp");
	btnsapxep.setBounds(651, 434, 100, 37);
	scrolldislay.add(btnsapxep);
	
	JLabel lblbackgroud = new JLabel("");
	lblbackgroud.setIcon(new ImageIcon("C:\\Users\\HP\\Desktop\\hinh-nen-powerpoint-don-gian-3.jpg"));
	lblbackgroud.setBounds(0, 0, 1070, 482);
	scrolldislay.add(lblbackgroud);
	
	btnsapxep.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			java.sql.Connection conn = null;
			try {
				 String dbURL = "jdbc:sqlserver://DESKTOP-B8MNLSB\\SQLEXPRESS:1433;databaseName=QLHV_JAVA;user=sa;password=aloxinh123";
		            conn = DriverManager.getConnection(dbURL);
		            java.sql.Statement s = conn.createStatement();
		            model.setRowCount(0);// reset table 
		            //truy van DISLAY
		            ResultSet rs = s.executeQuery("SELECT SinhVien.MaSV, TenSV, GioiTinh, NgaySinh, QueQuan, TenMH, HocKy, GiuaKy, BaiTap FROM [QLHV_JAVA].[dbo].[SinhVien] JOIN [QLHV_JAVA].[dbo].[Diem] ON SinhVien.MaSV = Diem.MaSV  JOIN [QLHV_JAVA].[dbo].[MonHoc] ON Diem.MaMH = MonHoc.MaMH order by HocKy DESC, GiuaKy DESC, BaiTap DESC");
		            while (rs.next()) {
		            	String MaSV= rs.getString("MaSV"); //getstring : lay du lieu tu table trong sql
						String TenSV =rs.getString("TenSV");
						String GioiTinh= rs.getString("GioiTinh");
						String NgaySinh =rs.getString("NgaySinh");
						String QueQuan = rs.getString("QueQuan");
						String TenMH = rs.getString("TenMH");
						String HocKy = rs.getString("HocKy");
						String GiuaKy = rs.getString("GiuaKy");
						String BaiTap = rs.getString("BaiTap");
		            	Object[] rowData = new Object[] { MaSV, TenSV, GioiTinh, NgaySinh, QueQuan, TenMH, HocKy, GiuaKy, BaiTap};
					    model.addRow(rowData);
					}
		            tbdislay.setModel(model);	
					conn.close();
				
			} catch (Exception e2) {
				// TODO: handle exception
			}
			
		}
	});
	
	
	btntimKiem.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			try {
				testTimKiem.timkiem();
			} catch (Exception e2) {
				// TODO: handle exception
				e2.printStackTrace();
			}
		}
	});
	
	
	//Fuction add lớp, môn học
	btnupdateinfo.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			
			try {
				updateinfo.updateinfo();
				
			} catch (Exception e2) {
				// TODO: handle exception
				e2.printStackTrace();
			}
		}
	});
	
	
	
	
	//FUNCTION THÊM
	btnthem.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			java.sql.Connection conn = null;
			try {
				 //connect SQL SERVER
	            String dbURL = "jdbc:sqlserver://DESKTOP-B8MNLSB\\SQLEXPRESS:1433;databaseName=QLHV_JAVA;user=sa;password=aloxinh123";
	            conn = DriverManager.getConnection(dbURL);
	            java.sql.Statement s = conn.createStatement();		            
	            
	          //kiem tra gender
				String gioitinh ="";
				if(rdbtnNam.isSelected()) {
					gioitinh = rdbtnNam.getText();
				}
				
				if(rdbtnNu.isSelected()) {
					gioitinh = rdbtnNu.getText();
				}
				
				//Truy van them vao SQL SERVER
	            int n = s.executeUpdate("Insert into [dbo].[SinhVien] values('"+tfmaSV.getText()+"',N'"+tfhoten.getText()+"',N'"+gioitinh+"','"+tfngaySinh.getText()+"',N'"+tfqueQuan.getText()+"','"+tfmaLop.getText()+"')");
				
				if(n>0) {
				JOptionPane.showConfirmDialog(rootPane, "Thêm Thành Công!");
				}
	        } catch (SQLException ex) {
	            ex.printStackTrace();
	        } 
			
		}
	});
	
	//FUNCTION UPDATE
	btnupdate.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			java.sql.Connection conn = null;
			try {
				
				//đi đến Jpanel mới
		            testupdate.update();
		            
				
			} catch (Exception e2) {
				// TODO: handle exception
				e2.printStackTrace();
			}
			
		}
	});
	
	//FUNCTION UPDATE điểm
	btnupdatediem.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			try {
				testupdatediem.updatediem();
			} catch (Exception e2) {
				// TODO: handle exception
				e2.printStackTrace();
			}
		}
	});
	
	//FUCTION DETELE
	btndelete.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			try {

				detele.delete();
		            
		            
			} catch (Exception e2) {
				// TODO: handle exception
			}
			
		}
	});
	
	//FUNCTION DISLAY
	btndislay.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			java.sql.Connection conn = null;
			try {
				//connect SQL SERVER
				   String dbURL = "jdbc:sqlserver://DESKTOP-B8MNLSB\\SQLEXPRESS:1433;databaseName=QLHV_JAVA;user=sa;password=aloxinh123";
		            conn = DriverManager.getConnection(dbURL);
		            java.sql.Statement s = conn.createStatement();
		            
		            model.setRowCount(0);// reset table 
		            //truy van DISLAY
		            ResultSet rs = s.executeQuery("SELECT SinhVien.MaSV, TenSV, GioiTinh, NgaySinh, QueQuan, TenMH, HocKy, GiuaKy, BaiTap FROM [QLHV_JAVA].[dbo].[SinhVien] JOIN [QLHV_JAVA].[dbo].[Diem] ON SinhVien.MaSV = Diem.MaSV  JOIN [QLHV_JAVA].[dbo].[MonHoc] ON Diem.MaMH = MonHoc.MaMH ");
		            while (rs.next()) {
		            	String MaSV= rs.getString("MaSV"); //getstring : lay du lieu tu table trong sql
						String TenSV =rs.getString("TenSV");
						String GioiTinh= rs.getString("GioiTinh");
						String NgaySinh =rs.getString("NgaySinh");
						String QueQuan = rs.getString("QueQuan");
						String TenMH = rs.getString("TenMH");
						String HocKy = rs.getString("HocKy");
						String GiuaKy = rs.getString("GiuaKy");
						String BaiTap = rs.getString("BaiTap");
		            	Object[] rowData = new Object[] { MaSV, TenSV, GioiTinh, NgaySinh, QueQuan, TenMH, HocKy, GiuaKy, BaiTap};
					    model.addRow(rowData);
					}
		            tbdislay.setModel(model);	
					conn.close();
										
			} catch (Exception e2) {
				// TODO: handle exception
				e2.printStackTrace();
			}
		}
	});
	
	
	
}

}

updateinfo.java

package GUI1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;

import javax.swing.JTextField;
import javax.swing.JButton;

public class updateinfo extends JFrame {

private JPanel contentPane;
private JTextField tfmaMH;
private JTextField tftenMH1;
private JTextField tfmaLOP1;
private JTextField tftenLop1;

/**
 * Launch the application.
 */
public static void updateinfo() {
	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				updateinfo frame = new updateinfo();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}

/**
 * Create the frame.
 */
public updateinfo() {
	setTitle("Ph\u1EA7n m\u1EC1m qu\u1EA3n l\u00FD H\u1ECCC VI\u00CAN - KenDzz");
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 616, 287);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JLabel lbltitle = new JLabel("TH\u00CAM M\u00D4N H\u1ECCC");
	lbltitle.setFont(new Font("Tahoma", Font.BOLD, 15));
	lbltitle.setBounds(92, 11, 120, 39);
	contentPane.add(lbltitle);
	
	JLabel lbltitle1 = new JLabel("TH\u00CAM L\u1EDAP H\u1ECCC");
	lbltitle1.setFont(new Font("Tahoma", Font.BOLD, 15));
	lbltitle1.setBounds(411, 15, 137, 31);
	contentPane.add(lbltitle1);
	
	JLabel lblmaMH1 = new JLabel("M\u00E3 m\u00F4n h\u1ECDc");
	lblmaMH1.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lblmaMH1.setBounds(10, 76, 72, 14);
	contentPane.add(lblmaMH1);
	
	tfmaMH = new JTextField();
	tfmaMH.setBounds(92, 74, 143, 20);
	contentPane.add(tfmaMH);
	tfmaMH.setColumns(10);
	
	JLabel lbltenMH1 = new JLabel("T\u00EAn m\u00F4n h\u1ECDc");
	lbltenMH1.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lbltenMH1.setBounds(10, 129, 94, 14);
	contentPane.add(lbltenMH1);
	
	tftenMH1 = new JTextField();
	tftenMH1.setBounds(92, 127, 143, 20);
	contentPane.add(tftenMH1);
	tftenMH1.setColumns(10);
	
	JButton btnupdate1 = new JButton("Th\u00EAm");
	btnupdate1.setBounds(92, 176, 120, 39);
	contentPane.add(btnupdate1);
	
	JLabel lblmaLop = new JLabel("M\u00E3 l\u1EDBp");
	lblmaLop.setFont(new Font("Tahoma", Font.PLAIN, 13));
	lblmaLop.setBounds(346, 77, 46, 14);
	contentPane.add(lblmaLop);
	
	JLabel lbltenLop1 = new JLabel("T\u00EAn l\u1EDBp");
	lbltenLop1.setFont(new Font("Tahoma", Font.PLAIN, 13));
	lbltenLop1.setBounds(346, 130, 46, 14);
	contentPane.add(lbltenLop1);
	
	tfmaLOP1 = new JTextField();
	tfmaLOP1.setBounds(411, 74, 143, 20);
	contentPane.add(tfmaLOP1);
	tfmaLOP1.setColumns(10);
	
	tftenLop1 = new JTextField();
	tftenLop1.setBounds(411, 127, 143, 20);
	contentPane.add(tftenLop1);
	tftenLop1.setColumns(10);
	
	JButton btnupdate2 = new JButton("Th\u00EAm");
	btnupdate2.setBounds(411, 176, 120, 39);
	contentPane.add(btnupdate2);
	
	btnupdate1.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			java.sql.Connection conn = null;
			try {
				//connect SQL SERVER
				String dbURL = "jdbc:sqlserver://DESKTOP-B8MNLSB\\SQLEXPRESS:1433;databaseName=QLHV_JAVA;user=sa;password=aloxinh123";
	            conn = DriverManager.getConnection(dbURL);
	            java.sql.Statement s = conn.createStatement();
	            
	            //Truy Vấn SQL SERVER
	            int n = s.executeUpdate("insert into [QLHV_JAVA].[dbo].[MonHoc] values ('"+tfmaMH.getText()+"',N'"+tftenMH1.getText()+"')");
	            if(n>0) {
	            	JOptionPane.showConfirmDialog(null, "Thêm Thành Công!!");
	            }
	            else {
	            	JOptionPane.showConfirmDialog(null, "Lỗi! Vui lòng nhập lại");
	            }
				
			} catch (Exception e2) {
				// TODO: handle exception
			}
			
		}
	});
	
	btnupdate2.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			java.sql.Connection conn = null;
			try {
				//connect SQL SERVER
				String dbURL = "jdbc:sqlserver://DESKTOP-B8MNLSB\\SQLEXPRESS:1433;databaseName=QLHV_JAVA;user=sa;password=aloxinh123";
	            conn = DriverManager.getConnection(dbURL);
	            java.sql.Statement s = conn.createStatement();
	            
	            //truy vấn sql server
	            int n = s.executeUpdate("insert into [QLHV_JAVA].[dbo].[Lop] values ('"+tfmaLOP1.getText()+"',N'"+tftenLop1.getText()+"')");
	            
				if(n>0) {
					JOptionPane.showConfirmDialog(null, "Thêm thành công!");
				}
				else {
					JOptionPane.showConfirmDialog(null, "Lỗi! Vui lòng nhập lại");
				}
			} catch (Exception e2) {
				// TODO: handle exception
			}
			
		}
	});
}

}

testupdatediem.java

package GUI1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;

import javax.swing.JTextField;
import javax.swing.JButton;

public class testupdatediem extends JFrame {

private JPanel contentPane;
private JTextField tfmaSV;
private JTextField tfmaMH;
private JTextField tfdiemHK;
private JTextField tfdiemGK;
private JTextField tfdiemBT;

/**
 * Launch the application.
 */
public static void updatediem() {
	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				testupdatediem frame = new testupdatediem();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}

/**
 * Create the frame.
 */
public testupdatediem() {
	setTitle("Ph\u1EA7n m\u1EC1m qu\u1EA3n l\u00FD H\u1ECCC VI\u00CAN - KENDZZ");
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 406, 456);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JLabel lbltitle = new JLabel("C\u1EACP NH\u1EACT \u0110I\u1EC2M ");
	lbltitle.setFont(new Font("Tahoma", Font.BOLD, 15));
	lbltitle.setBounds(136, 11, 125, 39);
	contentPane.add(lbltitle);
	
	JLabel lblmaSV = new JLabel("M\u00E3 SV");
	lblmaSV.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lblmaSV.setBounds(25, 81, 46, 14);
	contentPane.add(lblmaSV);
	
	tfmaSV = new JTextField();
	tfmaSV.setBounds(112, 79, 181, 20);
	contentPane.add(tfmaSV);
	tfmaSV.setColumns(10);
	
	JLabel lblmaMH = new JLabel("M\u00E3 m\u00F4n h\u1ECDc");
	lblmaMH.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lblmaMH.setBounds(25, 136, 83, 14);
	contentPane.add(lblmaMH);
	
	tfmaMH = new JTextField();
	tfmaMH.setBounds(112, 134, 181, 20);
	contentPane.add(tfmaMH);
	tfmaMH.setColumns(10);
	
	JLabel lbldiemHK = new JLabel("\u0110i\u1EC3m h\u1ECDc k\u1EF3");
	lbldiemHK.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lbldiemHK.setBounds(25, 186, 83, 14);
	contentPane.add(lbldiemHK);
	
	tfdiemHK = new JTextField();
	tfdiemHK.setBounds(112, 184, 181, 20);
	contentPane.add(tfdiemHK);
	tfdiemHK.setColumns(10);
	
	JLabel lbldiemGK = new JLabel("\u0110i\u1EC3m gi\u1EEFa k\u1EF3");
	lbldiemGK.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lbldiemGK.setBounds(25, 240, 83, 14);
	contentPane.add(lbldiemGK);
	
	tfdiemGK = new JTextField();
	tfdiemGK.setBounds(112, 238, 181, 20);
	contentPane.add(tfdiemGK);
	tfdiemGK.setColumns(10);
	
	JLabel lbldiemBT = new JLabel("\u0110i\u1EC3m b\u00E0i t\u1EADp");
	lbldiemBT.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lbldiemBT.setBounds(25, 289, 83, 14);
	contentPane.add(lbldiemBT);
	
	tfdiemBT = new JTextField();
	tfdiemBT.setBounds(112, 287, 181, 20);
	contentPane.add(tfdiemBT);
	tfdiemBT.setColumns(10);
	
	JButton btnupdatediem = new JButton("C\u1EADp Nh\u1EADt");
	btnupdatediem.setBounds(136, 352, 125, 47);
	contentPane.add(btnupdatediem);
	
	btnupdatediem.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			java.sql.Connection conn = null;
			try {
				//connect SQL SERVER
				String dbURL = "jdbc:sqlserver://DESKTOP-B8MNLSB\\SQLEXPRESS:1433;databaseName=QLHV_JAVA;user=sa;password=aloxinh123";
	            conn = DriverManager.getConnection(dbURL);
	            java.sql.Statement s = conn.createStatement();
	            
	            
	            
	            //truy van them diem vao SQL
	            int n = s.executeUpdate("Insert into [QLHV_JAVA].[dbo].[Diem] values ( '"+tfmaSV.getText()+"','"+tfmaMH.getText()+"', '"+tfdiemHK.getText()+"', '"+tfdiemGK.getText()+"', '"+tfdiemBT.getText()+"')");
	            
	            if(n>0) {
	            	JOptionPane.showConfirmDialog(rootPane, "Thành Công!!");
	            }
				
			} catch (Exception e2) {
				// TODO: handle exception
				e2.printStackTrace();
			}
		}
	});
}

}

testupdate.java

package GUI1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.Color;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;

import javax.swing.ImageIcon;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JButton;

public class testupdate extends JFrame {

private JPanel contentPane;
private JTextField tfmaSV;
private JTextField tftenSV;
private JTextField tfngaySinh;
private JTextField tfqueQuan;
private JTextField tfmaLop;

/**
 * Launch the application.
 */
public static void update() {
	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				testupdate frame = new testupdate();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}

/**
 * Create the frame.
 */
public testupdate() {
	setTitle("Ph\u1EA7n m\u1EC1m qu\u1EA3n l\u00FD H\u1ECCC VI\u00CAN - KenDzz");
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 397, 494);
	contentPane = new JPanel();
	contentPane.setBackground(SystemColor.inactiveCaptionBorder);
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JLabel lbltitle = new JLabel("C\u1EACP NH\u1EACT H\u1ED2 S\u01A0 H\u1ECCC VI\u00CAN");
	lbltitle.setFont(new Font("Tahoma", Font.BOLD, 15));
	lbltitle.setBounds(84, 11, 221, 35);
	contentPane.add(lbltitle);
	
	JLabel lblmaSV = new JLabel("M\u00C3 SV");
	lblmaSV.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lblmaSV.setBounds(46, 81, 46, 14);
	contentPane.add(lblmaSV);
	
	tfmaSV = new JTextField();
	tfmaSV.setText("Nh\u1EADp m\u00E3 SV c\u1EA7n ch\u1EC9nh s\u1EEDa..");
	tfmaSV.setBounds(122, 79, 163, 20);
	contentPane.add(tfmaSV);
	tfmaSV.setColumns(10);
	
	JLabel lbltenSV = new JLabel("T\u00EAn SV");
	lbltenSV.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lbltenSV.setBounds(46, 122, 46, 14);
	contentPane.add(lbltenSV);
	
	tftenSV = new JTextField();
	tftenSV.setBounds(122, 120, 163, 20);
	contentPane.add(tftenSV);
	tftenSV.setColumns(10);
	
	JLabel lblngaySinh = new JLabel("Ng\u00E0y Sinh");
	lblngaySinh.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lblngaySinh.setBounds(46, 161, 57, 14);
	contentPane.add(lblngaySinh);
	
	tfngaySinh = new JTextField();
	tfngaySinh.setBounds(122, 159, 163, 20);
	contentPane.add(tfngaySinh);
	tfngaySinh.setColumns(10);
	
	JLabel lblqueQuan = new JLabel("Qu\u00EA Qu\u00E1n");
	lblqueQuan.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lblqueQuan.setBounds(46, 202, 70, 14);
	contentPane.add(lblqueQuan);
	
	tfqueQuan = new JTextField();
	tfqueQuan.setBounds(122, 200, 163, 20);
	contentPane.add(tfqueQuan);
	tfqueQuan.setColumns(10);
	
	JLabel lblmaLop = new JLabel("M\u00E3 L\u1EDBp");
	lblmaLop.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lblmaLop.setBounds(46, 244, 46, 14);
	contentPane.add(lblmaLop);
	
	tfmaLop = new JTextField();
	tfmaLop.setBounds(122, 242, 163, 20);
	contentPane.add(tfmaLop);
	tfmaLop.setColumns(10);
	
	JButton btnupdate = new JButton("C\u1EADp Nh\u1EADt");
	btnupdate.setBounds(126, 301, 136, 46);
	contentPane.add(btnupdate);
	
	//function update
	btnupdate.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			java.sql.Connection conn = null;
			try {
				 String dbURL = "jdbc:sqlserver://DESKTOP-B8MNLSB\\SQLEXPRESS:1433;databaseName=QLHV_JAVA;user=sa;password=aloxinh123";
		            conn = DriverManager.getConnection(dbURL);
		            java.sql.Statement s = conn.createStatement();
		            
	
					//Truy van cap nhat thong tin vao SQL SERVER
		            int n = s.executeUpdate("update [dbo].[SinhVien] set TenSV=N'"+tftenSV.getText()+"', NgaySinh='"+tfngaySinh.getText()+"', QueQuan =N'"+tfqueQuan.getText()+"', MaLop ='"+tfmaLop.getText()+"' WHERE MaSV= '"+tfmaSV.getText()+"'");
					
					if(n>0) {
					JOptionPane.showConfirmDialog(rootPane, "Thêm Thành Công!");
					}
				
			} catch (Exception e2) {
				// TODO: handle exception
				e2.printStackTrace();
			}
		}
	});
}

}

detele.java

package GUI1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;

import javax.swing.JTextField;

public class detele extends JFrame {

private JPanel contentPane;
private JTextField tfmaSV;

/**
 * Launch the application.
 */
public static void delete() {
	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				detele frame = new detele();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}

/**
 * Create the frame.
 */
public detele() {
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 406, 245);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JLabel lbltitle = new JLabel("X\u00D3A TH\u00D4NG TIN");
	lbltitle.setFont(new Font("Tahoma", Font.BOLD, 15));
	lbltitle.setBounds(136, 9, 138, 49);
	contentPane.add(lbltitle);
	
	JLabel lblmaSV = new JLabel("M\u00E3 SV c\u1EA7n x\u00F3a");
	lblmaSV.setFont(new Font("Tahoma", Font.PLAIN, 12));
	lblmaSV.setBounds(29, 90, 96, 15);
	contentPane.add(lblmaSV);
	
	tfmaSV = new JTextField();
	tfmaSV.setBounds(135, 88, 206, 20);
	contentPane.add(tfmaSV);
	tfmaSV.setColumns(10);
	
	JButton btndelete = new JButton("X\u00D3A");
	btndelete.setBounds(141, 137, 116, 47);
	contentPane.add(btndelete);
	
	btndelete.addActionListener(new ActionListener() {
		
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			java.sql.Connection conn = null;
			try {
				String dbURL = "jdbc:sqlserver://DESKTOP-B8MNLSB\\SQLEXPRESS:1433;databaseName=QLHV_JAVA;user=sa;password=aloxinh123";
	            conn = DriverManager.getConnection(dbURL);
	            java.sql.Statement s = conn.createStatement();
	            
	            //truy vấn xóa SQL SERVER
	            int n = s.executeUpdate("delete FROM [QLHV_JAVA].[dbo].[Diem] WHERE MaSV = '"+tfmaSV.getText()+"'");
	            s.executeUpdate("delete FROM [QLHV_JAVA].[dbo].[SinhVien] WHERE MaSV = '"+tfmaSV.getText()+"'");
	            if(n>0) {
	            	JOptionPane.showConfirmDialog(null, "Xóa Thành Công!!");
	            }
				
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
	});
}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.