Пример #1
0
    private void CreateTreeView()
    {
        DataSet  ds     = GetDataSet();
        TreeNode node   = null;
        Button   button = new Button();

        button.Click += new EventHandler(button_Click);
        button.Text   = "Get Checked Noted";

        tree = new TreeView();

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            node              = new TreeNode();
            node.Text         = (string)dr["CategoryName"];
            node.ShowCheckBox = true;
            tree.Nodes.Add(node);
        }


        // Add to the Panel control
        Panel1.Controls.Add(tree);
        Panel1.Controls.Add(button);
        Panel1.DataBind();
    }
Пример #2
0
    private void CreateMenuWithXmlFile()
    {
        string  path = @"E:\MyXmlFile.xml";
        DataSet ds   = new DataSet();

        ds.ReadXml(path);

        Menu menu = new Menu();

        menu.MenuItemClick += new MenuEventHandler(menu_MenuItemClick);


        for (int i = 0; i < ds.Tables.Count; i++)
        {
            MenuItem parentItem = new MenuItem((string)ds.Tables[i].TableName);
            menu.Items.Add(parentItem);


            for (int c = 0; c < ds.Tables[i].Columns.Count; c++)
            {
                MenuItem column = new MenuItem((string)ds.Tables[i].Columns[c].ColumnName);
                menu.Items.Add(column);


                for (int r = 0; r < ds.Tables[i].Rows.Count; r++)
                {
                    MenuItem row = new MenuItem((string)ds.Tables[i].Rows[r][c].ToString());
                    parentItem.ChildItems.Add(row);
                }
            }
        }

        Panel1.Controls.Add(menu);
        Panel1.DataBind();
    }
Пример #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DropDownListPizza.DataSource = PizzasDal.ListaPizzasOrdenes();
         DropDownListPizza.DataBind();
         DropDownListClientes.DataSource = ClientesDal.ListaClientesOrdenes();
         DropDownListClientes.DataBind();
     }
     else
     {
         Panel1.DataBind();
     }
 }
Пример #4
0
    private void CreateTreeViewWithSqlMapDataSource()
    {
        XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();

        System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1);
        myCollection.Add("siteMapFile", "Web.sitemap");
        xmlSiteMap.Initialize("provider", myCollection);
        xmlSiteMap.BuildSiteMap();

        SiteMapDataSource siteMap = new SiteMapDataSource();

        TreeView tree = new TreeView();

        tree.DataSource = siteMap;
        Panel1.Controls.Add(tree);
        Panel1.DataBind();
    }
Пример #5
0
    private void PopulateMenu()
    {
        DataSet ds = GetDataSetForMenu();

        Menu menu = new Menu();

        foreach (DataRow parentItem in ds.Tables["Categories"].Rows)
        {
            MenuItem categoryItem = new MenuItem((string)parentItem["CategoryName"]);
            menu.Items.Add(categoryItem);

            foreach (DataRow childItem in parentItem.GetChildRows("Children"))
            {
                MenuItem childrenItem = new MenuItem((string)childItem["ProductName"]);
                categoryItem.ChildItems.Add(childrenItem);
            }
        }

        Panel1.Controls.Add(menu);
        Panel1.DataBind();
    }
Пример #6
0
    protected void saveButton_Click(object sender, EventArgs e)
    {
        saveChanges_inPage();

        gameID = Session["gameIDSession"].ToString();

        Session["CorrectAnswer"] = 0;

        XmlNode questionForEdit     = RealxmlDoc.SelectSingleNode("/tree/game[@code=" + gameID + "]/questions");
        XmlNode FakequestionForEdit = FakexmlDoc.SelectSingleNode("/tree/game/questions");

        questionForEdit.InnerXml = FakequestionForEdit.InnerXml;
        XmlNode gameQuestNum = FakexmlDoc.SelectSingleNode("/tree/game");

        questionForEdit.ParentNode.Attributes["totalQes"].Value = gameQuestNum.Attributes["totalQes"].Value;
        XmlDataSourceFakeGame.Save();
        XmlDataSourceRealGame.Save();
        Panel1.DataBind();
        innerGridView.DataBind();
        Response.Redirect("EditGame.aspx");
    }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Customer cs = new Customer();

            DdlCountry.DataSource     = cs.LoadCountries();
            DdlCountry.DataTextField  = "CountryName";
            DdlCountry.DataValueField = "ID";
            DdlCountry.DataBind();
            ListItem li = new ListItem("Choose", "0");

            DdlCountry.Items.Add(li);
            DdlCountry.SelectedValue = "0";


            DataSet DT = cs.LoadCustomer();

            GridViewCustomerDetails.DataSource = DT.Tables[0];
            GridViewCustomerDetails.DataBind();


            DisplayHobbies();
            Panel1.DataBind();
        }
