コード例 #1
0
 /// <summary>
 /// Constructor when multiple rows are selected from Search Results Window
 /// </summary>
 /// <param name="search"></param>
 public InventoryPage(List <SearchResult> search)
 {
     newRecord  = false;
     recordList = new List <Record>();
     searchList = new List <SearchResult>();
     foreach (SearchResult list in search)
     {
         searchResult = list;
         searchList.Add(searchResult);
         oldCode  = list.Code;
         oldOwner = list.Owner;
         oldTown  = list.Town;
         oldState = list.State;
         InitializeComponent();
         uxCode.Text       = list.Code;
         uxBreed.Text      = list.Breed;
         uxAnimalName.Text = list.AnimalName;
         uxRegNum.Text     = list.RegNum;
         uxOwner.Text      = list.Owner;
         uxCanNum.Text     = list.CanNum;
         notes             = "";
         isMorph           = false;
         isOldMorph        = false;
         populating        = false;
         Closing          += InventoryPage_Closing;
         recordList        = RetrieveRecords(list.Code);
         morph             = RetrieveMorph(list.Code);
     }
 }
コード例 #2
0
        /// <summary>
        /// Constructor for an existing record card window. Populates the necessary sections of the card with existing information.
        /// </summary>
        /// <param name="search">Search Result object containing basic information to populate with.</param>
        public RecordWindow(SearchResult search)
        {
            newRecord    = false;
            searchResult = search;

            InitializeComponent();

            uxCode.Text       = searchResult.Code;
            uxBreed.Text      = searchResult.Breed;
            uxAnimalName.Text = searchResult.AnimalName;
            uxRegNum.Text     = searchResult.RegNum;
            uxOwner.Text      = searchResult.Owner;
            uxCanNum.Text     = searchResult.CanNum;

            notes      = "";
            isMorph    = false;
            isOldMorph = false;

            Closing += RecordWindow_Closing;

            try
            {
                recordList = RetrieveRecords(searchResult.Code, CONNECTION_STRING); //populates the record card with any existing specific record entries
                morph      = RetrieveMorph(searchResult.Code, CONNECTION_STRING);   //populates the record card with any existing morphology info
            }
            catch (InvalidOperationException ex)
            {
                ShowErrorMessage();
            }
        }
コード例 #3
0
        /// <summary>
        /// Retrieves morphology info from the database matching the animal's unique ID
        /// </summary>
        /// <param name="id">animal ID</param>
        /// <param name="connectionString">The connection string of the current database location</param>
        /// <returns>the morphology info in an object</returns>
        public Morph RetrieveMorph(string id, string connectionString)
        {
            try
            {
                using (var connection = new MySqlConnection(connectionString))
                {
                    using (var command = new MySqlCommand("kabsu.RetrieveMorph", connection)) //Initializes command to the RetrieveMorph stored procedure
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        //Add the ID as an input for the procedure.
                        command.Parameters.AddWithValue("@AnimalID", id);
                        command.Parameters.AddWithValue("@Can", searchResult.CanNum);
                        command.Parameters.AddWithValue("@CollDate", searchResult.CollDate);
                        connection.Open();

                        var reader = command.ExecuteReader(); //Executes a procedure with a reader returning existing record rows

                        Morph morph = new Morph();
                        while (reader.Read())  //While there are still rows to return (1 expected)
                        {
                            morph = new Morph( //Create a morphology object from the current row
                                reader.GetString(reader.GetOrdinal("Notes")),
                                reader.GetString(reader.GetOrdinal("Date")),
                                reader.GetInt32(reader.GetOrdinal("Vigor")).ToString(),
                                reader.GetInt32(reader.GetOrdinal("Mot")).ToString(),
                                reader.GetInt32(reader.GetOrdinal("Morph")).ToString(),
                                reader.GetInt32(reader.GetOrdinal("Code")).ToString(),
                                reader.GetInt32(reader.GetOrdinal("Units")).ToString(), id, searchResult.CanNum, searchResult.CollDate);
                            if (morph.Notes != null) //if notes exist, populate private notes string
                            {
                                notes = morph.Notes;
                            }
                            isMorph    = true;
                            isOldMorph = true;
                        }
                        connection.Close();

                        return(morph); //return the morphology info
                    }
                }
            }
            catch (Exception ex) //Catches any SQL Exceptions and throws to the caller.
            {
                throw new InvalidOperationException(ex.ToString());
            }
        }
