コード例 #1
0
        private void Bind()
        {
            var Id = Guid.Empty;

            if (!string.IsNullOrWhiteSpace(Request.QueryString["Id"]))
            {
                Guid.TryParse(Request.QueryString["Id"], out Id);
            }
            if (!Id.Equals(Guid.Empty))
            {
                Page.Title = "编辑资讯";

                //获取当前Id的数据,并赋值到表单即可
                Information bll = new Information();
                DataSet     ds  = bll.GetModelOW(Id);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows != null && ds.Tables[0].Rows.Count > 0)
                {
                    DataTable dt = ds.Tables[0];
                    txtTitle.Value     = dt.Rows[0]["Title"].ToString();
                    txtContent.Value   = dt.Rows[0]["ContentText"].ToString();
                    txtSummary.Value   = dt.Rows[0]["Summary"].ToString();
                    txtRemark.Value    = dt.Rows[0]["Remark"].ToString();
                    txtSource.Value    = dt.Rows[0]["Source"].ToString();
                    txtViewCount.Value = dt.Rows[0]["ViewCount"].ToString();
                    txtSort.Value      = dt.Rows[0]["Sort"].ToString();
                    hId.Value          = Id.ToString();

                    InformationPicture bllPP = new InformationPicture();
                    DataSet            dsPP  = bllPP.GetListOW(Id.ToString());
                    if (dsPP != null && dsPP.Tables.Count > 0 && dsPP.Tables[0].Rows != null && dsPP.Tables[0].Rows.Count > 0)
                    {
                        DataTable dtPP = dsPP.Tables[0];
                        foreach (DataRow row in dtPP.Rows)
                        {
                            string html = "<div class=\"row_col w110 mb10\" style=\"width:200px;\">" +
                                          "<table style=\"width:100%;\">" +
                                          "<tr>" +
                                          "<td style=\"width:130px; vertical-align:top;\">" +
                                          "<img src=\"{0}\" alt=\"\" width=\"110px\" height=\"110px\" />" +
                                          "<input type=\"hidden\" name=\"PicId\" value=\"{1}\"/>" +
                                          "</td>" +
                                          "<td style=\"width:70px;\">" +
                                          "<a href=\"javascript:void(0)\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-remove',plain:true\" onclick=\"$(this).parents('.row_col').remove()\">删 除</a>" +
                                          "</td>" +
                                          "</tr>" +
                                          "</table>" +
                                          "</div>";
                            string picSrc = row["PictureId"] is DBNull ? "../../Images/nopic.gif" : string.Format("{0}{1}/PC/{1}_1{2}", row["FileDirectory"], row["RandomFolder"], row["FileExtension"]);
                            html = string.Format(html, picSrc, row["PictureId"].ToString());
                            imgContentPicture.InnerHtml += html;
                        }
                    }

                    if (0 == Convert.ToInt32(dt.Rows[0]["ViewType"]))
                    {
                        rdViewType1.Checked = false;
                        rdViewType0.Checked = true;
                        rdViewType2.Checked = false;
                    }
                    else if (1 == Convert.ToInt32(dt.Rows[0]["ViewType"]))
                    {
                        rdViewType1.Checked = true;
                        rdViewType0.Checked = false;
                        rdViewType2.Checked = false;
                    }
                    else
                    {
                        rdViewType1.Checked = false;
                        rdViewType0.Checked = false;
                        rdViewType2.Checked = true;
                    }

                    if (Convert.ToBoolean(dt.Rows[0]["IsDisable"]))
                    {
                        rdFalse.Checked = false;
                        rdTrue.Checked  = true;
                    }
                    else
                    {
                        rdFalse.Checked = true;
                        rdTrue.Checked  = false;
                    }
                }
            }
        }