Пример #8
0
    protected void questImageDelete(object sender, ImageClickEventArgs e)
    {
        string  questId       = Session["editQuestNum"].ToString();
        XmlNode ImageToDelete = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/pic");

        ImageToDelete.ParentNode.RemoveChild(ImageToDelete);
        ImageButtonquestImgtooltip.Style.Add("margin-top", "4%");
        ImageButtonquestImgtooltip.Text = "הוסף תמונה מסוג JPEG '\' PNG";
        ImageButton deleteImg0 = (ImageButton)FindControl("deleteImg0");

        ((ImageButton)FindControl("ImageButtonquestImg")).CssClass = "questImageClass";
        ((ImageButton)FindControl("ImageButtonquestImg")).ImageUrl = "~/Images/image_icon.png";
        ((Label)FindControl("QuestCuontLbl")).CssClass             = "IfImageFalse";
        questionText.CssClass = "questImageFalse";
        if (questionText.Text.Length != 0)
        {
            FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/questionText").InnerText = Server.UrlEncode(questionText.Text);
        }
        XmlDataSourceFakeGame.Save();
        Panel1.Controls.Remove(deleteImg0);
        Panel1.DataBind();
        Response.Redirect("EditGame.aspx");
    }
Пример #9
0
    protected void createacurd()
    {
        string      GameID = Session["gameIDSession"].ToString();
        XmlDocument myDoc  = new XmlDocument();

        myDoc.Load(Server.MapPath("/tree/game.xml"));
        int qunum = myDoc.SelectNodes("//game[@GameCode=" + GameID + "]//question").Count;


        for (int i = 1; i <= qunum; i++)
        {
            string          d      = i.ToString();
            HtmlInputButton mylbl1 = new HtmlInputButton();
            mylbl1.Attributes["class"] = "accordion";
            mylbl1.Value = Server.UrlDecode(myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]/questionText").InnerText);
            Panel1.Controls.Add(mylbl1);

            int   ansnum   = myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]//answer").Count;
            Table thetable = new Table();
            thetable.Attributes["class"] = "panel";
            TableRow  trd = new TableRow();
            TableCell tdt = new TableCell();
            trd.Controls.Add(tdt);
            TableCell td = new TableCell();
            if (myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]/img").InnerText != "")
            {
                Image tdi = new Image();
                tdi.ImageUrl            = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]/img").InnerText;
                tdi.Attributes["class"] = "dordor Qimg";
                td.Attributes["class"]  = "tdimg";
                td.Controls.Add(tdi);
            }
            trd.Controls.Add(td);
            thetable.Controls.Add(trd);

            for (int l = 1; l <= ansnum; l++)
            {
                TableRow  tr  = new TableRow();
                TableCell tct = new TableCell();
                if (myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]//answer[" + l + "]/@feedback").InnerText == "True")
                {
                    tct.Text = "<i class='fas fa-check'></i>";
                }
                if (myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]//answer[" + l + "]/@feedback").InnerText == "False")
                {
                    tct.Text = "<i class='fas fa-times'></i>";
                }
                tr.Controls.Add(tct);
                TableCell tc = new TableCell();

                if (myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]//answer[" + l + "]/@AnsType").InnerText == "picture")
                {
                    Image tci = new Image();
                    tci.ImageUrl            = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]//answer[" + l + "]").InnerText;
                    tci.Attributes["class"] = "dordor";
                    tc.Controls.Add(tci);
                }
                else
                {
                    tc.Text = Server.UrlDecode(myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + d + "]//answer[" + l + "]").InnerText);
                }
                tr.Controls.Add(tc);
                thetable.Controls.Add(tr);
            }
            Panel1.Controls.Add(thetable);
        }
        Panel1.DataBind();
    }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!Page.IsPostBack)
        {
            Menu menu = new Menu();
            menu.MenuItemClick += new MenuEventHandler(menu_MenuItemClick);

            menu.CssClass = "header";
            menu.StaticMenuItemStyle.CssClass  = "header";
            menu.StaticMenuStyle.CssClass      = "header";
            menu.StaticSelectedStyle.CssClass  = "header";
            menu.DynamicMenuItemStyle.CssClass = "header";
            menu.DynamicMenuStyle.CssClass     = "header";
            menu.DynamicSelectedStyle.CssClass = "header";
            menu.ForeColor = System.Drawing.Color.DarkBlue;
            menu.Font.Size = 12;
            menu.StaticMenuItemStyle.HorizontalPadding = 20;


            DataSet ds = createMenuDataSet();
            for (int i = 0; i < ds.Tables.Count; i++)
            {
                string   menuval    = (string)ds.Tables[i].TableName;
                string[] mvals      = menuval.Split('~');
                MenuItem parentItem = new MenuItem(mvals[0]);
                menu.Items.Add(parentItem);
                if (mvals.Length == 2)
                {
                    parentItem.NavigateUrl = "javascript:NavMenu('" + mvals[1] + "')";
                }

                for (int c = 0; c < ds.Tables[i].Columns.Count; c++)
                {
                    menuval = (string)ds.Tables[i].Columns[c].ColumnName;
                    mvals   = menuval.Split('~');
                    MenuItem column = new MenuItem(mvals[0]);

                    parentItem.ChildItems.Add(column);
                    if (mvals.Length == 2)
                    {
                        column.NavigateUrl = "javascript:NavMenu('" + mvals[1] + "')";
                    }
                }
            }

            if (Session["Login"] != null && Session["Login"].ToString() == "1")
            {
                if (Session["Name"] != null)
                {
                    MenuItem wel = new MenuItem("Welcome : " + Session["Name"].ToString() + " (" + Session["REG_NUM"].ToString() + ")");
                    menu.Items.Add(wel);
                }
            }

            menu.Orientation = Orientation.Horizontal;
            //menu.BackColor = System.Drawing.Color.LightBlue;
            //menu.ForeColor = System.Drawing.Color.DarkBlue;
            menu.Font.Bold = true;

            Panel1.Controls.Add(menu);
            Panel1.DataBind();
        }
    }
