//private void Btn_DeleteItemRow_Click(object sender, RoutedEventArgs e)
        //{
        //    int row_index = main_vm.selected_row_index;

        //    main_vm.DeleteQuoteItemRow(jobno, tabDynamic.SelectedIndex, row_index);
        //    Trace.WriteLine(string.Format("Item Row {0} Deleted...", row_index));
        //    main_vm.updateQuoteItemsByJob_And_Tab(jobno, main_vm.selected_tab_index);
        //}

        private void Btn_DeleteItemRow_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to remove the Quote Item?", "Delete Quote Item", MessageBoxButton.YesNo);

            switch (result)
            {
            case MessageBoxResult.Yes:
                MessageBox.Show("Quote Item removed successfully");
                break;

            case MessageBoxResult.No:
                break;
            }

            if (result == MessageBoxResult.Yes)
            {
                QuoteItemGrid grid = new QuoteItemGrid(jobno, tabDynamic.SelectedIndex, main_vm);
                TabItem       tab  = (TabItem)tabDynamic.SelectedItem;
                //int row_index = main_vm.selected_row_index;
                int row_index = ((HydrotestCentral.Models.QuoteItem)((HydrotestCentral.QuoteItemGrid)tab.Content).QItems.SelectedItem).row_index;

                main_vm.DeleteQuoteItemRow(jobno, tabDynamic.SelectedIndex, row_index);
                Trace.WriteLine(string.Format("Item Row {0} Deleted...", row_index));
                main_vm.updateQuoteItemsByJob_And_Tab(jobno, main_vm.selected_tab_index);

                grid.QItems.ItemsSource = main_vm.quote_items;
                tab.Content             = grid;
            }
        }
        public void getTabItemGrid(TabItem tab, int tab_index)
        {
            QuoteItemGrid grid = new QuoteItemGrid(jobno, tab_index, main_vm);

            main_vm.Jobno = jobno;
            //MessageBox.Show("Getting Tab Index: " + TabIndex);
            main_vm.updateQuoteItemsByJob_And_Tab(jobno, tab_index);
            grid.QItems.ItemsSource = main_vm.quote_items;
            tab.Content             = grid;
            //datagridTest.ItemsSource = main_vm.quote_items;
        }
        private void Btn_SaveItems_Click(object sender, RoutedEventArgs e)
        {
            QuoteItemGrid grid = new QuoteItemGrid(jobno, tabDynamic.SelectedIndex, main_vm);

            // Delete all items from QTE_ITEMS where jobno and tab_index match is found
            main_vm.DeleteQuoteItemGrid(jobno, tabDynamic.SelectedIndex);
            saveTabItemGrid(jobno, tabDynamic.SelectedIndex);
            main_vm.updateQuoteItemsByJob_And_Tab(jobno, main_vm.selected_tab_index);

            TabItem tab = (TabItem)tabDynamic.SelectedItem;

            grid.QItems.ItemsSource = main_vm.quote_items;
            tab.Content             = grid;
        }
        private void btn_AddItemRow_Click(object sender, RoutedEventArgs e)
        {
            TabItem tab = (TabItem)tabDynamic.SelectedItem;
            //main_vm.ADDQuoteItemsByJob_And_Tab(this.jobno, tabDynamic.SelectedIndex);
            //tab.Content = main_vm.quote_items;

            //QuoteItemGrid grid = new QuoteItemGrid(jobno, tabDynamic.SelectedIndex, main_vm);

            ////MessageBox.Show("Getting Tab Index: " + TabIndex);
            //main_vm.updateQuoteItemsByJob_And_Tab(jobno, tabDynamic.SelectedIndex);
            //grid.QItems.ItemsSource = main_vm.quote_items;
            //tab.Content = grid;

            QuoteItemGrid grid = new QuoteItemGrid(jobno, tabDynamic.SelectedIndex, main_vm);

            //MessageBox.Show("Getting Tab Index: " + TabIndex);
            main_vm.ADDQuoteItemsByJob_And_Tab(jobno, tabDynamic.SelectedIndex);
            grid.QItems.ItemsSource = main_vm.quote_items;
            tab.Content             = grid;
        }