コード例 #2
0
        public void SaveInformation(HttpContext context)
        {
            try
            {
                string id         = context.Request.Form["ctl00$cphMain$hId"].Trim();
                string sTitle     = context.Request.Form["ctl00$cphMain$txtTitle"].Trim();
                string sSummary   = context.Request.Form["ctl00$cphMain$txtSummary"].Trim();
                string sSource    = context.Request.Form["ctl00$cphMain$txtSource"].Trim();
                string sRemark    = context.Request.Form["ctl00$cphMain$txtRemark"].Trim();
                string sContent   = context.Request.Form["content"].Trim();
                string sIsDisable = context.Request.Form["isDisable"].Trim();
                string sViewType  = context.Request.Form["rdViewType"].Trim();
                string sSort      = context.Request.Form["ctl00$cphMain$txtSort"].Trim();
                sSort = sSort == "" ? "0" : sSort;
                string sViewCount = context.Request.Form["ctl00$cphMain$txtViewCount"].Trim();
                sViewCount = sViewCount == "" ? "0" : sViewCount;

                string sPictureIdList = context.Request.Form["pictureId"].TrimEnd(',');
                string sIsPush        = context.Request.Form["isPush"].Trim();

                sContent = HttpUtility.HtmlDecode(sContent);

                Guid gId = Guid.Empty;
                if (id != "")
                {
                    Guid.TryParse(id, out gId);
                }

                InformationInfo model = new InformationInfo();
                model.LastUpdatedDate = DateTime.Now;
                model.Remark          = sRemark;

                model.Id          = gId;
                model.Title       = sTitle;
                model.Summary     = sSummary;
                model.Source      = sSource;
                model.ContentText = sContent;
                model.Sort        = int.Parse(sSort);
                model.ViewCount   = int.Parse(sViewCount);
                model.ViewType    = byte.Parse(sViewType);
                model.IsDisable   = bool.Parse(sIsDisable);
                model.IsPush      = bool.Parse(sIsPush);

                if (string.IsNullOrWhiteSpace(model.ContentText))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }

                Information        bll   = new Information();
                InformationPicture bllPP = new InformationPicture();
                int effect = -1;

                if (!gId.Equals(Guid.Empty))
                {
                    effect = bll.Update(model);
                    if (effect > 0)
                    {
                        bllPP.Delete(model.Id);
                        if (!string.IsNullOrWhiteSpace(sPictureIdList))
                        {
                            foreach (string sPictureId in sPictureIdList.Split(','))
                            {
                                InformationPictureInfo infoPP = new InformationPictureInfo();
                                Guid pictureId = Guid.Empty;
                                Guid.TryParse(sPictureId, out pictureId);
                                infoPP.InformationId = model.Id;
                                infoPP.PictureId     = pictureId;
                                bllPP.InsertModel(infoPP);
                            }
                        }
                    }
                }
                else
                {
                    model.LastUpdatedDate = DateTime.Now;
                    Guid anformationId = bll.InsertByOutput(model);
                    if (!anformationId.Equals(Guid.Empty))
                    {
                        effect = 1;
                        if (!string.IsNullOrWhiteSpace(sPictureIdList))
                        {
                            foreach (string sPictureId in sPictureIdList.Split(','))
                            {
                                InformationPictureInfo infoPP = new InformationPictureInfo();
                                Guid pictureId = Guid.Empty;
                                Guid.TryParse(sPictureId, out pictureId);
                                infoPP.InformationId = anformationId;
                                infoPP.PictureId     = pictureId;
                                bllPP.InsertModel(infoPP);
                            }
                        }
                    }
                }

                if (effect == 110)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}");
                    return;
                }

                if (effect < 1)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Error + "\"}");
                    return;
                }

                if (model.IsPush)
                {
                    #region   推送信息到推送服务系统
                    try
                    {
                        PushContentService pushProxy = new PushContentService();
                        if (System.Configuration.ConfigurationManager.AppSettings["PushServiceUrl"] != null)
                        {
                            pushProxy.Url = System.Configuration.ConfigurationManager.AppSettings["PushServiceUrl"].ToString();
                        }

                        string sxml = "";
                        sxml = string.Format(@"<XmlParameters><ReceivePushContent><PushType>{0}</PushType><PushContent>{1}</PushContent><Title>{2}</Title><PushParam>{3}</PushParam></ReceivePushContent></XmlParameters>",
                                             "xwfb", "", model.Title, "1");

                        pushProxy.ReceivePushContentAsync(sxml);
                    }
                    catch
                    {
                    }
                    #endregion
                }

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