Пример #11
0
    protected void Page_init(object sender, EventArgs e)
    {
        myDoc.Load(MapPath("trees/XMLFile1.xml"));
        XmlNodeList myNodes;
        string      theItemId = Session["theItemIdSession"].ToString();

        myNodes = myDoc.SelectNodes("//games/game[@id='" + theItemId + "']//question");
        foreach (XmlNode myNode in myNodes)
        {
            ListItem li = new ListItem();
            li.Text  = myNode.Attributes["text"].Value;
            li.Value = myNode.Attributes["id"].Value;
            RadioButtonList1.Items.Add(li);
        }
        RadioButtonList1.DataBind();


        Label questionlbl = new Label();

        questionlbl.ID   = "Questionlbl";
        questionlbl.Text = "הקלד שאלה";
        Panel1.Controls.Add(questionlbl);

        LiteralControl li7 = new LiteralControl("</br>");

        Panel1.Controls.Add(li7);

        TextBox question = new TextBox();

        question.ID = "Question";
        Panel1.Controls.Add(question);

        LiteralControl li8 = new LiteralControl("</br>");

        Panel1.Controls.Add(li8);

        Label anslbl = new Label();

        anslbl.ID   = "Anslbllbl";
        anslbl.Text = "הקלד תשובות לשאלה";
        Panel1.Controls.Add(anslbl);

        LiteralControl li11 = new LiteralControl("</br>");

        Panel1.Controls.Add(li11);

        for (int i = 0; i < 4; i++)
        {
            if (i == 0)
            {
                Label RightAnsLBL = new Label();
                RightAnsLBL.ID   = "RightAnslbl";
                RightAnsLBL.Text = "תשובה נכונה";
                Panel1.Controls.Add(RightAnsLBL);

                TextBox ans = new TextBox();
                ans.ID = "RightAns";
                Panel1.Controls.Add(ans);
            }
            else
            {
                LiteralControl li9 = new LiteralControl("</br>");
                Panel1.Controls.Add(li9);

                Label wrongAnsLBL = new Label();
                wrongAnsLBL.ID   = "wrongAnslbl" + i;
                wrongAnsLBL.Text = "תשובה לא נכונה";
                Panel1.Controls.Add(wrongAnsLBL);

                TextBox ans = new TextBox();
                ans.ID = "Ans" + i;
                Panel1.Controls.Add(ans);
            }
        }

        LiteralControl li10 = new LiteralControl("</br>");

        Panel1.Controls.Add(li10);

        Button btn = new Button();

        btn.Text   = "עדכן";
        btn.ID     = "btn1";
        btn.Click += new EventHandler(Clickbtn);
        Panel1.Controls.Add(btn);

        Panel1.DataBind();
    }
    protected void GeneratePritim(int nop)//בלחיצה על אחת הקטגוריות מופעלת הפונקציה להצגת הפריטים
    {
        int         selectedCategory = Convert.ToInt16(ListBox1.SelectedValue);
        XmlDocument myDoc            = new XmlDocument();

        myDoc.Load(MapPath("trees/XMLFile.xml"));
        string  myGameNum  = Convert.ToString(Session["theItemIdSessions"]);
        XmlNode myCategory = myDoc.SelectSingleNode("//Game[@id='" + myGameNum + "']").ChildNodes.Item(selectedCategory);

        if (nop >= 0)
        {
            for (int x = 0; x <= nop; x++)
            {
                if (myCategory.ChildNodes.Item(x).Attributes["type"].Value == "text")
                {
                    Panel mypanelT = new Panel();
                    mypanelT.ID       = "panelT" + x.ToString();
                    mypanelT.CssClass = "Pane";

                    Panel mypanelDesign = new Panel();
                    mypanelDesign.ID       = "designP" + x.ToString();
                    mypanelDesign.CssClass = "designP";

                    Label mylabel = new Label();
                    mylabel.ID       = "Label" + x.ToString();
                    mylabel.Text     = myCategory.ChildNodes.Item(x).InnerXml;
                    mylabel.CssClass = "LabelC";



                    ImageButton DeleteBTN = new ImageButton();
                    DeleteBTN.ImageUrl = "~/images/delete.png ";
                    DeleteBTN.ID       = "deleteI" + x.ToString();
                    DeleteBTN.CssClass = "DeleteB";

                    ImageButton EditBTN = new ImageButton();
                    EditBTN.ImageUrl = "~/images/edit.png";
                    EditBTN.ID       = "editI" + x.ToString();
                    EditBTN.CssClass = "EditB";


                    EditBTN.Click   += edit_text;
                    DeleteBTN.Click += delete_Show;

                    mypanelDesign.Controls.Add(EditBTN);
                    mypanelDesign.Controls.Add(DeleteBTN);


                    mypanelT.Controls.Add(mylabel);
                    mypanelT.Controls.Add(mypanelDesign);

                    Panel1.Controls.Add(mypanelT);
                }



                else
                {
                    Panel panelPic = new Panel();
                    panelPic.ID       = "panelPic" + x.ToString();
                    panelPic.CssClass = "Pane";

                    Panel mypanelDesignP = new Panel();
                    mypanelDesignP.ID       = "designPIC" + x.ToString();
                    mypanelDesignP.CssClass = "designPIC";


                    Image picturebox = new Image();
                    picturebox.ID       = "picturebox" + x.ToString();
                    picturebox.ImageUrl = myCategory.ChildNodes.Item(x).InnerXml;
                    picturebox.CssClass = "imageC";

                    using (System.Drawing.Image img =
                               System.Drawing.Image.FromFile(Server.MapPath(picturebox.ImageUrl)))
                    {
                        picturebox.Width  = new Unit(img.Width);
                        picturebox.Height = new Unit(img.Height);

                        if (Convert.ToInt16(img.Width) > Convert.ToInt16(img.Height))
                        {
                            picturebox.Width = 108;
                            int smaller = img.Width / 108;
                            int newH    = Convert.ToInt16(img.Height / (smaller));
                            picturebox.Height = new Unit(newH);
                        }
                        else if (Convert.ToInt16(img.Width) < Convert.ToInt16(img.Height))
                        {
                            picturebox.Height = 87;
                            int newsize = img.Height / 87;
                            int newW    = Convert.ToInt16(img.Width / (newsize));
                            picturebox.Width = new Unit(newW);
                        }
                        else
                        {
                            picturebox.Width  = 91;
                            picturebox.Height = 91;
                        }
                    }


                    ImageButton DeleteBTN = new ImageButton();
                    DeleteBTN.ImageUrl = "~/images/delete.png ";
                    DeleteBTN.ID       = "deleteI" + x.ToString();
                    DeleteBTN.CssClass = "DeleteB";

                    ImageButton EditBTNP = new ImageButton();
                    EditBTNP.ImageUrl = "~/images/edit.png";
                    EditBTNP.ID       = "editI" + x.ToString();
                    EditBTNP.CssClass = "EditBP";


                    EditBTNP.Click  += edit_Pic;
                    DeleteBTN.Click += delete_pic;

                    mypanelDesignP.Controls.Add(EditBTNP);
                    mypanelDesignP.Controls.Add(DeleteBTN);


                    panelPic.Controls.Add(picturebox);
                    panelPic.Controls.Add(mypanelDesignP);

                    Panel1.Controls.Add(panelPic);
                }
                Panel1.DataBind();
            }
        }
        else
        {
        }
    }
