Example #1
0
        /// <summary>
        /// Creator: Brandyn T. Coverdill
        /// Created: 2020/04/07
        /// Approver: Dalton Reierson
        /// Approver:  Jesse Tomash
        ///
        /// Method that adds a new item report.
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        public bool addNewItemReport(ItemReport itemReport)
        {
            bool result = false;

            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_add_item_report", conn)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.AddWithValue("@ItemID", itemReport.ItemID);
            cmd.Parameters.AddWithValue("@ItemQuantity", itemReport.ItemQuantity);
            cmd.Parameters.AddWithValue("@Report", itemReport.Report);

            try
            {
                conn.Open();
                result = 1 == cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(result);
        }
        async void SubmitButtonAction()
        {
            // ItemReportStorage is responsible for the ReportTime,
            // EditTime, IsMine, and setting the ID when creating

            ItemReport ir = new ItemReport()
            {
                Title        = TitleInputText,
                Description  = DescriptionInputText,
                ItemLocation = SelectedLocation,
                ItemPhoto    = PhotoSelection
            };

            if (EditingItemReport != null)
            {
                ir.ID = EditingItemReport.ID;
            }

            System.Diagnostics.Debug.WriteLine(ir);

            try
            {
                int ID = await ItemReportStorage.SubmitItem(ir);

                await NavigationService.GoBackAsync(ir);
            }
            catch (Exception e)
            {
                Toaster.DisplayError(e.Message);
            }
        }
Example #3
0
        public void TestUpdateItemReport()
        {
            // Arrange
            ItemReport oldItemReport = new ItemReport()
            {
                ItemID       = 1000,
                ItemName     = "Item 1",
                ItemQuantity = 20,
                Description  = "Item Report 1"
            };

            ItemReport newItemReport = new ItemReport()
            {
                ItemID       = 1000,
                ItemName     = "Item 2",
                ItemQuantity = 30,
                Report       = "Item Report 2"
            };

            // Act
            bool result = false;

            result = _itemReportManager.editItemReports(oldItemReport.ItemQuantity, oldItemReport.Report, newItemReport.ItemQuantity, newItemReport.Report, oldItemReport.ItemID);

            // Assert
            Assert.AreEqual(true, result);
        }
        /// <summary>
        /// Creator: Brandyn T. Coverdill
        /// Created: 2020/04/07
        /// Approver: Dalton Reierson
        /// Approver:  Jesse Tomash
        ///
        /// Method for removing an item report.
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        public int removeItemReport(int itemId, int itemQty, string report)
        {
            int rowsAffected = 0;

            ItemReport itemReport = new ItemReport();

            itemReport.ItemID       = itemId;
            itemReport.Report       = report;
            itemReport.ItemQuantity = itemQty;

            foreach (var rpt in _itemReport)
            {
                if (itemReport.ItemID == rpt.ItemID && itemReport.Report == rpt.Report && itemReport.ItemQuantity == rpt.ItemQuantity)
                {
                    try
                    {
                        _itemReport.Remove(rpt);
                        rowsAffected = 1;
                    }
                    catch
                    {
                        throw new ApplicationException();
                    }
                }
            }
            return(rowsAffected);
        }
Example #5
0
        public List <ItemReport> getItemReport(string query)
        {
            List <ItemReport> data = null;

            SqlConnection connection = new SqlConnection(CONN_STRING);

            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand(query, connection);
                try
                {
                    SqlDataReader reader = command.ExecuteReader();
                    try
                    {
                        data = new List <ItemReport>();
                        while (reader.Read())
                        {
                            ItemReport itemReport = new ItemReport();
                            itemReport.Id    = reader[0].ToString();
                            itemReport.Title = reader[1].ToString();
                            data.Add(itemReport);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e.Message);
                        errorMessage = e.Message;
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    errorMessage = e.Message;
                }
                finally
                {
                    command.Dispose();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                errorMessage = e.Message;
            }
            finally
            {
                connection.Dispose();
            }

            return(data);
        }
Example #6
0
        public override Task ReturnToAsync(object return_data)
        {
            ItemReport ir = (ItemReport)return_data;

            if (ir != null)
            {
                ItemReport = ir;
            }
            return(Task.CompletedTask);
        }
Example #7
0
        void EnterAllDataAndSubmitAsync()
        {
            string title_input       = "A couch I found";
            string description_input = "Looks alright";

            ReportItemViewModel vm = new ReportItemViewModel(
                pic_taker, null, null, null, item_report_storage);

            vm.NavigationService = nav;

            vm.TitleInputText       = title_input;
            vm.DescriptionInputText = description_input;

            // IPictureTaker should return an ImageSource
            // to set PhotoTaken asynchronously
            //vm.CameraButtonCommand.Execute(null);
            vm.PhotoSelection = ImageSourceExample;

            vm.SelectedLocation = MicrosoftHQ;

            // give time for async picture
            //System.Threading.Thread.Sleep(100);
            System.Diagnostics.Debug.WriteLine("BeforeTakePic");
            //await pic_taker.TakePicture();
            System.Diagnostics.Debug.WriteLine("AfterTakePic");

            /*ItemReport item_report_from_event = null;
             * vm.ReportItemSubmitted += (s, e) =>
             * {
             *  item_report_from_event = e.ItemReport;
             * };*/
            vm.SubmitButtonCommand.Execute(null);


            //nav_mock.Verify(n => n.GoBackAsync(item_report_from_event));

            // make sure the ItemReport that was put in storage
            // matches the input
            Assert.AreEqual(1, item_report_storage.LocalItemReports.Count);

            ItemReport ir = item_report_storage.LocalItemReports[0];

            Assert.AreEqual(title_input, ir.Title);
            Assert.AreEqual(description_input, ir.Description);
            Assert.AreEqual(MicrosoftHQ, ir.ItemLocation);
            Assert.AreEqual(ImageSourceExample, ir.ItemPhoto);

            // make sure the ItemReport from event is the same
            // as the one found in storage
            //Assert.IsNotNull(item_report_from_event);
            //Assert.AreEqual(ir, item_report_from_event);


            // TODO: test to make sure INotifyPropertyChanged is working
        }
 public void Startup()
 {
     test_item_report = new ItemReport()
     {
         Title        = "Test item",
         Description  = "found on side of road on my way to work this morning",
         ItemLocation = new LocationCoordinates(1.0, 1.0),
         ReportTime   = DateTime.Now,
         ItemPhoto    = new StreamImageSource()
     };
 }
 /// <summary>
 /// Creator: Brandyn T. Coverdill
 /// Created: 2020/04/07
 /// Approver: Dalton Reierson
 /// Approver:  Jesse Tomash
 ///
 /// Creates a new Item Report.
 /// </summary>
 ///
 /// <remarks>
 /// Updated By:
 /// Updated:
 /// Update:
 /// </remarks>
 public bool createNewItemReport(ItemReport itemReport)
 {
     try
     {
         return(_itemReportAccessor.addNewItemReport(itemReport));
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Unable to add a new Item Report.", ex);
     }
 }
        public async void SubmitItem_ValidItemReport_Async()
        {
            Mock <IValidator <ItemReport> > validator_mock = new Mock <IValidator <ItemReport> >();

            VolatileItemReportStorage virs = new VolatileItemReportStorage(validator_mock.Object);

            ItemReport ir = new ItemReport();
            await virs.SubmitItem(ir);

            Assert.AreEqual(ir, virs.LocalItemReports[0]);
            Assert.AreEqual(1, ir.ID); // sets ID to 1. 0 is invalid
        }
        public void WeeklyAverage_ScrapesCorrectly()
        {
            //Given
            _doc.Load("./Data/oridecon.html");
            var report   = new ItemReport(_doc);
            var expected = 21308;

            //When
            var actual = report.WeeklyAverage;

            //Then
            Assert.Equal(expected, actual);
        }
        public void WeeklyNumberSold_ScrapesCorrectly()
        {
            _doc.Load("./Data/oridecon.html");
            //Given
            var report   = new ItemReport(_doc);
            var expected = 27122;

            //When
            var actual = report.WeeklyNumberSold;

            //Then
            Assert.Equal(expected, actual);
        }
        /// <summary>
        /// Creator: Brandyn T. Coverdill
        /// Created: 2020/04/08
        /// Approver:
        /// Approver:
        ///
        /// Event that navigates to the EditItemReports screen.
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnViewItemReport_Click(object sender, RoutedEventArgs e)
        {
            ItemReport itemReport = (ItemReport)dgViewItemReport.SelectedItem;

            if (dgViewItemReport.SelectedItem != null)
            {
                this.NavigationService?.Navigate(new EditItemReports(itemReport));
            }
            else
            {
                "Please pick an item report to view.".ErrorMessage();
            }
        }
        public void MonthlyStdDeviation_ScrapesCorrectly()
        {
            //Given
            _doc.Load("./Data/oridecon.html");
            var report   = new ItemReport(_doc);
            var expected = 1570;

            //When
            var actual = report.MonthlyStdDeviation;

            //Then
            Assert.Equal(expected, actual);
        }
        public void CardListings_ScrapedCorrectly()
        {
            //Given
            _doc.Load("./Data/EoEStr3.html");
            var report = new ItemReport(_doc);

            var itemOf = new Item
            {
                Name  = "Essence Of Evil STR 3",
                Id    = 4910,
                Slots = 0
            };

            var expected = new List <CardListing>
            {
                new CardListing(itemOf, itemOf, 7900000, 0, "None", "newvending,66,154"),
                new CardListing(itemOf, itemOf, 8000000, 0, "None", "aldebaran,124,121"),
                new CardListing(itemOf, itemOf, 8000000, 0, "None", "newvending,86,41"),
                new CardListing(itemOf, itemOf, 8000000, 0, "None", "niflheim,182,177"),
                new CardListing(itemOf, itemOf, 8000000, 0, "None", "gonryun,146,113"),
                new CardListing(itemOf, itemOf, 8000000, 0, "None", "splendide,211,127"),
                new CardListing(itemOf, itemOf, 10000000, 0, "None", "newvending,66,145"),
                new CardListing(itemOf, new Item {
                    Name = "Rideword Hat [1]", Id = 5208, Slots = 0
                }, 10000000, 4, "Essence Of Evil STR 3", "newvending,90,126"),
                new CardListing(itemOf, new Item {
                    Name = "Rideword Hat [1]", Id = 5208, Slots = 0
                }, 12000000, 4, "Essence Of Evil STR 3", "newvending,62,207"),
                new CardListing(itemOf, new Item {
                    Name = "Rideword Hat [1]", Id = 5208, Slots = 0
                }, 14000000, 4, "Essence Of Evil STR 3", "newvending,103,66"),
                new CardListing(itemOf, new Item {
                    Name = "Ship Captain's Hat [1]", Id = 5359, Slots = 0
                }, 28500000, 0, "Essence Of Evil STR 3", "newvending,111,60")
            };

            //When
            var actual = report.CurrentListings.ToList();

            //Then
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.Equal(expected[i].ItemOf.Id, actual[i].ItemOf.Id);
                Assert.Equal(expected[i].Location, actual[i].Location);
                Assert.Equal(expected[i].Price, actual[i].Price);

                Assert.Equal(expected[i].ItemIn.Id, (actual[i] as CardListing).ItemIn.Id);
                Assert.Equal(expected[i].Refine, (actual[i] as CardListing).Refine);
                Assert.Equal(expected[i].AdditionalProperties, (actual[i] as CardListing).AdditionalProperties);
            }
        }
        public async void SubmitItem_InvalidEdit_Async()
        {
            Mock <IValidator <ItemReport> > validator_mock = new Mock <IValidator <ItemReport> >();

            VolatileItemReportStorage virs = new VolatileItemReportStorage(validator_mock.Object);

            ItemReport ir = new ItemReport()
            {
                ID = 5
            };

            await Assert.ThrowsExceptionAsync <InvalidOperationException>(
                () => virs.SubmitItem(ir));
        }
        /// <summary>
        /// Creator: Brandyn T. Coverdill
        /// Created: 2020/04/08
        /// Approver:
        /// Approver:
        ///
        /// This event deletes an Item Report (Damaged/Missing Items from shelf).
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteItemReport_Click(object sender, RoutedEventArgs e)
        {
            ItemReport itemReport = (ItemReport)dgViewItemReport.SelectedItem;

            if (dgViewItemReport.SelectedItem != null)
            {
                _itemReportManager.deleteItemReport(itemReport.ItemID, itemReport.ItemQuantity, itemReport.Report);
                dgViewItemReport.ItemsSource = _itemReportManager.retrieveItemReports();
            }
            else
            {
                "Please pick an item report to delete.".ErrorMessage();
            }
        }
Example #18
0
        public override Task InitializeAsync(object navigation_data)
        {
            EditingItemReport = navigation_data as ItemReport;
            if (EditingItemReport != null)
            {
                this.Title           = "Edit item report";
                TitleInputText       = EditingItemReport.Title;
                DescriptionInputText = EditingItemReport.Description;
                SelectedLocation     = EditingItemReport.ItemLocation;
                PhotoSelection       = EditingItemReport.ItemPhoto;
            }

            return(Task.CompletedTask);
        }
Example #19
0
        public void TestCreateNewItemReportException()
        {
            // arrange
            ItemReport report = new ItemReport()
            {
                Report   = "Report Field: Test Create New Item Report",
                ItemID   = 0000,
                ItemName = "Item A",
                Quantity = 10
            };

            bool created = false;

            // act
            created = _itemReportManager.createNewItemReport(report);
        }
        /// <summary>
        /// Creator: Brandyn T. Coverdill
        /// Created: 2020/04/07
        /// Approver: Dalton Reierson
        /// Approver:  Jesse Tomash
        ///
        /// Method for adding a new item report.
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        public bool addNewItemReport(ItemReport itemReport)
        {
            bool itemID   = itemReport.ItemID.Equals(10000);
            bool report   = itemReport.Report.Equals("Report Field: Test Create New Item Report");
            bool Quantity = itemReport.Quantity.Equals(10);
            bool itemName = itemReport.ItemName.Equals("Item A");

            if (itemID && report && Quantity && itemName)
            {
                return(true);
            }
            else
            {
                throw new ApplicationException("Cannot add new Item Report.");
            }
        }
        public async Task <ActionResult <Item> > UpdateItem(ItemReport report)
        {
            // For simplicity, drop the id if supplied on the create action.
            Item existingItem = this._logicContext.ConvertReportToModel(report);

            if (this._logicContext.Validate(existingItem))
            {
                ((DbContext)this._context).Update(existingItem);
                await((DbContext)this._context).SaveChangesAsync();

                return(CreatedAtAction("GetItems", new { id = existingItem.ItemId }, existingItem));
            }
            else
            {
                return(BadRequest());
            }
        }
Example #22
0
        public void TestCreateNewItemReport()
        {
            // arrange
            ItemReport itemReport = new ItemReport()
            {
                Report   = "Report Field: Test Create New Item Report",
                ItemID   = 10000,
                ItemName = "Item A",
                Quantity = 10
            };
            bool created        = false;
            bool expectedResult = true;

            // act
            created = _itemReportManager.createNewItemReport(itemReport);

            // assert
            Assert.AreEqual(expectedResult, created);
        }
        public void Item_ScrapesCorrectly()
        {
            //Given
            _doc.Load("./Data/EoEStr3.html");
            var report   = new ItemReport(_doc);
            var expected = new Item
            {
                Name  = "Essence Of Evil STR 3",
                Id    = 4910,
                Slots = 0
            };

            //When
            var actual = report.Item;

            //Then
            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.Slots, actual.Slots);
        }
        public void ItemListings_ScrapedCorrectly()
        {
            //Given
            _doc.Load("./Data/oridecon.html");
            var report = new ItemReport(_doc);

            var itemOf = new Item
            {
                Name  = "Oridecon",
                Id    = 984,
                Slots = 0
            };

            var expected = new List <ItemListing>
            {
                new ItemListing(itemOf, 19000, 43, "newvending,103,219"),
                new ItemListing(itemOf, 19999, 203, "newvending,62,145"),
                new ItemListing(itemOf, 20000, 28, "newvending,86,10"),
                new ItemListing(itemOf, 20000, 40, "newvending,74,132"),
                new ItemListing(itemOf, 20000, 200, "newvending,62,186"),
                new ItemListing(itemOf, 20000, 274, "newvending,127,100"),
                new ItemListing(itemOf, 20000, 300, "newvending,107,148"),
                new ItemListing(itemOf, 20000, 305, "pay_arche,64,138"),
                new ItemListing(itemOf, 20000, 400, "newvending,135,213"),
                new ItemListing(itemOf, 21000, 400, "newvending,70,60"),
                new ItemListing(itemOf, 21450, 148, "gonryun,146,111")
            };

            //When
            var actual = report.CurrentListings.ToList();

            //Then
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.Equal(expected[i].ItemOf.Id, actual[i].ItemOf.Id);
                Assert.Equal(expected[i].Location, actual[i].Location);
                Assert.Equal(expected[i].Price, actual[i].Price);
                Assert.Equal(expected[i].Quantity, (actual[i] as ItemListing).Quantity);
            }
        }
