private void BtnExport_Click(object sender, RoutedEventArgs e)
        {
            DataTable dataTable = ClsCantierDB.GetFGInventory(Convert.ToInt16(cboCustomer.SelectedValue.ToString().Trim()));

            var excelApplication = new Excel.Application();

            var excelWorkBook = excelApplication.Application.Workbooks.Add(Type.Missing);

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "Excel files (*.xlsx)|*.xlsx";
            saveFileDialog.FilterIndex      = 0;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.CreatePrompt     = true;
            saveFileDialog.FileName         = "Inventory Result As Of " + DateTime.Now.Date.ToString("yyyy-MMM-dd");
            saveFileDialog.Title            = "Export Excel File To";

            DataColumnCollection dataColumnCollection = dataTable.Columns;

            for (int i = 1; i <= dataTable.Rows.Count + 1; i++)
            {
                for (int j = 1; j <= dataTable.Columns.Count; j++)
                {
                    if (i == 1)
                    {
                        excelApplication.Cells[i, j] = dataColumnCollection[j - 1].ToString();
                    }
                    else
                    {
                        excelApplication.Cells[i, j] = dataTable.Rows[i - 2][j - 1].ToString();
                    }
                }
            }

            //Excel.Range rg = (Excel.Range)excelApplication.Range["G:G"];
            //rg.NumberFormat = "yyyy/MM/dd";

            //Save the excel file at desired location
            Nullable <bool> result = saveFileDialog.ShowDialog();

            // Process save file dialog box results
            if (result == true)
            {
                string fullpath = saveFileDialog.FileName;
                excelApplication.ActiveWorkbook.SaveCopyAs(fullpath);
                excelApplication.ActiveWorkbook.Saved = true;

                // Close the Excel Application
                excelApplication.Quit();

                //connection.Close();

                //Release or clear the COM object
                releaseObject(excelWorkBook);
                releaseObject(excelApplication);

                MessageBox.Show("Your data is exported Successfully into Excel File.");

                if (!File.Exists(fullpath))
                {
                    return;
                }

                // combine the arguments together
                //it doesn't matter if there is a space after ','
                string argument = "/select, \"" + fullpath + "\"";

                Process.Start("explorer.exe", argument);
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            PopulateCustomers();

            gridNGDetails.ItemsSource = ClsCantierDB.GetFGInventory(Convert.ToInt16(cboCustomer.SelectedValue.ToString().Trim())).DefaultView;
        }
        private void BtnGenerate_Click(object sender, RoutedEventArgs e)
        {
            gridNGDetails.ItemsSource = ClsCantierDB.GetFGInventory(Convert.ToInt16(cboCustomer.SelectedValue.ToString().Trim())).DefaultView;

            MessageBox.Show("Records successfully refreshed");
        }
 private void CboCustomer_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     gridNGDetails.ItemsSource = ClsCantierDB.GetFGInventory(Convert.ToInt16(cboCustomer.SelectedValue.ToString().Trim())).DefaultView;
 }