private void BindData(DataGridViewCellEventArgs e) { if (e.RowIndex == -1 || e.RowIndex == grvProductList.RowCount - 1 || e.RowIndex == 0) { return; } btDelete.Visible = true; btAddNew.Visible = true; DataGridViewRow row = grvProductList.Rows[e.RowIndex]; int productId = int.Parse(row.Cells[Constant.ProductSearch.ProductGridColumnName.PRODUCT_ID].Value.ToString()); int prodId = int.Parse(row.Cells[Constant.ProductSearch.ProductGridColumnName.ProdId].Value.ToString()); if (cboxStoreFind.SelectedValue != null) { storeId = int.Parse(cboxStoreFind.SelectedValue.ToString()); } JSManagementDataSet.ProductDataTable productDataTable = productTableAdapter.GetProductById(productId, storeId); JSManagementDataSet.ProdDataTable prodDataTable = prodTableAdapter.GetDataById(prodId); string productCode = prodDataTable[0].ProductCode; string brand = prodDataTable[0].Brand; string productType = prodDataTable[0].ProductType; decimal productCost = productDataTable[0].ProductCost; decimal price = productDataTable[0].Price; decimal price2 = productDataTable[0].Price2; decimal price3 = productDataTable[0].Price3; decimal price4 = productDataTable[0].Price4; string size = productDataTable[0].Size; string imageUrls = productDataTable[0].ImageUrls; lbProductHeader.Text = string.Format("Sửa mã hàng {0} Hiệu:{1} Size:{2}", productCode, brand, size); txtProductCode.Text = productCode; cbBoxProductType.Text = productType; cbBoxBrand.Text = brand; lbProductId.Text = productId.ToString(); lbProdId.Text = productDataTable[0].ProdId.ToString(); txtPrice.Text = price.ToString("#,###"); txtPrice2.Text = price2 == 0? "0": price2.ToString("#,###"); txtPrice3.Text = price3 == 0 ? "0" : price3.ToString("#,###"); txtPrice4.Text = price4 == 0 ? "0" : price4.ToString("#,###"); cbBoxSize.Text = size; txtInputPrice.Text = productCost == 0 ? "0" : productCost.ToString("#,###"); txtNote.Text = prodDataTable[0].Note == null ? string.Empty: prodDataTable[0].Note; grvProductInOutDetail.DataSource = getProductInOutDetailTableAdapter.GetProductInOutDetailByProductId(productId, storeId); FormatProductInOutDetailGridview(); panelPicture.Controls.Clear(); if (imageUrls != null) { string[] imglinks = imageUrls.Split(','); if (!imageUrls.Contains(",")) { imglinks.SetValue(imageUrls, 0); } int p = -80; foreach (var link in imglinks) { if (link.Equals(imglinks[0])) { p += 80; WebRequest req = WebRequest.Create(link); WebResponse res = req.GetResponse(); Stream imgStream = res.GetResponseStream(); Image img1 = Image.FromStream(imgStream); imgStream.Close(); PictureBox pic = new PictureBox(); pic.Click += pic_Click; pic.Height = 80; pic.Width = 80; pic.Image = img1; pic.SizeMode = PictureBoxSizeMode.StretchImage; pic.Location = new Point(p, 0); panelPicture.Controls.Add(pic); } } } }