Пример #13
0
    protected void answerImageButton_Click(object sender, ImageClickEventArgs e)
    {
        string      questId = Session["editQuestNum"].ToString();
        ImageButton btn     = (ImageButton)sender;
        string      AnsId   = btn.ID;
        int         ansNum  = Convert.ToInt16(AnsId.Substring(AnsId.Length - 1));

        Session["answer"] = ansNum;

        //FakexmlDoc = XmlDataSourceFakeGame.GetXmlDocument();

        XmlElement Answer = FakexmlDoc.CreateElement("Answer");

        Answer.SetAttribute("pic", "no");
        Answer.SetAttribute("result", "wrong");
        XmlNode answers = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/Answers");

        answers.AppendChild(Answer);

        ImageButton delete = new ImageButton();

        delete.ID       = "answerDelete" + ansNum;
        delete.CssClass = "answer" + ansNum + "deleteClass";
        delete.ImageUrl = "images/Exit.png";
        delete.Click   += Delete_Answer;

        RadioButtonList answersList = (RadioButtonList)FindControl("answersList");
        ListItem        check       = new ListItem();

        check.Text  = "";
        check.Value = ansNum.ToString();
        answersList.Items.Add(check);

        ((Label)FindControl("answer" + ansNum + "tooltip")).Style.Add("visibility", "hidden");
        ((ImageButton)FindControl("ImageButton" + ansNum)).Enabled = false;
        ((Label)FindControl("Label" + ansNum)).Enabled             = false;
        ((ImageButton)FindControl("ImageButton" + ansNum)).Style.Add("visibility", "hidden");
        ((Label)FindControl("Label" + ansNum)).Style.Add("visibility", "hidden");

        if (ansNum != 6)
        {
            ((ImageButton)FindControl("ImageButton" + (ansNum + 1))).Style.Add("visibility", "visible");
            ((ImageButton)FindControl("answerImage" + (ansNum + 1))).Style.Add("visibility", "visible");
            ((Label)FindControl("Label" + (ansNum + 1))).Style.Add("visibility", "visible");
            ((Label)FindControl("answer" + (ansNum + 1) + "tooltip")).Style.Add("visibility", "visible");
            ((Label)FindControl("answer" + (ansNum + 1) + "tooltip")).Text = "ניתן להוסיף תשובה רק לאחר מילוי תוכן התשובות הקיימות";
        }

        if (AnsId.Contains("Button"))
        {
            TextBox ansewrText = new TextBox();
            ansewrText.TextMode = TextBoxMode.MultiLine;
            ansewrText.Attributes["placeholder"] = "הזן תשובה";
            ansewrText.Attributes["enableThis"]  = (ansNum + 1).ToString();
            ansewrText.ID       = "answer" + ansNum + "Textbox";
            ansewrText.CssClass = "ansText" + ansNum + "Class";
            ansewrText.Attributes["CharacterLimit"]    = "50";
            ansewrText.Attributes["CharacterForLabel"] = "AnslableCount" + ansNum;
            ansewrText.Attributes["ifEmptyDisable"]    = "ImageButton" + (ansNum + 1);
            Label lableCount = new Label();
            lableCount.ID       = "AnslableCount" + ansNum;
            lableCount.CssClass = "ansText" + ansNum + "Class";
            lableCount.Text     = ansewrText.Text.Length.ToString() + "/50";
            lableCount.Style.Add("visibility", "hidden");
            Panel1.Controls.Add(ansewrText);
            Panel1.Controls.Add(lableCount);
        }
        else
        {
            Answer.Attributes["pic"].Value = "yes";
            //נתיב לשמירה התמונות
            string imagesLibPath = "uploadedFiles/";

            string fileType = ((FileUpload)FindControl("FileUpload" + ansNum)).PostedFile.ContentType;

            if (fileType.Contains("image"))     //בדיקה האם הקובץ שהוכנס הוא תמונה
            {
                // הנתיב המלא של הקובץ עם שמו האמיתי של הקובץ
                string fileName = ((FileUpload)FindControl("FileUpload" + ansNum)).PostedFile.FileName;
                // הסיומת של הקובץ
                string endOfFileName = fileName.Substring(fileName.LastIndexOf("."));
                //לקיחת הזמן האמיתי למניעת כפילות בתמונות
                string myTime = DateTime.Now.ToString("dd_MM_yy-HH_mm_ss");
                // חיבור השם החדש עם הסיומת של הקובץ
                string imageNewName = myTime + ansNum + endOfFileName;
                // Bitmap המרת הקובץ שיתקבל למשתנה מסוג
                System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(((FileUpload)FindControl("FileUpload" + ansNum)).PostedFile.InputStream);
                //קריאה לפונקציה המקטינה את התמונה
                //אנו שולחים לה את התמונה שלנו בגירסאת הביטמאפ ואת האורך והרוחב שאנו רוצים לתמונה החדשה
                System.Drawing.Image objImage = FixedSize(bmpPostedImage, 300, 300);
                //שמירה של הקובץ לספרייה בשם החדש שלו
                objImage.Save(Server.MapPath(imagesLibPath) + imageNewName);
                //הצגה של הקובץ החדש מהספרייה
                ((ImageButton)FindControl("answerImage" + ansNum)).ImageUrl = imagesLibPath + imageNewName;
                Answer.InnerText = Server.UrlEncode(imagesLibPath + imageNewName);

                if (ansNum != 6)
                {
                    ((Label)FindControl("answer" + (ansNum + 1) + "tooltip")).Style.Add("visibility", "hidden");
                    ((ImageButton)FindControl("ImageButton" + (ansNum + 1))).Enabled = true;
                    ((ImageButton)FindControl("answerImage" + (ansNum + 1))).Enabled = true;
                    ((Label)FindControl("Label" + (ansNum + 1))).Enabled             = true;
                    ((Label)FindControl("Label" + (ansNum + 1))).CssClass            = "answerLabelClass";
                }
            }
            else
            {
                //הצגה של המסך האפור
                grayWindows.Visible = true;
                //הצגת הפופ-אפ של המחיקה
                DeleteConfPopUp.Visible = true;

                popUpmessage.Text     = "הקובץ שבחרת איננו מסוג PNG  /  JPEG";
                OkBtn0.Text           = "בחר קובץ אחר";
                OkBtn0.OnClientClick += "openFileUploader(" + ansNum + "); return false;";
                myExitBtn.Text        = "המשך עריכה";
            }
            ImageButton NewImageAns = (ImageButton)FindControl("answerImage" + ansNum);
            NewImageAns.CssClass = "answerImageClassTrue";
        }
        saveButton.Enabled = true;
        saveButtontooltip.Style.Add("visibility", "hidden");
        XmlDataSourceFakeGame.Save();
        Panel1.Controls.Add(delete);
        Panel1.DataBind();
    }
