Beispiel #1
0
        protected void btnClone_Click(object sender, ImageClickEventArgs e)
        {
            var so = Survey.FetchObject(int.Parse(SID.Text));
            var sn = Survey.FetchObject(int.Parse(SID.Text));

            sn.SID    = 0;
            sn.Name   = txtNewName.Text;
            sn.Status = 1;
            sn.Insert();

            var ds1 = SurveyQuestion.GetAll(so.SID);

            foreach (DataRow r1 in ds1.Tables[0].Rows)
            {
                var QID = Convert.ToInt32(r1["QID"]);

                var q = SurveyQuestion.FetchObject(QID);
                q.SID = sn.SID;
                q.QID = 0;
                q.Insert();

                var ds2 = SQChoices.GetAll(QID);
                foreach (DataRow r2 in ds2.Tables[0].Rows)
                {
                    var SQCID = Convert.ToInt32(r2["SQCID"]);
                    var c     = SQChoices.FetchObject(SQCID);
                    c.SQCID = 0;
                    c.QID   = q.QID;
                    c.Insert();
                }

                var ds3 = SQMatrixLines.GetAll(QID);
                foreach (DataRow r3 in ds3.Tables[0].Rows)
                {
                    var SQMLID = Convert.ToInt32(r3["SQMLID"]);
                    var l      = SQMatrixLines.FetchObject(SQMLID);
                    l.SQMLID = 0;
                    l.QID    = q.QID;
                    l.Insert();
                }
            }
            Session["SID"] = sn.SID;
            Response.Redirect("SurveyList.aspx");
            Response.Redirect("SurveyAddEdit.aspx");
        }
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Setup/SurveyQuestionAddEdit.aspx";

            if (e.CommandName.ToLower() == "addrecord")
            {
                var s = Survey.FetchObject(int.Parse(SID.Text));
                if (s.Status == 2)
                {
                    MasterPage.PageError = String.Format("<font color=red>{0}", "This Survey/Test is 'Locked / Active' and cannot be modified.");
                    return;
                }

                Response.Redirect("~/ControlRoom/Modules/Setup/SurveyQuestionAddWizard.aspx");
            }
            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);
                Session["QID"] = key; Response.Redirect(editpage);
            }
            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var obj = SurveyQuestion.FetchObject(key);
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        obj.Delete();

                        LoadData();
                        var masterPage = (IControlRoomMaster)Master;
                        if (masterPage != null)
                        {
                            masterPage.PageMessage = SRPResources.DeleteOK;
                        }
                    }
                    else
                    {
                        var    masterPage = (IControlRoomMaster)Master;
                        string message    = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        if (masterPage != null)
                        {
                            masterPage.PageError = message;
                        }
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                    }
                }
            }

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

                LoadData();
            }

            if (e.CommandName.ToLower() == "movedn")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SurveyQuestion.MoveDn(key);
                MasterPage.PageMessage = "Survey/Test Question Moved Down";
                LoadData();
            }


            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect("~/ControlRoom/Modules/Setup/SurveyList.aspx");
            }

            if (e.CommandName.ToLower() == "preview")
            {
                Session["QNum"]           = null;
                Session["TextReturnPage"] = "~/ControlRoom/Modules/Setup/SurveyQuestionList.aspx";
                Response.Redirect("~/ControlRoom/Modules/Setup/SurveyPreview.aspx");
            }

            if (e.CommandName.ToLower() == "results")
            {
                int key = Convert.ToInt32(e.CommandArgument);
                Response.Redirect("~/ControlRoom/Modules/Setup/SurveyResults.aspx");
            }
        }