Example #25
0
        /// <summary>
        /// Creator: Brandyn T. Coverdill
        /// Created: 2020/04/07
        /// Approver: Dalton Reierson
        /// Approver:  Jesse Tomash
        ///
        /// This method adds a new Item Report.
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            // Check for validation.
            if (txtReport.Text.Length > 250)
            {
                "Report is too long.".ErrorMessage();
            }
            if (txtReport.Text == "")
            {
                "Please enter a Report.".ErrorMessage();
            }
            if (txtItemQuantity.Text == "")
            {
                "Please enter a Quantity.".ErrorMessage();
            }
            if (txtItemQuantity.Text != "" && txtReport.Text != "")
            {
                try
                {
                    int        quantity   = Int32.Parse(txtItemQuantity.Text);
                    ItemReport itemReport = new ItemReport();
                    itemReport.ItemName     = txtName.Text.ToString();
                    itemReport.ItemQuantity = quantity;
                    itemReport.Report       = txtReport.Text.ToString();
                    itemReport.ItemID       = Int32.Parse(txtItemID.Text);
                    _itemReportManager.createNewItemReport(itemReport);
                    txtReport.Clear();
                    txtItemQuantity.Clear();

                    // Return to ViewInventory Screen.
                    this.NavigationService?.Navigate(new ViewInventory());
                }
                catch (FormatException)
                {
                    "Quanitity must be a number.".ErrorMessage();
                }
            }
        }
        public async void SubmitItem_EditItemReport_Async()
        {
            Mock <IValidator <ItemReport> > validator_mock = new Mock <IValidator <ItemReport> >();

            VolatileItemReportStorage virs = new VolatileItemReportStorage(validator_mock.Object);

            ItemReport ir = new ItemReport();
            await virs.SubmitItem(ir);

            Assert.AreEqual(ir, virs.LocalItemReports[0]);
            Assert.AreEqual(1, ir.ID); // sets ID to 1. 0 is invalid

            ItemReport edited = new ItemReport()
            {
                ID    = 1,
                Title = "new title"
            };

            await virs.SubmitItem(edited);

            Assert.AreNotEqual(ir, virs.LocalItemReports[0]);
            Assert.AreEqual(edited, virs.LocalItemReports[0]);
            Assert.AreEqual("new title", virs.LocalItemReports[0].Title);
        }