Пример #14
0
    protected void questionImageButton_Click(object sender, ImageClickEventArgs e)
    {
        string questId = Session["editQuestNum"].ToString();
        //FakexmlDoc = XmlDataSourceFakeGame.GetXmlDocument();
        XmlNode question      = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]");
        string  imagesLibPath = "uploadedFiles/";

        string fileType = ((FileUpload)FindControl("FileUpload0")).PostedFile.ContentType;

        if (fileType.Contains("image")) //בדיקה האם הקובץ שהוכנס הוא תמונה
        {
            // הנתיב המלא של הקובץ עם שמו האמיתי של הקובץ
            string fileName = ((FileUpload)FindControl("FileUpload0")).PostedFile.FileName;
            // הסיומת של הקובץ
            string endOfFileName = fileName.Substring(fileName.LastIndexOf("."));
            //לקיחת הזמן האמיתי למניעת כפילות בתמונות
            string myTime = DateTime.Now.ToString("dd_MM_yy-HH_mm_ss");
            // חיבור השם החדש עם הסיומת של הקובץ
            string imageNewName = myTime + "0" + endOfFileName;
            // Bitmap המרת הקובץ שיתקבל למשתנה מסוג
            System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(((FileUpload)FindControl("FileUpload0")).PostedFile.InputStream);
            //קריאה לפונקציה המקטינה את התמונה
            //אנו שולחים לה את התמונה שלנו בגירסאת הביטמאפ ואת האורך והרוחב שאנו רוצים לתמונה החדשה
            System.Drawing.Image objImage = FixedSize(bmpPostedImage, 300, 300);
            //שמירה של הקובץ לספרייה בשם החדש שלו
            objImage.Save(Server.MapPath(imagesLibPath) + imageNewName);
            //הצגה של הקובץ החדש מהספרייה
            ((ImageButton)FindControl("ImageButtonquestImg")).ImageUrl = imagesLibPath + imageNewName;

            XmlElement pic = FakexmlDoc.CreateElement("pic");

            pic.InnerText = Server.UrlEncode(imagesLibPath + imageNewName);

            ((ImageButton)FindControl("ImageButtonquestImg")).CssClass = "questImageClassTrue";
            ((TextBox)FindControl("questionText")).CssClass            = "questImageTrue";
            ((Label)FindControl("QuestCuontLbl")).CssClass             = "IfImageTrue";
            ImageButton deleteImg0 = new ImageButton();
            deleteImg0.Style.Add("visibility", "visible");
            deleteImg0.ID       = "deleteImg0";
            deleteImg0.ImageUrl = "images/Exit.png";
            deleteImg0.Click   += questImageDelete;
            FakexmlDoc.SelectSingleNode("//question[@numberQues = " + questId + "]").InsertBefore(pic, question.ChildNodes[1]);

            ImageButtonquestImgtooltip.Style.Add("margin-top", "1.5%");
            ImageButtonquestImgtooltip.Text = "ערוך תמונה";

            if (questionText.Text.Length != 0)
            {
                FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/questionText").InnerText = Server.UrlEncode(questionText.Text);
            }
            XmlDataSourceFakeGame.Save();
            Panel1.Controls.Add(deleteImg0);
            Panel1.DataBind();
            Response.Redirect("EditGame.aspx");
        }
        else
        {
            //הצגה של המסך האפור
            grayWindows.Visible = true;
            //הצגת הפופ-אפ של המחיקה
            DeleteConfPopUp.Visible = true;

            popUpmessage.Text     = "הקובץ שבחרת איננו מסוג PNG  /  JPEG";
            OkBtn0.Text           = "בחר קובץ אחר";
            OkBtn0.OnClientClick += "openFileUploader(0); return false;";
            myExitBtn.Text        = "המשך עריכה";
        }
    }
