コード例 #1
0
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            string   strValueForValidation;
            string   strErrorMessage    = "";
            bool     blnFatalError      = false;
            bool     blnThereIsAProblem = false;
            string   strAssetPartNumber;
            string   strAssetDescription;
            decimal  decAssetCost  = 0;
            DateTime datActiveDate = DateTime.Now;
            string   strAssetNotes;
            DateTime datDataEntryDate = DateTime.Now;
            int      intEmployeeID;
            string   strSerialNumber;

            try
            {
                strAssetPartNumber = txtAssetPartNumber.Text;
                if (strAssetPartNumber.Length < 3)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Part Number is not Long Enough\n";
                }
                if (cboSelectAssetType.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Asset Type Was Not Selected\n";
                }
                strAssetDescription = txtAssetDescription.Text;
                if (strAssetDescription.Length < 6)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Asset Description Was Not Long Enough\n";
                }
                strValueForValidation = txtAssetPrice.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Asset Cost is not Numeric\n";
                }
                else
                {
                    decAssetCost = Convert.ToDecimal(strValueForValidation);
                }
                strSerialNumber = txtSerialNumber.Text;
                if (strSerialNumber.Length < 5)
                {
                    blnFatalError    = true;
                    strErrorMessage += "Serial Number is not Long Enough\n";
                }
                intEmployeeID         = MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID;
                strValueForValidation = txtActiveDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Active Date is not a Date\n";
                }
                else
                {
                    datActiveDate = Convert.ToDateTime(strValueForValidation);
                }
                strAssetNotes = txtAssetNotes.Text;
                if (strAssetNotes.Length < 6)
                {
                    strAssetNotes = "NO ASSET NOTES ENTERED";
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);

                    return;
                }

                blnFatalError = TheAssetClass.InsertAssetMain(strAssetPartNumber, gintAssetTypeID, strAssetDescription, decAssetCost, MainWindow.gintWarehouseID, intEmployeeID, strAssetNotes, datDataEntryDate, strSerialNumber);

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

                if (Convert.ToInt32(decAssetCost) >= 2500)
                {
                }

                blnFatalError = TheEmployeeDataEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Create Asset");

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

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

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

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