protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e) {

            if(e.CommandName.Equals("Details", StringComparison.OrdinalIgnoreCase)) {
                pnlList.Visible = false;
                var o = new Offer();
                o.Fetch(int.Parse(e.CommandArgument.ToString()));
                lblTitle.Text = o.Title;
                o.TotalImpressions = o.TotalImpressions + 1;
                lblSerial.Text = o.SerialPrefix + o.TotalImpressions.ToString();
                Coupon.ImageUrl = string.Format("~/images/Offers/{0}.png", o.OID);
                o.Update();
                pnlDetail.Visible = true;
            }
        }
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/OfferList.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 Offer();
                    obj.isEnabled = ((CheckBox)((DetailsView)sender).FindControl("isEnabled")).Checked;
                    obj.AdminName = ((TextBox)((DetailsView)sender).FindControl("AdminName")).Text;
                    obj.Title = ((TextBox)((DetailsView)sender).FindControl("Title")).Text;
                    obj.ExternalRedirectFlag = ((CheckBox)((DetailsView)sender).FindControl("ExternalRedirectFlag")).Checked;
                    obj.RedirectURL = ((TextBox)((DetailsView)sender).FindControl("RedirectURL")).Text;
                    obj.MaxImpressions = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("MaxImpressions")).Text);
                    //obj.TotalImpressions = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("TotalImpressions")).Text);
                    obj.SerialPrefix = ((TextBox)((DetailsView)sender).FindControl("SerialPrefix")).Text;
                    obj.ZipCode = ((TextBox)((DetailsView)sender).FindControl("ZipCode")).Text;
                    obj.AgeStart = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("AgeStart")).Text);
                    obj.AgeEnd = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("AgeEnd")).Text);
                    obj.ProgramId = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("ProgramId")).SelectedValue);
                    obj.BranchId = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("BranchId")).SelectedValue);

                    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();
                        new SessionTools(Session).RemoveCache(Cache, CacheKey.OffersActive);
                        if (e.CommandName.ToLower() == "addandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        lblPK.Text = obj.OID.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 Offer();
                    int pk = int.Parse(lblPK.Text);
                    obj.Fetch(pk);

                    obj.isEnabled = ((CheckBox)((DetailsView)sender).FindControl("isEnabled")).Checked;
                    obj.AdminName = ((TextBox)((DetailsView)sender).FindControl("AdminName")).Text;
                    obj.Title = ((TextBox)((DetailsView)sender).FindControl("Title")).Text;
                    obj.ExternalRedirectFlag = ((CheckBox)((DetailsView)sender).FindControl("ExternalRedirectFlag")).Checked;
                    obj.RedirectURL = ((TextBox)((DetailsView)sender).FindControl("RedirectURL")).Text;
                    obj.MaxImpressions = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("MaxImpressions")).Text);
                    //obj.TotalImpressions = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("TotalImpressions")).Text);
                    obj.SerialPrefix = ((TextBox)((DetailsView)sender).FindControl("SerialPrefix")).Text;
                    obj.ZipCode = ((TextBox)((DetailsView)sender).FindControl("ZipCode")).Text;
                    obj.AgeStart = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("AgeStart")).Text);
                    obj.AgeEnd = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("AgeEnd")).Text);
                    obj.ProgramId = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("ProgramId")).SelectedValue);
                    obj.BranchId = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("BranchId")).SelectedValue);

                    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);
                }
            }
        }
Ejemplo n.º 3
0
        public static int Delete(Offer o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

            try
            {

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

                var fileName = (HttpContext.Current.Server.MapPath("~/Images/Offers/") + "\\" + o.OID.ToString() + ".png");
                File.Delete(fileName);
                fileName = (HttpContext.Current.Server.MapPath("~/Images/Offers/") + "\\sm_" + o.OID.ToString() + ".png");
                File.Delete(fileName);
                fileName = (HttpContext.Current.Server.MapPath("~/Images/Offers/") + "\\md_" + o.OID.ToString() + ".png");
                File.Delete(fileName);
            }

            catch (SqlException exx)
            {

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

            }

            return iReturn;

        }
