Beispiel #1
0
        public static int Insert(MGOnlineBookPages o)
        {
            SqlParameter[] arrParams = new SqlParameter[14];

            arrParams[0]            = new SqlParameter("@OBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OBID, o.OBID.GetTypeCode()));
            arrParams[1]            = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[2]            = new SqlParameter("@PageNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PageNumber, o.PageNumber.GetTypeCode()));
            arrParams[3]            = new SqlParameter("@TextEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextEasy, o.TextEasy.GetTypeCode()));
            arrParams[4]            = new SqlParameter("@TextMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextMedium, o.TextMedium.GetTypeCode()));
            arrParams[5]            = new SqlParameter("@TextHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextHard, o.TextHard.GetTypeCode()));
            arrParams[6]            = new SqlParameter("@AudioEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioEasy, o.AudioEasy.GetTypeCode()));
            arrParams[7]            = new SqlParameter("@AudioMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioMedium, o.AudioMedium.GetTypeCode()));
            arrParams[8]            = new SqlParameter("@AudioHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioHard, o.AudioHard.GetTypeCode()));
            arrParams[9]            = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[10]           = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[11]           = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[12]           = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));
            arrParams[13]           = new SqlParameter("@OBPGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OBPGID, o.OBPGID.GetTypeCode()));
            arrParams[13].Direction = ParameterDirection.Output;

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

            o.OBPGID = int.Parse(arrParams[13].Value.ToString());

            return(o.OBPGID);
        }
Beispiel #2
0
        public static int Update(MGOnlineBookPages o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[14];

            arrParams[0]  = new SqlParameter("@OBPGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OBPGID, o.OBPGID.GetTypeCode()));
            arrParams[1]  = new SqlParameter("@OBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OBID, o.OBID.GetTypeCode()));
            arrParams[2]  = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[3]  = new SqlParameter("@PageNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PageNumber, o.PageNumber.GetTypeCode()));
            arrParams[4]  = new SqlParameter("@TextEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextEasy, o.TextEasy.GetTypeCode()));
            arrParams[5]  = new SqlParameter("@TextMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextMedium, o.TextMedium.GetTypeCode()));
            arrParams[6]  = new SqlParameter("@TextHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextHard, o.TextHard.GetTypeCode()));
            arrParams[7]  = new SqlParameter("@AudioEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioEasy, o.AudioEasy.GetTypeCode()));
            arrParams[8]  = new SqlParameter("@AudioMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioMedium, o.AudioMedium.GetTypeCode()));
            arrParams[9]  = new SqlParameter("@AudioHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioHard, o.AudioHard.GetTypeCode()));
            arrParams[10] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[11] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[12] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[13] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

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

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

            return(iReturn);
        }
Beispiel #3
0
        public static int Delete(MGOnlineBookPages o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

            try
            {
                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_MGOnlineBookPages_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/MGOnlineBookPagesList.aspx";
            //string returnURL = "~/ControlRoom/Modules/Setup/MGOnlineBookPagesList.aspx?MGID=" + lblMGID.Text;
            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 MGOnlineBookPages();
                    //obj.GenNotificationFlag = ((CheckBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2").FindControl("GenNotificationFlag")).Checked;

                    obj.OBID = FormatHelper.SafeToInt(lblOBID.Text);
                    obj.MGID = FormatHelper.SafeToInt(lblMGID.Text);
                    //obj.PageNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PageNumber")).Text);
                    obj.TextEasy = ((TextBox)((DetailsView)sender).FindControl("TextEasy")).Text;
                    obj.TextMedium = ((TextBox)((DetailsView)sender).FindControl("TextMedium")).Text;
                    obj.TextHard = ((TextBox)((DetailsView)sender).FindControl("TextHard")).Text;
                    obj.AudioEasy= string.Empty;// ((TextBox)((DetailsView)sender).FindControl("AudioEasy")).Text;
                    obj.AudioMedium= string.Empty;//"((TextBox)((DetailsView)sender).FindControl("AudioMedium")).Text;
                    obj.AudioHard= string.Empty;//"((TextBox)((DetailsView)sender).FindControl("AudioHard")).Text;

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

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

                        lblPK.Text = obj.OBPGID.ToString();

                        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")
            {
                try
                {
                    var obj = new MGOnlineBookPages();
                    int pk = int.Parse(((TextBox)((DetailsView)sender).FindControl("OBPGID")).Text);
                    obj.Fetch(pk);
                    obj.OBID = FormatHelper.SafeToInt(lblOBID.Text);
                    obj.MGID = FormatHelper.SafeToInt(lblMGID.Text);
                    //obj.PageNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PageNumber")).Text);
                    obj.TextEasy = ((TextBox)((DetailsView)sender).FindControl("TextEasy")).Text;
                    obj.TextMedium = ((TextBox)((DetailsView)sender).FindControl("TextMedium")).Text;
                    obj.TextHard = ((TextBox)((DetailsView)sender).FindControl("TextHard")).Text;
                    obj.AudioEasy= string.Empty;// ((TextBox)((DetailsView)sender).FindControl("AudioEasy")).Text;
                    obj.AudioMedium= string.Empty;//"((TextBox)((DetailsView)sender).FindControl("AudioMedium")).Text;
                    obj.AudioHard= string.Empty;//"((TextBox)((DetailsView)sender).FindControl("AudioHard")).Text;

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

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();
                        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);
                }
            }
        }
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Setup/MGOnlineBookPagesAddEdit.aspx";
            if (e.CommandName.ToLower() == "addrecord")
            {
                Response.Redirect(String.Format("{0}?MGID={1}&OBID={2}", editpage, lblMGID.Text, lblOBID.Text));
            }

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect("~/ControlRoom/Modules/Setup/MGOnlineBookAddEdit.aspx");
                //Response.Redirect(String.Format("~/ControlRoom/Modules/Setup/MGOnlineBookAddEdit.aspx?PK={0}", lblMGID.Text));
            }
            if (e.CommandName.ToLower() == "moveup")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                DAL.MGOnlineBookPages.MoveUp(key);
                var masterPage = (IControlRoomMaster)Master;
                masterPage.PageMessage = "Level Moved Up!";
                LoadData();
            }

            if (e.CommandName.ToLower() == "movedn")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                DAL.MGOnlineBookPages.MoveDn(key);
                var masterPage = (IControlRoomMaster)Master;
                masterPage.PageMessage = "Level Moved Down";
                LoadData();
            }


            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);
                Response.Redirect(String.Format("{0}?PK={1}", editpage, key));
            }
            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var obj = new MGOnlineBookPages();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        MGOnlineBookPages.FetchObject(key).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);
                }
            }
        }
Beispiel #6
0
        public static MGOnlineBookPages FetchObjectByPage(int page, int obid)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[2];

            arrParams[0] = new SqlParameter("@Page", page);
            arrParams[1] = new SqlParameter("@OBID", obid);
            dr           = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_MGOnlineBookPages_GetByPage", arrParams);

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

                MGOnlineBookPages result = new MGOnlineBookPages();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["OBPGID"].ToString(), out _int))
                {
                    result.OBPGID = _int;
                }
                if (int.TryParse(dr["OBID"].ToString(), out _int))
                {
                    result.OBID = _int;
                }
                if (int.TryParse(dr["MGID"].ToString(), out _int))
                {
                    result.MGID = _int;
                }
                if (int.TryParse(dr["PageNumber"].ToString(), out _int))
                {
                    result.PageNumber = _int;
                }
                result.TextEasy    = dr["TextEasy"].ToString();
                result.TextMedium  = dr["TextMedium"].ToString();
                result.TextHard    = dr["TextHard"].ToString();
                result.AudioEasy   = dr["AudioEasy"].ToString();
                result.AudioMedium = dr["AudioMedium"].ToString();
                result.AudioHard   = dr["AudioHard"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime))
                {
                    result.LastModDate = _datetime;
                }
                result.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime))
                {
                    result.AddedDate = _datetime;
                }
                result.AddedUser = dr["AddedUser"].ToString();

                dr.Close();

                return(result);
            }

            dr.Close();

            return(null);
        }
