Ejemplo n.º 1
0
        //TheKhachHang_BUS theKH_BUS = new TheKhachHang_BUS();
        //LoaiTheKhachHang_BUS loaiTheKH_BUS = new LoaiTheKhachHang_BUS();
        //List<clsTheKhachHang> lstTheKH;
        //List<clsLoaiTheKhachHang> lstLoaiTheKH;
        private void HienThiDSTheKhachHang(string ma, string ten)
        {
            TheKhachHang_BUS           theKH_BUS     = new TheKhachHang_BUS();
            LoaiTheKhachHang_BUS       loaiTheKH_BUS = new LoaiTheKhachHang_BUS();
            List <clsTheKhachHang>     lstTheKH      = theKH_BUS.LayDanhSachTheKH(ma, ten);
            List <clsLoaiTheKhachHang> lstLoaiTheKH  = loaiTheKH_BUS.LayLoaiTheKhachHang();

            var query = from theKH in lstTheKH
                        join loaiTheKH in lstLoaiTheKH
                        on theKH.MaLoaiThe equals loaiTheKH.MaLoaiThe
                        select new
            {
                theKH.MaThe,
                theKH.MaKhachHang,
                theKH.MaLoaiThe,
                theKH.NgayDangKy,
                theKH.TrangThai,
                loaiTheKH.TenLoaiTheKH,
                loaiTheKH.DonViGiamGia,
                loaiTheKH.GiamGia
            };

            dgvDSTheKH.AutoGenerateColumns = false;
            //dgvDSTheKH.DataSource = lstTheKH;
            dgvDSTheKH.DataSource = query.ToList();
        }
Ejemplo n.º 2
0
        private void dgvDSTheKH_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (dgvDSTheKH.Columns[e.ColumnIndex].Name.ToString() == "colTrangThai")
            {
                if (Convert.ToBoolean(e.Value) == true)
                {
                    e.Value = "Mở";
                }
                else
                {
                    e.Value = "Khóa";
                }
            }

            if (dgvDSTheKH.Columns[e.ColumnIndex].Name.ToString() == "colTenKH")
            {
                KhachHang_BUS           bus   = new KhachHang_BUS();
                List <clsKhachHang_DTO> lstKH = bus.LayDanhSachKhachHang("", -1);
                clsKhachHang_DTO        KH    = lstKH.First(u => u.MaKhachHang == e.Value.ToString());
                e.Value = KH.TenKhachHang;
            }


            LoaiTheKhachHang_BUS       LoaiTheKH_bus = new LoaiTheKhachHang_BUS();
            List <clsLoaiTheKhachHang> lstLoaiTheKH  = LoaiTheKH_bus.LayLoaiTheKhachHang();

            if (dgvDSTheKH.Columns[e.ColumnIndex].Name.ToString() == "colLoaiThe")
            {
                clsLoaiTheKhachHang LoaiTheKH = lstLoaiTheKH.First(u => u.MaLoaiThe == e.Value.ToString());
                e.Value = LoaiTheKH.TenLoaiTheKH;
            }

            //if (dgvDSTheKH.Columns[e.ColumnIndex].Name.ToString() == "colGiamGia")
            //{
            //  e.Value = lstLoaiTheKH[0].GiamGia;
            //}

            //if (dgvDSTheKH.Columns[e.ColumnIndex].Name.ToString() == "colDonViGiamGia")
            //{
            //  e.Value = lstLoaiTheKH[0].DonViGiamGia;
            //}



            if (dgvDSTheKH.Columns[e.ColumnIndex].Name.ToString() == "colNgayDangKy")
            {
                e.Value = DateTime.Parse(e.Value.ToString()).ToShortDateString();
            }


            foreach (DataGridViewRow r in dgvDSTheKH.Rows)
            {
                if (!Convert.ToBoolean(r.Cells["colTrangThai"].Value.ToString()))
                {
                    r.DefaultCellStyle.ForeColor = Color.Gray;
                }
                else
                {
                    r.DefaultCellStyle.ForeColor = Color.Black;
                }
            }
        }