Exemplo n.º 1
0
        public bool Fetch(int SID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

            if (dr.Read())
            {

                // declare return value

                Survey result = new Survey();

                int _int;

                if (int.TryParse(dr["SID"].ToString(), out _int)) this.SID = _int;
                this.Name = dr["Name"].ToString();
                this.LongName = dr["LongName"].ToString();
                this.Description = dr["Description"].ToString();
                this.Preamble = dr["Preamble"].ToString();
                if (int.TryParse(dr["Status"].ToString(), out _int)) this.Status = _int;
                if (int.TryParse(dr["TakenCount"].ToString(), out _int)) this.TakenCount = _int;
                if (int.TryParse(dr["PatronCount"].ToString(), out _int)) this.PatronCount = _int;
                this.CanBeScored = bool.Parse(dr["CanBeScored"].ToString());
                if (int.TryParse(dr["TenID"].ToString(), out _int)) this.TenID = _int;
                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 DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/SurveyList.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() == "add" || e.CommandName.ToLower() == "addandback") {
                try {
                    var obj = new Survey();
                    //obj.GenNotificationFlag = ((CheckBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2").FindControl("GenNotificationFlag")).Checked;

                    obj.Name = ((TextBox)((DetailsView)sender).FindControl("Name")).Text;
                    obj.LongName = ((TextBox)((DetailsView)sender).FindControl("LongName")).Text;
                    obj.Description = ((TextBox)((DetailsView)sender).FindControl("Description")).Text;
                    obj.Preamble = ((HtmlTextArea)((DetailsView)sender).FindControl("Preamble")).InnerHtml;
                    obj.Status = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("Status")).SelectedValue);
                    //obj.TakenCount = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("TakenCount")).Text);
                    //obj.PatronCount = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PatronCount")).Text);
                    //obj.CanBeScored = ((CheckBox)((DetailsView)sender).FindControl("CanBeScored")).Checked;

                    if(obj.IsValid(BusinessRulesValidationMode.INSERT)) {
                        obj.Insert();
                        if(e.CommandName.ToLower() == "addandback") {
                            Response.Redirect(returnURL);
                        }

                        lblPK.Text = obj.SID.ToString();
                        Session["SID"] = obj.SID;

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

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.AddedOK;
                    } 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);
                        masterPage.PageError = message;
                    }
                } catch(Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if(e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback" || e.CommandName.ToLower() == "questions") {
                try {
                    var obj = new Survey();
                    int pk = int.Parse(lblPK.Text);
                    obj.Fetch(pk);

                    obj.Name = ((TextBox)((DetailsView)sender).FindControl("Name")).Text;
                    obj.LongName = ((TextBox)((DetailsView)sender).FindControl("LongName")).Text;
                    obj.Description = ((TextBox)((DetailsView)sender).FindControl("Description")).Text;
                    obj.Preamble = ((HtmlTextArea)((DetailsView)sender).FindControl("Preamble")).InnerHtml;
                    obj.Status = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("Status")).SelectedValue);

                    if(obj.IsValid(BusinessRulesValidationMode.UPDATE)) {
                        obj.Update();
                        if(e.CommandName.ToLower() == "saveandback") {
                            Response.Redirect(returnURL);
                        }

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

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

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.SaveOK;
                    } 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);
                        masterPage.PageError = message;
                    }
                } catch(Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }

            if(e.CommandName.ToLower() == "results") {
                Response.Redirect("SurveyResults.aspx");
            }

            if(e.CommandName.ToLower() == "embed") {
                Response.Redirect("SurveyEmbedCode.aspx");
            }
        }
