Quản lý nhân sự công ty bằng c# _ full source code
62.175 lượt xem;
- clschitiethopdong.cs
- Class /
- QuanLyNhanSu /
- project /
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Windows.Forms;
5 using System.Data.SqlClient;
6 using System.Collections;
7 using System.Data;
8 namespace QuanLyNhanSu.Class
9 {
10 class clschitiethopdong
11 {
12 public QuanLyNhanSu.Class.sql sql = new QuanLyNhanSu.Class.sql();
13 public SqlConnection sc = frmMain.me.sql.connectSQL();
14 public SqlDataAdapter sda = new SqlDataAdapter();
15 public DataSet ds = new DataSet();
16 public DataSet ds1 = new DataSet();
17 //lấy dữ liệu theo mã nhân viên
18 public DataSet laydl(string manv)
19 {
20 ds.Clear();
21 string sel_ = " select a.sohd,a.manv,a.maloaihd,b.tenloaihd,a.ngayky,a.ngayketthuc,a.luongcoban"
22 + " from tbl_chitiethopdong a inner join tbl_loaihd b on a.maloaihd=b.maloaihd where a.manv ='"+manv+"'";
23 sc.Open();
24 SqlCommand sel = new SqlCommand(sel_, sc);
25 sda.SelectCommand = sel;
26 sda.Fill(ds, "NV_HopDong");
27 sc.Close();
28 return ds;
29 }
30 //thêm dữ liệu trong tbl_Chitiethopdong
31 public void them(string sohd_1, int maloaihd_2, string manv_3, DateTime ngayky_4, DateTime ngaykt_5, int luongcb_6)
32 {
33 sql.ExecuteNonQuery("Insert_tbl_ChitietHopDong", CommandType.StoredProcedure, "@SoHD_1", sohd_1,
34 "@MaLoaiHD_2", maloaihd_2,
35 "@MaNV_3", manv_3,
36 "@NgayKy_4", ngayky_4,
37 "@NgayKetThuc_5", ngaykt_5,
38 "@LuongCoBan_6", luongcb_6);
39
40 }
41 //xóa dữ liệu trong tbl_ChiTietHopDong
42 public void xoa(string sohd_1)
43 {
44
45 sql.ExecuteNonQuery("Delete_tbl_ChiTietHopDong", CommandType.StoredProcedure, "@SoHD_1", sohd_1);
46
47 }
48 //sửa dữ liệu trong tbl_ChiTietHopDong
49 public void sua(string sohd_1, int maloaihd_2, string manv_3, DateTime ngayky_4, DateTime ngaykt_5, int luongcb_6)
50 {
51
52 sql.ExecuteNonQuery("Update_tbl_ChitietHopDong", CommandType.StoredProcedure, "@SoHD_1", sohd_1,
53 "@MaLoaiHD_2", maloaihd_2,
54 "@MaNV_3", manv_3,
55 "@NgayKy_4", ngayky_4,
56 "@NgayKetThuc_5", ngaykt_5,
57 "@LuongCoBan_6", luongcb_6);
58 }
59 //kiểm tra xem nhân viên đó có hợp đồng hay không
60 public bool kiemtra(string ma)
61 {
62 sc.Open();
63 string sel_ = "select manv from tbl_ChiTietHopDong where manv ='" + ma + "'";
64 SqlCommand sel = new SqlCommand(sel_, sc);
65 object o = sel.ExecuteScalar();
66 sc.Close();
67 if (o == null)
68 return false;
69 else
70 return true;
71 }
72 //lấy dữ liệu theo mã hợp đồng
73 public DataTable laytthd(string ma)
74 {
75 ds.Clear();
76 sc.Open();
77 string sel_ = " select * from tbl_ChiTietHopDong where SoHD = '" + ma + "'";
78 SqlCommand sel = new SqlCommand(sel_, sc);
79 sda.SelectCommand = sel;
80 sda.Fill(ds, "HopDong");
81 sc.Close();
82 return ds.Tables["HopDong"];
83 }
84 //lấy ra những nv có hợp đồng đã hết hạn
85 public DataTable layNV_HDhethan(string chuoidk)
86 {
87 ds1.Clear();
88 sc.Open();
89 sql.ExecuteNonQuery("kiemtrahopdong", CommandType.StoredProcedure);
90 string sel = "Select * from view_KTHDhethan where "+chuoidk;
91 SqlCommand scmd = new SqlCommand(sel, sc);
92 sda.SelectCommand = scmd;
93 sda.Fill(ds1,"NV_HDhethan");
94 sc.Close();
95 return ds1.Tables["NV_HDhethan"];
96 }
97 //Lấy mã hợp đồng cuối cùng
98 public string laysohd()
99 {
100 string sel = "select top 1 percent sohd from tbl_chitiethopdong order by sohd desc";
101 sc.Open();
102 SqlCommand sel1 = new SqlCommand(sel, sc);
103 object o = sel1.ExecuteScalar();
104 sc.Close();
105 return o.ToString();
106 }
107 }
108 }
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Windows.Forms;
5 using System.Data.SqlClient;
6 using System.Collections;
7 using System.Data;
8 namespace QuanLyNhanSu.Class
9 {
10 class clschitiethopdong
11 {
12 public QuanLyNhanSu.Class.sql sql = new QuanLyNhanSu.Class.sql();
13 public SqlConnection sc = frmMain.me.sql.connectSQL();
14 public SqlDataAdapter sda = new SqlDataAdapter();
15 public DataSet ds = new DataSet();
16 public DataSet ds1 = new DataSet();
17 //lấy dữ liệu theo mã nhân viên
18 public DataSet laydl(string manv)
19 {
20 ds.Clear();
21 string sel_ = " select a.sohd,a.manv,a.maloaihd,b.tenloaihd,a.ngayky,a.ngayketthuc,a.luongcoban"
22 + " from tbl_chitiethopdong a inner join tbl_loaihd b on a.maloaihd=b.maloaihd where a.manv ='"+manv+"'";
23 sc.Open();
24 SqlCommand sel = new SqlCommand(sel_, sc);
25 sda.SelectCommand = sel;
26 sda.Fill(ds, "NV_HopDong");
27 sc.Close();
28 return ds;
29 }
30 //thêm dữ liệu trong tbl_Chitiethopdong
31 public void them(string sohd_1, int maloaihd_2, string manv_3, DateTime ngayky_4, DateTime ngaykt_5, int luongcb_6)
32 {
33 sql.ExecuteNonQuery("Insert_tbl_ChitietHopDong", CommandType.StoredProcedure, "@SoHD_1", sohd_1,
34 "@MaLoaiHD_2", maloaihd_2,
35 "@MaNV_3", manv_3,
36 "@NgayKy_4", ngayky_4,
37 "@NgayKetThuc_5", ngaykt_5,
38 "@LuongCoBan_6", luongcb_6);
39
40 }
41 //xóa dữ liệu trong tbl_ChiTietHopDong
42 public void xoa(string sohd_1)
43 {
44
45 sql.ExecuteNonQuery("Delete_tbl_ChiTietHopDong", CommandType.StoredProcedure, "@SoHD_1", sohd_1);
46
47 }
48 //sửa dữ liệu trong tbl_ChiTietHopDong
49 public void sua(string sohd_1, int maloaihd_2, string manv_3, DateTime ngayky_4, DateTime ngaykt_5, int luongcb_6)
50 {
51
52 sql.ExecuteNonQuery("Update_tbl_ChitietHopDong", CommandType.StoredProcedure, "@SoHD_1", sohd_1,
53 "@MaLoaiHD_2", maloaihd_2,
54 "@MaNV_3", manv_3,
55 "@NgayKy_4", ngayky_4,
56 "@NgayKetThuc_5", ngaykt_5,
57 "@LuongCoBan_6", luongcb_6);
58 }
59 //kiểm tra xem nhân viên đó có hợp đồng hay không
60 public bool kiemtra(string ma)
61 {
62 sc.Open();
63 string sel_ = "select manv from tbl_ChiTietHopDong where manv ='" + ma + "'";
64 SqlCommand sel = new SqlCommand(sel_, sc);
65 object o = sel.ExecuteScalar();
66 sc.Close();
67 if (o == null)
68 return false;
69 else
70 return true;
71 }
72 //lấy dữ liệu theo mã hợp đồng
73 public DataTable laytthd(string ma)
74 {
75 ds.Clear();
76 sc.Open();
77 string sel_ = " select * from tbl_ChiTietHopDong where SoHD = '" + ma + "'";
78 SqlCommand sel = new SqlCommand(sel_, sc);
79 sda.SelectCommand = sel;
80 sda.Fill(ds, "HopDong");
81 sc.Close();
82 return ds.Tables["HopDong"];
83 }
84 //lấy ra những nv có hợp đồng đã hết hạn
85 public DataTable layNV_HDhethan(string chuoidk)
86 {
87 ds1.Clear();
88 sc.Open();
89 sql.ExecuteNonQuery("kiemtrahopdong", CommandType.StoredProcedure);
90 string sel = "Select * from view_KTHDhethan where "+chuoidk;
91 SqlCommand scmd = new SqlCommand(sel, sc);
92 sda.SelectCommand = scmd;
93 sda.Fill(ds1,"NV_HDhethan");
94 sc.Close();
95 return ds1.Tables["NV_HDhethan"];
96 }
97 //Lấy mã hợp đồng cuối cùng
98 public string laysohd()
99 {
100 string sel = "select top 1 percent sohd from tbl_chitiethopdong order by sohd desc";
101 sc.Open();
102 SqlCommand sel1 = new SqlCommand(sel, sc);
103 object o = sel1.ExecuteScalar();
104 sc.Close();
105 return o.ToString();
106 }
107 }
108 }