Example #1
0
        private void expRemoveAsset_Expanded(object sender, RoutedEventArgs e)
        {
            bool   blnFatalError = false;
            string strToolID;
            int    intToolKey;
            int    intRecordsReturned;

            try
            {
                const string     message = "Are You Sure You Want To Remove This Asset?";
                const string     caption = "Are You Sure";
                MessageBoxResult result  = MessageBox.Show(message, caption, MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    blnFatalError = TheAssetClass.DeleteWaspAsset(MainWindow.gintAssetID);

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

                    const string     secmessage = "Are You Sure You Want To Remove This From The Tool Table?";
                    const string     seccaption = "Are You Sure";
                    MessageBoxResult secresult  = MessageBox.Show(secmessage, seccaption, MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (secresult == MessageBoxResult.Yes)
                    {
                        strToolID = txtBJCAssetID.Text;
                        if (strToolID.Length > 3)
                        {
                            TheFindActiveToolByToolIDDataSet = TheToolsClass.FindActiveToolByToolID(strToolID);

                            intRecordsReturned = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID.Rows.Count;

                            if (intRecordsReturned > 0)
                            {
                                intToolKey = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID[0].ToolKey;

                                blnFatalError = TheToolsClass.DeleteTool(intToolKey);

                                if (blnFatalError == true)
                                {
                                    throw new Exception();
                                }
                            }
                            else if (intRecordsReturned < 1)
                            {
                                TheMessagesClass.ErrorMessage("The Tool Was Not Found");
                            }
                        }
                    }

                    TheMessagesClass.InformationMessage("The Asset Has Been Deleted");

                    this.Close();
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Edit Wasp Asset // Remove Asset Expander " + Ex.Message);
            }
        }