示例#1
0
        public static int Update(MGCodeBreaker o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[11];

            arrParams[0]  = new SqlParameter("@CBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CBID, o.CBID.GetTypeCode()));
            arrParams[1]  = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[2]  = new SqlParameter("@EasyString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EasyString, o.EasyString.GetTypeCode()));
            arrParams[3]  = new SqlParameter("@EnableMediumDifficulty", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EnableMediumDifficulty, o.EnableMediumDifficulty.GetTypeCode()));
            arrParams[4]  = new SqlParameter("@EnableHardDifficulty", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EnableHardDifficulty, o.EnableHardDifficulty.GetTypeCode()));
            arrParams[5]  = new SqlParameter("@MediumString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MediumString, o.MediumString.GetTypeCode()));
            arrParams[6]  = new SqlParameter("@HardString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HardString, o.HardString.GetTypeCode()));
            arrParams[7]  = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[8]  = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[9]  = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[10] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

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

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

            return(iReturn);
        }
示例#2
0
        public bool Fetch(int CBID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

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

                MGCodeBreaker result = new MGCodeBreaker();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["CBID"].ToString(), out _int))
                {
                    this.CBID = _int;
                }
                if (int.TryParse(dr["MGID"].ToString(), out _int))
                {
                    this.MGID = _int;
                }
                this.EasyString             = dr["EasyString"].ToString();
                this.EnableMediumDifficulty = bool.Parse(dr["EnableMediumDifficulty"].ToString());
                this.EnableHardDifficulty   = bool.Parse(dr["EnableHardDifficulty"].ToString());
                this.MediumString           = dr["MediumString"].ToString();
                this.HardString             = dr["HardString"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime))
                {
                    this.LastModDate = _datetime;
                }
                this.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime))
                {
                    this.AddedDate = _datetime;
                }
                this.AddedUser = dr["AddedUser"].ToString();

                dr.Close();

                return(true);
            }

            dr.Close();

            return(false);
        }