Example #27
0
        /// <summary>
        /// Loads a form to the panel
        /// </summary>
        /// <param name="tag">The tag of the button - Here is stored what type of form is supposed to be opened</param>
        private void LoadForm(string tag)
        {
            var yEnd = new YearEnd();

            if (yEnd.InventoryRequired(false))
            {
                switch (VisibilitySetting.HandleUnits)
                {
                case 1:
                    yEnd.GenerateAutomaticInventory();
                    break;

                case 2:
                    yEnd.GenerateAutomaticInventoryByUnit();
                    break;

                case 3:
                    yEnd.GenerateAutomaticInventoryByUnit();
                    break;
                }
            }

            Form frm;

            switch (tag)
            {
            case "Receives":
                frm = new ReceivingForm();
                AddTab("Receiving Form", frm);
                break;

            case "Issues":
                frm = new IssueForm();
                AddTab("Issue Form", frm);
                break;

            case "AMCs":
                frm = new AMCView();
                AddTab("AMC Report", frm);
                break;

            case "menuItemPriceOnlyReport":
                frm = new ItemPriceOnlyReport();
                AddTab("Item Price Only", frm);
                break;

            case "Facility Settings":
                frm = new Hospital();
                AddTab("Facility Settings", frm);
                break;

            case "Drug List":
                frm = new ManageItems();
                AddTab("Manage Drug List", frm);
                break;

            case "Supplies List":
                //frm = new ManageItems();
                frm = new ManageSupplies();
                AddTab("Manage Supplies List", frm);
                break;

            case "Item Consolidator":
                //frm = new ManageItems();
                frm = new ItemConsolidator();
                AddTab("Update Items List From The Directory Service", frm);
                break;

            case "Customize Druglist":
                frm = new CustomDrugList();
                AddTab("Customize Drug List", frm);
                break;

            case "System Settings":
                frm = new SystemSetting();
                AddTab("System Settings", frm);
                break;

            case "Facility Details":
                frm = new HospitalSettings();
                AddTab("Facility Details", frm);
                break;

            case "User Accounts":
                frm = new UserAccounts();
                AddTab("Manage Users", frm);
                break;

            case "Pipeline":
                frm = new Pipeline();
                AddTab("Pipeline", frm);
                break;

            case "Change Password":
                frm = new ChangePassword(UserId);
                AddTab("Change Password", frm);
                break;

            case "Transfer Log":
                frm = new LogTransfer();
                AddTab("Transfer Log", frm);
                break;


            case "VRF Form":
                frm = new vrfmainForm();
                AddTab("Vaccine Requistion and Report Form", frm);
                break;

            case "Losses/Adjustment":
                frm = new LossesAdjustment();
                AddTab("Losses and Adjustment", frm);
                break;

            case "Receive Log":
                frm = new LogReceive();
                AddTab("Receive Transaction Log", frm);
                break;

            case "Issue Log":
                frm = new LogIssues();
                AddTab("Issue Transaction Log", frm);
                break;

            case "Adjustment Log":
                frm = new LogAdjustment();
                AddTab("Loss / Adjustment Transaction Log", frm);
                break;

            case "Inventory Log":
                frm = new LogInventory();
                AddTab("Inventory Log", frm);
                break;

            case "Stock Status":
                frm = new ItemReport();
                AddTab("Stock Status", frm);
                break;

            case "Over Stocked":
                frm = new OtherItemReport("Over Stocked");
                AddTab("Over Stock Items", frm);
                break;

            case "Transfers":
                frm = new TransferForm();
                AddTab("Transfer Form", frm);
                break;

            case "Stock Out":
                frm = new OtherItemReport("Stock Out");
                AddTab("Stocked Out Items", frm);
                break;

            case "ConsumptionTrend":
                frm = new ConsumptionTrendReport();
                AddTab("Consumption Trend", frm);
                break;

            case "Issues By Receiving Unit":
                frm = new IssuesByDep();
                AddTab("Issues By Receiving Unit", frm);
                break;

            case "Expired Products":
                frm = new ExpiredProducts();
                AddTab("Expired Products", frm);
                break;

            case "Near Expiry":
                frm = new NearlyExpired();
                AddTab("Near Expiry Products", frm);
                break;

            case "SOH Trend":
                frm = new SOHTrend();
                AddTab("SOH Trend", frm);
                break;

            case "Receive Trend":
                frm = new ReceiveTrend();
                AddTab("Receive Trend", frm);
                break;

            case "Balance":
                frm = new BalanceReport();
                AddTab("Balance", frm);
                break;

            case "Summary Report":
                frm = new GeneralReport();
                AddTab("Summary Report", frm);
                break;

            case "Cost Summary":
                frm = new GeneralCostChart();
                AddTab("Cost Summary", frm);
                break;

            case "Wastage Rate":
                frm = new WastageRate();
                AddTab("Wastage Rate", frm);
                break;

            case "Summary Chart":
                frm = new GeneralChart();
                AddTab("General Chart", frm);
                break;

            case "Activity Log Reports":
                frm = new ActivityLogReports();
                AddTab("Activity Log", frm);
                break;

            case "ECLS":
                frm = new ECLS();
                AddTab("CS Stock Status", frm);
                break;

            case "Year End Process":
                frm = new YearEndProcess();
                AddTab("Inventory", frm);
                break;

            case "Default Year End Process":
                frm = new YearEndProcess(true);
                AddTab("Inventory", frm);
                break;

            case "Stock Expiry Status":
                frm = new GeneralExpiryChart();
                AddTab("Stock Status", frm);
                break;

            case "DataBase":
                frm = new DatabaseActions();
                AddTab("Database Actions", frm);
                break;

            case "PDA":
                frm = new ItemReport();
                AddTab("Stock Status", frm);
                break;

            case "Consumables List":
                frm = new ManageSupplies();
                AddTab("Supplies List", frm);
                break;

            case "RRF Form":
                frm = new RRFForm();
                AddTab("Report and Requisition Form", frm);
                break;

            case "LossReport":
                frm = new ExpiredProductsReport();
                AddTab("Loss / Adjustment Reporting View", frm);
                break;

            case "CostReport":
                frm = new CostReport();
                AddTab("Cost Report", frm);
                break;

            case "ConsumptionByUnit":
                frm = new ConsumptionByUnits();
                AddTab("Consumption By Dispensary Unit", frm);
                break;

            case "About":
                Program.ShowHCMISVersionInfoMessageBox();
                break;
            }
        }
