예제 #1
0
 /// <summary>
 /// Handles the Click event of the btnAddQuestionnarie control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 protected void btnAddQuestionnarie_Click(object sender, EventArgs e)
 {
     try
     {
         QuestionnarieREBAL questionnarieBAL = new QuestionnarieREBAL();
         recruiterId = 12;
         questionnarieName = txtQuestionnarieName.Text.Trim();
         questionnarieId = questionnarieBAL.SaveQuestionnarieBAL(questionnarieName, recruiterId);
         // Check if questionnarieId is not equal to zero
         if (questionnarieId != 0)
         {
             ViewState["QuestionnarieId"] = questionnarieId;
             pnlQuestion.Visible = true;
             pnlQuestionnarie.Visible = false;
         }
         else
         {
             Response.Write("<script language='javascript'>alert('Questionnarie already exists')</script>");
         }
     }
     catch (Exception)
     {
         // throw;
     }
 }
예제 #2
0
 /// <summary>
 /// Handles the Click event of the btnSubmit control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         QuestionnarieREBAL questionnarieBAL = new QuestionnarieREBAL();
         DataTable dtQuestionnarie = (DataTable)ViewState["Questionnarie"];
         questionnarieBAL.SaveQuestionBAL(dtQuestionnarie);
         grdQuestionnarie.DataSource = null;
         grdQuestionnarie.DataBind();
         ViewState["Questionnarie"] = null;
         ViewState["QuestionnarieId"] = null;
         Response.Write("<script language='javascript'>alert('Questionnarie created...')</script>");
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet dsQuestionnarie = new DataSet();

            QuestionnarieREBAL questionnarieBAL = new QuestionnarieREBAL();
            dsQuestionnarie = questionnarieBAL.ViewQuestionnarieBAL(questionnarieId);
            // Check if dsQuestionnarie is not null
            if (dsQuestionnarie != null)
            {
                foreach (DataRow item in dsQuestionnarie.Tables[0].Rows)
                {
                    HtmlGenericControl innerDiv = new HtmlGenericControl("div");
                    Label lbl = new Label();
                    lbl.Text = item.Field<string>("QuestionName");
                    innerDiv.Controls.Add(lbl);
                    PlaceHolder1.Controls.Add(innerDiv);
                    //tr.Controls.Add(td1);

                    switch (item.Field<string>("QuestionType"))
                    {
                        case "TextBox":
                            HtmlGenericControl textBoxDiv = new HtmlGenericControl("div");
                            TextBox textBox = new TextBox();
                            textBoxDiv.Controls.Add(textBox);
                            PlaceHolder1.Controls.Add(textBoxDiv);

                            break;

                        case "List Menu":
                            HtmlGenericControl dropDownDiv = new HtmlGenericControl("div");
                            DropDownList dropDown = new DropDownList();

                            ListItem li = new ListItem();
                            li.Text = item.Field<string>("AnswerOption");
                            string list = li.Text;
                            string[] listMenu = list.Split(new char[] { ',' });
                            int count = 0;
                            foreach (string dropDownList in listMenu)
                            {
                                count += 1;
                                dropDown.Items.Add(dropDownList);
                            }
                            dropDownDiv.Controls.Add(dropDown);
                            PlaceHolder1.Controls.Add(dropDownDiv);
                            break;

                        case "Radio Button":
                            HtmlGenericControl radioButtonDiv = new HtmlGenericControl("div");
                            RadioButtonList radioButtonList = new RadioButtonList();
                            ListItem liRadioButton = new ListItem();
                            liRadioButton.Text = item.Field<string>("AnswerOption");
                            string radioButton = liRadioButton.Text;
                            string[] radioButtonMenu = radioButton.Split(new char[] { ',' });
                            int radioCount = 0;
                            foreach (string radioButtonLst in radioButtonMenu)
                            {
                                radioCount += 1;
                                radioButtonList.Items.Add(radioButtonLst);
                            }
                            radioButtonDiv.Controls.Add(radioButtonList);
                            PlaceHolder1.Controls.Add(radioButtonDiv);
                            break;

                        case "Check Box":
                            CheckBoxList chkList = new CheckBoxList();
                            HtmlGenericControl checkBoxListDiv = new HtmlGenericControl("div");
                            ListItem liCheckBoxList = new ListItem();
                            liCheckBoxList.Text = item.Field<string>("AnswerOption");
                            string checkBox = liCheckBoxList.Text;
                            string[] checkBoxListMenu = checkBox.Split(new char[] { ',' });
                            int checkCount = 0;
                            foreach (string checkBoxList in checkBoxListMenu)
                            {
                                checkCount += 1;
                                chkList.Items.Add(checkBoxList);
                            }
                            checkBoxListDiv.Controls.Add(chkList);
                            PlaceHolder1.Controls.Add(checkBoxListDiv);
                            break;

                        default:
                            break;
                    }
                }
            }
        }