示例#3
0
        public static int Delete(MGCodeBreaker o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

            try {
                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_MGCodeBreaker_Delete", arrParams);
            } catch (SqlException exx) {
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return(iReturn);
        }
示例#4
0
        public static int Insert(MGCodeBreaker o)
        {
            SqlParameter[] arrParams = new SqlParameter[11];

            arrParams[0]            = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[1]            = new SqlParameter("@EasyString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EasyString, o.EasyString.GetTypeCode()));
            arrParams[2]            = new SqlParameter("@EnableMediumDifficulty", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EnableMediumDifficulty, o.EnableMediumDifficulty.GetTypeCode()));
            arrParams[3]            = new SqlParameter("@EnableHardDifficulty", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EnableHardDifficulty, o.EnableHardDifficulty.GetTypeCode()));
            arrParams[4]            = new SqlParameter("@MediumString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MediumString, o.MediumString.GetTypeCode()));
            arrParams[5]            = new SqlParameter("@HardString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HardString, o.HardString.GetTypeCode()));
            arrParams[6]            = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[7]            = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[8]            = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[9]            = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));
            arrParams[10]           = new SqlParameter("@CBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CBID, o.CBID.GetTypeCode()));
            arrParams[10].Direction = ParameterDirection.Output;

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

            o.CBID = int.Parse(arrParams[10].Value.ToString());

            return(o.CBID);
        }
        public static int Insert(Minigame o)
        {

            SqlParameter[] arrParams = new SqlParameter[23];

            arrParams[0] = new SqlParameter("@MiniGameType", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MiniGameType, o.MiniGameType.GetTypeCode()));
            arrParams[1] = new SqlParameter("@MiniGameTypeName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MiniGameTypeName, o.MiniGameTypeName.GetTypeCode()));
            arrParams[2] = new SqlParameter("@AdminName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode()));
            arrParams[3] = new SqlParameter("@GameName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.GameName, o.GameName.GetTypeCode()));
            arrParams[4] = new SqlParameter("@isActive", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.isActive, o.isActive.GetTypeCode()));
            arrParams[5] = new SqlParameter("@NumberPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NumberPoints, o.NumberPoints.GetTypeCode()));
            arrParams[6] = new SqlParameter("@AwardedBadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AwardedBadgeID, o.AwardedBadgeID.GetTypeCode()));
            arrParams[7] = new SqlParameter("@Acknowledgements", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Acknowledgements, o.Acknowledgements.GetTypeCode())); 
            arrParams[8] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[9] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[10] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[11] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

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

            arrParams[22] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[22].Direction = ParameterDirection.Output;

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

            o.MGID = int.Parse(arrParams[22].Value.ToString());


            if (o.MiniGameType == 1)
            {
                var o2 = new MGOnlineBook {MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate,LastModUser = o.LastModUser };
                o2.Insert();
            }
            if (o.MiniGameType == 2)
            {
                var o2 = new MGMixAndMatch() { MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser };
                o2.Insert();
            }
            if (o.MiniGameType == 3)
            {
                var o2 = new MGCodeBreaker() { MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser };
                o2.Insert();
            }            
            
            if (o.MiniGameType == 4)
            {
                var o2 = new MGWordMatch() { MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser };
                o2.Insert();
            }


            if (o.MiniGameType == 5)
            {
                var o2 = new MGMatchingGame() { MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser };
                o2.Insert();
            }


            if (o.MiniGameType == 6)
            {
                var o2 = new MGHiddenPic() { MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser };
                o2.Insert();
            }


            if (o.MiniGameType == 7)
            {
                var o2 = new MGChooseAdv() { MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser };
                o2.Insert();
            }
            

            return o.MGID;

        }
        public static int Delete(MGCodeBreaker o) {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

            try {

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

            } catch(SqlException exx) {

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

            }

            return iReturn;

        }
        public static int Update(MGCodeBreaker o) {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[11];

            arrParams[0] = new SqlParameter("@CBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CBID, o.CBID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[2] = new SqlParameter("@EasyString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EasyString, o.EasyString.GetTypeCode()));
            arrParams[3] = new SqlParameter("@EnableMediumDifficulty", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EnableMediumDifficulty, o.EnableMediumDifficulty.GetTypeCode()));
            arrParams[4] = new SqlParameter("@EnableHardDifficulty", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EnableHardDifficulty, o.EnableHardDifficulty.GetTypeCode()));
            arrParams[5] = new SqlParameter("@MediumString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MediumString, o.MediumString.GetTypeCode()));
            arrParams[6] = new SqlParameter("@HardString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HardString, o.HardString.GetTypeCode()));
            arrParams[7] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[8] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[9] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[10] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

            try {

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

            } catch(SqlException exx) {

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

            }

            return iReturn;

        }
        public static int Insert(MGCodeBreaker o) {

            SqlParameter[] arrParams = new SqlParameter[11];

            arrParams[0] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@EasyString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EasyString, o.EasyString.GetTypeCode()));
            arrParams[2] = new SqlParameter("@EnableMediumDifficulty", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EnableMediumDifficulty, o.EnableMediumDifficulty.GetTypeCode()));
            arrParams[3] = new SqlParameter("@EnableHardDifficulty", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EnableHardDifficulty, o.EnableHardDifficulty.GetTypeCode()));
            arrParams[4] = new SqlParameter("@MediumString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MediumString, o.MediumString.GetTypeCode()));
            arrParams[5] = new SqlParameter("@HardString", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HardString, o.HardString.GetTypeCode()));
            arrParams[6] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[7] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[8] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[9] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));
            arrParams[10] = new SqlParameter("@CBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CBID, o.CBID.GetTypeCode()));
            arrParams[10].Direction = ParameterDirection.Output;

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

            o.CBID = int.Parse(arrParams[10].Value.ToString());

            return o.CBID;

        }
        public bool Fetch(int CBID) {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

            if(dr.Read()) {

                // declare return value

                MGCodeBreaker result = new MGCodeBreaker();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if(int.TryParse(dr["CBID"].ToString(), out _int))
                    this.CBID = _int;
                if(int.TryParse(dr["MGID"].ToString(), out _int))
                    this.MGID = _int;
                this.EasyString = dr["EasyString"].ToString();
                this.EnableMediumDifficulty = bool.Parse(dr["EnableMediumDifficulty"].ToString());
                this.EnableHardDifficulty = bool.Parse(dr["EnableHardDifficulty"].ToString());
                this.MediumString = dr["MediumString"].ToString();
                this.HardString = dr["HardString"].ToString();
                if(DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime))
                    this.LastModDate = _datetime;
                this.LastModUser = dr["LastModUser"].ToString();
                if(DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime))
                    this.AddedDate = _datetime;
                this.AddedUser = dr["AddedUser"].ToString();

                dr.Close();

                return true;

            }

            dr.Close();

            return false;

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

            if (e.CommandName.ToLower() == "more")
            {
                ////Session["MGID"] = (int)e.CommandArgument;  // Already set ...
                //Response.Redirect("~/ControlRoom/Modules/Setup/MGCodeBreakerKeySetup.aspx?CBID=" + ((TextBox)((DetailsView)sender).FindControl("CBID")).Text);
                ////Response.Redirect("~/ControlRoom/Modules/Setup/MGCodeBreakerKeySetup.aspx?MGID=" + e.CommandArgument + "&CBID=" + ((TextBox)((DetailsView)sender).FindControl("CBID")).Text);
                Response.Redirect("~/ControlRoom/Modules/Setup/MGCodeBreakerKeySetup.aspx?CBID=" + ((TextBox)((DetailsView)sender).FindControl("CBID")).Text + "&d=1");
            }
            if (e.CommandName.ToLower() == "more2")
            {
                Response.Redirect("~/ControlRoom/Modules/Setup/MGCodeBreakerKeySetup.aspx?CBID=" + ((TextBox)((DetailsView)sender).FindControl("CBID")).Text + "&d=2");
            }
            if (e.CommandName.ToLower() == "more3")
            {
                Response.Redirect("~/ControlRoom/Modules/Setup/MGCodeBreakerKeySetup.aspx?CBID=" + ((TextBox)((DetailsView)sender).FindControl("CBID")).Text + "&d=3");
            }

            if (e.CommandName.ToLower() == "preview")
            {
                Session["MGID"] = e.CommandArgument;
                int key = Convert.ToInt32(e.CommandArgument);
                var obj = Minigame.FetchObject(key);
                Session["CRGoToUrl"] = Minigame.GetEditPage(obj.MiniGameType) + "?PK=" + e.CommandArgument;
                Response.Redirect("~/ControlRoom/Modules/Setup/MinigamePreview.aspx?MGID=" + e.CommandArgument);
            }

            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
                {
                    var obj = new MGCodeBreaker();
                    //int pk = int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text);
                    int pk = int.Parse(((TextBox)((DetailsView)sender).FindControl("CBID")).Text);
                    obj.Fetch(pk);

                    var obj2 = Minigame.FetchObject(obj.MGID);


                    obj2.AdminName = ((TextBox)((DetailsView)sender).FindControl("AdminName")).Text;
                    obj2.GameName = ((TextBox)((DetailsView)sender).FindControl("GameName")).Text;
                    obj2.isActive = ((CheckBox)((DetailsView)sender).FindControl("isActive")).Checked;
                    obj2.NumberPoints = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("NumberPoints")).Text);
                    obj2.AwardedBadgeID = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("AwardedBadgeID")).SelectedValue);
                    obj2.Acknowledgements = ((HtmlTextArea)((DetailsView)sender).FindControl("Acknowledgements")).InnerHtml;

                    obj.EasyString = ((TextBox)((DetailsView)sender).FindControl("EasyString")).Text;
                    obj.MediumString = ((TextBox)((DetailsView)sender).FindControl("MediumString")).Text;
                    obj.HardString = ((TextBox)((DetailsView)sender).FindControl("HardString")).Text;

                    obj.EnableMediumDifficulty = ((CheckBox)((DetailsView)sender).FindControl("EnableMediumDifficulty")).Checked;
                    obj.EnableHardDifficulty = ((CheckBox)((DetailsView)sender).FindControl("EnableHardDifficulty")).Checked;

                    obj2.LastModDate = obj.LastModDate = DateTime.Now;
                    obj2.LastModUser = obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE) && obj2.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();
                        obj2.Update();
                        new SessionTools(Session).RemoveCache(Cache, CacheKey.AdventuresActive);

                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        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);
                }
            }
        }
