Exemplo n.º 1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model">公告信息实体</param>
        /// <returns>true:成功 false:失败</returns>
        public bool Add(EyouSoft.Model.CompanyStructure.News model)
        {
            EyouSoft.Data.News dataNews = new EyouSoft.Data.News();
            dataNews.Id         = model.ID;
            dataNews.CompanyId  = model.CompanyId;
            dataNews.Title      = model.Title;
            dataNews.Iisuer     = string.IsNullOrEmpty(model.OperatorName) ? "" : model.OperatorName;
            dataNews.IisuerTime = model.IssueTime;
            dataNews.Content    = model.Content;
            dataNews.Files      = model.UploadFiles;
            dataNews.Views      = model.Clicks;
            dataNews.IsDelete   = model.IsDelete ? "1" : "0";

            if (model.AcceptList != null && model.AcceptList.Count > 0)
            {
                ((List <EyouSoft.Model.CompanyStructure.NewsAccept>)model.AcceptList).ForEach(item =>
                {
                    EyouSoft.Data.NewsAccept dataNewsAccept = new EyouSoft.Data.NewsAccept();
                    //dataNewsAccept.NewId = model.ID;
                    dataNewsAccept.AcceptId   = item.AcceptId;
                    dataNewsAccept.AcceptType = (byte)item.AcceptType;
                    dataNews.NewNewsAcceptList.Add(dataNewsAccept);
                    dataNewsAccept = null;
                });
            }

            dcDal.News.InsertOnSubmit(dataNews);
            dcDal.SubmitChanges();
            return(dcDal.ChangeConflicts.Count == 0 ? true : false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 分页获取公告信息列表
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="RecordCount"></param>
        /// <param name="CompanyId"></param>
        /// <returns></returns>
        public IList <EyouSoft.Model.CompanyStructure.News> GetList(int PageSize, int PageIndex, ref int RecordCount, int CompanyId)
        {
            IList <EyouSoft.Model.CompanyStructure.News> totals = new List <EyouSoft.Model.CompanyStructure.News>();

            string tableName     = "tbl_News";
            string primaryKey    = "ID";
            string orderByString = "IisuerTime DESC";
            string fields        = " Id, CompanyId, Title, Iisuer,IisuerTime,[Content],Views,Files,IsDelete";

            StringBuilder cmdQuery = new StringBuilder(" IsDelete='0' ");

            cmdQuery.AppendFormat(" and CompanyId='{0}' ", CompanyId);

            using (IDataReader rdr = EyouSoft.Toolkit.DAL.DbHelper.ExecuteReader(this._db, PageSize, PageIndex, ref RecordCount, tableName, primaryKey, fields, cmdQuery.ToString(), orderByString))
            {
                while (rdr.Read())
                {
                    EyouSoft.Model.CompanyStructure.News newInfo = new EyouSoft.Model.CompanyStructure.News();

                    newInfo.ID           = rdr.GetInt32(rdr.GetOrdinal("ID"));
                    newInfo.CompanyId    = rdr.GetInt32(rdr.GetOrdinal("CompanyId"));
                    newInfo.Title        = rdr.IsDBNull(rdr.GetOrdinal("Title")) ? " " : rdr.GetString(rdr.GetOrdinal("Title"));
                    newInfo.OperatorName = rdr.GetString(rdr.GetOrdinal("Iisuer"));
                    newInfo.IssueTime    = rdr.GetDateTime(rdr.GetOrdinal("IisuerTime"));
                    newInfo.Content      = rdr.IsDBNull(rdr.GetOrdinal("Content")) ? " " : rdr.GetString(rdr.GetOrdinal("Content"));
                    newInfo.Clicks       = rdr.IsDBNull(rdr.GetOrdinal("Views")) ? 0 : rdr.GetInt32(rdr.GetOrdinal("Views"));
                    newInfo.UploadFiles  = rdr.IsDBNull(rdr.GetOrdinal("Files")) ? " " : rdr.GetString(rdr.GetOrdinal("Files"));
                    newInfo.IsDelete     = Convert.ToBoolean(rdr.GetOrdinal("IsDelete"));

                    totals.Add(newInfo);
                }
            }

            return(totals);
        }
Exemplo n.º 3
0
 private void DataInit()
 {
     tid = Utils.GetInt(Utils.GetQueryStringValue("tid"));
     if (tid > 0)
     {
         nModel = nBll.GetModel(tid);
         nBll.SetClicks(tid);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model">公告信息实体</param>
        /// <returns>true:成功 false:失败</returns>
        public bool Update(EyouSoft.Model.CompanyStructure.News model)
        {
            bool result = false;

            result = Dal.Update(model);
            handleLogsBll.Add(AddLogs("修改", result));

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model">公告信息实体</param>
        /// <returns>true:成功 false:失败</returns>
        public bool Update(EyouSoft.Model.CompanyStructure.News model)
        {
            EyouSoft.Data.News dataNews = dcDal.News.FirstOrDefault(item => item.Id == model.ID);

            if (dataNews != null)
            {
                dataNews.Id         = model.ID;
                dataNews.CompanyId  = model.CompanyId;
                dataNews.Title      = model.Title;
                dataNews.Iisuer     = string.IsNullOrEmpty(model.OperatorName) ? "" : model.OperatorName;
                dataNews.IisuerTime = model.IssueTime;
                dataNews.Content    = model.Content;
                if (!string.IsNullOrEmpty(model.UploadFiles))
                {
                    dataNews.Files = model.UploadFiles;
                }
                dataNews.Views    = model.Clicks;
                dataNews.IsDelete = model.IsDelete ? "1" : "0";

                if (dataNews.NewNewsAcceptList != null && dataNews.NewNewsAcceptList.Count > 0)
                {
                    if (this.AcceptNewsDelete(dataNews.Id))
                    {
                        ((List <EyouSoft.Model.CompanyStructure.NewsAccept>)model.AcceptList).ForEach(item =>
                        {
                            EyouSoft.Data.NewsAccept dataNewsAccept = new EyouSoft.Data.NewsAccept();
                            dataNewsAccept.NewId      = model.ID;
                            dataNewsAccept.AcceptId   = item.AcceptId;
                            dataNewsAccept.AcceptType = (byte)item.AcceptType;
                            dataNews.NewNewsAcceptList.Add(dataNewsAccept);
                            dataNewsAccept = null;
                        }
                                                                                                      );
                    }
                }

                dcDal.SubmitChanges();
            }

            return(dcDal.ChangeConflicts.Count == 0 ? true : false);
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //判断权限
            if (!CheckGrant(global::Common.Enum.TravelPermission.系统设置_信息管理_信息管理栏目))
            {
                Utils.ResponseNoPermit(global::Common.Enum.TravelPermission.系统设置_信息管理_信息管理栏目, true);
                return;
            }
            infoId = Utils.GetInt(Utils.GetQueryStringValue("infoId"));
            string method = Utils.GetFormValue("hidMethod");

            //如果当前操作为保存或者保存继续添加
            if (method == "save" || method == "continue")
            {
                #region 保存信息
                string[] publichTo = Utils.GetFormValues("chkPublishTo");//发布对象
                if (publichTo != null && publichTo.Length > 0)
                {
                    IList <EyouSoft.Model.CompanyStructure.NewsAccept> acceptList = new List <EyouSoft.Model.CompanyStructure.NewsAccept>();
                    if (publichTo.Contains("cInner"))
                    {
                        EyouSoft.Model.CompanyStructure.NewsAccept acceptModel = new EyouSoft.Model.CompanyStructure.NewsAccept();
                        acceptModel.AcceptType = EyouSoft.Model.EnumType.PersonalCenterStructure.AcceptType.所有;
                        acceptList.Add(acceptModel);
                    }
                    else if (publichTo.Contains("sDepart"))
                    {
                        if (!string.IsNullOrEmpty(txtDeparts.Value))
                        {
                            string[] departs = txtDeparts.Value.Split(',');
                            foreach (string dId in departs)
                            {
                                EyouSoft.Model.CompanyStructure.NewsAccept acceptModel = new EyouSoft.Model.CompanyStructure.NewsAccept {
                                    AcceptType = EyouSoft.Model.EnumType.PersonalCenterStructure.AcceptType.指定部门, AcceptId = Utils.GetInt(dId)
                                };
                                acceptList.Add(acceptModel);
                            }
                        }
                    }
                    if (publichTo.Contains("cTour"))
                    {
                        EyouSoft.Model.CompanyStructure.NewsAccept acceptModel = new EyouSoft.Model.CompanyStructure.NewsAccept {
                            AcceptType = EyouSoft.Model.EnumType.PersonalCenterStructure.AcceptType.指定组团
                        };
                        acceptList.Add(acceptModel);
                    }
                    newModel.AcceptList = acceptList;
                }
                else
                {
                    MessageBox.Show(this, "请填写完整数据!");
                    return;
                }
                newModel.CompanyId = CurrentUserCompanyID;

                newModel.Title   = Utils.InputText(txtInfoTitle.Value);       //发布标题
                newModel.Content = Utils.EditInputText(txtInfoContent.Value); //内容
                Utils.InputText(txtDeparts.Value);                            //发布的部门
                newModel.OperatorId   = SiteUserInfo.ID;                      //发布人
                newModel.OperatorName = SiteUserInfo.ContactInfo.ContactName;
                newModel.IssueTime    = Utils.GetDateTime(Utils.InputText(txtPublishDate.Value));

                HttpPostedFile attachFile1 = Request.Files["fileAttach"];//获取附件
                bool           result      = false;
                if (attachFile1 != null && !string.IsNullOrEmpty(attachFile1.FileName))
                {
                    string filePath = string.Empty;
                    string fileName = string.Empty;
                    result = UploadFile.FileUpLoad(attachFile1, "systemset", out filePath, out fileName);
                    if (result)
                    {
                        newModel.UploadFiles = filePath;
                    }
                }
                else
                {
                    result = true;
                }

                if (result)
                {
                    if (infoId != 0)
                    {
                        //修改
                        newModel.ID = infoId;
                        result      = newsBll.Update(newModel);
                    }
                    else
                    {
                        //新增
                        result = newsBll.Add(newModel);
                    }
                }
                if (result)
                {
                    //保存成功跳转列表或重新发布信息
                    MessageBox.ShowAndRedirect(this, "信息保存成功", method == "save" ? "/systemset/infomanage/InfoList.aspx" : "/systemset/infomanage/InfoEdit.aspx");
                }
                else
                {
                    MessageBox.Show(this, "信息保存失败!");
                }
                #endregion
            }
            else
            {
                if (infoId != 0)
                {
                    #region 初始化数据
                    newModel = newsBll.GetModel(infoId);
                    if (newModel != null)
                    {
                        //初始化数据
                        IList <EyouSoft.Model.CompanyStructure.NewsAccept> acceptList = newModel.AcceptList;
                        if (acceptList != null && acceptList.Count > 0)
                        {
                            if (acceptList.Where(i => i.AcceptType == EyouSoft.Model.EnumType.PersonalCenterStructure.AcceptType.所有).Count() > 0)
                            {
                                innerChecked = "checked=\"checked\"";
                            }
                            IEnumerable <EyouSoft.Model.CompanyStructure.NewsAccept> acceptListDepart = acceptList.Where(i => i.AcceptType == EyouSoft.Model.EnumType.PersonalCenterStructure.AcceptType.指定部门);
                            if (acceptListDepart.Count() > 0)
                            {
                                StringBuilder strBuilder = new StringBuilder();
                                foreach (var i in acceptListDepart)
                                {
                                    strBuilder.AppendFormat("{0},", i.AcceptId);
                                }
                                txtDeparts.Value = strBuilder.ToString().TrimEnd(',');
                                departChecked    = "checked=\"checked\"";
                            }
                            if (acceptList.Where(i => i.AcceptType == EyouSoft.Model.EnumType.PersonalCenterStructure.AcceptType.指定组团).Count() > 0)
                            {
                                tourChecked = "checked=\"checked\"";
                            }
                        }
                        txtAuthor.Value      = newModel.OperatorName;
                        txtInfoTitle.Value   = newModel.Title;
                        txtPublishDate.Value = newModel.IssueTime.ToString("yyyy-MM-dd HH:mm:ss");
                        attchFile            = newModel.UploadFiles;
                        txtInfoContent.Value = newModel.Content;
                    }
                    #endregion
                }
                else
                {
                    txtAuthor.Value      = SiteUserInfo.ContactInfo.ContactName;
                    txtPublishDate.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
            }
        }