private void LoadDataInto_DataGridViewOfTitle() { List <titlesDTO> listTitles = titlesBUS.selectedTitle(); if (listTitles == null) { MessageBox.Show("Chưa có thông tin đầu sách"); } dgvTitlesManage.Columns.Clear(); dgvTitlesManage.DataSource = null; dgvTitlesManage.ReadOnly = true; dgvTitlesManage.AutoGenerateColumns = false; dgvTitlesManage.AllowUserToAddRows = false; dgvTitlesManage.DataSource = listTitles; DataGridViewTextBoxColumn clTitlesCode = new DataGridViewTextBoxColumn(); clTitlesCode.Name = "authCode"; clTitlesCode.HeaderText = "Mã đầu sách"; clTitlesCode.DataPropertyName = "MaDauSach"; dgvTitlesManage.Columns.Add(clTitlesCode); DataGridViewTextBoxColumn clTitlesName = new DataGridViewTextBoxColumn(); clTitlesName.Name = "titlesName"; clTitlesName.HeaderText = "Tên đầu sách"; clTitlesName.DataPropertyName = "TenDauSach"; dgvTitlesManage.Columns.Add(clTitlesName); DataGridViewTextBoxColumn clSumTitles = new DataGridViewTextBoxColumn(); clSumTitles.Name = "sumTitles"; clSumTitles.HeaderText = "Tổng số lượng"; clSumTitles.DataPropertyName = "TongSoLuongTrongKho"; // haven't counted amout of titles yet dgvTitlesManage.Columns.Add(clSumTitles); DataGridViewTextBoxColumn clBorrowedAmoutTitles = new DataGridViewTextBoxColumn(); clBorrowedAmoutTitles.Name = "borrowedAmoutTitles"; clBorrowedAmoutTitles.HeaderText = "Số lượng đã mượn"; clBorrowedAmoutTitles.DataPropertyName = "SoLuotMuon"; // haven't counted amout of titles are being borrowed yet dgvTitlesManage.Columns.Add(clBorrowedAmoutTitles); DataGridViewTextBoxColumn clRemainingAmoutTitles = new DataGridViewTextBoxColumn(); clRemainingAmoutTitles.Name = " remainingAmoutTitles"; clRemainingAmoutTitles.HeaderText = "Số lượng còn lại"; clRemainingAmoutTitles.DataPropertyName = "SoLuongConLai"; // haven't counted amout of titles are remaining yet dgvTitlesManage.Columns.Add(clRemainingAmoutTitles); }
private void LoadTitlesInto_ComboBox() { List <titlesDTO> listTitles = titlesBUS.selectedTitle(); if (cbTitleName == null) { MessageBox.Show("DB chưa có thông tin của bất cứ đầu sách nào"); return; } cbTitleName.DataSource = new BindingSource(listTitles, String.Empty); cbTitleName.DisplayMember = "TenDauSach"; cbTitleName.ValueMember = "MaDauSach"; CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[cbTitleName.DataSource]; myCurrencyManager.Refresh(); if (cbTitleName.Items.Count > 0) { cbTitleName.SelectedIndex = 0; } }