示例#1
0
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            //setting up the local variables;
            bool    blnFatalError   = false;
            string  strErrorMessage = "";
            string  strDescription;
            string  strBJCAssetID;
            string  strSerialNumber;
            string  strManufacturer;
            string  strModel;
            int     intRecordsReturned;
            bool    blnItemExists      = false;
            int     intToolKey         = 0;
            string  strPartNumber      = "";
            int     intCurrentLocation = 0;
            decimal decPartCost        = 0;
            string  strToolNotes       = "";

            try
            {
                strDescription = txtDescription.Text;
                if (strDescription.Length < 6)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Description is to Short\n";
                }
                if (cboAssetCategory.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Category Was Not Selected\n";
                }
                strBJCAssetID = txtBJCAssetID.Text;
                if (strBJCAssetID.Length < 4)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The BJC Asset ID is to Short\n";
                }
                else
                {
                    TheFindActiveToolByToolIDDataSet = TheToolsClass.FindActiveToolByToolID(strBJCAssetID);

                    intRecordsReturned = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        blnItemExists      = true;
                        intToolKey         = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID[0].ToolKey;
                        strPartNumber      = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID[0].PartNumber;
                        intCurrentLocation = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID[0].CurrentLocation;
                        decPartCost        = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID[0].ToolCost;
                        strToolNotes       = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID[0].ToolNotes;
                    }
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);

                    return;
                }

                strSerialNumber = txtSerialNo.Text;
                strManufacturer = txtManufacturer.Text;
                strModel        = txtModel.Text;

                blnFatalError = TheAssetClass.UpdateWaspAsset(MainWindow.gintAssetID, strDescription, gstrAssetCategory, strBJCAssetID, strSerialNumber, strManufacturer, strModel);

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

                if (blnItemExists == false)
                {
                    blnFatalError = TheToolsClass.InsertTools(strBJCAssetID, MainWindow.gintWarehouseID, strSerialNumber, MainWindow.gintCategoryID, strDescription, 0, MainWindow.gintWarehouseID);

                    if (blnFatalError == true)
                    {
                        throw new Exception();
                    }
                }
                else if (blnItemExists == true)
                {
                    blnFatalError = TheToolsClass.UpdateToolActive(intToolKey, true);

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

                    blnFatalError = TheToolsClass.UpdateToolCategory(intToolKey, MainWindow.gintCategoryID);

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

                    blnFatalError = TheToolsClass.UpdateToolInfo(intToolKey, strPartNumber, strDescription, intCurrentLocation, decPartCost, strToolNotes);

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

                TheMessagesClass.InformationMessage("The Asset has been Updated");

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

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