示例#11
0
        public static int Insert(Minigame o)
        {
            SqlParameter[] arrParams = new SqlParameter[23];

            arrParams[0]  = new SqlParameter("@MiniGameType", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MiniGameType, o.MiniGameType.GetTypeCode()));
            arrParams[1]  = new SqlParameter("@MiniGameTypeName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MiniGameTypeName, o.MiniGameTypeName.GetTypeCode()));
            arrParams[2]  = new SqlParameter("@AdminName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode()));
            arrParams[3]  = new SqlParameter("@GameName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.GameName, o.GameName.GetTypeCode()));
            arrParams[4]  = new SqlParameter("@isActive", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.isActive, o.isActive.GetTypeCode()));
            arrParams[5]  = new SqlParameter("@NumberPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NumberPoints, o.NumberPoints.GetTypeCode()));
            arrParams[6]  = new SqlParameter("@AwardedBadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AwardedBadgeID, o.AwardedBadgeID.GetTypeCode()));
            arrParams[7]  = new SqlParameter("@Acknowledgements", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Acknowledgements, o.Acknowledgements.GetTypeCode()));
            arrParams[8]  = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[9]  = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[10] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[11] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

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

            arrParams[22]           = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[22].Direction = ParameterDirection.Output;

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

            o.MGID = int.Parse(arrParams[22].Value.ToString());


            if (o.MiniGameType == 1)
            {
                var o2 = new MGOnlineBook {
                    MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser
                };
                o2.Insert();
            }
            if (o.MiniGameType == 2)
            {
                var o2 = new MGMixAndMatch()
                {
                    MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser
                };
                o2.Insert();
            }
            if (o.MiniGameType == 3)
            {
                var o2 = new MGCodeBreaker()
                {
                    MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser
                };
                o2.Insert();
            }

            if (o.MiniGameType == 4)
            {
                var o2 = new MGWordMatch()
                {
                    MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser
                };
                o2.Insert();
            }


            if (o.MiniGameType == 5)
            {
                var o2 = new MGMatchingGame()
                {
                    MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser
                };
                o2.Insert();
            }


            if (o.MiniGameType == 6)
            {
                var o2 = new MGHiddenPic()
                {
                    MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser
                };
                o2.Insert();
            }


            if (o.MiniGameType == 7)
            {
                var o2 = new MGChooseAdv()
                {
                    MGID = o.MGID, AddedDate = o.AddedDate, AddedUser = o.AddedUser, LastModDate = o.LastModDate, LastModUser = o.LastModUser
                };
                o2.Insert();
            }


            return(o.MGID);
        }