Exemplo n.º 3
0
        public static int Insert(Survey o)
        {
            SqlParameter[] arrParams = new SqlParameter[19];

            arrParams[0] = new SqlParameter("@Name", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Name, o.Name.GetTypeCode()));
            arrParams[1] = new SqlParameter("@LongName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LongName, o.LongName.GetTypeCode()));
            arrParams[2] = new SqlParameter("@Description", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Description, o.Description.GetTypeCode()));
            arrParams[3] = new SqlParameter("@Preamble", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Preamble, o.Preamble.GetTypeCode()));
            arrParams[4] = new SqlParameter("@Status", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Status, o.Status.GetTypeCode()));
            arrParams[5] = new SqlParameter("@TakenCount", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TakenCount, o.TakenCount.GetTypeCode()));
            arrParams[6] = new SqlParameter("@PatronCount", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronCount, o.PatronCount.GetTypeCode()));
            arrParams[7] = new SqlParameter("@CanBeScored", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CanBeScored, o.CanBeScored.GetTypeCode()));

            arrParams[8] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[9] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[10] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[11] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[12] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[13] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[14] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[15] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[16] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));
            arrParams[18] = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            arrParams[18].Direction = ParameterDirection.Output;

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

            o.SID = int.Parse(arrParams[18].Value.ToString());

            return o.SID;
        }
Exemplo n.º 4
0
        public static int Update(Survey o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[19];

            arrParams[0] = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@Name", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Name, o.Name.GetTypeCode()));
            arrParams[2] = new SqlParameter("@LongName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LongName, o.LongName.GetTypeCode()));
            arrParams[3] = new SqlParameter("@Description", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Description, o.Description.GetTypeCode()));
            arrParams[4] = new SqlParameter("@Preamble", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Preamble, o.Preamble.GetTypeCode()));
            arrParams[5] = new SqlParameter("@Status", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Status, o.Status.GetTypeCode()));
            arrParams[6] = new SqlParameter("@TakenCount", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TakenCount, o.TakenCount.GetTypeCode()));
            arrParams[7] = new SqlParameter("@PatronCount", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronCount, o.PatronCount.GetTypeCode()));
            arrParams[8] = new SqlParameter("@CanBeScored", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CanBeScored, o.CanBeScored.GetTypeCode()));

            arrParams[9] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[10] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[11] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[12] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[13] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[14] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[15] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[16] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[18] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            try
            {

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

            }

            catch (SqlException exx)
            {

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

            }

            return iReturn;
        }
Exemplo n.º 5
0
        public static int Delete(Survey o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

            try
            {

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

            }

            catch (SqlException exx)
            {

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

            }

            return iReturn;
        }
Exemplo n.º 6
0
        public static int Insert(Survey o)
        {

            var arrParams = new List<SqlParameter>();

            arrParams.Add(new SqlParameter("@Name", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Name, o.Name.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LongName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LongName, o.LongName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Description", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Description, o.Description.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Preamble", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Preamble, o.Preamble.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Status", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Status, o.Status.GetTypeCode())));
            arrParams.Add(new SqlParameter("@TakenCount", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TakenCount, o.TakenCount.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PatronCount", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronCount, o.PatronCount.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CanBeScored", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CanBeScored, o.CanBeScored.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BadgeId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BadgeId, o.BadgeId.GetTypeCode())));

            var sidParam = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            sidParam.Direction = ParameterDirection.Output;
            arrParams.Add(sidParam);

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

            o.SID = int.Parse(arrParams[18].Value.ToString());

            return o.SID;

        }
Exemplo n.º 7
0
        public static Survey FetchObject(int SID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

            if (dr.Read())
            {

                // declare return value

                Survey survey = new Survey();

                int _int;

                if (int.TryParse(dr["SID"].ToString(), out _int)) survey.SID = _int;
                survey.Name = dr["Name"].ToString();
                survey.LongName = dr["LongName"].ToString();
                survey.Description = dr["Description"].ToString();
                survey.Preamble = dr["Preamble"].ToString();
                if (int.TryParse(dr["Status"].ToString(), out _int)) survey.Status = _int;
                if (int.TryParse(dr["TakenCount"].ToString(), out _int)) survey.TakenCount = _int;
                if (int.TryParse(dr["PatronCount"].ToString(), out _int)) survey.PatronCount = _int;
                survey.CanBeScored = bool.Parse(dr["CanBeScored"].ToString());

                if (int.TryParse(dr["TenID"].ToString(), out _int)) survey.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) survey.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) survey.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) survey.FldInt3 = _int;
                survey.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                survey.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                survey.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                survey.FldText1 = dr["FldText1"].ToString();
                survey.FldText2 = dr["FldText2"].ToString();
                survey.FldText3 = dr["FldText3"].ToString();
                if (int.TryParse(dr["BadgeId"].ToString(), out _int)) survey.BadgeId = _int;

                dr.Close();

                return survey;

            }

            dr.Close();

            return null;

        }