Пример #15
0
    protected void Delete_Answer(object sender, ImageClickEventArgs e)
    {
        Session["CorrectAnswer"] = 0;
        ImageButton btn               = (ImageButton)sender;
        string      AnsId             = btn.ID;
        int         x                 = Convert.ToInt16(AnsId.Substring(AnsId.Length - 1));
        Label       countLbl          = (Label)FindControl("AnslableCount" + x);
        string      questId           = Session["editQuestNum"].ToString();
        int         z                 = x - 1;
        XmlNode     questioninnerText = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/questionText");
        XmlNode     answersList       = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/Answers");

        questioninnerText.InnerText = Server.UrlEncode(questionText.Text);

        for (int i = 0; i <= 5; i++)
        {
            if ((TextBox)FindControl("answer" + (i + 1) + "Textbox") != null)
            {
                answersList.ChildNodes[i].InnerText = Server.UrlEncode(((TextBox)FindControl("answer" + (i + 1) + "Textbox")).Text);
            }
        }

        answersList.ChildNodes[z].InnerText = answersList.LastChild.InnerText;
        answersList.ChildNodes[z].Attributes["pic"].Value    = answersList.LastChild.Attributes["pic"].Value;
        answersList.ChildNodes[z].Attributes["result"].Value = answersList.LastChild.Attributes["result"].Value;

        XmlNode answerToRemove = answersList.LastChild;

        //if (answerToRemove.Attributes["result"].Value == "correct")
        //     {
        //         ((CheckBox)FindControl("answersList_" + x)).Checked = false;
        //     }

        if (answerToRemove.Attributes["pic"].Value == "yes")
        {
            string filePath = answerToRemove.InnerText;
            File.Delete(Server.MapPath(filePath));
            ImageButton AnswerImageToRemove = (ImageButton)FindControl("answerImage" + x);
            AnswerImageToRemove.ImageUrl = "/images/image_icon.png";
            AnswerImageToRemove.CssClass = "answerImageClass";
        }
        else
        {
            TextBox AnswerTxtToRemove = (TextBox)FindControl("answer" + x + "Textbox");
            Panel1.Controls.Remove(AnswerTxtToRemove);
        }

        answersList.RemoveChild(answerToRemove);
        XmlDataSourceFakeGame.Save();


        ((ImageButton)FindControl("ImageButton" + x)).Enabled = true;
        ((ImageButton)FindControl("answerImage" + x)).Enabled = true;
        ((ImageButton)FindControl("ImageButton" + x)).Style.Add("visibility", "visible");
        ((ImageButton)FindControl("answerImage" + x)).Style.Add("visibility", "visible");
        ((Label)FindControl("Label" + x)).Enabled = true;
        ((Label)FindControl("Label" + x)).Style.Add("visibility", "visible");

        Panel1.Controls.Remove(btn);
        Panel1.Controls.Remove(countLbl);
        Panel1.DataBind();
        Response.Redirect("EditGame.aspx");
    }
