public bool InsertPBH(DTO_PhieuBanHang obj)
        {
            using (CellphoneComponentEntities db = new CellphoneComponentEntities())
            {
                var result = db.Database
                             .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'")
                             .FirstOrDefault();
                PhieuBanHang phieuBanHang = new PhieuBanHang();
                phieuBanHang.MaPhieuBanHang = obj.MaPhieuBanHang;
                phieuBanHang.NgayBan        = obj.NgayBan;
                phieuBanHang.MaNhanVien     = result;
                phieuBanHang.TenKhachHang   = obj.TenKhachHang;
                phieuBanHang.SoDienThoai    = obj.SoDienThoai;
                phieuBanHang.TongTien       = obj.TongTien;
                phieuBanHang.GhiChu         = obj.GhiChu;
                phieuBanHang.NgayChinhSua   = obj.NgayChinhSua;

                db.PhieuBanHangs.Add(phieuBanHang);
                if (db.SaveChanges() > 0)
                {
                    return(true);
                }
                return(false);
            }
        }
Exemple #2
0
 public UI_LapPhieuBanHang(DTO_PhieuBanHang obj)
 {
     InitializeComponent();
     txtMaPhieuBanHang.Text      = obj.MaPhieuBanHang;
     dpNgayLap.SelectedDate      = obj.NgayBan;
     dpNgayChinhSua.SelectedDate = obj.NgayChinhSua;
     txtTenNhanVien.Text         = obj.TenNhanVien;
     txtTenKhachHang.Text        = obj.TenKhachHang;
     txtSoDienThoai.Text         = obj.SoDienThoai;
     txtGhiChu.Text   = obj.GhiChu;
     txtTongTien.Text = obj.TongTien.ToString();
     isNew            = false;
     loadCombobox();
     loadChiTiet(obj.MaPhieuBanHang);
 }
        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 (dgvPhieuBanHang.SelectedItem != null)
                {
                    DTO_PhieuBanHang obj = dgvPhieuBanHang.SelectedItem as DTO_PhieuBanHang;
                    String           id  = obj.MaPhieuBanHang;

                    if (BUS_PhieuBanHang.Delete(id))
                    {
                        dgvPhieuBanHang.ItemsSource = BUS_PhieuBanHang.showData();
                    }
                    else
                    {
                        MessageBox.Show("Xóa thất bại!");
                    }
                }
            }
        }
 public bool Update(DTO_PhieuBanHang obj)
 {
     return(PhieuBanHang.Instance.update(obj));
 }
 public bool InsertPBH(DTO_PhieuBanHang obj)
 {
     return(PhieuBanHang.Instance.InsertPBH(obj));
 }