Exemplo n.º 1
0
        public ObservableCollection <vo_NhanVien> getALlNhanVien()
        {
            try
            {
                dao_NhanVien dao = new dao_NhanVien();
                DataTable    dt  = dao.getAllNhanVien();
                ObservableCollection <vo_NhanVien> dsNhanVien = new ObservableCollection <vo_NhanVien>();
                foreach (DataRow dr in dt.Rows)
                {
                    vo_NhanVien vo = new vo_NhanVien();

                    vo.Id          = int.Parse(dr["ID"].ToString());
                    vo.IdChucVu    = int.Parse(dr["ID_CHUCVU"].ToString());
                    vo.MaNhanVien  = dr["MANHANVIEN"].ToString();
                    vo.HoTen       = dr["HOTEN"].ToString();
                    vo.NgaySinh    = dr["NGAYSINH"].ToString();
                    vo.NgayVaoLam  = dr["NGAYVAOLAM"].ToString();
                    vo.QueQuan     = dr["QUEQUAN"].ToString();
                    vo.SoDienThoai = dr["SODIENTHOAI"].ToString();
                    vo.SoTaiKhoan  = dr["SOTAIKHOAN"].ToString();
                    vo.Cmnd        = dr["CMND"].ToString();
                    vo.DiaChi      = dr["DIACHI"].ToString();
                    vo.GhiChu      = dr["GHICHU"].ToString();
                    vo.GioiTinh    = int.Parse(dr["GIOITINH"].ToString());

                    dsNhanVien.Add(vo);
                }
                return(dsNhanVien);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public vo_NhanVien getNhanVienById(int id)
        {
            try
            {
                dao_NhanVien dao = new dao_NhanVien();
                DataTable    dt  = dao.getNhanVienById(id);
                vo_NhanVien  vo  = new vo_NhanVien();

                DataRow dr = dt.Rows[0];
                vo.Id          = int.Parse(dr["ID"].ToString());
                vo.IdChucVu    = int.Parse(dr["ID_CHUCVU"].ToString());
                vo.MaNhanVien  = dr["MANHANVIEN"].ToString();
                vo.HoTen       = dr["HOTEN"].ToString();
                vo.NgaySinh    = dr["NGAYSINH"].ToString();
                vo.NgayVaoLam  = dr["NGAYVAOLAM"].ToString();
                vo.QueQuan     = dr["QUEQUAN"].ToString();
                vo.SoDienThoai = dr["SODIENTHOAI"].ToString();
                vo.SoTaiKhoan  = dr["SOTAIKHOAN"].ToString();
                vo.Cmnd        = dr["CMND"].ToString();
                vo.DiaChi      = dr["DIACHI"].ToString();
                vo.GhiChu      = dr["GHICHU"].ToString();
                vo.GioiTinh    = int.Parse(dr["GIOITINH"].ToString());

                return(vo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
 public int addNhanVien(vo_NhanVien vo_NV)
 {
     try
     {
         dao_NhanVien dao = new dao_NhanVien();
         int          id  = dao.insertNhanVien(vo_NV);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
 public int updateNhanVien(vo_NhanVien vo_NV)
 {
     try
     {
         dao_NhanVien dao = new dao_NhanVien();
         int          id  = dao.updateNhanVien(vo_NV);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
 public int updateNhanVien(params object[] oParams)
 {
     try
     {
         if (oParams != null)
         {
             vo_NhanVien vo_NV = (vo_NhanVien)oParams[0];
             string      query = "UPDATE NHANVIEN SET HOTEN=@hoTen, GIOITINH=@gioiTinh, NGAYSINH=@ngaySinh, CMND=@cmnd, DIACHI=@diaChi" +
                                 ", QUEQUAN=@queQuan, SOTAIKHOAN=@stk, SODIENTHOAI=@sdt, GHICHU=@ghiChu, NGAYVAOLAM=@ngayVaoLam, ID_CHUCVU=@idChucVu WHERE OUTPUT INSERTED.ID ID=@id";
             ConnectionString cnn      = new ConnectionString();
             string[]         arrParam = new string[] { "@hoTen", "@gioiTinh", "@ngaySinh", "@cmnd", "@diaChi", "@queQuan", "@stk", "@sdt", "@ghiChu", "@ngayVaoLam", "@idChucVu", "@id" };
             SqlDbType[]      arrType  = new SqlDbType[] { SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar,
                                                           SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Int };
             object[] arrvalues = new object[] { vo_NV.HoTen, vo_NV.GioiTinh, vo_NV.NgaySinh, vo_NV.Cmnd,
                                                 vo_NV.DiaChi, vo_NV.QueQuan, vo_NV.SoTaiKhoan, vo_NV.SoDienThoai, vo_NV.GhiChu, vo_NV.NgayVaoLam, vo_NV.IdChucVu, vo_NV.Id };
             return(cnn.conn.ExecuteQueryReturnID(query, arrParam, arrvalues, arrType));
         }
         return(0);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
 public int insertNhanVien(params object[] oParams)
 {
     try
     {
         if (oParams != null)
         {
             vo_NhanVien      vo_NV = (vo_NhanVien)oParams[0];
             ConnectionString cnn   = new ConnectionString();
             string           query = "INSERT INTO NHANVIEN (MANHANVIEN, HOTEN, GIOITINH, NGAYSINH, CMND, DIACHI, QUEQUAN, SOTAIKHOAN, SODIENTHOAI, GHICHU, NGAYVAOLAM, ID_CHUCVU) " +
                                      "output INSERTED.ID VALUES(@maNV, @hoTen, @gioiTinh, @ngaySinh, @cmnd, @diaChi, @queQuan, @stk, @sdt, @ghiChu, @ngayVaoLam, @idChucVu)";
             string[]    arrParam = new string[] { "@maNV", "@hoTen", "@gioiTinh", "@ngaySinh", "@cmnd", "@diaChi", "@queQuan", "@stk", "@sdt", "@ghiChu", "@ngayVaoLam", "@idChucVu" };
             SqlDbType[] arrType  = new SqlDbType[] { SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar,
                                                      SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Int };
             object[] arrvalues = new object[] { vo_NV.MaNhanVien, vo_NV.HoTen, vo_NV.GioiTinh, vo_NV.NgaySinh, vo_NV.Cmnd,
                                                 vo_NV.DiaChi, vo_NV.QueQuan, vo_NV.SoTaiKhoan, vo_NV.SoDienThoai, vo_NV.GhiChu, vo_NV.NgayVaoLam, vo_NV.IdChucVu };
             return(cnn.conn.ExecuteQueryReturnID(query, arrParam, arrvalues, arrType));
         }
         return(0);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }