Пример #1
0
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            int status;
            DatabaseConnection connection = new DatabaseConnection();

            connection.setStoredProc("dbo.procStoreHerbariumSheet");
            connection.addSprocParameter("@accessionNumber", SqlDbType.VarChar, lblAccessionNumber.Text);
            connection.addSprocParameter("@boxNumber", SqlDbType.VarChar, lblBox.Text);
            connection.addSprocParameter("@loanAvailable", SqlDbType.Bit, (btnLoanAvailable.IsChecked == true));
            status = connection.executeProcedure();

            switch (status)
            {
            case 0:
                MessageBox.Show("Herbarium Sheet is now Stored in " + lblBox.Text, "Record Saved", MessageBoxButton.OK, MessageBoxImage.Information);
                break;

            case 1:
                MessageBox.Show("Transaction Failed, The system had run to an Error", "Record Saved", MessageBoxButton.OK, MessageBoxImage.Information);
                break;
            }
            pnlPlantDeposit.Visibility = Visibility.Hidden;
            btnReturn_Click(btnReturn, null);

            getHerbariumSheet();
        }
        private void addExistingDeposit()
        {
            int  status;
            bool pictureEmpty = false;

            byte[] picture   = null;
            char   plantType = 'X';

            try { picture = getPictureToBinary(picHerbariumPlant); }
            catch (Exception) { pictureEmpty = true; }

            if (rbtVascular.IsChecked == true)
            {
                plantType = 'V';
            }
            else if (rbtFlowering.IsChecked == true)
            {
                plantType = 'F';
            }
            else if (rbtAlgae.IsChecked == true)
            {
                plantType = 'A';
            }
            else if (rbtBryophyte.IsChecked == true)
            {
                plantType = 'B';
            }

            DatabaseConnection connection = new DatabaseConnection();

            connection.setStoredProc("dbo.procInsertPlantDeposit");
            if (!pictureEmpty)
            {
                connection.addSprocParameter("@herbariumSheet", System.Data.SqlDbType.VarBinary, picture);
            }
            connection.addSprocParameter("@locality", System.Data.SqlDbType.VarChar, cbxLocality.SelectedItem);
            connection.addSprocParameter("@collector", System.Data.SqlDbType.VarChar, cbxCollector.SelectedItem);
            connection.addSprocParameter("@staff", System.Data.SqlDbType.VarChar, StaticData.staffname);
            connection.addSprocParameter("@dateCollected", System.Data.SqlDbType.Date, dpkDateCollected.DateContent);
            connection.addSprocParameter("@description", System.Data.SqlDbType.VarChar, txaDescription.Text);
            connection.addSprocParameter("@plantType", System.Data.SqlDbType.Char, plantType);
            connection.addSprocParameter("@accessionDigits", System.Data.SqlDbType.VarChar, txfAccessionNumber.TextContent);
            connection.addSprocParameter("@dateDeposited", System.Data.SqlDbType.Date, dpkDateDeposited.DateContent);
            status = connection.executeProcedure();

            switch (status)
            {
            case 0:
                MessageBox.Show("Existing Plant Deposit Recorded", "Record Saved", MessageBoxButton.OK, MessageBoxImage.Information);
                break;

            case 1:
                MessageBox.Show("Transaction Failed, The system had run to an Error", "Record Saved", MessageBoxButton.OK, MessageBoxImage.Information);
                break;
            }

            btnClear_Click(btnClear, null);
        }
