private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            tbPartCode.Text = _partCode;

            foreach (DataRow dr in ClsPCSDB.Sohbi_GetPartsByCustomer4productLabelling(_cusID).Rows)
            {
                tbPartname.Text = dr[1].ToString();
            }
        }
        private void FillGrid()
        {
            if (ClsPCSDB.GetNGMonthlyOutput(Convert.ToInt32(cboFilterMonth.SelectedValue.ToString().Trim())
                                            , Convert.ToInt32(cboFilterYear.SelectedItem.ToString().Trim())).Rows.Count == 0)
            {
                MessageBox.Show("No Records Found On This Date Range");
            }

            gridNGDetails.ItemsSource = ClsPCSDB.GetNGMonthlyOutput(Convert.ToInt32(cboFilterMonth.SelectedValue.ToString().Trim())
                                                                    , Convert.ToInt32(cboFilterYear.SelectedItem.ToString().Trim()));
        }
Esempio n. 3
0
        private void FillGrid()
        {
            if (ClsPCSDB.GetNGDailyOutput(dateStart.SelectedDate.Value.ToString("yyyy-MM-dd")
                                          , dateEnd.SelectedDate.Value.ToString("yyyy-MM-dd")).Rows.Count == 0)
            {
                MessageBox.Show("No Records Found On This Date Range");
            }

            gridNGDetails.ItemsSource = ClsPCSDB.GetNGDailyOutput(dateStart.SelectedDate.Value.ToString("yyyy-MM-dd")
                                                                  , dateEnd.SelectedDate.Value.ToString("yyyy-MM-dd"));
        }
        private void BtnExport_Click(object sender, RoutedEventArgs e)
        {
            if (cboFilterMonth.SelectedIndex == -1 &&
                cboFilterYear.SelectedIndex == -1)
            {
                MessageBox.Show("Invalid Date Range");
            }
            else
            {
                DataTable dataTable = ClsPCSDB.GetNGMonthlyOutput(Convert.ToInt32(cboFilterMonth.SelectedValue.ToString().Trim())
                                                                  , Convert.ToInt32(cboFilterYear.SelectedItem.ToString().Trim()));

                var excelApplication = new Microsoft.Office.Interop.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         = "NG Data from the month of " + cboFilterMonth.Text.Trim()
                                                  + ", " + cboFilterYear.SelectedItem.ToString().Trim();
                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();
                        }
                    }
                }

                Microsoft.Office.Interop.Excel.Range rg = (Microsoft.Office.Interop.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 Boolean _validateIfPrinted()
        {
            SqlCommand cmd = new SqlCommand("SELECT ISNULL(count(*),0) FROM tblLotCardGroup WHERE LotCardGroupNo=@LotCardNo AND IsPrinted = 1");

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.AddWithValue("@LotCardNo", _formNos.ToString().Trim());

            if (Convert.ToInt32(SqlHelper.ExecuteScalar(ClsConfig.BarCodeDBConnectionString, cmd)) > 0)
            {
                MessageBoxResult messageBoxResult = MessageBox.Show("This lot card was already printed. Are you sure you want to print it again?"
                                                                    , "Confirmation", MessageBoxButton.YesNo);

                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    //reportViewer.ViewerCore.PrintReport();

                    if (ClsPCSDB.Sohbi_GetEPPIinsideLotCards4Printing(_formNos.ToString().Trim()).Rows.Count > 0)
                    {
                        PrintData(docA, docB, 1, 0, 0);
                        MessageBox.Show("Record Successfully Printed");
                        this.Close();
                    }
                    else
                    {
                        PrintData2(docA, 1, 0, 0);
                        MessageBox.Show("Record Successfully Printed");
                        this.Close();
                    }
                }
                else
                {
                }
            }
            else
            {
                SqlCommand cmd2 = new SqlCommand(
                    "UPDATE [ProdSys].[dbo].[tblLotCardGroup] SET IsPrinted = 1 WHERE LotCardGroupNo=@LotCardNo");

                cmd2.CommandType = CommandType.Text;

                cmd2.Parameters.AddWithValue("@LotCardNo", _formNos.ToString().Trim());

                SqlHelper.ExecuteNonQuery(ClsConfig.SOMSConnectionString, cmd2);

                //reportViewer.ViewerCore.PrintReport();

                if (ClsPCSDB.Sohbi_GetEPPIinsideLotCards4Printing(_formNos.ToString().Trim()).Rows.Count > 0)
                {
                    PrintData(docA, docB, 1, 0, 0);
                    MessageBox.Show("Record Successfully Printed");
                }
                else
                {
                    PrintData2(docA, 1, 0, 0);
                    MessageBox.Show("Record Successfully Printed");
                }
            }

            return(true);
        }