private void DgvLoaiHangHoa_SelectionChanged(object sender, SelectionChangedEventArgs e) { DTO_LoaiHangHoa obj = new DTO_LoaiHangHoa(); obj = dgvLoaiHangHoa.SelectedItem as DTO_LoaiHangHoa; if (obj != null) { txtMaLoaiHangHoa.Text = obj.MaLoaiHangHoa; txtTenLoaiHangHoa.Text = obj.TenLoaiHangHoa; txtPhanTramLoiNhuan.Text = obj.PhanTramLoiNhuan.ToString(); isNew = false; } }
public bool insert(DTO_LoaiHangHoa obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { LoaiHangHoa loaiHangHoa = new LoaiHangHoa(); loaiHangHoa.MaLoaiHangHoa = obj.MaLoaiHangHoa; loaiHangHoa.TenLoaiHangHoa = obj.TenLoaiHangHoa; loaiHangHoa.PhanTramLoiNhuan = obj.PhanTramLoiNhuan; db.LoaiHangHoas.Add(loaiHangHoa); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool update(DTO_LoaiHangHoa obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { LoaiHangHoa loaiHangHoa = new LoaiHangHoa(); loaiHangHoa.MaLoaiHangHoa = obj.MaLoaiHangHoa; loaiHangHoa.TenLoaiHangHoa = obj.TenLoaiHangHoa; loaiHangHoa.PhanTramLoiNhuan = obj.PhanTramLoiNhuan; db.LoaiHangHoas.Attach(loaiHangHoa); db.Entry(loaiHangHoa).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { return(true); } return(false); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Bạn có muốn xóa dòng này?", "Confirmation", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { if (dgvLoaiHangHoa.SelectedItem != null) { DTO_LoaiHangHoa obj = new DTO_LoaiHangHoa(); obj = dgvLoaiHangHoa.SelectedItem as DTO_LoaiHangHoa; String id = obj.MaLoaiHangHoa; if (BUS_LoaiHangHoa.Delete(id)) { refresh(); } else { MessageBox.Show("Xóa thất bại!"); } } } }
public bool Update(DTO_LoaiHangHoa obj) { return(LoaiHangHoa.Instance.update(obj)); }
public bool Insert(DTO_LoaiHangHoa obj) { return(LoaiHangHoa.Instance.insert(obj)); }