Пример #3
0
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result;

            result = MessageBox.Show("Do you want to Confirm Verification of this Plant Deposit",
                                     "Confirm Verify Plant",
                                     MessageBoxButton.YesNo,
                                     MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                int    status;
                string refAccession = (chkIsDuplicate.IsChecked == false)
                                       ? lblAccessionNumber.Text : cbxReferenceNumber.SelectedItem.ToString();

                DatabaseConnection connection = new DatabaseConnection();
                connection.setStoredProc("dbo.procVerifyPlantDeposit");
                connection.addSprocParameter("@accessionNo", SqlDbType.VarChar, lblAccessionNumber.Text);
                connection.addSprocParameter("@referenceNo", SqlDbType.VarChar, refAccession);
                connection.addSprocParameter("@taxonName", SqlDbType.VarChar, cbxScientificName.SelectedItem);
                connection.addSprocParameter("@validatorName", SqlDbType.VarChar, StaticData.staffname);
                status = connection.executeProcedure();

                switch (status)
                {
                case 0:
                    MessageBox.Show("Herbarium Sheet is Now Verified", "Record Saved", MessageBoxButton.OK, MessageBoxImage.Information);
                    break;

                case 1:
                    MessageBox.Show("Transaction Failed, The system had run to an Error", "Record Saved", MessageBoxButton.OK, MessageBoxImage.Information);
                    break;
                }
                pnlPlantDeposit.Visibility = Visibility.Hidden;

                getPlantDeposit();
            }
        }
Пример #4
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (validateLoanSpecies())
            {
                MessageBoxResult response = MessageBox.Show("Do you want to Process this Loan Transaction?",
                                                            "Confirm Transaction",
                                                            MessageBoxButton.YesNo,
                                                            MessageBoxImage.Question);
                if (response == MessageBoxResult.Yes)
                {
                    int                status;
                    string             loanStatus = (StaticData.role == "STUDENT ASSISTANT") ? "Requesting" : "Approved";
                    string             loanNumber = "";
                    DatabaseConnection connection = new DatabaseConnection();

                    connection.setStoredProc("dbo.procProcessLoan");
                    connection.addSprocParameter("@collectorName", SqlDbType.VarChar, lblCollector.Text);
                    connection.addSprocParameter("@startDate", SqlDbType.Date, loanDate);
                    connection.addSprocParameter("@endDate", SqlDbType.Date, returnDate);
                    connection.addSprocParameter("@purpose", SqlDbType.VarChar, lblPurpose.Text);
                    connection.addSprocParameter("@status", SqlDbType.VarChar, loanStatus);
                    status = connection.executeProcedure();

                    if (status == 0)
                    {
                        connection.setQuery("SELECT strLoanNumber " +
                                            "FROM viewPlantLoans " +
                                            "WHERE strCollector = @collector AND dateLoan = @startdate AND dateReturning = @enddate");
                        connection.addParameter("@collector", SqlDbType.VarChar, lblCollector.Text);
                        connection.addParameter("@startdate", SqlDbType.Date, loanDate);
                        connection.addParameter("@enddate", SqlDbType.Date, returnDate);

                        SqlDataReader sqlData = connection.executeResult();
                        while (sqlData.Read())
                        {
                            loanNumber = sqlData[0].ToString();
                        }
                        connection.closeResult();

                        foreach (ListSpecies list in dgrTaxonSpecies.Items)
                        {
                            if (list.IsChecked)
                            {
                                connection.setStoredProc("dbo.procLoanPlants");
                                connection.addSprocParameter("@loanNumber", SqlDbType.VarChar, loanNumber);
                                connection.addSprocParameter("@taxonName", SqlDbType.VarChar, list.TaxonName);
                                connection.addSprocParameter("@copies", SqlDbType.Int, list.Copies);
                                status = connection.executeProcedure();

                                if (status == 1)
                                {
                                    break;
                                }
                            }
                        }

                        switch (status)
                        {
                        case 0:
                            MessageBox.Show("Plant Deposit Transaction Processed Successfully");
                            break;

                        case 1:
                            MessageBox.Show("Plant Deposit Transaction Processed with Some Error Records");
                            break;
                        }
                    }
                    else
                    {
                        MessageBox.Show("The System had run to an Error");
                    }
                }

                pnlPlantLoaningForm.Visibility = Visibility.Hidden;
                getLoanTable();
            }
        }