示例#1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int section = int.Parse(dropSection.SelectedValue);

        //int? intSUCID = null;
        //int? intSUCIDLF = null;
        //int? intSUCIDRT = null;

        //if(intSUCID == 7)
        //{
        //    intSUCIDLF = int.Parse(dropsub.SelectedValue);
        //   // intSUCIDRT = int.Parse(dropsubrigth.SelectedValue);
        //}
        //else
        //{
        //    intSUCID = int.Parse(dropsub.SelectedValue);
        //}

        List <Model_Assessment_Choice> cl = new List <Model_Assessment_Choice>();

        if (!string.IsNullOrEmpty(Request.Form["chk_choice"]))
        {
            string[] arrchoice = Request.Form["chk_choice"].Split(',');

            foreach (string i in arrchoice)
            {
                cl.Add(new Model_Assessment_Choice
                {
                    Questions = Request.Form["question_s_" + i],
                    Priority  = int.Parse(Request.Form["pri_s_" + i]),
                    SUCID     = int.Parse(Request.Form["sel_sub_" + i]),
                    Code      = Request.Form["choice_sub_s_" + i]
                });
            }
        }

        Model_Assessment ass = new Model_Assessment
        {
            Questions = QuestionTitle.Text.Trim(),
            Code      = txtCode.Text.Trim(),
            SCID      = int.Parse(dropSection.SelectedValue),
            SUCID     = int.Parse(dropsub.SelectedValue),
            SUCID2    = string.IsNullOrEmpty(dropsub2.SelectedValue) ? (int?)null : int.Parse(dropsub2.SelectedValue),
            Status    = bool.Parse(status.SelectedValue),
            QTID      = byte.Parse(dropQType.SelectedValue),

            Priority        = int.Parse(txtpri.Text.Trim()),
            StartRank       = int.Parse(txtStartRank.Text.Trim()),
            EndRank         = int.Parse(txtEndRank.Text.Trim()),
            AssChoice       = cl,
            Side            = byte.Parse(dropside.SelectedValue),
            GroupName       = txtGroup.Text.Trim(),
            LeftScaleTitle  = leftTitle.Text,
            RigthScaleTitle = rightTitle.Text
        };

        Button btn = (Button)sender;

        if (!string.IsNullOrEmpty(Request.QueryString["ass"]))
        {
            int intID = int.Parse(Request.QueryString["ass"]);
            ass.ASID = intID;
            if (AssessmentController.EditAssessment(ass))
            {
                Response.Redirect("Assessment?Section=" + dropSection.SelectedValue);
            }
        }
        else
        {
            int Assid = AssessmentController.AddAssessment(ass);
            if (Assid > 0)
            {
                Response.Redirect("Assessment?Section=" + dropSection.SelectedValue);
                //Model_Assessment_Choice
                // Response.Redirect(Request.Url.ToString());
            }
        }
    }