Beispiel #1
0
        private void DeliveryManagerForm_Load(object sender, EventArgs e)
        {
            dgTools.dbName = "Products";

            dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products Where Quality IN ('Satisfactory','Defective')";

            dgTools.PopulateDataGrid(prodDataGridView);
        }
        private void QualityAnalyzerForm_Load(object sender, EventArgs e)
        {
            dgTools.dbName = "Products";

            dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products";

            dgTools.PopulateDataGrid(prodDataGridView);
        }
Beispiel #3
0
        // Event handler for Stockiest Form load
        private void StockiestForm_Load(object sender, EventArgs e)
        {
            // Fill the data grid view on form with contents of given database using a data grid object
            dgTools.dbName = "RawMaterials";

            dgTools.SqlCommand = "SELECT RawMaterialName, Quantity FROM RawMaterials"; // Viewing all data from RawMaterials database except the ID

            dgTools.PopulateDataGrid(stockDataGridView);
        }
Beispiel #4
0
        // Event handler for Product Manager Form load
        private void ProductManagerForm_Load(object sender, EventArgs e)
        {
            // Fill the Product Manager form with Products database information upon creation
            try
            {
                dgTools.dbName = "Products";

                dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products";

                dgTools.PopulateDataGrid(prodDataGridView);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Warning!");
            }

            removeItemBtn.Visible = false;
        }
        private void ProductReport_Load(object sender, EventArgs e)
        {
            dgTools.dbName = "Products";

            dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products Where Quality IN ('Satisfactory','Defective')";

            dgTools.PopulateDataGrid(stockDataGridView);

            int    Count   = dbReport.CountProducts();
            string Counter = Count.ToString();

            countlbl1.Text = Counter;

            int    Avg     = dbReport.AvgQuantProducts();
            string Average = Avg.ToString();

            averagelbl1.Text = Average;

            int    Quality      = dbReport.GoodProducts();
            string Qualitylabel = Quality.ToString();

            satisfactorylbl1.Text = Qualitylabel;

            int    BadQuality = dbReport.BadProducts();
            string Badlabel   = BadQuality.ToString();

            defectivelbl1.Text = Badlabel;

            int    ProgressQuality = dbReport.ProgressProducts();
            string Progresslabel   = ProgressQuality.ToString();

            progresslbl1.Text = Progresslabel;

            decimal QualPercent = (Quality * 100 / Count);
            // Decimal QualPercent2 = Decimal.Truncate(QualPercent);
            string QualityPercent = QualPercent.ToString();

            qualitylbl1.Text = QualityPercent + "%";

            int    salescount = dbReport.SalesProducts();
            string SalesCount = salescount.ToString();

            saleslbl.Text = SalesCount;

            int    manucount = dbReport.ManuProducts();
            string ManuCount = manucount.ToString();

            manufacturinglbl1.Text = ManuCount;

            decimal salesPercent = (salescount * 100 / Count);
            // Decimal QualPercent2 = Decimal.Truncate(QualPercent);
            string SalesPercent = salesPercent.ToString();

            percentsaleslbl1.Text = SalesPercent + "%";
        }
