To begin the week, I faced database bug without any error prompted. When updating my data on existing database, UI/ViewModel seems like it saved the latest changes. But when data grid list is refreshed, the edited data will be removed. After perform an integration test and run debug mode, it appears to be attribute is not sync with correct variable. Hence, causing the new set of data are not able to update. Beside that, old set of data is removed due to implementation to remove existing set of data after they are edited.
Next, when two or more user is using the application, concurrency situation will occurs. Hence, a test is performed to solve this situation. Updating data list might fail whenever the data on database and ViewModel selected data is differ. After test is done, I implemented a dialog box to notify the user when their data changes failed. Despite that, context is not reload to latest data list, thus, the error dialog kept prompt as I try to update new data. Therefore, I implemented a reload function in repository class to make sure latest data is reloaded whenever data update is failed through error handling.
Other than that, I found a bug in my implementation, everything works fine until I close the window and reopen it. By doing that, It would prompt error of “Invalid SelectedId” or “Object reference not set to an instance of an object” when I try to edit/delete selected data. It appears to be an issue of event aggregator been subscribed twice. By adding a dispose( ) function and Unsubscribe event upon closing the window, the issue is solved.
Implementation of Pick History View
For this week, a new feature which is the pick history view is implemented for the pick module. As what it named, it is used to view the pick history for specific line item. On line item selected, it will parse the line item id through publishing the event. While the pick history view model will subscribe the event and load the pick history with the selected line item id to filter the pick history that belongs to the line item.
Furthermore, I’ve also implemented the filtration of sales order by its pick status. Two checkbox is added to the view for user to select the type they wish to filter the sales order in different scenarios.
Lastly, I’ve conducted the integration tests for pick module in order to test out the concurrency situation will prevent the data to be entered into database and will rollback the transaction.
Implementation of Percentage and Tiny Integer
Adding in new button to new class that derive specific calculation. Value in new class consist of percentage, which then been used in calculation of existing ViewModel classes. This class would appear as data grid combo box in main WPF application.
While I am at it, I faced an issue where class name is similar in other module. I am unable to add in new data to correct database table. All the data I saved in current module appears in database table of existing module. After some tests, I found out that both module crosslinked. I manage to make it function properly refactor class name and region name of new module.
Then, I was required to implement new attribute “IsReady” with tinyint(1) in config. It is use to signal other module that It is ready to be used. In ViewModel, I implemented a dialog to ask whether user want selected data ready to be used; under same button, it undergoes same process to undo the changes made. Button text would change based value of attribute in database:
i – (Repo) If bool IsReady = true || 1 (value in database)
(VM) button text shows “Undo Ready to Use”
ii – (Repo) If bool IsReady= false || 0 (value in database)
(VM) button text shows “Ready to Use”
The button alter between (i) and (ii) whenever IsReady is successfully updated to the database.
New feature on Pick module
For this week I’ve implement a new feature on the pick module which is to filter the line item by the current user floor. When the current user is in charge of floor 1, by selecting the checkbox, it will refresh the line item data grid view and display the line item that contains the item that located at the same floor.
In order to implement it, new aggregate of Location and Floor is created. Therefore, each Item will contains a Location that indicate their respective IDs. While each Location will contains a Items list that include all the Items in the same Location.
At last, I’ve add warning dialog that alert user that they have unsaved pick. For example, when user had picked but not saved, it will pop dialog when user is try to select the view floor only checkbox, select other sales order and select other line item.
Calculation in System and Malfunction of Buttons
Some calculation is needed in current system we are working on. Thus, I had to implement Regex for few text input. Allowing only numeric and special symbol to be used, restricts all alphabetic and any other symbol . With implementation of Regex, undefined result for calculation can be avoided.
Next, I need to allow calculation result to be 0 based on given example. Therefore, I added a check box within data grid of DetailView, hence, control my calculation result. Then, functionality is altered within DetailViewModel as we are maintaining MVVM implementation. As the check box is checked, it will set the result to 0; it will be actual result otherwise.
There is still some malfunction for state of my refresh button. Other buttons would become disable to be clicked after refresh button is triggered. I shall refactor my code to fix this issue, to ensure smooth user experience. Few unit tests is coded check if refresh button acts as intended.
User action validation on Pick Module
After the color indicator for pick module had been completed, for this week, I’ve implement the features that will alert user when they did not save their pick.
In order to implement the feature, I’ve used the data grid SelectionChanged event. This event will be fire when the selected item in the data grid had been changed. Therefore, I’ve retrieve the RemovedItems from the SelectionChangedEventArgs and compared its pickQuantity with database. If the pickQuantity is same with the database, it allow user to proceed with another row, reset to previous row if it is not same with database and prompt error dialog.
However, I’ve faced problem when the selected item is reset to previous item, but the focus is pointed on another row. Therefore, the PreviewLostKeyboardFocus event is used to solve the problem. It fired when the user attempt to leave the textbox focus. When the event is fired, it will work the same as the SelectionChanged event which compare the value of pickQuantity with database to verify whether user had modify the value. If the pickQuantity had been modified, it will reset the focus back to the previous textbox by using OldFocus.Focus();
Combo Box Implementation & Dependencies Issue
I create an implementation of “Terms”, which means setting a fixed or limited period for something. Implementation is based on previous implementation as example. In this implementation, I learnt that we can code a grid list in combo box other than normal list.
Next, I was told to alter an entity from 2 decimal places input to 3 decimal places input. It has to be alter to match certain Unit of Measurement.
Major issue that I faced is the project dependencies is directly linked to one of my project dll file. This has restrict me from debugging due to built system ignored current code I am working on. After going through possible problems, the system does not works as how it suppose to be. In the end, the problem solved by moving the dll file into “Projects” child under dependencies.
Lastly, after the dependencies issue being solved, I now face new problem in the module I am working on. The module does not save certain entity into the database. Therefore, I will need perform multiple test to figure out the problem.
Color Indicator for Pick Module
For this week, I’ve coded out the basic functionalities of the pick module which is the pick and pick all functions. While the pick function refer to when the user had enter the amount to pick, a pick data will be generate which contains the line item ID that picked, picked quantity and the user ID that perform the pick.
Before the pick is saved into database, it need to update with the stock quantity database table which increment the amount of stock and decrement in the stock quantity. For the pick all function it perform the same with the pick function with just the pick quantity is set to the line item quantity on button clicked.
After that, I’ve add in with the color indicator function which alert the user on the sales order list on which order is completely picked while which haven’t. Different line items will be indicated with their respective unique colors.
The color indicator is been called in the LoadingRow event which fired when the datagridview is generated and inserting the row into it. It read the current row cell which is the sales order first, and retrieve all the line items inside the sales order. The color indicator determine the color to set by comparing all the pick quantity with the line item quantity, when the pick quantity is equal to line item quantity, the variable picked++.
Lastly, if the picked amount is equal with the line item list count, it means all the line item inside this sales order is picked, with correct colour indicator.
Altering Tests based on Database Changes & Testing New Interface
I added new entity into existing database migration, and update stored value in database. Due to new entity is added, most unit tests and integration tests failed. When put those tests to debug, It appears that there is database type of exception. Hence, I need refactor existing Test Base by adding value for new entities in order for tests to assert properly.
After that, I get to play around with new interface and get familiar with it implementation. The implementation are the use of Regex, Unit of Measurement for calculation in system. Also, implementation of combo box, search bar, CRUD and data injection from few other MVVM services for functionality in system.
Multithreading on Pick module
For this week, I’ve continue to develop on the new task which is the pick module. After the UI creation is completed, I’ve inserted some dummy data to test the UI. However, in order to make sure the user always get the latest sales order data from the database for pick module, multithreading is applied to the module.
Multithreading is used in the pick module which aim to refresh the sales order data and update the UI data grid view at the background. Not only that, it also require retrieve the latest row version in order to avoid concurrency error.
However, I’ve faced problem which update data grid binding source in the thread does not reflect in the UI data grid view even thought I’ve define a new collection for the binding source. After I’ve search for solution on the Internet, I’ve learned that I should call dispatcher for UI updating work and for the binding source, I’m only allowed to perform .Clear(), .Add(), AddRange(), and Remove() instead of defining new collection.
