private void dgvList_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } isSelect = true; var row = dgvList.Rows[e.RowIndex].DataBoundItem; string dirSource = dirImage; switch (type) { case 1: //Ebook vEbook obj = ((vEbook)row); id = obj.Id; txtFile.Text = obj.Path + @"\" + obj.Name + "." + obj.Format; txtTitle.Text = obj.Name; txtPage.Text = obj.Pages.ToString(); cboLanguage.SelectedValue = obj.LanguageId.Value; break; case 2: //Knowledge Knowledge.DBContext.Knowledge obj2 = ((Knowledge.DBContext.Knowledge)row); id = obj2.Id; txtTitle.Text = obj2.Title; rtbContent.Text = obj2.Description; cboLanguage.SelectedValue = 1002; //vn dirSource += @"\Knowledge\"; break; case 3: //Term Term obj3 = ((Term)row); id = obj3.Id; txtTitle.Text = obj3.Vn; rtbContent.Text = obj3.Description; cboLanguage.SelectedValue = 1002; //vn break; case 4: //Rule Knowledge.DBContext.Rule obj4 = ((Knowledge.DBContext.Rule)row); id = obj4.Id; txtTitle.Text = obj4.Title; rtbContent.Text = obj4.Description; cboLanguage.SelectedValue = 1002; //vn dirSource += @"\Rule\"; break; } string[] files = Directory.GetFiles(dirSource, "*" + id + "_*"); foreach (string file in files) { lstFile.Items.Add(file); } }
private void dgvList_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } string dirSource = dirImage; if (func == 1) { Knowledge.DBContext.Knowledge row = (Knowledge.DBContext.Knowledge)dgvList.Rows[e.RowIndex].DataBoundItem; id = row.Id; txtDescription.Text = row.Description; txtTitle.Text = row.Title.ToString(); cboType.SelectedValue = row.TypeId; chkIsFile.Checked = row.IsFile.Value; txtUrl.Text = row.Url; dirSource += @"\Knowledge\"; } else { Knowledge.DBContext.Rule row = (Knowledge.DBContext.Rule)dgvList.Rows[e.RowIndex].DataBoundItem; id = row.Id; txtDescription.Text = row.Description; txtTitle.Text = row.Title.ToString(); cboType.SelectedValue = row.TypeId; chkIsFile.Checked = row.IsFile.Value; txtUrl.Text = row.Url; dirSource += @"\Rule\"; } string [] files = Directory.GetFiles(dirSource, "*" + id + "_*"); foreach (string file in files) { lstFile.Items.Add(file); } }