示例#1
0
        public void update(DTO_PhieuBaoHanh obj)
        {
            using (CellphoneComponentEntities db = new CellphoneComponentEntities())
            {
                var resultMaNhanVien = db.Database
                                       .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'")
                                       .FirstOrDefault();
                var resultMaHangHoa = db.Database
                                      .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'")
                                      .FirstOrDefault();
                PhieuBaoHanh item = new PhieuBaoHanh();
                item.MaPhieuBaoHanh = obj.MaPhieuBaoHanh;
                item.NgayLap        = obj.NgayLap;
                item.NgayGiao       = obj.NgayGiao;
                item.MaNhanVien     = resultMaNhanVien;
                item.TenKhachHang   = obj.TenKhachHang;
                item.SoDienThoai    = obj.SoDienThoai;
                item.TongTien       = obj.TongTien;
                item.GhiChu         = obj.GhiChu;
                item.DaGiao         = obj.DaGiao;
                item.NgayChinhSua   = obj.NgayChinhSua;
                item.MaHangHoa      = resultMaHangHoa;

                db.PhieuBaoHanhs.Attach(item);
                db.Entry(item).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
        }
示例#2
0
        public UI_ThemPhieuBaoHanh(Grid gridMain, DTO_PhieuBaoHanh obj)
        {
            InitializeComponent();

            this.gridMain = gridMain;
            if (obj == null)
            {
                clearData();
                isNew = true;
            }
            else
            {
                getDataFromEditUI(obj);
            }
        }
示例#3
0
        private void getDataFromEditUI(DTO_PhieuBaoHanh obj)
        {
            txtMaPhieuBaoHanh.Text  = obj.MaPhieuBaoHanh;
            dpNgayLap.SelectedDate  = obj.NgayLap;
            dpNgayGiao.SelectedDate = obj.NgayGiao;
            cbbTenHangHoa.Text      = obj.TenHangHoa;
            txtTenNhanVien.Text     = obj.TenNhanVien;
            txtTenKhachHang.Text    = obj.TenKhachHang;
            txtSoDienThoai.Text     = obj.SoDienThoai;
            cbDaGiao.IsChecked      = obj.DaGiao;
            txtGhiChu.Text          = obj.GhiChu;
            txtTongTien.Text        = obj.TongTien.ToString();

            isNew = 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 (dgvPhieuBaoHanh.SelectedItem != null)
                {
                    DTO_PhieuBaoHanh obj = new DTO_PhieuBaoHanh();
                    obj = dgvPhieuBaoHanh.SelectedItem as DTO_PhieuBaoHanh;
                    String id = obj.MaPhieuBaoHanh;

                    BUS_PhieuBaoHanh.Delete(id);
                    dgvPhieuBaoHanh.ItemsSource = BUS_PhieuBaoHanh.showData();
                }
            }
        }
示例#5
0
 public void Update(DTO_PhieuBaoHanh obj)
 {
     PhieuBaoHanh.Instance.update(obj);
 }
示例#6
0
 public void Insert(DTO_PhieuBaoHanh obj)
 {
     PhieuBaoHanh.Instance.insert(obj);
 }