コード例 #1
0
        public NhanVienChucVuDTO LayNhanVienChucVuTheoMaNVMaCVTuNgay(int maNV, int maCV, string tungay)
        {
            NhanVienChucVuDTO nhanVienChucVu = new NhanVienChucVuDTO();

            KetNoiCSDL.MoKetNoi();
            DateTime   dt        = DateTime.ParseExact(tungay, "dd/MM/yyyy", null);
            string     sqlSelect = "Select * from nhanvien_chucvu where manhanvien=@manv and machucvu=@macv and tungay=@ngay";
            SqlCommand cmd       = new SqlCommand(sqlSelect, KetNoiCSDL.KetNoi);

            cmd.Parameters.Add("manv", maNV);
            cmd.Parameters.Add("macv", maCV);
            cmd.Parameters.Add("ngay", dt.ToString("MM/dd/yyyy"));

            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                DateTime date = DateTime.Parse(dr["denngay"].ToString());
                nhanVienChucVu.MaNhanVien = maNV;
                nhanVienChucVu.MaChucVu   = maCV;
                nhanVienChucVu.TuNgay     = tungay;
                nhanVienChucVu.DenNgay    = date.ToString("dd/MM/yyyy");
            }

            KetNoiCSDL.DongKetNoi();
            return(nhanVienChucVu);
        }
コード例 #2
0
        public List <NhanVienChucVuDTO> LayNhanVienChucVuTheoMaNVMaCV(int manv, int macv)
        {
            List <NhanVienChucVuDTO> ds = new List <NhanVienChucVuDTO>();

            KetNoiCSDL.MoKetNoi();

            string     sqlSelect = "select tungay from nhanvien_chucvu where manhanvien=@manv and machucvu=@macv";
            SqlCommand cmd       = new SqlCommand(sqlSelect, KetNoiCSDL.KetNoi);

            cmd.Parameters.Add("manv", manv);
            cmd.Parameters.Add("macv", macv);

            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                DateTime          dt = DateTime.Parse(dr["tungay"].ToString());
                NhanVienChucVuDTO nv = new NhanVienChucVuDTO(
                    manv, macv,
                    dt.ToString("dd/MM/yyyy"),
                    ""
                    );
                ds.Add(nv);
            }

            KetNoiCSDL.DongKetNoi();
            return(ds);
        }