コード例 #1
0
        //public void Insert(NhanVien obj)
        //{
        //    db.Insert("INSERT INTO `nhanvien` (`MaNhanVien`, `MaPB`, `MaCV`, `HeSoLuong`, `TenNV`, `GioiTinh`, `NgaySinh`, `NgayVaoLam`, `SoCM`, `DienThoai`, `DiaChi`, `Email`) VALUES('"+obj.MaNhanVien+"', '"+obj.MaPB+"', '"+obj.MaCV+"', '"+obj.HeSoLuong+"', '"+obj.TenNV+"', '"+obj.GioiTinh+"', '"+obj.NgaySinh+"', '"+obj.NgayVaoLam+"', '"+obj.SoCM+"', '"+obj.DienThoai+"', '"+obj.DiaChi+"', '"+obj.DiaChi+"')");
        //}



        public void Update(NhanVien obj)
        {
            db.Update("UPDATE `nhanvien` SET `MaPB` = '" + obj.MaPB + "', `MaCV` = '" + obj.MaCV + "', `HeSoLuong` = '" + obj.HeSoLuong + "', `TenNV` = '" + obj.TenNV + "', `GioiTinh` = '" + obj.GioiTinh + "', `NgaySinh` = '" + obj.NgaySinh + "',`NgayVaoLam` = '" + obj.NgayVaoLam + "',`SoCM` = '" + obj.SoCM + "',`SoCM` = '" + obj.SoCM + "',`DienThoai` = '" + obj.DienThoai + "',`DiaChi` = '" + obj.DiaChi + "',`Email` = '" + obj.Email + "' WHERE `nhanvien`.`MaNhanVien` = '" + obj.MaNhanVien + "'");
        }
コード例 #2
0
        // Loc Nhan Vien
        public List <NhanVien> LocDSNhanVien(NhanVien nv)
        {
            try
            {
                OpenConnection();
                List <NhanVien> nvlist     = new List <NhanVien>();
                SqlCommand      sqlCommand = new SqlCommand();
                SqlDataReader   sqlReader  = null;
                DataTable       dt         = new DataTable();

                if (nv.Search == "Mã Nhân Viên")
                {
                    sqlCommand.CommandType = CommandType.Text;
                    sqlCommand.CommandText = "SELECT MANV FROM dbo.NHANVIEN";
                    sqlCommand.Connection  = conn;
                    sqlReader = sqlCommand.ExecuteReader();

                    dt.Load(sqlReader);

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        NhanVien nvs = new NhanVien();
                        nvs.MaNv = int.Parse(dt.Rows[i][0].ToString());

                        nvlist.Add(nvs);
                    }
                }
                else if (nv.Search == "Họ Tên")
                {
                    sqlCommand.CommandText = "SELECT HOTEN FROM dbo.NHANVIEN";
                    sqlCommand.Connection  = conn;
                    sqlReader = sqlCommand.ExecuteReader();

                    dt.Load(sqlReader);

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        NhanVien nvs = new NhanVien();
                        nvs.Hoten = dt.Rows[i][0].ToString();

                        nvlist.Add(nvs);
                    }
                }
                else if (nv.Search == "Ngày Sinh")
                {
                    sqlCommand.CommandText = "SELECT NGAYSINH FROM dbo.NHANVIEN";
                    sqlCommand.Connection  = conn;
                    sqlReader = sqlCommand.ExecuteReader();
                    dt.Load(sqlReader);

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        NhanVien nvs = new NhanVien();
                        nvs.NgaySinh = DateTime.Parse(dt.Rows[i][0].ToString());

                        nvlist.Add(nvs);
                    }
                }
                else if (nv.Search == "Số Điện Thoại")
                {
                    sqlCommand.CommandText = "SELECT SDT FROM dbo.NHANVIEN";
                    sqlCommand.Connection  = conn;
                    sqlReader = sqlCommand.ExecuteReader();
                    dt.Load(sqlReader);

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        NhanVien nvs = new NhanVien();
                        nvs.Sdt = int.Parse(dt.Rows[i][0].ToString());

                        nvlist.Add(nvs);
                    }
                }
                else if (nv.Search == "Mail")
                {
                    sqlCommand.CommandText = "SELECT MAIL FROM dbo.NHANVIEN";
                    sqlCommand.Connection  = conn;
                    sqlReader = sqlCommand.ExecuteReader();
                    dt.Load(sqlReader);

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        NhanVien nvs = new NhanVien();
                        nvs.Mail = dt.Rows[i][0].ToString();

                        nvlist.Add(nvs);
                    }
                }
                else if (nv.Search == "Giới Tính")
                {
                    sqlCommand.CommandText = "SELECT DISTINCT(GT) FROM dbo.NHANVIEN";
                    sqlCommand.Connection  = conn;
                    sqlReader = sqlCommand.ExecuteReader();
                    dt.Load(sqlReader);

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        NhanVien nvs = new NhanVien();
                        nvs.GioTinh = dt.Rows[i][0].ToString();

                        nvlist.Add(nvs);
                    }
                }

                sqlReader.Close();
                return(nvlist);
            }
            catch
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }
コード例 #3
0
        public string GetTenNV(string ma)
        {
            NhanVien nv = da.NhanViens.Where(t => t.maNV == ma).SingleOrDefault();

            return(nv.tenNV);
        }
コード例 #4
0
        public int suaNhanVien(NhanVien nv)
        {
            string query = "UPDATE dbo.NhanVien SET TenNV=@ten,DiaChi=@dc,SDT=@sdt,NgaySinh=@ns,GT=@gt,ChucVu=@chv,Luongcb=@lucb,PhuCap=@pc,HSLuong=@hsl,Thuong=@thug WHERE MaNV=@manv";

            return(DatabaseDAL.executeNonQuery(query, nv.tenNV, nv.diaChi, nv.sDT, nv.ngaySinh, nv.gT, nv.chucVu, nv.luongCB, nv.phuCap, nv.hSLuong, nv.thuong, nv.maNV));
        }
コード例 #5
0
ファイル: NhanVien_DAL.cs プロジェクト: nguyenkhanh2003/DATN
        // Sửa dữ liệu khi không sửa mật khẩu

        //  XÓA DỮ LIỆU
        public void DeleteData(NhanVien ex)
        {
            KetNoi.ExecuteReader(@"update NhanVien Set TrangThai=N'0' Where MaNV='" + ex.MaNV + "'");
        }
コード例 #6
0
ファイル: NhanVien_DAL.cs プロジェクト: nguyenkhanh2003/DATN
 //  SỬA DỮ LIỆU
 public void EditData(NhanVien ex)
 {
     KetNoi.ExecuteReader(@"UPDATE NhanVien SET MaCV=N'" + ex.MaCV + "',TenNV=N'" + ex.TenNV + "',GioiTinh=N'" + ex.GioiTinh + "',Email=N'" + ex.Email + "',NgaySinh='" + ex.NgaySinh + "',DienThoai=N'" + ex.DienThoai + "',CMND=N'" + ex.CMND + "',DiaChi=N'" + ex.DiaChi + "',HinhAnh=N'" + ex.HinhAnh + "',UserName=N'" + ex.UserName + "',PassWord=N'" + ex.PassWord + "',TrangThai=N'" + ex.TrangThai + "' Where MaNV='" + ex.MaNV + "' ");
 }
コード例 #7
0
ファイル: NhanVien_DAL.cs プロジェクト: nguyenkhanh2003/DATN
 // THÊM DỮ LIỆU
 public void AddData(NhanVien ex)
 {
     KetNoi.ExecuteReader(@"INSERT INTO NhanVien(MaNV,MaCV,TenNV,GioiTinh,Email,NgaySinh,DienThoai,CMND,DiaChi,HinhAnh,UserName,PassWord,TrangThai)      
                            VALUES(N'" + ex.MaNV + "',N'" + ex.MaCV + "',N'" + ex.TenNV +
                          "',N'" + ex.GioiTinh + "',N'" + ex.Email + "',N'" + ex.NgaySinh + "',N'" + ex.DienThoai + "',N'" + ex.CMND + "',N'" + ex.DiaChi + "',N'" + ex.HinhAnh + "',N'" + ex.UserName + "',N'" + ex.PassWord + "',N'" + ex.TrangThai + "')");
 }