Example #28
0
 public void TestTearDown()
 {
     _itemReport             = null;
     _fakeItemReportAccessor = null;
     _itemReportManager      = null;
 }
Example #29
0
 /// <summary>
 /// Creator: Brandyn T. Coverdill
 /// Created: 2020/04/08
 /// Approver: Dalton Reierson
 /// Approver:  Jesse Tomash
 ///
 /// Constructor for EditItemReports.
 /// </summary>
 ///
 /// <remarks>
 /// Updated By:
 /// Updated:
 /// Update:
 /// </remarks>
 public EditItemReports(ItemReport itemReport)
 {
     _itemReportManager = new ItemReportManager();
     _itemReport        = itemReport;
     InitializeComponent();
 }
Example #30
0
        public static ReportViewModel Create(IRepository repository, ItemReport itemReport, Item item, bool fromExcel = true)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new ReportViewModel
            {
                ItemId = item.Id,
                ReportName = itemReport.Name,
                ItemReportId = itemReport.Id
            };

            if (itemReport.Name == "Checks" && itemReport.SystemReusable)
            {
                return GenerateChecks(viewModel, itemReport, item);
            }

            return GenerateGeneric(viewModel, itemReport, item, fromExcel);
        }
        private void saveTransactionButton_Click(object sender, RoutedEventArgs e)
        {
            if (transaction.IssuerId == 0)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Issuer is required!");
                defaultDialog.ShowDialog();
                return;
            }
            if (transaction.ReceiverId == 0)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Receiver is required!");
                defaultDialog.ShowDialog();
                return;
            }
            if (transaction.ItemId == 0)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Item is required!");
                defaultDialog.ShowDialog();
                return;
            }
            if (transaction.Amount == 0)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Amount must be greater than 0!");
                defaultDialog.ShowDialog();
                return;
            }
            if (transaction.IssuerId == transaction.ReceiverId)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Can not Issure to your self!");
                defaultDialog.ShowDialog();
                return;
            }
            Item item = (Item)ItemCombo.SelectedItem;

            if (transaction.Amount > item.Stock && !transaction.Credit)
            {
                DefaultDialog defaultDialog = new DefaultDialog(this, "", "Cant issue more more than stock!");
                defaultDialog.ShowDialog();
                return;
            }
            try
            {
                System.Diagnostics.Debug.WriteLine(transaction.Id);
                using (var db = new ApplicationDBContext())
                {
                    if (transaction.Credit)
                    {
                        item.Stock += transaction.Amount;
                    }
                    else
                    {
                        item.Stock -= transaction.Amount;
                    }
                    ItemReport itemReport = db.ItemReports.Where(ir => ir.ItemId == item.Id && ir.Created.Date == DateTime.Today).SingleOrDefault();
                    if (itemReport == null)
                    {
                        itemReport = new ItemReport();

                        if (transaction.Credit)
                        {
                            itemReport.Brought += transaction.Amount;
                        }
                        else
                        {
                            itemReport.Taken += transaction.Amount;
                        }
                        itemReport.Remaining     = item.Stock;
                        itemReport.Transactions += 1;
                        itemReport.ItemId        = item.Id;
                        db.ItemReports.Add(itemReport);
                    }
                    else
                    {
                        if (transaction.Credit)
                        {
                            itemReport.Brought += transaction.Amount;
                        }
                        else
                        {
                            itemReport.Taken += transaction.Amount;
                        }
                        itemReport.Remaining     = item.Stock;
                        itemReport.Transactions += 1;
                        itemReport.ItemId        = item.Id;
                        db.ItemReports.Update(itemReport);
                    }
                    db.Items.Update(item);
                    db.Transactions.Add(transaction);
                    db.SaveChanges();
                }
            }
            catch (DbUpdateException ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }


            this.DialogResult = true;
            this.Close();
        }