Beispiel #7
0
        public bool Fetch(int OBPGID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

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

                MGOnlineBookPages result = new MGOnlineBookPages();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["OBPGID"].ToString(), out _int))
                {
                    this.OBPGID = _int;
                }
                if (int.TryParse(dr["OBID"].ToString(), out _int))
                {
                    this.OBID = _int;
                }
                if (int.TryParse(dr["MGID"].ToString(), out _int))
                {
                    this.MGID = _int;
                }
                if (int.TryParse(dr["PageNumber"].ToString(), out _int))
                {
                    this.PageNumber = _int;
                }
                this.TextEasy    = dr["TextEasy"].ToString();
                this.TextMedium  = dr["TextMedium"].ToString();
                this.TextHard    = dr["TextHard"].ToString();
                this.AudioEasy   = dr["AudioEasy"].ToString();
                this.AudioMedium = dr["AudioMedium"].ToString();
                this.AudioHard   = dr["AudioHard"].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);
        }
        public static int Delete(MGOnlineBookPages o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

            try
            {

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

            }

            catch (SqlException exx)
            {

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

            }

            return iReturn;

        }
        public static int Update(MGOnlineBookPages o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[14];

            arrParams[0] = new SqlParameter("@OBPGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OBPGID, o.OBPGID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@OBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OBID, o.OBID.GetTypeCode()));
            arrParams[2] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[3] = new SqlParameter("@PageNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PageNumber, o.PageNumber.GetTypeCode()));
            arrParams[4] = new SqlParameter("@TextEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextEasy, o.TextEasy.GetTypeCode()));
            arrParams[5] = new SqlParameter("@TextMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextMedium, o.TextMedium.GetTypeCode()));
            arrParams[6] = new SqlParameter("@TextHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextHard, o.TextHard.GetTypeCode()));
            arrParams[7] = new SqlParameter("@AudioEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioEasy, o.AudioEasy.GetTypeCode()));
            arrParams[8] = new SqlParameter("@AudioMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioMedium, o.AudioMedium.GetTypeCode()));
            arrParams[9] = new SqlParameter("@AudioHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioHard, o.AudioHard.GetTypeCode()));
            arrParams[10] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[11] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[12] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[13] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

            try
            {

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

            }

            catch (SqlException exx)
            {

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

            }

            return iReturn;

        }
        public static int Insert(MGOnlineBookPages o)
        {

            SqlParameter[] arrParams = new SqlParameter[14];

            arrParams[0] = new SqlParameter("@OBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OBID, o.OBID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode()));
            arrParams[2] = new SqlParameter("@PageNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PageNumber, o.PageNumber.GetTypeCode()));
            arrParams[3] = new SqlParameter("@TextEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextEasy, o.TextEasy.GetTypeCode()));
            arrParams[4] = new SqlParameter("@TextMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextMedium, o.TextMedium.GetTypeCode()));
            arrParams[5] = new SqlParameter("@TextHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TextHard, o.TextHard.GetTypeCode()));
            arrParams[6] = new SqlParameter("@AudioEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioEasy, o.AudioEasy.GetTypeCode()));
            arrParams[7] = new SqlParameter("@AudioMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioMedium, o.AudioMedium.GetTypeCode()));
            arrParams[8] = new SqlParameter("@AudioHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioHard, o.AudioHard.GetTypeCode()));
            arrParams[9] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[10] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[11] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[12] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));
            arrParams[13] = new SqlParameter("@OBPGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OBPGID, o.OBPGID.GetTypeCode()));
            arrParams[13].Direction = ParameterDirection.Output;

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

            o.OBPGID = int.Parse(arrParams[13].Value.ToString());

            return o.OBPGID;

        }
        public bool Fetch(int OBPGID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

            if (dr.Read())
            {

                // declare return value

                MGOnlineBookPages result = new MGOnlineBookPages();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["OBPGID"].ToString(), out _int)) this.OBPGID = _int;
                if (int.TryParse(dr["OBID"].ToString(), out _int)) this.OBID = _int;
                if (int.TryParse(dr["MGID"].ToString(), out _int)) this.MGID = _int;
                if (int.TryParse(dr["PageNumber"].ToString(), out _int)) this.PageNumber = _int;
                this.TextEasy = dr["TextEasy"].ToString();
                this.TextMedium = dr["TextMedium"].ToString();
                this.TextHard = dr["TextHard"].ToString();
                this.AudioEasy = dr["AudioEasy"].ToString();
                this.AudioMedium = dr["AudioMedium"].ToString();
                this.AudioHard = dr["AudioHard"].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;

        }
        public static MGOnlineBookPages FetchObjectByPage(int page, int obid)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[2];

            arrParams[0] = new SqlParameter("@Page", page);
            arrParams[1] = new SqlParameter("@OBID", obid);
            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_MGOnlineBookPages_GetByPage", arrParams);

            if (dr.Read())
            {

                // declare return value

                MGOnlineBookPages result = new MGOnlineBookPages();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["OBPGID"].ToString(), out _int)) result.OBPGID = _int;
                if (int.TryParse(dr["OBID"].ToString(), out _int)) result.OBID = _int;
                if (int.TryParse(dr["MGID"].ToString(), out _int)) result.MGID = _int;
                if (int.TryParse(dr["PageNumber"].ToString(), out _int)) result.PageNumber = _int;
                result.TextEasy = dr["TextEasy"].ToString();
                result.TextMedium = dr["TextMedium"].ToString();
                result.TextHard = dr["TextHard"].ToString();
                result.AudioEasy = dr["AudioEasy"].ToString();
                result.AudioMedium = dr["AudioMedium"].ToString();
                result.AudioHard = dr["AudioHard"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) result.LastModDate = _datetime;
                result.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) result.AddedDate = _datetime;
                result.AddedUser = dr["AddedUser"].ToString();

                dr.Close();

                return result;

            }

            dr.Close();

            return null;

        }