Beispiel #1
0
        public FindTechPayItemByDescriptionDataSet FindTechPayItemByDescription(string strJobDescription)
        {
            try
            {
                aFindTechPayItemByDescriptionDataSet      = new FindTechPayItemByDescriptionDataSet();
                aFindTechPayItemByDescriptionTableAdapter = new FindTechPayItemByDescriptionDataSetTableAdapters.FindTechPayItemByDescriptionTableAdapter();
                aFindTechPayItemByDescriptionTableAdapter.Fill(aFindTechPayItemByDescriptionDataSet.FindTechPayItemByDescription, strJobDescription);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Tech Pay Class // Find Tech Pay Item By Description " + Ex.Message);
            }

            return(aFindTechPayItemByDescriptionDataSet);
        }
        private void BtnImportExcel_Click(object sender, RoutedEventArgs e)
        {
            Excel.Application xlDropOrder;
            Excel.Workbook    xlDropBook;
            Excel.Worksheet   xlDropSheet;
            Excel.Range       range;

            string  strTechPayCode;
            string  strJobDescription;
            string  strValueForValidation;
            decimal decTechPayPrice = 0;
            bool    blnFatalError   = false;
            int     intCounter;
            int     intNumberOfRecords;
            int     intRecordsReturned;
            int     intColumnRange;
            bool    blnItemFound;

            try
            {
                TheImportedTechPayDataSet.importedtechpay.Rows.Clear();

                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName   = "Document";             // Default file name
                dlg.DefaultExt = ".xlsx";                // Default file extension
                dlg.Filter     = "Excel (.xlsx)|*.xlsx"; // Filter files by extension

                // Show open file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    string filename = dlg.FileName;
                }

                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                xlDropOrder = new Excel.Application();
                xlDropBook  = xlDropOrder.Workbooks.Open(dlg.FileName, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                xlDropSheet = (Excel.Worksheet)xlDropOrder.Worksheets.get_Item(1);

                range = xlDropSheet.UsedRange;
                intNumberOfRecords = range.Rows.Count;
                intColumnRange     = range.Columns.Count;

                for (intCounter = 2; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strTechPayCode        = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                    strJobDescription     = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper();
                    strValueForValidation = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2).ToUpper();
                    blnItemFound          = false;

                    blnFatalError = TheDataValidationClass.VerifyDoubleData(strValueForValidation);

                    if (blnFatalError == false)
                    {
                        decTechPayPrice = Convert.ToDecimal(strValueForValidation);
                    }

                    TheFindTechPayItemByCodeDataSet = TheTechPayClass.FindTechPayItemByCode(strTechPayCode);

                    intRecordsReturned = TheFindTechPayItemByCodeDataSet.FindTechPayItemByCode.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        blnItemFound = true;
                    }

                    if (blnItemFound == false)
                    {
                        TheFindTechPayItemByDescriptionDataSet = TheTechPayClass.FindTechPayItemByDescription(strJobDescription);

                        intRecordsReturned = TheFindTechPayItemByDescriptionDataSet.FindTechPayItemByDescription.Rows.Count;

                        if (intRecordsReturned > 0)
                        {
                            blnItemFound = true;
                        }
                    }

                    if (blnItemFound == false)
                    {
                        ImportedTechPayDataSet.importedtechpayRow NewTechPayRow = TheImportedTechPayDataSet.importedtechpay.NewimportedtechpayRow();

                        NewTechPayRow.JobDescription = strJobDescription;
                        NewTechPayRow.TechPayCode    = strTechPayCode;
                        NewTechPayRow.TechPayPrice   = decTechPayPrice;

                        TheImportedTechPayDataSet.importedtechpay.Rows.Add(NewTechPayRow);
                    }
                }

                PleaseWait.Close();
                dgrResults.ItemsSource = TheImportedTechPayDataSet.importedtechpay;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Import Tech Pay Items // Import Excel Button " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        private void BtnProcess_Click(object sender, RoutedEventArgs e)
        {
            string  strTechPayCode;
            string  strJobDescription;
            string  strValueForValidation;
            string  strErrorMessage    = "";
            decimal decTechPayPrice    = 0;
            bool    blnThereIsAProblem = false;
            bool    blnFatalError      = false;
            int     intRecordsReturned;

            try
            {
                //data validation
                strTechPayCode = txtTechPayCode.Text;
                if (strTechPayCode == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Tech Pay Code Was Not Entered\n";
                }
                else
                {
                    TheFindTechPayItemByCodeDataSet = TheTechPayClass.FindTechPayItemByCode(strTechPayCode);

                    intRecordsReturned = TheFindTechPayItemByCodeDataSet.FindTechPayItemByCode.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Tech Pay Code Has Been Entered Already\n";
                    }
                }
                strJobDescription = txtJobDescription.Text;
                if (strJobDescription == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Job Description was not Entered\n";
                }
                else
                {
                    TheFindTechPayItemByDescriptionDataSet = TheTechPayClass.FindTechPayItemByDescription(strJobDescription);

                    intRecordsReturned = TheFindTechPayItemByDescriptionDataSet.FindTechPayItemByDescription.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Job Description Has Been Entered Already\n";
                    }
                }
                strValueForValidation = txtTechPayPrice.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Tech Pay Price is not Numeric\n";
                }
                else
                {
                    decTechPayPrice = Convert.ToDecimal(strValueForValidation);
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                blnFatalError = TheTechPayClass.InsertTechPayItem(strTechPayCode, strJobDescription, decTechPayPrice);

                if (blnFatalError == true)
                {
                    throw new Exception();
                }

                TheMessagesClass.InformationMessage("The Tech Pay Item Has Been Entered");

                ResetControls();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Add Tech Pay Item // Process Button " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }