Beispiel #1
0
 private void dgvSach_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     for (int i = 0; i < dgvSach.Rows.Count; i++)
     {
         for (int j = 0; j < dgvSach.Columns.Count; j++)
         {
             if (dgvSach.Rows[i].Cells[j].Selected == true)
             {
                 lbMaSach.Text   = dgvSach.Rows[i].Cells[0].Value.ToString();
                 lbTenSach.Text  = dgvSach.Rows[i].Cells[1].Value.ToString();
                 lbTacGia.Text   = BUS_OBJ.layTenTacGia(dgvSach.Rows[i].Cells[2].Value.ToString());
                 lbTheLoai.Text  = BUS_OBJ.layTenTheLoai(dgvSach.Rows[i].Cells[3].Value.ToString());
                 lbNXB.Text      = BUS_OBJ.layTenNXB(dgvSach.Rows[i].Cells[4].Value.ToString());
                 lbNamXB.Text    = dgvSach.Rows[i].Cells[5].Value.ToString();
                 lbSoTrang.Text  = dgvSach.Rows[i].Cells[6].Value.ToString();
                 lbGia.Text      = dgvSach.Rows[i].Cells[7].Value.ToString();
                 lbSoBan.Text    = dgvSach.Rows[i].Cells[8].Value.ToString();
                 lbSoBanTon.Text = dgvSach.Rows[i].Cells[9].Value.ToString();
             }
         }
     }
     lbMaSach.Show();
     lbTenSach.Show();
     lbTacGia.Show();
     lbTheLoai.Show();
     lbNXB.Show();
     lbNamXB.Show();
     lbSoTrang.Show();
     lbGia.Show();
     lbSoBan.Show();
     lbSoBanTon.Show();
 }
Beispiel #2
0
 private void hieuChinhDGV()
 {
     dgvSach.DefaultCellStyle.Alignment            = DataGridViewContentAlignment.MiddleRight;
     dgvSach.Columns[0].HeaderText                 = "Mã sách";
     dgvSach.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
     dgvSach.Columns[0].Width      = 50;
     dgvSach.Columns[1].HeaderText = "Tên sách";
     dgvSach.Columns[1].Width      = 264;
     dgvSach.Columns[2].HeaderText = "Mã tác giả";
     dgvSach.Columns[2].Width      = 68;
     dgvSach.Columns[3].HeaderText = "Mã thể loại";
     dgvSach.Columns[3].Width      = 68;
     dgvSach.Columns[4].HeaderText = "Mã nhà xuất bản";
     dgvSach.Columns[4].Width      = 80;
     dgvSach.Columns[5].HeaderText = "Năm xuất bản";
     dgvSach.Columns[5].Width      = 80;
     dgvSach.Columns[6].HeaderText = "Số trang";
     dgvSach.Columns[6].Width      = 60;
     dgvSach.Columns[7].HeaderText = "Giá";
     dgvSach.Columns[7].Width      = 46;
     dgvSach.Columns[8].HeaderText = "Số bản";
     dgvSach.Columns[8].Width      = 50;
     dgvSach.Columns[9].HeaderText = "Tồn";
     dgvSach.Columns[9].Width      = 50;
     foreach (DataGridViewColumn col in dgvSach.Columns)
     {
         col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
         col.HeaderCell.Style.Font      = new Font("Segoe UI", 12F, FontStyle.Bold, GraphicsUnit.Pixel);
     }
     if (dgvSach.Rows.Count == 2)
     {
         lbMaSach.Text   = dgvSach.Rows[0].Cells[0].Value.ToString();
         lbTenSach.Text  = dgvSach.Rows[0].Cells[1].Value.ToString();
         lbTacGia.Text   = BUS_OBJ.layTenTacGia(dgvSach.Rows[0].Cells[2].Value.ToString());
         lbTheLoai.Text  = BUS_OBJ.layTenTheLoai(dgvSach.Rows[0].Cells[3].Value.ToString());
         lbNXB.Text      = BUS_OBJ.layTenNXB(dgvSach.Rows[0].Cells[4].Value.ToString());
         lbNamXB.Text    = dgvSach.Rows[0].Cells[5].Value.ToString();
         lbSoTrang.Text  = dgvSach.Rows[0].Cells[6].Value.ToString();
         lbGia.Text      = dgvSach.Rows[0].Cells[7].Value.ToString();
         lbSoBan.Text    = dgvSach.Rows[0].Cells[8].Value.ToString();
         lbSoBanTon.Text = dgvSach.Rows[0].Cells[9].Value.ToString();
         lbMaSach.Show();
         lbTenSach.Show();
         lbTacGia.Show();
         lbTheLoai.Show();
         lbNXB.Show();
         lbNamXB.Show();
         lbSoTrang.Show();
         lbGia.Show();
         lbSoBan.Show();
         lbSoBanTon.Show();
     }
 }