private void btnTruKho_Click(object sender, RoutedEventArgs e)
        {
            ChiTietClient = new ChiTietPhieuNhapKhoSVCClient();
            ChiTietClient.ChiTietPhieuNhapKho_GetItemsCompleted += new EventHandler<ChiTietPhieuNhapKho_GetItemsCompletedEventArgs>(ChiTietClient_ChiTietPhieuNhapKho_GetItemsCompleted);
            ChiTietClient.ChiTietPhieuNhapKho_GetItemsAsync(PhieuNhapID);

            PhieuNhapKhoClient = new PhieuNhapKhoSVCClient();
            PhieuNhapKhoClient.PhieuNhapKho_DeleteCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(PhieuNhapKhoClient_PhieuNhapKho_DeleteCompleted);
            PhieuNhapKhoClient.PhieuNhapKho_DeleteAsync(PhieuNhapID, User.UserID, DateTime.Now.ToString("MM/dd/yyyy"));
        }
        void ChiTietClient_ChiTietPhieuNhapKho_GetItemsCompleted(object sender, ChiTietPhieuNhapKho_GetItemsCompletedEventArgs e)
        {
            List<ChiTietPhieuNhapKhoInfo> ChiTiet = e.Result;
            foreach (ChiTietPhieuNhapKhoInfo Item in ChiTiet)
            {
                ChiTietClient = new ChiTietPhieuNhapKhoSVCClient();
                ChiTietClient.ChiTietPhieuNhapKho_GetItemCompleted += new EventHandler<ChiTietPhieuNhapKho_GetItemCompletedEventArgs>(ChiTietClient_ChiTietPhieuNhapKho_GetItemCompleted);
                ChiTietClient.ChiTietPhieuNhapKho_GetItemAsync(Item.ChiTietPhieuNhapID);

                //ChiTietClient.ChiTietPhieuNhapKho_DeleteAsync(Item.ChiTietPhieuNhapID);
            }
        }
        public void CTPhieuNhapKhoEdit_Load(int _CTPhieuNhapKhoID, int _PhieuNhapKhoID)
        {
            PhieuNhapKhoID = _PhieuNhapKhoID;
            DichVuClient = new DichVuSVCClient();
            DichVuClient.DichVu_GetItemsCompleted += new EventHandler<DichVu_GetItemsCompletedEventArgs>(DichVuClient_DichVu_GetItemsCompleted);
            DichVuClient.DichVu_GetItemsAsync();
            cbxDichVu.SelectedIndex = 0;

            if (_CTPhieuNhapKhoID != 0)
            {
                CTPhieuNhapKhoID = _CTPhieuNhapKhoID;
                ChiTietClient = new ChiTietPhieuNhapKhoSVCClient();
                ChiTietClient.ChiTietPhieuNhapKho_GetItemCompleted += new EventHandler<ChiTietPhieuNhapKho_GetItemCompletedEventArgs>(ChiTietClient_ChiTietPhieuNhapKho_GetItemCompleted);
                ChiTietClient.ChiTietPhieuNhapKho_GetItemAsync(CTPhieuNhapKhoID);
            }
        }
        public void PhieuNhapKhoEdit_Load(int _PhieuNhapKhoID)
        {
            rdpNgayNhap.SelectedDate = DateTime.Now.Date;
            if (_PhieuNhapKhoID != 0)
            {
                LoadingPanel.IsBusy = true;
                btnThemPhieuNhap.Content = "Cập nhật phiếu nhập";
                btnAddDichVu.IsEnabled = true;
                PhieuNhapKhoID = _PhieuNhapKhoID;

                PhieuNhapKhoClient = new PhieuNhapKhoSVCClient();
                PhieuNhapKhoClient.PhieuNhapKho_GetItemCompleted += new EventHandler<PhieuNhapKho_GetItemCompletedEventArgs>(PhieuNhapKhoClient_PhieuNhapKho_GetItemCompleted);
                PhieuNhapKhoClient.PhieuNhapKho_GetItemAsync(PhieuNhapKhoID);

                ChiTietClient = new ChiTietPhieuNhapKhoSVCClient();
                ChiTietClient.ChiTietPhieuNhapKho_GetItemsCompleted += new EventHandler<ChiTietPhieuNhapKho_GetItemsCompletedEventArgs>(ChiTietClient_ChiTietPhieuNhapKho_GetItemsCompleted);
                ChiTietClient.ChiTietPhieuNhapKho_GetItemsAsync(PhieuNhapKhoID);
            }
        }
 void PhieuNhapKho_ChiTiet_Closed(object sender, EventArgs e)
 {
     frmPhieuNhapKho_ChiTiet PhieuNhapKho_ChiTiet = sender as frmPhieuNhapKho_ChiTiet;
     if (PhieuNhapKho_ChiTiet.DialogResult == true)
     {
         ChiTietClient = new ChiTietPhieuNhapKhoSVCClient();
         ChiTietClient.ChiTietPhieuNhapKho_GetItemsCompleted += new EventHandler<ChiTietPhieuNhapKho_GetItemsCompletedEventArgs>(ChiTietClient_ChiTietPhieuNhapKho_GetItemsCompleted);
         ChiTietClient.ChiTietPhieuNhapKho_GetItemsAsync(PhieuNhapKhoID);
     }
 }
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(txtSoLuong.Text.Trim()))
            {
                if (CTPhieuNhapKhoID == -1)
                {
                    ChiTietClient = new ChiTietPhieuNhapKhoSVCClient();
                    ChiTietClient.ChiTietPhieuNhapKho_AddCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(ChiTietClient_ChiTietPhieuNhapKho_AddCompleted);
                    ChiTietClient.ChiTietPhieuNhapKho_AddAsync(PhieuNhapKhoID, int.Parse(txtSoLuong.Text.ToString()), decimal.Parse(txtDonGia.Text.ToString()),
                        decimal.Parse(txtTongTien.Text.ToString()), (int)cbxDichVu.SelectedValue);
                    sl = int.Parse(txtSoLuong.Text.ToString());
                }
                else
                {
                    ChiTietClient = new ChiTietPhieuNhapKhoSVCClient();
                    ChiTietClient.ChiTietPhieuNhapKho_EditCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(ChiTietClient_ChiTietPhieuNhapKho_EditCompleted);
                    ChiTietClient.ChiTietPhieuNhapKho_EditAsync(CTPhieuNhapKhoID, PhieuNhapKhoID, int.Parse(txtSoLuong.Text.ToString()), decimal.Parse(txtDonGia.Text.ToString()),
                        decimal.Parse(txtTongTien.Text.ToString()), (int)cbxDichVu.SelectedValue);
                    sl = int.Parse(txtSoLuong.Text.ToString()) - sl;
                }

                //DichVuClient.DichVu_Edit_SLCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(DichVuClient_DichVu_Edit_SLCompleted);
                DichVuClient.DichVu_Edit_SLAsync((int)cbxDichVu.SelectedValue, sl);
            }
            else
            {
                MessageBox.Show("Kiểm tra lại cái trường bắt buộc nhập", "Thông báo", MessageBoxButton.OK);
            }
        }