Exemplo n.º 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Question q = new Question(rblType.SelectedIndex, txtDescription.Text);

            q.setDescription(txtDescription.Text);
            if (rblType.SelectedIndex == 0)
            {
                q.setChoice(0, txtChoice1.Text);
                q.setChoice(1, txtChoice2.Text);
                q.setChoice(2, txtChoice3.Text);
                q.setChoice(3, txtChoice4.Text);
                q.setChoice(4, txtChoice5.Text);
            }
            EvaluationForm eForm;

            if (Session["eForm"] != null)
            {
                eForm = Session["eForm"] as EvaluationForm;
            }
            else
            {
                eForm = new EvaluationForm();
            }
            eForm.addQuestion(q);
            Session["eForm"]    = eForm;
            txtDescription.Text = "";
            txtChoice1.Text     = "";
            txtChoice2.Text     = "";
            txtChoice3.Text     = "";
            txtChoice4.Text     = "";
            txtChoice5.Text     = "";
            refreshList();
        }
Exemplo n.º 2
0
        protected void btnPublish_Click(object sender, EventArgs e)
        {
            EvaluationForm eForm = Session["eForm"] as EvaluationForm;

            if (txtName.Text != "" && eForm != null)
            {
                // Insert class data
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
                conn.Open();
                string     insertQuery = "insert into [FormsQuestions] ([CreatorID],[FormName],[Description],[Choice1],[Choice2],[Choice3],[Choice4],[Choice5]) values (@CreatorID,@FormName,@Description,@Choice1,@Choice2,@Choice3,@Choice4,@Choice5)";
                SqlCommand comm        = new SqlCommand(insertQuery, conn);
                comm.Parameters.AddWithValue("@CreatorID", Session["ASU ID"].ToString());
                comm.Parameters.AddWithValue("@FormName", txtName.Text);

                foreach (Question q in eForm.getQuestions())
                {
                    comm.Parameters.AddWithValue("@Description", q.getDescription());
                    comm.Parameters.AddWithValue("@Choice1", q.getChoice(0));
                    comm.Parameters.AddWithValue("@Choice2", q.getChoice(1));
                    comm.Parameters.AddWithValue("@Choice3", q.getChoice(2));
                    comm.Parameters.AddWithValue("@Choice4", q.getChoice(3));
                    comm.Parameters.AddWithValue("@Choice5", q.getChoice(4));
                    comm.ExecuteNonQuery();
                }
                conn.Close();
                Response.Redirect("ClassManager.aspx");
            }
        }
Exemplo n.º 3
0
        private void refreshList()
        {
            ListBox1.Items.Clear();
            EvaluationForm eForm = Session["eForm"] as EvaluationForm;

            foreach (Question q in eForm.getQuestions())
            {
                ListBox1.Items.Add(q.getDescription());
            }
        }
Exemplo n.º 4
0
        protected void btnPublish_Click(object sender, EventArgs e)
        {
            EvaluationForm eForm = Session["eForm"] as EvaluationForm;

            eForm.setName(txtName.Text);
            string fLocation = Path.Combine(HttpRuntime.AppDomainAppPath, @"App_Data\" + txtName.Text + ".txt");

            //serialize
            using (Stream stream = File.Open(fLocation, FileMode.Create))
            {
                var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

                bformatter.Serialize(stream, eForm);
            }
        }
Exemplo n.º 5
0
        protected void btnModify_Click(object sender, EventArgs e)
        {
            EvaluationForm eForm = Session["eForm"] as EvaluationForm;
            Question       q     = eForm.getQuestions(ListBox1.SelectedIndex);

            q.setDescription(txtDescription.Text);
            if (rblType.SelectedIndex == 0)
            {
                q.setChoice(0, txtChoice1.Text);
                q.setChoice(1, txtChoice2.Text);
                q.setChoice(2, txtChoice3.Text);
                q.setChoice(3, txtChoice4.Text);
                q.setChoice(4, txtChoice5.Text);
            }
            eForm.replaceQuestion(ListBox1.SelectedIndex, q);
            Session["eForm"] = eForm;
            refreshList();
        }
Exemplo n.º 6
0
        protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            EvaluationForm eForm = Session["eForm"] as EvaluationForm;
            Question       q     = eForm.getQuestions(ListBox1.SelectedIndex);

            txtDescription.Text = q.getDescription();
            if (q.getType() == 0)
            {
                rblType.SelectedIndex = 0;
                setToVisible(true);
                txtChoice1.Text = q.getChoice(0);
                txtChoice2.Text = q.getChoice(1);
                txtChoice3.Text = q.getChoice(2);
                txtChoice4.Text = q.getChoice(3);
                txtChoice5.Text = q.getChoice(4);
            }
            else
            {
                rblType.SelectedIndex = 1;
                setToVisible(false);
            }
        }