private Sanpham Laythongtinsp() { Sanpham sanpham = new Sanpham(); sanpham.TenHang = txtTenhang.Text; sanpham.LoaiHang = cbbLoaihang.Text.ToString(); sanpham.NgaySanXuat = txtngaysx.Text; sanpham.XuatXu = txtXuatxu.Text; sanpham.SoLuong = (int)txtsoluong.Value; sanpham.HinhAnh = srcAnh; sanpham.NhaCungCap = cbbNhacungcap.Text; sanpham.GiaMua = (int)txtGiamua.Value; sanpham.GiaBan = (int)txtGiabanle.Value; sanpham.VAT = (int)txtGiabansi.Value; sanpham.Khohang = cbbkhohang.Text; sanpham.Thuonghieu = cbbthuonghieu.Text; return(sanpham); }
public Themsuasanpham(Sanpham s) { InitializeComponent(); btnLuu.Text = "Cập nhật sản phẩm"; this.Text = "Cập nhật sản phẩm"; Id = s.Id; txtTenhang.Text = s.TenHang; txtngaysx.Text = s.NgaySanXuat; txtXuatxu.Text = s.XuatXu; txtsoluong.Value = s.SoLuong; txtGiabanle.Value = s.GiaBan; txtGiabansi.Value = s.VAT; txtGiamua.Value = s.GiaMua; cbbkhohang.EditValue = laykhohang(s.Khohang); cbbLoaihang.Text = s.LoaiHang; cbbNhacungcap.EditValue = layncc(s.NhaCungCap); cbbthuonghieu.Text = s.Thuonghieu; pictureBox1.ImageLocation = s.HinhAnh.ToString(); srcAnh = s.HinhAnh.ToString(); }
private void BtnLuu_Click(object sender, EventArgs e) { Sanpham sanpham = Laythongtinsp(); var row = sanphamBus.themsuasanpham(Id, sanpham); if (row > 0) { khicapnhat(); if (Id != 0) { MessageBox.Show("Cập nhật thành công!"); } else { MessageBox.Show("Thêm sản phẩm thành công!"); } this.Close(); } else { MessageBox.Show("Cập nhật thất bại!"); } }
private void Btnsua_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Object id = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "Id"); Object tenHang = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "TenHang"); Object loaiHang = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "LoaiHang"); Object ngaySanXuat = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "NgaySanXuat"); Object xuatXu = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "XuatXu"); Object soLuong = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "SoLuong"); Object hinhAnh = Laylocation((int)id); Object nhaCungCap = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "NhaCungCap"); Object giaMua = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "GiaMua"); Object giaBanLe = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "GiaBan"); Object giaBanSi = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "VAT"); Object khohang = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "Khohang"); Object thuonghieu = grviewsanpham.GetRowCellValue(grviewsanpham.FocusedRowHandle, "Thuonghieu"); Sanpham sanpham = new Sanpham() { Id = int.Parse(id.ToString()), TenHang = tenHang.ToString(), LoaiHang = loaiHang.ToString(), NgaySanXuat = ngaySanXuat.ToString(), XuatXu = xuatXu.ToString(), SoLuong = int.Parse(soLuong.ToString()), HinhAnh = hinhAnh, NhaCungCap = nhaCungCap.ToString(), GiaMua = long.Parse(giaMua.ToString()), GiaBan = long.Parse(giaBanLe.ToString()), VAT = int.Parse(giaBanSi.ToString()), Khohang = khohang.ToString(), Thuonghieu = thuonghieu.ToString() }; Themsuasanpham themsuasanpham = new Themsuasanpham(sanpham); themsuasanpham.Show(); themsuasanpham.khicapnhat += Themsuasanpham_khicapnhat; }