Example #32
0
        private static ReportViewModel GenerateChecks(ReportViewModel viewModel, ItemReport itemReport, Item item)
        {
            //deal with the column names
            foreach (var ir in itemReport.Columns)
            {
                viewModel.ColumnNames.Add(ir.Name);
            }

            // go through all the transactions
            foreach (var x in item.Transactions.Where(a => a.ParentTransaction == null))
            {
                // go through all the unqiue quantity ids
                foreach (var y in x.PaymentLogs.Where(a => a.Check && a.Accepted))
                {
                    // this represents one row worth of data
                    var row = new List<string>();

                    // go through all the requested columns, x=transaction, y=quantityId
                    foreach (var z in itemReport.Columns)
                    {
                        row.Add(ExtractCheckValue(y, z.Name));
                    }

                    viewModel.RowValues.Add(row.ToArray());
                }
            }

            return viewModel;
        }
Example #33
0
        public ActionResult Create(int itemId, string name, CreateReportParameter[] createReportParameters)
        {
            var item = Repository.OfType<Item>().GetNullableById(itemId);

            if (item == null)
            {
                Message = NotificationMessages.STR_ObjectNotFound.Replace(NotificationMessages.ObjectType, "Item");
                return this.RedirectToAction<ItemManagementController>(a => a.List(null));
            }

            var report = new ItemReport(name, item,
                                        Repository.OfType<User>().Queryable.Where(
                                            a => a.LoginID == CurrentUser.Identity.Name).FirstOrDefault());
            if (createReportParameters == null || createReportParameters.Count() < 1)
            {
                Message = "Report Columns not Selected";
                var viewModel2 = CreateReportViewModel.Create(Repository, item);
                viewModel2.ItemReport = report;
                return View(viewModel2);
            }
            foreach(var crp in createReportParameters)
            {
                var questionSet = Repository.OfType<QuestionSet>().GetNullableById(crp.QuestionSetId);
                var question = Repository.OfType<Question>().GetNullableById(crp.QuestionId);

                ItemReportColumn itemReportColumn = crp.Property ? new ItemReportColumn(crp.PropertyName, report)
                    : new ItemReportColumn(question.Name, report);

                itemReportColumn.Transaction = crp.Transaction;
                itemReportColumn.Quantity = crp.Quantity;
                itemReportColumn.Property = crp.Property;
                itemReportColumn.QuestionSet = questionSet;
                itemReportColumn.Format = crp.Format;

                report.AddReportColumn(itemReportColumn);
            }

            MvcValidationAdapter.TransferValidationMessagesTo(ModelState, report.ValidationResults());

            if (ModelState.IsValid)
            {
                Repository.OfType<ItemReport>().EnsurePersistent(report);
                Message = NotificationMessages.STR_ObjectCreated.Replace(NotificationMessages.ObjectType, "Report");
                //return Redirect(ReturnUrlGenerator.DetailItemUrl(item.Id, StaticValues.Tab_Reports));

                return Redirect(Url.DetailItemUrl(item.Id, StaticValues.Tab_Reports));
            }

            Message = "Errors with report found.";
            var viewModel = CreateReportViewModel.Create(Repository, item);
            viewModel.ItemReport = report;
            return View(viewModel);
        }