Exemplo n.º 8
0
        public bool Fetch(int SID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

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

                Survey result = new Survey();

                int _int;

                if (int.TryParse(dr["SID"].ToString(), out _int))
                {
                    this.SID = _int;
                }
                this.Name        = dr["Name"].ToString();
                this.LongName    = dr["LongName"].ToString();
                this.Description = dr["Description"].ToString();
                this.Preamble    = dr["Preamble"].ToString();
                if (int.TryParse(dr["Status"].ToString(), out _int))
                {
                    this.Status = _int;
                }
                if (int.TryParse(dr["TakenCount"].ToString(), out _int))
                {
                    this.TakenCount = _int;
                }
                if (int.TryParse(dr["PatronCount"].ToString(), out _int))
                {
                    this.PatronCount = _int;
                }
                this.CanBeScored = bool.Parse(dr["CanBeScored"].ToString());
                if (int.TryParse(dr["TenID"].ToString(), out _int))
                {
                    this.TenID = _int;
                }
                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);
        }
Exemplo n.º 9
0
        public static Survey FetchObject(int SID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

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

                Survey survey = new Survey();

                int _int;

                if (int.TryParse(dr["SID"].ToString(), out _int))
                {
                    survey.SID = _int;
                }
                survey.Name        = dr["Name"].ToString();
                survey.LongName    = dr["LongName"].ToString();
                survey.Description = dr["Description"].ToString();
                survey.Preamble    = dr["Preamble"].ToString();
                if (int.TryParse(dr["Status"].ToString(), out _int))
                {
                    survey.Status = _int;
                }
                if (int.TryParse(dr["TakenCount"].ToString(), out _int))
                {
                    survey.TakenCount = _int;
                }
                if (int.TryParse(dr["PatronCount"].ToString(), out _int))
                {
                    survey.PatronCount = _int;
                }
                survey.CanBeScored = bool.Parse(dr["CanBeScored"].ToString());

                if (int.TryParse(dr["TenID"].ToString(), out _int))
                {
                    survey.TenID = _int;
                }
                if (int.TryParse(dr["FldInt1"].ToString(), out _int))
                {
                    survey.FldInt1 = _int;
                }
                if (int.TryParse(dr["FldInt2"].ToString(), out _int))
                {
                    survey.FldInt2 = _int;
                }
                if (int.TryParse(dr["FldInt3"].ToString(), out _int))
                {
                    survey.FldInt3 = _int;
                }
                survey.FldBit1  = bool.Parse(dr["FldBit1"].ToString());
                survey.FldBit2  = bool.Parse(dr["FldBit2"].ToString());
                survey.FldBit3  = bool.Parse(dr["FldBit3"].ToString());
                survey.FldText1 = dr["FldText1"].ToString();
                survey.FldText2 = dr["FldText2"].ToString();
                survey.FldText3 = dr["FldText3"].ToString();
                if (int.TryParse(dr["BadgeId"].ToString(), out _int))
                {
                    survey.BadgeId = _int;
                }

                dr.Close();

                return(survey);
            }

            dr.Close();

            return(null);
        }