コード例 #4
0
 /// <summary>
 /// constructor when one row is selected from Search Results Window
 /// </summary>
 /// <param name="search"></param>
 public InventoryPage(SearchResult search)
 {
     newRecord    = false;
     searchResult = search;
     oldCode      = searchResult.Code;
     oldOwner     = searchResult.Owner;
     oldTown      = searchResult.Town;
     oldState     = searchResult.State;
     InitializeComponent();
     uxCode.Text       = searchResult.Code;
     uxBreed.Text      = searchResult.Breed;
     uxAnimalName.Text = searchResult.AnimalName;
     uxRegNum.Text     = searchResult.RegNum;
     uxOwner.Text      = searchResult.Owner;
     uxCanNum.Text     = searchResult.CanNum;
     notes             = "";
     isMorph           = false;
     isOldMorph        = false;
     populating        = false;
     Closing          += InventoryPage_Closing;
     recordList        = RetrieveRecords(searchResult.Code);
     morph             = RetrieveMorph(searchResult.Code);
 }
コード例 #5
0
        /// <summary>
        /// Event handler on closing the window. Prompts the user for additional info, then store the information into the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RecordWindow_Closing(object sender, CancelEventArgs e)
        {
            CollectAdditionalInfo(); //Opens the additional info window
            SortListByDate();        //if possible, sort records by oldest record first
            this.IsEnabled = false;
            List <string> list      = new List <string>();
            List <string> morphList = new List <string>();
            int           textCount = 0;

            foreach (TextBox tb in FindVisualChildren <TextBox>(this))
            {
                list.Add(tb.Text);
                if (tb.Text != "" && (tb.Parent != uxBottomGrid && tb.Parent != uxMorphGrid) && tb.Text != "mm/dd/yyyy") //if the text added belongs to record rows
                {
                    textCount++;
                }
                if (tb.Text != "" && (tb.Parent != uxBottomGrid && tb.Parent != uxTopGrid1 && tb.Parent != uxTopGrid2)) //if any morphology data is found
                {
                    isMorph = true;
                }
            }
            recordList = new List <Record>();
            for (int i = 0; textCount > 0; i++) //while there  is record text to be combined into record rows
            {
                if (list[i] != "" || (list[i + ROW_SPACING] != "" && list[i + ROW_SPACING] != "mm/dd/yyyy") || list[i + (ROW_SPACING * 2)] != "" || list[i + (ROW_SPACING * 3)] != "" || list[i + (ROW_SPACING * 4)] != "")
                {
                    recordList.Add(new Record(list[i], list[i + ROW_SPACING], list[i + (ROW_SPACING * 2)], list[i + (ROW_SPACING * 3)], list[i + (ROW_SPACING * 4)], list[ID_INDEX], list[CAN_INDEX], list[DATE_INDEX]));

                    //Decrement text counter
                    if (list[i] != "")
                    {
                        textCount--;
                    }
                    if (list[i + ROW_SPACING] != "")
                    {
                        textCount--;
                    }
                    if (list[i + (ROW_SPACING * 2)] != "")
                    {
                        textCount--;
                    }
                    if (list[i + (ROW_SPACING * 3)] != "")
                    {
                        textCount--;
                    }
                    if (list[i + (ROW_SPACING * 4)] != "")
                    {
                        textCount--;
                    }
                }
            }

            if (!CheckBalance())
            {
                ReplaceBalance();
            }
            try
            {
                StoreParent(CONNECTION_STRING);
            }
            catch (InvalidOperationException ex)
            {
                ShowErrorMessage();
            }

            if (isMorph) //if morphology info exists
            {
                //create new morphology object
                morph = new Morph(notes, list[MORPH_ID], list[MORPH_ID + 1], list[MORPH_ID + 2], list[MORPH_ID + 3], list[MORPH_ID + 4], list[MORPH_ID + 5], list[ID_INDEX], list[CAN_INDEX], list[DATE_INDEX]);
            }

            try
            {
                StoreRecords(list[ID_INDEX], list[CAN_INDEX], list[DATE_INDEX], CONNECTION_STRING); //store the record list into the database
                StoreMorph(CONNECTION_STRING);                                                      //store the morphology info into the database
            }
            catch (InvalidOperationException ex)
            {
                ShowErrorMessage();
            }
        }