예제 #1
0
        private void Bind()
        {
            Guid adItemId = Guid.Empty;

            Guid.TryParse(Request.QueryString["adItemId"], out adItemId);
            if (!adItemId.Equals(Guid.Empty))
            {
                AdItemContent bll   = new AdItemContent();
                var           model = bll.GetModel(adItemId);
                if (model != null)
                {
                    txtaDescr.Value   = model.Descr;
                    txtaContent.Value = model.ContentText;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 广告项内容提交
        /// </summary>
        /// <param name="context"></param>
        private void SaveAdItemContent(HttpContext context)
        {
            try
            {
                Guid adId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["adId"]))
                {
                    Guid.TryParse(context.Request.Form["adId"], out adId);
                }
                if (adId.Equals(Guid.Empty))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"请先完成基本信息\"}");
                    return;
                }

                Guid adItemId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["adItemId"]))
                {
                    Guid.TryParse(context.Request.Form["adItemId"], out adItemId);
                }
                if (adItemId.Equals(Guid.Empty))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"请先完成广告项再继续此操作\"}");
                    return;
                }

                if (string.IsNullOrWhiteSpace(context.Request.Form["content"]))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }
                string content = HttpUtility.HtmlDecode(context.Request.Form["content"].Trim());

                AdItemContent bll = new AdItemContent();

                AdItemContentInfo model = new AdItemContentInfo();
                model.AdItemId    = adItemId;
                model.Descr       = context.Request.Form["txtaDescr"].Trim();
                model.ContentText = content;

                int effect = -1;

                if (bll.IsExist(adItemId))
                {
                    effect = bll.Update(model);
                }
                else
                {
                    effect = bll.Insert(model);
                }

                if (effect == 110)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}");
                    return;
                }
                if (effect != 1)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"操作失败,原因:请正确输入并重试,如果再出现此问题请联系管理员\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"" + MessageContent.Submit_Success + "\"}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.AlertTitle_Ex_Error + ":" + ex.Message + "\"}");
            }
        }
예제 #3
0
        /// <summary>
        /// 广告项提交
        /// </summary>
        /// <param name="context"></param>
        private void SaveAdItem(HttpContext context)
        {
            try
            {
                Guid adId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["adId"]))
                {
                    Guid.TryParse(context.Request.Form["adId"], out adId);
                }
                if (adId.Equals(Guid.Empty))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"请先完成基本信息\"}");
                    return;
                }

                if (string.IsNullOrWhiteSpace(context.Request.Form["ddlActionType"]))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }

                Guid adItemId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["hAdItemId"]))
                {
                    Guid.TryParse(context.Request.Form["hAdItemId"], out adItemId);
                }
                Guid pictureId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["hImgPictureId"]))
                {
                    Guid.TryParse(context.Request.Form["hImgPictureId"], out pictureId);
                }
                Guid actionTypeId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ddlActionType"]))
                {
                    Guid.TryParse(context.Request.Form["ddlActionType"], out actionTypeId);
                }
                int sort = 0;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["txtSort"]))
                {
                    int.TryParse(context.Request.Form["txtSort"], out sort);
                }
                bool isDisable = false;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["isDisable"]))
                {
                    bool.TryParse(context.Request.Form["isDisable"], out isDisable);
                }

                AdItem bll = new AdItem();

                AdItemInfo model = new AdItemInfo();
                model.AdvertisementId = adId;
                model.Id           = adItemId;
                model.PictureId    = pictureId;
                model.ActionTypeId = actionTypeId;
                model.Sort         = sort;
                model.IsDisable    = isDisable;

                int effect = -1;

                if (!adItemId.Equals(Guid.Empty))
                {
                    var oldModel = bll.GetModel(adItemId);
                    if (oldModel.ActionTypeId != model.ActionTypeId)
                    {
                        AdItemLink adlBll = new AdItemLink();
                        if (adlBll.Delete(adItemId) < 1)
                        {
                            AdItemContent adcBll = new AdItemContent();
                            adcBll.Delete(adItemId);
                        }
                    }
                    else
                    {
                        effect = bll.Update(model);
                    }
                }
                else
                {
                    model.Id = Guid.NewGuid();
                    effect   = bll.Insert(model);
                }

                if (effect == 110)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}");
                    return;
                }
                if (effect != 1)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"操作失败,原因:请正确输入并重试,如果再出现此问题请联系管理员\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"" + MessageContent.Submit_Success + "\",\"data\": \"" + model.Id + "\"}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.AlertTitle_Ex_Error + ":" + ex.Message + "\"}");
            }
        }