Esempio n. 1
0
        public void loadProductList()
        {
            try
            {
                //load a list of all products
                products = handler.getAllProducts();
                //track row count & number of products cound
                int count = 0;

                if (products.Count > 0)
                {
                    //disply the table headers
                    //create a new row in the table and set the height
                    TableRow newRow = new TableRow();
                    newRow.Height = 50;
                    tblProductTable.Rows.Add(newRow);
                    //create a header row and set cell withs
                    //Product image row
                    TableHeaderCell newHeaderCell = new TableHeaderCell();
                    newHeaderCell.Width = 100;
                    tblProductTable.Rows[count].Cells.Add(newHeaderCell);
                    //create a header row and set cell withs
                    newHeaderCell       = new TableHeaderCell();
                    newHeaderCell.Text  = "Name: ";
                    newHeaderCell.Width = 300;
                    tblProductTable.Rows[count].Cells.Add(newHeaderCell);
                    //create a header row and set cell withs
                    newHeaderCell       = new TableHeaderCell();
                    newHeaderCell.Text  = "Description: ";
                    newHeaderCell.Width = 500;
                    tblProductTable.Rows[count].Cells.Add(newHeaderCell);
                    newHeaderCell       = new TableHeaderCell();
                    newHeaderCell.Width = 100;
                    tblProductTable.Rows[count].Cells.Add(newHeaderCell);

                    //increment rowcounter
                    count++;

                    foreach (PRODUCT prod in products)
                    {
                        //if the product maches the selected type
                        //if product matches the tearm
                        if ((function.compareToSearchTerm(prod.Name, txtProductSearchTerm.Text) == true ||
                             function.compareToSearchTerm(prod.ProductDescription, txtProductSearchTerm.Text) == true) &&
                            prod.ProductType[0] == 'S')
                        {
                            //diplay the product details
                            //add a new row to the table
                            newRow        = new TableRow();
                            newRow.Height = 50;
                            tblProductTable.Rows.Add(newRow);

                            //image
                            TableCell newCell = new TableCell();
                            //image display to be added here
                            tblProductTable.Rows[count].Cells.Add(newCell);

                            //Edit service link to be added by Sivu
                            //view service link to be added by Lachea

                            //Name
                            newCell      = new TableCell();
                            newCell.Text = "<a class='btn btn-default' href ='../cheveux/services.aspx?ProductID="
                                           + prod.ProductID.ToString().Replace(" ", string.Empty) + "'>" + prod.Name + "</a>";
                            tblProductTable.Rows[count].Cells.Add(newCell);

                            //Description
                            newCell      = new TableCell();
                            newCell.Text = "<a class='btn btn-default' href ='../cheveux/services.aspx?ProductID="
                                           + prod.ProductID.ToString().Replace(" ", string.Empty) + "'>" + prod.ProductDescription + "</a> ";
                            tblProductTable.Rows[count].Cells.Add(newCell);


                            if (prod.Active[0] == 'Y')
                            {
                                newCell = new TableCell();
                                tblProductTable.Rows[count].Cells.Add(newCell);
                            }
                            else
                            {
                                newCell      = new TableCell();
                                newCell.Text = "Inactive Service";
                                tblProductTable.Rows[count].Cells.Add(newCell);
                            }

                            //increment counter
                            count++;
                        }
                    }
                }

                //result count
                productJumbotronLable.Text = count - 1 + " Services";
                if (count - 1 == 0)
                {
                    productJumbotronLable.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    productJumbotronLable.ForeColor = System.Drawing.Color.Black;
                }
            }
            catch (Exception Err)
            {
                function.logAnError(Err.ToString()
                                    + " An error occurred retrieving list of Services with tearm " + txtProductSearchTerm.Text
                                    + " in loadEmployeeList() method on Manager/Employee page");
                productJumbotronLable.Font.Size = 22;
                productJumbotronLable.Font.Bold = true;
                productJumbotronLable.Text      = "An error occurred retrieving employee details";
            }
        }