Example #1
0
        private void dtgvPhieuMuon_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (dtgvPhieuMuon.Tag + "" != "1" || e.RowIndex == dtgvPhieuMuon.Rows.Count - 1)
            {
                dtgvChiTiet.Rows.Clear();
                return;
            }
            dtgvChiTiet.Rows.Clear();
            clsMuonTraSach_ChiTiet cls = new clsMuonTraSach_ChiTiet();

            cls.ID_MuonSach = int.Parse(dtgvPhieuMuon.Rows[e.RowIndex].Cells["ID_MuonSach"].Value.ToString());
            DataTable dt = cls.Select_wID_MuonSach();

            foreach (DataRow drCT in dt.Rows)
            {
                DataGridViewRow row = (DataGridViewRow)dtgvChiTiet.Rows[0].Clone();
                row.Cells[0].Value = drCT["Ten_Sach"];
                row.Cells[1].Value = drCT["SoLuong"];
                dtgvChiTiet.Rows.Add(row);
            }
        }
Example #2
0
        private void LoadForm()
        {
            LoadCmbDocGia();
            LoadCmbSach();
            dgvChiTiet.Rows.Clear();
            if (m_iID_MuonSach > 0)
            {
                clsMuonTraSach cls = new clsMuonTraSach();
                cls.ID_MuonSach = m_iID_MuonSach;
                DataRow dr = cls.SelectOne().Rows[0];
                cbDocGia.SelectedValue = dr["ID_DocGia"];
                dtpNgayMuon.Value      = dr.Field <DateTime>("NgayMuon");
                dtpNgayTra.Value       = dr.Field <DateTime>("NgayTra");

                if (dr.IsNull("NgayTra_ThucTe"))
                {
                    dtpNgayTra_ThucTe.Checked = false;
                }
                else
                {
                    dtpNgayTra_ThucTe.Checked = true;
                    dtpNgayTra_ThucTe.Value   = dr.Field <DateTime>("NgayTra_ThucTe");
                }

                clsMuonTraSach_ChiTiet clsCT = new clsMuonTraSach_ChiTiet();
                clsCT.ID_MuonSach = m_iID_MuonSach;
                DataTable dtCT = clsCT.Select_wID_MuonSach();

                foreach (DataRow drCT in dtCT.Rows)
                {
                    DataGridViewRow row = (DataGridViewRow)dgvChiTiet.Rows[0].Clone();
                    row.Cells[0].Value = drCT["ID_Sach"];
                    row.Cells[1].Value = drCT["Ten_Sach"];
                    row.Cells[2].Value = drCT["SoLuong"];
                    dgvChiTiet.Rows.Add(row);
                }
            }
        }