Пример #16
0
    protected void Page_init(object sender, EventArgs e)
    {
        Panel3.BackImageUrl = "/images/spaceship.png";
        gameID  = Session["gameIDSession"].ToString();
        questId = Session["editQuestNum"].ToString();

        XmlDataSourceRealGame.XPath = "/tree/game[@code = " + gameID + "]/questions/question";
        XmlDataSourceFakeGame.XPath = "/tree/game[@code = " + gameID + "]/questions/question";

        RealxmlDoc = XmlDataSourceRealGame.GetXmlDocument();
        RealxmlDoc.Load(Server.MapPath("tree/games.xml"));

        FakexmlDoc = XmlDataSourceFakeGame.GetXmlDocument();
        FakexmlDoc.Load(Server.MapPath("tree/fake.xml"));

        XmlNode fakeQuestNode = FakexmlDoc.SelectSingleNode("/tree/game[@code = " + gameID + "]/questions/question[@numberQues = " + questId + "]");
        XmlNode realQuestNode = RealxmlDoc.SelectSingleNode("/tree/game[@code = " + gameID + "]/questions/question[@numberQues = " + questId + "]");


        if (questId != "0")
        {
            saveButton.Text = "שמור שינויים";
            if (realQuestNode.InnerXml == fakeQuestNode.InnerXml)
            {
                save = false;
                saveButton.Enabled = false;
                saveButtontooltip.Style.Add("visibility", "visible");
                saveButtontooltip.Text = "טרם נערכו שינויים בשאלה";
            }
        }
        else
        {
            saveButtontooltip.Text = "טרם נערכו שינויים בשאלה";
            saveButton.Text        = "שמור שאלה";
        }

        gameName.Text = Server.UrlDecode(FakexmlDoc.SelectSingleNode("/tree/game[@code = " + gameID + "]/gameName").InnerText);

        XmlNode fakeQuest = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]");

        XmlNode fakeQuestText = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/questionText");

        questionText.Text  = Server.UrlDecode(fakeQuestText.InnerText);
        QuestCuontLbl.Text = questionText.Text.Length.ToString() + "/100";
        XmlNode fakeQuestImage = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/pic");

        if (fakeQuestImage != null)
        {
            questionText.CssClass        = "questImageTrue";
            ImageButtonquestImg.ImageUrl = Server.UrlDecode(fakeQuestImage.InnerText);
            ImageButtonquestImg.CssClass = "questImageClassTrue";
            ImageButton deleteImg0 = new ImageButton();
            deleteImg0.ID       = "deleteImg0";
            deleteImg0.ImageUrl = "images/Exit.png";
            deleteImg0.Click   += questImageDelete;
            Panel1.Controls.Add(deleteImg0);
            ImageButtonquestImgtooltip.Text = "החלפת תמונה";
            ((Label)FindControl("QuestCuontLbl")).CssClass = "IfImageTrue";
            ((Label)FindControl("QuestCuontLbl")).Style.Add("visibility", "hidden");
        }


        XmlNode fakeQuestAnsewrs = FakexmlDoc.SelectSingleNode("/tree/game/questions/question[@numberQues = " + questId + "]/Answers");

        int ansNum = 1;

        RadioButtonList answersList = new RadioButtonList();

        answersList.ID           = "answersList";
        answersList.AutoPostBack = true;
        Panel1.Controls.Add(answersList);

        if (questionText.Text.Length != 0)
        {
            ((Label)FindControl("answer1tooltip")).Style.Add("visibility", "hidden");
            ((ImageButton)FindControl("ImageButton1")).Enabled = true;
            ((ImageButton)FindControl("answerImage1")).Enabled = true;
            ((ImageButton)FindControl("ImageButton1")).Style.Add("visibility", "visible");
            ((ImageButton)FindControl("answerImage1")).Style.Add("visibility", "visible");
            ((Label)FindControl("Label1")).Enabled = true;
            ((Label)FindControl("Label1")).Style.Add("visibility", "visible");

            if (fakeQuestAnsewrs.ChildNodes.Count <= 1)
            {
                saveButtontooltip.Text = "שאלה חייבת להכיל שתי תשובות לפחות";
            }
        }

        for (int i = 3; i <= 6; i++)
        {
            ((Label)FindControl("answer" + i + "tooltip")).Style.Add("visibility", "hidden");
            ((ImageButton)FindControl("ImageButton" + i)).Style.Add("visibility", "hidden");
            ((ImageButton)FindControl("answerImage" + i)).Style.Add("visibility", "hidden");
            ((Label)FindControl("Label" + i)).Style.Add("visibility", "hidden");
        }


        foreach (XmlNode node in fakeQuestAnsewrs)
        {
            ((Label)FindControl("answer" + ansNum + "tooltip")).Style.Add("visibility", "hidden");
            ((ImageButton)FindControl("ImageButton" + ansNum)).Enabled = false;
            ((ImageButton)FindControl("answerImage" + ansNum)).Enabled = false;
            ((ImageButton)FindControl("ImageButton" + ansNum)).Style.Add("visibility", "hidden");
            ((ImageButton)FindControl("answerImage" + ansNum)).Style.Add("visibility", "hidden");
            ((Label)FindControl("Label" + ansNum)).Enabled = false;
            ((Label)FindControl("Label" + ansNum)).Style.Add("visibility", "hidden");

            ImageButton delete = new ImageButton();
            delete.ID       = "answerDelete" + ansNum;
            delete.CssClass = "answer" + ansNum + "deleteClass";
            delete.ImageUrl = "images/Exit.png";

            ListItem check = new ListItem();
            check.Text  = "";
            check.Value = ansNum.ToString();
            answersList.Items.Add(check);

            if (node.Attributes["result"].Value == "correct")
            {
                Session["CorrectAnswer"] = ansNum;
                check.Text     = ".";
                check.Selected = true;
            }

            if (node.Attributes["pic"].Value == "no")
            {
                TextBox ansewrText = new TextBox();
                ansewrText.Attributes["placeholder"] = "הזן תשובה";
                ansewrText.Attributes["enableThis"]  = (ansNum + 1).ToString();
                ansewrText.Text     = Server.UrlDecode(node.InnerText);
                ansewrText.TextMode = TextBoxMode.MultiLine;
                ansewrText.ID       = "answer" + ansNum + "Textbox";
                ansewrText.CssClass = "ansText" + ansNum + "Class";
                ansewrText.Attributes["CharacterLimit"]    = "50";
                ansewrText.Attributes["CharacterForLabel"] = "AnslableCount" + ansNum;

                Label lableCount = new Label();
                lableCount.ID       = "AnslableCount" + ansNum;
                lableCount.CssClass = "ansText" + ansNum + "Class";
                lableCount.Text     = ansewrText.Text.Length.ToString() + "/50";
                lableCount.Style.Add("visibility", "hidden");
                Panel1.Controls.Add(ansewrText);
                Panel1.Controls.Add(lableCount);
            }
            else
            {
                ((ImageButton)FindControl("answerImage" + ansNum)).Enabled = true;
                ((ImageButton)FindControl("answerImage" + ansNum)).Style.Add("visibility", "visible");
                ImageButton ansewrImage = (ImageButton)FindControl("answerImage" + ansNum);
                ansewrImage.ImageUrl = Server.UrlDecode(node.InnerText);
                ansewrImage.CssClass = "answerImageClassTrue";
            }

            delete.Click += Delete_Answer;
            Panel1.Controls.Add(delete);

            if (ansNum < 6)
            {
                ansNum++;
            }

            ((Label)FindControl("answer" + ansNum + "tooltip")).Style.Add("visibility", "hidden");
            ((ImageButton)FindControl("ImageButton" + ansNum)).Enabled = true;
            ((ImageButton)FindControl("answerImage" + ansNum)).Enabled = true;
            ((ImageButton)FindControl("ImageButton" + ansNum)).Style.Add("visibility", "visible");
            ((ImageButton)FindControl("answerImage" + ansNum)).Style.Add("visibility", "visible");
            ((Label)FindControl("Label" + ansNum)).Enabled = true;
            ((Label)FindControl("Label" + ansNum)).Style.Add("visibility", "visible");
        }
        if (answersList.SelectedValue == "")
        {
            saveButton.Enabled = false;
            if (answersList.Items.Count >= 2)
            {
                saveButtontooltip.Text = "חובה לסמן תשובה נכונה";
            }
        }
        else
        {
            if (answersList.Items.Count <= 1)
            {
                saveButtontooltip.Text = "שאלה חייבל להכיל שתי תשובות לפחות";
                saveButton.Enabled     = false;
            }
            else
            {
                if (saveButton.Enabled == true)
                {
                    saveButtontooltip.Style.Add("visibility", "hidden");
                }
            }
        }

        Panel1.Controls.Add(new LiteralControl("<br/>"));
        Panel1.DataBind();
    }