Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var techSupportContext = new TechSupportContext();

            // If this is the first time we are loading the page, we query the data and populate the drop down lists
            if (!Page.IsPostBack)
            {
                List <SportsPro.Models.Customer>   customerList   = techSupportContext.getAllCustomers();
                List <SportsPro.Models.Technician> technicianList = techSupportContext.getAllTechnicians();
                List <SportsPro.Models.Product>    productList    = techSupportContext.getAllProducts();
                List <SportsPro.Models.Incident>   openIncidents  = techSupportContext.getOpenIncidents();

                if (customerList != null)
                {
                    ddl_customers.DataSource     = customerList;
                    ddl_customers.DataValueField = "CustomerID";
                    ddl_customers.DataTextField  = "Name";
                    ddl_customers.DataBind();
                }

                if (technicianList != null)
                {
                    ddl_technicians.DataSource     = technicianList;
                    ddl_technicians.DataValueField = "TechID";
                    ddl_technicians.DataTextField  = "Name";
                    ddl_technicians.DataBind();
                }

                if (productList != null)
                {
                    ddl_products.DataSource     = productList;
                    ddl_products.DataValueField = "ProductCode";
                    ddl_products.DataTextField  = "Name";
                    ddl_products.DataBind();
                }

                if (openIncidents != null)
                {
                    ddl_openIncidents.DataSource     = openIncidents;
                    ddl_openIncidents.DataValueField = "IncidentID";
                    ddl_openIncidents.DataTextField  = "IncidentID";
                    ddl_openIncidents.DataBind();
                }
            }

            // Now, whenever a PostBack happens, the Accordian Control updates it's data
            int selectedID = Convert.ToInt32(ddl_customers.SelectedValue);

            // We make sure that the selected value in the Customer ddl is a valid integer.
            if (selectedID > 0)
            {
                TechSupportContext context  = new TechSupportContext();
                List <Incident>    incident = context.returnIncidents(selectedID);
                Accd_Incident_View.DataSource = incident;
                Accd_Incident_View.DataBind();

                // The following line makes sure that the Accordian clears itself if a Customer without issues is selected
                if (incident == null)
                {
                    Accd_Incident_View.Panes.Clear();
                }
            }
        }