Beispiel #6
0
        private void RawMaterialsReport_Load(object sender, EventArgs e)
        {
            // Fill the data grid view on form with contents of given database using a data grid object
            dgTools.dbName     = "RawMaterials";
            dgTools.SqlCommand = "SELECT RawMaterialName, Quantity FROM RawMaterials"; // Viewing all data from RawMaterials database except the ID
            dgTools.PopulateDataGrid(stockDataGridView);

            int    Count   = dbReport.CountMaterials();
            string Counter = Count.ToString();

            countlbl.Text = Counter;

            int    Avg     = dbReport.AvgQuantMaterials();
            string Average = Avg.ToString();

            averagelbl.Text = Average;
        }
        private void EditUser_Load(object sender, EventArgs e)
        {
            UserManager userManager = new UserManager();

            // Show Stockiests
            try
            {
                dgTools.dbName = "AuthorizedUsers";

                dgTools.SqlCommand = "SELECT firstname, lastname FROM AuthorizedUsers WHERE userjob in ('Stockiest')";

                dgTools.PopulateDataGrid(StockiestDataGridView);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Warning!");
            }

            // Show Product Managers
            try
            {
                dgTools.dbName = "AuthorizedUsers";

                dgTools.SqlCommand = "SELECT firstname, lastname FROM AuthorizedUsers WHERE userjob in ('Product Manager')";

                dgTools.PopulateDataGrid(ProductDataGridView);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Warning!");
            }

            // Show Delivery Managers
            try
            {
                dgTools.dbName = "AuthorizedUsers";

                dgTools.SqlCommand = "SELECT firstname, lastname FROM AuthorizedUsers WHERE userjob in ('Delivery Manager')";

                dgTools.PopulateDataGrid(DeliveryDataGridView);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Warning!");
            }

            // Show Report Managers
            try
            {
                dgTools.dbName = "AuthorizedUsers";

                dgTools.SqlCommand = "SELECT firstname, lastname FROM AuthorizedUsers WHERE userjob in ('Report Manager')";

                dgTools.PopulateDataGrid(ReportDataGridView);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Warning!");
            }

            // Show Quality Analyzers
            try
            {
                dgTools.dbName = "AuthorizedUsers";

                dgTools.SqlCommand = "SELECT firstname,lastname FROM AuthorizedUsers WHERE userjob in ('Quality Analyzer')";

                dgTools.PopulateDataGrid(QualityDataGridView);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Warning!");
            }
            // Show Admins
            try
            {
                dgTools.dbName = "AuthorizedUsers";

                dgTools.SqlCommand = "SELECT firstname, lastname FROM AuthorizedUsers WHERE userjob in ('Administrator')";

                dgTools.PopulateDataGrid(AdminDataGridView);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Warning!");
            }
        }
        public void ProductManagerFilterDatagrid(string nameFilter, string qualityFilter, string locationFilter, string quantityFilter, string inequality, DataGridView dataGrid, ToolStripStatusLabel status, string filterMenu)
        {
            dgTools.dbName     = this.dbName;
            dgTools.SqlCommand = this.SqlCommand;
            string info     = nameFilter;
            string qual     = qualityFilter;
            string location = locationFilter;

            // Filtering Products database
            if (dbName.Equals("Products"))
            {
                try
                {
                    switch (filterMenu)
                    {
                    case "Name":                                                                                                                           // Filtering by name
                        dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products WHERE ProductName LIKE " + "'%" + info + "%'"; // Any matches of the inputted search term
                        dgTools.PopulateDataGrid(dataGrid);
                        status.Text = ViewFilterResults(dataGrid);
                        break;

                    case "Quality":     // Filtering by quality
                        dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products WHERE Quality = " + "'" + qual + "'";
                        dgTools.PopulateDataGrid(dataGrid);
                        status.Text = ViewFilterResults(dataGrid);
                        break;

                    case "Quantity":     // Filtering by quantity
                        if (int.Parse(quantityFilter) > 0)
                        {
                            switch (inequality)
                            {
                            case "GREATER THAN":
                                dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products WHERE Quantity > " + "'" + quantityFilter + "'";
                                break;

                            case "LESS THAN":
                                dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products WHERE Quantity < " + "'" + quantityFilter + "'";
                                break;

                            case "EQUAL TO":
                                dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products WHERE Quantity = " + "'" + quantityFilter + "'";
                                break;

                            default:
                                MessageBox.Show("Not a valid selection. Please try again.", "Warning!");
                                break;
                            }
                        }
                        else     // Entered quantity is <= 0
                        {
                            MessageBox.Show("Quantity must be greater than zero");
                            status.Text = "";
                        }

                        dgTools.PopulateDataGrid(dataGrid);
                        status.Text = ViewFilterResults(dataGrid);
                        break;

                    case "Location":     // Filtering by location
                        dgTools.SqlCommand = "SELECT ProductName, Quality, Quantity, Location FROM Products WHERE Location = " + "'" + location + "'";
                        dgTools.PopulateDataGrid(dataGrid);
                        status.Text = ViewFilterResults(dataGrid);
                        break;

                    default:
                        break;
                    }
                }
                catch (FormatException)
                {
                    MessageBox.Show("Please input the correct information");
                    throw;
                }
            }
            else if (dbName.Equals("RawMaterials")) // Filtering Raw Materials database
            {
                try
                {
                    switch (filterMenu)
                    {
                    case "Name":
                        dgTools.SqlCommand = "SELECT RawMaterialName, Quantity FROM RawMaterials WHERE RawMaterialName LIKE " + "'%" + info + "%'";     // Any matches of the inputted search
                        dgTools.PopulateDataGrid(dataGrid);
                        status.Text = ViewFilterResults(dataGrid);
                        break;

                    case "Quantity":
                        if (int.Parse(quantityFilter) > 0)
                        {
                            switch (inequality)
                            {
                            case "GREATER THAN":
                                dgTools.SqlCommand = "SELECT RawMaterialName, Quantity FROM RawMaterials WHERE Quantity > " + "'" + quantityFilter + "'";
                                break;

                            case "LESS THAN":
                                dgTools.SqlCommand = "SELECT RawMaterialName, Quantity FROM RawMaterials WHERE Quantity < " + "'" + quantityFilter + "'";
                                break;

                            case "EQUAL TO":
                                dgTools.SqlCommand = "SELECT RawMaterialName, Quantity FROM RawMaterials WHERE Quantity = " + "'" + quantityFilter + "'";
                                break;

                            default:
                                MessageBox.Show("Not a valid selection. Please try again.", "Warning!");
                                break;
                            }
                        }
                        else     // Entered quantity is <= 0
                        {
                            MessageBox.Show("Quantity must be greater than zero");
                            status.Text = "";
                        }
                        dgTools.PopulateDataGrid(dataGrid);
                        status.Text = ViewFilterResults(dataGrid);
                        break;

                    default:
                        break;
                    }
                }
                catch (FormatException)
                {
                    //MessageBox.Show(err.Message, "Please input the correct information");
                    throw;
                }
            }
        }