private void gvchitietdonhang_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex > -1) { DataGridViewRow row = gvchitietdonhang.Rows[e.RowIndex]; frmhanghoa frmhh = new frmhanghoa(); hanghoa hh = frmhh.chitiethanghoa(row.Cells[1].Value.ToString()); txtnhapmahang.Text = hh.mahang.ToString(); txtnhapmaloai.Text = hh.maloai.ToString(); txtnhapmanhom.Text = hh.manhom.ToString(); txtnhaptenhang.Text = hh.tenhang.ToString(); txtnhapgia.Text = hh.gia.ToString(); txtnhaphinh.Text = hh.hinh.ToString(); txtnhapmota.Text = hh.mota.ToString(); string linkanh = tt.linkanh + hh.hinh.ToString(); try { picnhaphinh.Image = Image.FromFile(linkanh); picnhaphinh.SizeMode = PictureBoxSizeMode.StretchImage; } catch { picnhaphinh.Image = null; }; } } catch { }; }
public void themmanhinhhanghoa() { pnloadform.Controls.Clear(); frmhanghoa frmhh = new frmhanghoa(); frmhh.TopLevel = false; pnloadform.Controls.Add(frmhh); frmhh.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; frmhh.Dock = DockStyle.Fill; frmhh.Show(); }
private void btnthemvaodsmua_Click(object sender, EventArgs e) { frmhanghoa frmhh = new frmhanghoa(); try { hanghoa hh = frmhh.chitiethanghoa(txtmahangtch.Text); if (hh != null) { bool dkthem = true; for (int i = 0; i < lvmuataicuahang.Items.Count; i++) { ListViewItem lv = lvmuataicuahang.Items[i]; if (txtmahangtch.Text == lv.SubItems[0].Text) { dkthem = false; } } if (dkthem == true) { ListViewItem lvi = new ListViewItem(txtmahangtch.Text); lvi.SubItems.Add(hh.tenhang); lvi.SubItems.Add(txtsoluongtch.Text); if (txtkhuyenmai.Text == "") { txtkhuyenmai.Text = "0"; } float khuyenmai = ((float)Convert.ToDouble(txtkhuyenmai.Text) / 100) * hh.gia; int gia1sp = hh.gia - (int)khuyenmai; int tong = Convert.ToInt32(txtsoluongtch.Text) * gia1sp; lvi.SubItems.Add(gia1sp.ToString()); lvi.SubItems.Add(tong.ToString()); lvmuataicuahang.Items.Add(lvi); } else { MessageBox.Show("sản phẩm đã tồn tại trong danh sách mua "); } } else { MessageBox.Show("không tìm thấy hàng hóa"); } } catch { MessageBox.Show("loi!"); }; txtmahangtch.Text = ""; txtsoluongtch.Text = ""; txtkhuyenmai.Text = ""; }