private void button7_Click(object sender, EventArgs e) { HidePanels(); menuStrip1.Visible = true; capnhatsoluong.Visible = true; tonkhobus tkbus = new tonkhobus(); danhsachtonkhodgv.DataSource = tkbus.listtonkho(); DataGridViewImageColumn ic = new DataGridViewImageColumn(); ic.HeaderText = "Hình ảnh"; ic.Image = null; ic.Name = "cImg"; ic.Width = 100; danhsachtonkhodgv.Columns.Insert(0, ic); danhsachtonkhodgv.Columns[1].Visible = false; foreach (DataGridViewRow row in danhsachtonkhodgv.Rows) { DataGridViewImageCell cell = row.Cells[0] as DataGridViewImageCell; string path = "default-product-image.jpg"; try { path = row.Cells[1].Value.ToString(); } catch (Exception) { } path = appPath + path; Console.WriteLine(path); cell.Value = Bitmap.FromFile(path); row.Height = 100; } }
private void luutonkhobtn_Click(object sender, EventArgs e) { tonkhodto tkdto = new tonkhodto(); tkdto.Manhaphang = madonnhaplbl.Text; tkdto.Mavp = masplbl.Text; tkdto.Ngayhethan = ngayhethan.Value.Date.ToShortDateString(); tkdto.Soluongnhap = Convert.ToInt32(soluongnhap.Value); tkdto.Soluongton = tkdto.Soluongnhap; tonkhobus tkbus = new tonkhobus(); tkbus.add(tkdto); thongtindonnhapdgv.DataSource = tkbus.listtonkho(tkdto.Manhaphang); }