Ejemplo n.º 4
0
        public static int Update(Offer o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[28];

            arrParams[0] = new SqlParameter("@OID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.OID, o.OID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@isEnabled", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.isEnabled, o.isEnabled.GetTypeCode()));
            arrParams[2] = new SqlParameter("@AdminName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode()));
            arrParams[3] = new SqlParameter("@Title", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Title, o.Title.GetTypeCode()));
            arrParams[4] = new SqlParameter("@ExternalRedirectFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ExternalRedirectFlag, o.ExternalRedirectFlag.GetTypeCode()));
            arrParams[5] = new SqlParameter("@RedirectURL", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.RedirectURL, o.RedirectURL.GetTypeCode()));
            arrParams[6] = new SqlParameter("@MaxImpressions", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxImpressions, o.MaxImpressions.GetTypeCode()));
            arrParams[7] = new SqlParameter("@TotalImpressions", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TotalImpressions, o.TotalImpressions.GetTypeCode()));
            arrParams[8] = new SqlParameter("@SerialPrefix", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SerialPrefix, o.SerialPrefix.GetTypeCode()));
            arrParams[9] = new SqlParameter("@ZipCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ZipCode, o.ZipCode.GetTypeCode()));
            arrParams[10] = new SqlParameter("@AgeStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AgeStart, o.AgeStart.GetTypeCode()));
            arrParams[11] = new SqlParameter("@AgeEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AgeEnd, o.AgeEnd.GetTypeCode()));
            arrParams[12] = new SqlParameter("@ProgramId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ProgramId, o.ProgramId.GetTypeCode()));
            arrParams[13] = new SqlParameter("@BranchId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BranchId, o.BranchId.GetTypeCode()));
            arrParams[14] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[15] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[16] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[17] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

            arrParams[18] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[19] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[20] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[21] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[22] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[23] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[24] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[25] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[26] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[27] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            try
            {

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

            }

            catch (SqlException exx)
            {

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

            }

            return iReturn;

        }
Ejemplo n.º 5
0
        public static int Insert(Offer o)
        {

            SqlParameter[] arrParams = new SqlParameter[28];

            arrParams[0] = new SqlParameter("@isEnabled", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.isEnabled, o.isEnabled.GetTypeCode()));
            arrParams[1] = new SqlParameter("@AdminName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode()));
            arrParams[2] = new SqlParameter("@Title", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Title, o.Title.GetTypeCode()));
            arrParams[3] = new SqlParameter("@ExternalRedirectFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ExternalRedirectFlag, o.ExternalRedirectFlag.GetTypeCode()));
            arrParams[4] = new SqlParameter("@RedirectURL", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.RedirectURL, o.RedirectURL.GetTypeCode()));
            arrParams[5] = new SqlParameter("@MaxImpressions", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxImpressions, o.MaxImpressions.GetTypeCode()));
            arrParams[6] = new SqlParameter("@TotalImpressions", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TotalImpressions, o.TotalImpressions.GetTypeCode()));
            arrParams[7] = new SqlParameter("@SerialPrefix", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SerialPrefix, o.SerialPrefix.GetTypeCode()));
            arrParams[8] = new SqlParameter("@ZipCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ZipCode, o.ZipCode.GetTypeCode()));
            arrParams[9] = new SqlParameter("@AgeStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AgeStart, o.AgeStart.GetTypeCode()));
            arrParams[10] = new SqlParameter("@AgeEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AgeEnd, o.AgeEnd.GetTypeCode()));
            arrParams[11] = new SqlParameter("@ProgramId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ProgramId, o.ProgramId.GetTypeCode()));
            arrParams[12] = new SqlParameter("@BranchId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BranchId, o.BranchId.GetTypeCode()));
            arrParams[13] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[14] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[15] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[16] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

            arrParams[17] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[18] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[19] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[20] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[21] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[22] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[23] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[24] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[25] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[26] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

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

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

            o.OID = int.Parse(arrParams[27].Value.ToString());

            return o.OID;

        }
Ejemplo n.º 6
0
        public bool Fetch(int OID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

            if (dr.Read())
            {

                // declare return value

                Offer result = new Offer();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["OID"].ToString(), out _int)) this.OID = _int;
                this.isEnabled = bool.Parse(dr["isEnabled"].ToString());
                this.AdminName = dr["AdminName"].ToString();
                this.Title = dr["Title"].ToString();
                this.ExternalRedirectFlag = bool.Parse(dr["ExternalRedirectFlag"].ToString());
                this.RedirectURL = dr["RedirectURL"].ToString();
                if (int.TryParse(dr["MaxImpressions"].ToString(), out _int)) this.MaxImpressions = _int;
                if (int.TryParse(dr["TotalImpressions"].ToString(), out _int)) this.TotalImpressions = _int;
                this.SerialPrefix = dr["SerialPrefix"].ToString();
                this.ZipCode = dr["ZipCode"].ToString();
                if (int.TryParse(dr["AgeStart"].ToString(), out _int)) this.AgeStart = _int;
                if (int.TryParse(dr["AgeEnd"].ToString(), out _int)) this.AgeEnd = _int;
                if (int.TryParse(dr["ProgramId"].ToString(), out _int)) this.ProgramId = _int;
                if (int.TryParse(dr["BranchId"].ToString(), out _int)) this.BranchId = _int;
                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();

                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 GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Setup/OfferAddEdit.aspx";
            if (e.CommandName.ToLower() == "addrecord")
            {
                Session["OFF"]= string.Empty; Response.Redirect(editpage);
            }
            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);
                Session["OFF"] = key; Response.Redirect(editpage);
            }
            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var obj = new Offer();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        Offer.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);
                }
            }
        }
Ejemplo n.º 8
0
        public bool Fetch(int OID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

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

                Offer result = new Offer();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["OID"].ToString(), out _int))
                {
                    this.OID = _int;
                }
                this.isEnabled            = bool.Parse(dr["isEnabled"].ToString());
                this.AdminName            = dr["AdminName"].ToString();
                this.Title                = dr["Title"].ToString();
                this.ExternalRedirectFlag = bool.Parse(dr["ExternalRedirectFlag"].ToString());
                this.RedirectURL          = dr["RedirectURL"].ToString();
                if (int.TryParse(dr["MaxImpressions"].ToString(), out _int))
                {
                    this.MaxImpressions = _int;
                }
                if (int.TryParse(dr["TotalImpressions"].ToString(), out _int))
                {
                    this.TotalImpressions = _int;
                }
                this.SerialPrefix = dr["SerialPrefix"].ToString();
                this.ZipCode      = dr["ZipCode"].ToString();
                if (int.TryParse(dr["AgeStart"].ToString(), out _int))
                {
                    this.AgeStart = _int;
                }
                if (int.TryParse(dr["AgeEnd"].ToString(), out _int))
                {
                    this.AgeEnd = _int;
                }
                if (int.TryParse(dr["ProgramId"].ToString(), out _int))
                {
                    this.ProgramId = _int;
                }
                if (int.TryParse(dr["BranchId"].ToString(), out _int))
                {
                    this.BranchId = _int;
                }
                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();

                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);
        }