Example #1
0
        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string FromCB = AvalCB.Text;

                Regex CheckReg = new Regex("[^0-9.]");

                string FromTB = NewDataValueTB.Text;

                if (FromTB != null && !CheckReg.IsMatch(FromTB) && FromCB != "")
                {
                    string query = "update FC_DepotCity set " + FromCB + " = " + FromTB + " where FC_CarrierID = " + selectedCityForEditing.FC_CarrierID.ToString() + " and CityName = '" + selectedCityForEditing.CityName + "';";
                    SQL.GenericFunction(query);

                    NewDataValueTB.Text = "";
                    AvalCB.Text         = "";

                    LoadRateFeeTab();
                }
            }
            catch (Exception ex)
            {
                TMSLogger.LogIt(" | " + "AdminPage.xaml.cs" + " | " + "AdminPage" + " | " + "ConfirmButton_Click" + " | " + ex.GetType().ToString() + " | " + ex.Message + " | ");
            }
        }
        private void ConfirmInvoice_Click(object sender, RoutedEventArgs e)
        {
            if (BuyerClass.SelectedForInvoice != null && BuyerClass.SelectedForInvoice.Count > 0)
            {
                FC_Invoice invTemp = PlannerClass.GenerateInvoice(BuyerClass.SelectedForInvoice[0]);
                PlannerClass.InsertInvoice(invTemp, BuyerClass.SelectedForInvoice[0]);
                PlannerClass.UpdateContratState(BuyerClass.SelectedForInvoice[0], 4);

                BuyerClass.SelectedForInvoice.Remove(BuyerClass.SelectedForInvoice[0]);

                foreach (FC_LocalContract c in BuyerClass.SelectedForInvoice)
                {
                    PlannerClass.AddContractToInvoices(invTemp, c);
                    PlannerClass.UpdateContratState(c, 4);
                }


                InvoiceForFileSystem fsIn = new InvoiceForFileSystem(invTemp);


                try
                {
                    string invoiceDir = Directory.GetCurrentDirectory() + "\\Invoices";

                    FileInfo fi = new FileInfo(invoiceDir);
                    if (fi.Exists == false)
                    {
                        Directory.CreateDirectory(invoiceDir);
                    }

                    string filePath = "\\invoice_" + fsIn.FC_InvoiceID + ".txt";

                    /// Open the filestream to append to the file.
                    FileStream   fileStream = new FileStream(invoiceDir + filePath, FileMode.Create, FileAccess.Write);
                    StreamWriter fileWriter = new StreamWriter(fileStream);

                    /// Add each log entry from the working list to the file as a BSV
                    fileWriter.WriteLine(fsIn.ToString());
                    fileWriter.Flush();

                    /// Close the file
                    fileWriter.Close(); fileStream.Close();
                }
                /// If an exception is thrown here, catch it
                catch (Exception ex)
                {
                    TMSLogger.LogIt("|" + "/InvoiceSelection.xaml.cs" + "|" + "InvoiceSelection" + "|" + "ConfirmInvoice_Click" + "|" + ex.GetType().ToString() + "|" + ex.Message + "|");
                }
                BuyerPage newpage = new BuyerPage();
                this.NavigationService.Navigate(newpage);
            }
        }
Example #3
0
        // LOG TAB FUNCTIONS ===================================================================================
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			private void LoadClick(object sender, RoutedEventArgs e)
         *	\brief		This adds logs to the search results.
         *	\details	This adds logs to the search results which match search strings entered. This will first
         *	            read from the Log file before it adds in any entries. This isn't done the most efficiently
         *	\exception	string.Contains() may throw an Argument Null exception
         *	\see		TMSLogger.LogIt()
         *	\return		void
         *
         * ---------------------------------------------------------------------------------------------------- */
        private void LogSearchClick(object sender, RoutedEventArgs e)
        {
            bool   dateRange  = false;
            string tempString = (LogSearchTags.Text.Trim()).ToLower();

            /// This clears logSearchResults if the Log file is read in successfully
            if (TMSLogger.ReadExistingLogFile() == true)
            {
                logSearchResults.Clear();
            }
            try
            {
                foreach (TMSLog l in TMSLogger.logs)
                {
                    dateRange = false;

                    if ((l.logTime.Date >= LogStartDate.SelectedDate) && (l.logTime.Date <= LogEndDate.SelectedDate))
                    {
                        dateRange = true;
                    }

                    if ((dateRange == true) && (tempString != ""))
                    {
                        /// Compare search tags box to logs in the local list and add to logSearchResults list if matching
                        if ((l.logType.ToLower()).Contains(tempString) || ((l.logMessage.ToLower()).Contains(tempString)))
                        {
                            logSearchResults.Add(l);
                        }
                        else if ((l.logMethod.ToLower()).Contains(tempString) || ((l.logClass.ToLower()).Contains(tempString)))
                        {
                            logSearchResults.Add(l);
                        }
                    }
                    else if ((dateRange == true) && (tempString == ""))
                    {
                        logSearchResults.Add(l);
                    }
                }
            }
            /// Catch errors from Contains calls
            catch (Exception ex)
            {
                TMSLogger.LogIt("|" + "/AdminPage.xaml.cs" + "|" + "AdminPage" + "|" + "LoadClick" + "|" + ex.GetType().ToString() + "|" + ex.Message + "|");
            }

            /// Refresh the UI data grid
            LogsList.Items.Refresh();
        }
