示例#1
0
        protected void SaveType4Lines(int QID)
        {
            if (Session["tmpL4"] == null)
            {
                return;
            }
            var ds = (DataSet)Session["tmpL4"];

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                var obj = new SQMatrixLines();
                obj.QID      = QID;
                obj.LineText = r["LineText"].ToString();

                obj.Insert();
            }
        }
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/SurveyQuestionList.aspx";

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try
                {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageMessage = SRPResources.RefreshOK;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try
                {
                    if (Save((DetailsView)sender))
                    {
                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        MasterPage.PageMessage = SRPResources.SaveOK;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }

            if (e.CommandName.ToLower() == "moveup21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";

                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movedn21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "deleterecord21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQChoices.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecord21")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                var p4   = (Panel)tab2.FindControl("pnlType2Answers");

                var obj = new SQChoices();
                obj.QID                   = int.Parse(lblPK.Text);
                obj.ChoiceText            = ((TextBox)p4.FindControl("ChoiceText2")).Text;
                obj.Score                 = ((TextBox)p4.FindControl("Score2")).Text.SafeToInt();
                obj.JumpToQuestion        = ((DropDownList)p4.FindControl("JumpToQuestion2")).Text.SafeToInt();
                obj.AskClarification      = ((CheckBox)p4.FindControl("AskClarification2")).Checked;
                obj.ClarificationRequired = ((CheckBox)p4.FindControl("ClarificationRequired2")).Checked;
                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                odsData41.DataBind();
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }


            if (e.CommandName.ToLower() == "moveup41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";

                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movedn41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "deleterecord41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQChoices.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecord41")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                var p4   = (Panel)tab2.FindControl("pnlType4Answers");

                var obj = new SQChoices();
                obj.QID            = int.Parse(lblPK.Text);
                obj.ChoiceText     = ((TextBox)p4.FindControl("ChoiceText4")).Text;
                obj.Score          = ((TextBox)p4.FindControl("Score4")).Text.SafeToInt();
                obj.JumpToQuestion = ((DropDownList)p4.FindControl("JumpToQuestion4")).Text.SafeToInt();

                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                odsData41.DataBind();
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }



            if (e.CommandName.ToLower() == "moveupl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQMatrixLines.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movednl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQMatrixLines.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }



            if (e.CommandName.ToLower() == "deleterecordl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQMatrixLines.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecordl")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");

                var p4 = (Panel)tab2.FindControl("pnlType4Answers");

                var obj = new SQMatrixLines();
                obj.QID      = int.Parse(lblPK.Text);
                obj.LineText = ((TextBox)p4.FindControl("LineText4")).Text;

                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";

                odsData42.DataBind();
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }
        }