public static int Update(SQMatrixLines o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[13];

            arrParams[0]  = new SqlParameter("@SQMLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQMLID, o.SQMLID.GetTypeCode()));
            arrParams[1]  = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode()));
            arrParams[2]  = new SqlParameter("@LineOrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LineOrder, o.LineOrder.GetTypeCode()));
            arrParams[3]  = new SqlParameter("@LineText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LineText, o.LineText.GetTypeCode()));
            arrParams[4]  = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[5]  = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[6]  = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[7]  = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[8]  = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[9]  = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[10] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[11] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[12] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            try
            {
                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQMatrixLines_Update", arrParams);
            }

            catch (SqlException exx)
            {
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return(iReturn);
        }
        public static int Insert(SQMatrixLines o)
        {
            SqlParameter[] arrParams = new SqlParameter[13];

            arrParams[0]            = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode()));
            arrParams[1]            = new SqlParameter("@LineOrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LineOrder, o.LineOrder.GetTypeCode()));
            arrParams[2]            = new SqlParameter("@LineText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LineText, o.LineText.GetTypeCode()));
            arrParams[3]            = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[4]            = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[5]            = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[6]            = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[7]            = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[8]            = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[9]            = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[10]           = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[11]           = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));
            arrParams[12]           = new SqlParameter("@SQMLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQMLID, o.SQMLID.GetTypeCode()));
            arrParams[12].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQMatrixLines_Insert", arrParams);

            o.SQMLID = int.Parse(arrParams[12].Value.ToString());

            return(o.SQMLID);
        }
Exemplo n.º 3
0
        public static int MaxScore(int SID)
        {
            var maxScore = 0;
            var dsQ      = SurveyQuestion.GetAll(SID);

            foreach (DataRow qRow in dsQ.Tables[0].Rows)
            {
                var qType = Convert.ToInt32(qRow["QType"]);
                if (qType == 3)
                {
                    return(0);             // cannot score a test that has multiple choice
                }
                var isRequired = Convert.ToBoolean(qRow["IsRequired"]);
                if ((qType == 2 && !isRequired) || (qType == 4 && !isRequired))
                {
                    return(0);                                                             // cannot score a test that does not have all questions/answers required
                }
                var isCheckbox = Convert.ToInt32(qRow["DisplayControl"]) == 1;
                var QID        = Convert.ToInt32(qRow["QID"]);
                var qScore     = 0;

                if (qType == 2 || qType == 4)
                {
                    var dsA       = SQChoices.GetAll(QID);
                    var maxAScore = 0;
                    foreach (DataRow aRow in dsA.Tables[0].Rows)
                    {
                        var score = Convert.ToInt32(aRow["Score"]);
                        if (isCheckbox)
                        {
                            qScore += score;
                        }
                        else
                        {
                            if (score > maxAScore)
                            {
                                maxAScore = score;
                            }
                        }
                    }
                    if (!isCheckbox)
                    {
                        qScore += maxAScore;
                    }
                }
                if (qType == 4)
                {
                    //Matrix, how many lines?

                    var dsML     = SQMatrixLines.GetAll(QID);
                    var numLines = dsML.Tables[0].Rows.Count;
                    qScore = qScore * numLines;
                }
                maxScore += qScore;
            }

            return(maxScore);
        }
        public static int Delete(SQMatrixLines o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@SQMLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQMLID, o.SQMLID.GetTypeCode()));

            try
            {
                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQMatrixLines_Delete", arrParams);
            }

            catch (SqlException exx)
            {
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return(iReturn);
        }
        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();
            }

        }
        public static int Delete(SQMatrixLines o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@SQMLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQMLID, o.SQMLID.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQMatrixLines_Delete", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;

        }
        public static int Update(SQMatrixLines o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[13];

            arrParams[0] = new SqlParameter("@SQMLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQMLID, o.SQMLID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode()));
            arrParams[2] = new SqlParameter("@LineOrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LineOrder, o.LineOrder.GetTypeCode()));
            arrParams[3] = new SqlParameter("@LineText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LineText, o.LineText.GetTypeCode()));
            arrParams[4] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[5] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[6] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[7] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[8] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[9] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[10] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[11] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[12] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQMatrixLines_Update", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;

        }
        public static int Insert(SQMatrixLines o)
        {

            SqlParameter[] arrParams = new SqlParameter[13];

            arrParams[0] = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@LineOrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LineOrder, o.LineOrder.GetTypeCode()));
            arrParams[2] = new SqlParameter("@LineText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LineText, o.LineText.GetTypeCode()));
            arrParams[3] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[4] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[5] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[6] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[7] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[8] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[9] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[10] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[11] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));
            arrParams[12] = new SqlParameter("@SQMLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQMLID, o.SQMLID.GetTypeCode()));
            arrParams[12].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQMatrixLines_Insert", arrParams);

            o.SQMLID = int.Parse(arrParams[12].Value.ToString());

            return o.SQMLID;

        }
        public bool Fetch(int SQMLID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@SQMLID", SQMLID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_SQMatrixLines_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                SQMatrixLines result = new SQMatrixLines();

                int _int;

                if (int.TryParse(dr["SQMLID"].ToString(), out _int)) this.SQMLID = _int;
                if (int.TryParse(dr["QID"].ToString(), out _int)) this.QID = _int;
                if (int.TryParse(dr["LineOrder"].ToString(), out _int)) this.LineOrder = _int;
                this.LineText = dr["LineText"].ToString();
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) this.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) this.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) this.FldInt3 = _int;
                this.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();

                dr.Close();

                return true;

            }

            dr.Close();

            return false;

        }
        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();
            }
        }
        public bool Fetch(int SQMLID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@SQMLID", SQMLID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_SQMatrixLines_GetByID", arrParams);

            if (dr.Read())
            {
                // declare return value

                SQMatrixLines result = new SQMatrixLines();

                int _int;

                if (int.TryParse(dr["SQMLID"].ToString(), out _int))
                {
                    this.SQMLID = _int;
                }
                if (int.TryParse(dr["QID"].ToString(), out _int))
                {
                    this.QID = _int;
                }
                if (int.TryParse(dr["LineOrder"].ToString(), out _int))
                {
                    this.LineOrder = _int;
                }
                this.LineText = dr["LineText"].ToString();
                if (int.TryParse(dr["FldInt1"].ToString(), out _int))
                {
                    this.FldInt1 = _int;
                }
                if (int.TryParse(dr["FldInt2"].ToString(), out _int))
                {
                    this.FldInt2 = _int;
                }
                if (int.TryParse(dr["FldInt3"].ToString(), out _int))
                {
                    this.FldInt3 = _int;
                }
                this.FldBit1  = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2  = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3  = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();

                dr.Close();

                return(true);
            }

            dr.Close();

            return(false);
        }