Example #4
0
        private void RestoreSelected_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (BackupsList.SelectedItem != null)
                {
                    TMSBackup.RecoverRestorePoint((TMSBackup)BackupsList.SelectedItem);
                }
            }
            catch (Exception ex)
            {
                TMSLogger.LogIt(" | " + "AdminPage.xaml.cs" + " | " + "AdminPage" + " | " + "RestoreSelected_Click" + " | " + ex.GetType().ToString() + " | " + ex.Message + " | ");
            }

            UpdateBackupsList();
        }
Example #5
0
        private void ReacInvlocesFromDatabase(object sender, RoutedEventArgs e)
        {
            DirectoryInfo d = new DirectoryInfo(@"./Invoices/");//Assuming Test is your Folder

            //FileInfo fi = new FileInfo(d);
            //if (fi.Exists == false)
            //{
            //    Directory.CreateDirectory(invoiceDir);
            //}

            if (Folder.SelectedItem != null)
            {
                string viewInvoice = (string)Folder.SelectedItem;
                string invoiceText = "";

                ViewInvoice.Text = "";

                try
                {
                    /// Open the file stream to read from the file
                    FileStream   fileStream   = new FileStream((viewInvoice), FileMode.Open, FileAccess.Read);
                    StreamReader streamReader = new StreamReader(fileStream);

                    /// Fill the working list with lines from the file
                    while (!streamReader.EndOfStream)
                    {
                        invoiceText += streamReader.ReadLine() + "\n";
                    }

                    ViewInvoice.Text = invoiceText;

                    /// Close the file
                    streamReader.Close(); fileStream.Close();
                }
                /// If an exception is thrown here, create a log for it.
                catch (Exception ex)
                {
                    TMSLogger.LogIt("|" + "/BuyerPage.xaml.cs" + "|" + "BuyerPage" + "|" + "Folder_SelectionChanged" + "|" + ex.GetType().ToString() + "|" + ex.Message + "|");
                }
            }
        }
 private void TMSStartup()
 {
     TMSLogger.SetDefaultLogFilePath(); // Initialize logger location when app opens
     TMSBackup.SetDefaultBackupFilePath();
     //TMSLogger.LogStatusEvent += LogStatusEventHandler;
 }
Example #7
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			void ChangeLogLocation() -- STUB
         *	\brief		This function will change where the log file is stored
         *	\details	This function allows the user to select a new location for the log file storage. Then
         *	            the program copies the current file to the new location. If the copy is successful,
         *	            the old file is deleted. Otherwise the old file is kept.
         *	\exception	From FileStream and StreamReader / StreamWriter
         *	\see
         *	\return		Void
         *
         * ---------------------------------------------------------------------------------------------------- */
        private void ChangeLogLocation(object sender, RoutedEventArgs e)
        {
            bool   saveSuccess = true;
            string oldLogPath  = TMSLogger.LogFilePath;
            string newLogPath  = "";

            // View Save As File Dialog
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "Text Document (*.txt)|*.txt|All files (*.*)|*.*";

            // Set a text range using the textbox name
            // TextRange textRange = new TextRange(myTextbox.Document.ContentStart, myTextbox.Document.ContentEnd);

            if (saveFileDialog.ShowDialog() == true)
            {
                /// Get the new path
                newLogPath = (saveFileDialog.FileName);

                /// Open both files to copy
                try
                {
                    /// Open file streams
                    FileStream   newFile      = new FileStream(newLogPath, FileMode.Create);
                    FileStream   oldFile      = new FileStream(oldLogPath, FileMode.Open);
                    StreamReader streamReader = new StreamReader(oldFile);
                    StreamWriter streamWriter = new StreamWriter(newFile);

                    /// Read any copy through the files
                    while (!streamReader.EndOfStream)
                    {
                        streamWriter.WriteLine(streamReader.ReadLine());
                        streamWriter.Flush();
                    }

                    /// Close all the streams
                    streamWriter.Close(); streamReader.Close();
                    newFile.Close(); oldFile.Close();
                }
                catch (Exception ex)
                {
                    TMSLogger.LogIt("|" + "/AdminPage.xaml.cs" + "|" + "AdminPage" + "|" + "ChangeLogLocation" + "|" + ex.GetType().ToString() + "|" + ex.Message + "|");
                    saveSuccess = false;
                }

                if (saveSuccess == true)
                {
                    /// Set location of LogFilePath to new path
                    TMSLogger.LogFilePath = newLogPath;

                    /// Delete old file
                    try
                    {
                        File.Delete(oldLogPath);
                    }
                    catch (Exception exc)
                    {
                        TMSLogger.LogIt("|" + "/AdminPage.xaml.cs" + "|" + "AdminPage" + "|" + "ChangeLogLocation" + "|" + exc.GetType().ToString() + "|" + exc.Message + "|");
                    }
                }
            }
        }