Example #34
0
        private static ReportViewModel GenerateGeneric(ReportViewModel viewModel, ItemReport itemReport, Item item, bool fromExcel)
        {
            //deal with the column names
            foreach (var ir in itemReport.Columns)
            {
                viewModel.ColumnNames.Add(!string.IsNullOrWhiteSpace(ir.Format) && !fromExcel
                                              ? string.Format("{0} ({1})", ir.Name, ir.Format)
                                              : ir.Name);
            }

            // deal with the row values, if there are any quantity properties, we need to go through the quantity values
            if (itemReport.Columns.Any(a => a.Quantity))
            {
                // go through all the transactions
                foreach (var x in item.Transactions.Where(a => a.ParentTransaction == null))
                {
                    // go through all the unqiue quantity ids
                    foreach (var y in x.QuantityAnswers.Select(a => a.QuantityId).Distinct())
                    {
                        // this represents one row worth of data
                        var row = new List<string>();

                        // go through all the requested columns, x=transaction, y=quantityId
                        foreach (var z in itemReport.Columns)
                        {
                            row.Add(ExtractValue(z, x, y));
                        }

                        viewModel.RowValues.Add(row.ToArray());
                    }
                }
            }
            // otherwise it's a transaction level report
            else
            {
                // go through all the transactions
                foreach (var x in item.Transactions.Where(a => a.ParentTransaction == null))
                {
                    var row = new List<string>();

                    foreach (var z in itemReport.Columns)
                    {
                        row.Add(ExtractValue(z, x, null));
                    }

                    viewModel.RowValues.Add(row.ToArray());
                }
            }

            return viewModel;
        }