Exemple #1
0
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList2.Items.Clear();
            DropDownList3.Items.Clear();
            DropDownList4.Items.Clear();
            DropDownList5.Items.Clear();

            if (DropDownList1.SelectedItem.Text == "Select")
            {
                table1.Visible = false;
                table2.Visible = false;
                table3.Visible = false;
                table4.Visible = false;
                table5.Visible = false;
            }

            if (DropDownList1.SelectedItem.Text == "Add New Item")
            {
                table1.Visible = true;
                table2.Visible = false;
                table3.Visible = false;
                table4.Visible = false;
                table5.Visible = false;
            }
            if (DropDownList1.SelectedItem.Text == "Add New Manager")
            {
                table1.Visible = false;
                table2.Visible = true;
                table3.Visible = false;
                table4.Visible = false;
                table5.Visible = false;

                ShopHandler b = new ShopHandler();
                DataSet     d = b.GetAllUserNamesInSystem();
                DataSet     m = b.GetStoreManagers(Session["editshop"].ToString());
                int         c = 1;


                List <string> d1 = new List <string>();

                d1.Add(Session["username"].ToString());
                for (int j = 0; j < m.Tables[0].Rows.Count; j++)
                {
                    d1.Add(m.Tables[0].Rows[j]["username"].ToString());
                }

                DropDownList2.Items.Insert(0, new ListItem("please select a Manager"));

                for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                {
                    if (!(d1.Contains(d.Tables[0].Rows[i]["username"].ToString())))
                    {
                        DropDownList2.Items.Insert(c, new ListItem(d.Tables[0].Rows[i]["username"].ToString()));
                        c++;
                    }
                }
            }
            if (DropDownList1.SelectedItem.Text == "Add New Owner")
            {
                table1.Visible = false;
                table2.Visible = false;
                table3.Visible = true;
                table4.Visible = false;
                table5.Visible = false;

                ShopHandler b = new ShopHandler();
                DataSet     d = b.GetAllUserNamesInSystem();


                DataSet m = b.GetStoreOwners(Session["editshop"].ToString());
                int     c = 1;


                List <string> d1 = new List <string>();

                d1.Add(Session["username"].ToString());
                for (int j = 0; j < m.Tables[0].Rows.Count; j++)
                {
                    d1.Add(m.Tables[0].Rows[j]["username"].ToString());
                }

                DropDownList3.Items.Insert(0, new ListItem("please select a Owner"));

                for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                {
                    if (!(d1.Contains(d.Tables[0].Rows[i]["username"].ToString())))
                    {
                        DropDownList3.Items.Insert(c, new ListItem(d.Tables[0].Rows[i]["username"].ToString()));
                        c++;
                    }
                }
            }
            if (DropDownList1.SelectedItem.Text == "Fire Manager")
            {
                table1.Visible = false;
                table2.Visible = false;
                table3.Visible = false;
                table4.Visible = true;
                table5.Visible = false;

                ShopHandler b = new ShopHandler();
                DataSet     d = b.GetStoreManagers(Session["editshop"].ToString());
                DropDownList4.Items.Add(new ListItem("please select a Manager", "0"));
                for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                {
                    DropDownList4.Items.Insert(i, new ListItem(d.Tables[0].Rows[i]["username"].ToString()));
                }
                firegif.Visible = true;
            }
            if (DropDownList1.SelectedItem.Text == "Fire Owner")
            {
                table1.Visible = false;
                table2.Visible = false;
                table3.Visible = false;
                table4.Visible = false;
                table5.Visible = true;

                ShopHandler b = new ShopHandler();
                DataSet     d = b.GetStoreOwners(Session["editshop"].ToString());
                DropDownList5.Items.Add(new ListItem("please select a Owner", "0"));
                for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                {
                    if (!d.Tables[0].Rows[i]["username"].ToString().Equals(Session["username"]))
                    {
                        DropDownList5.Items.Insert(i, new ListItem(d.Tables[0].Rows[i]["username"].ToString()));
                    }
                }
                firegif.Visible = true;
            }
        }