Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op     = RequestData.Get <string>("op");
            id     = RequestData.Get <string>("id");
            typeid = RequestData.Get <string>("TypeId");

            VideoNews ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <VideoNews>();
                ent.HomePagePopup = RequestData.Get <string>("HomePagePopup");
                ent.State         = "1";
                if (RequestData["param"] + "" == "tj")
                {
                    ent.PostUserId   = UserInfo.UserID;
                    ent.PostUserName = UserInfo.Name;
                    ent.PostTime     = DateTime.Now;
                    ent.State        = "2";
                }
                ent.SaveAndFlush();

                SaveDetail(ent.Id, ent.ShowImg);
                InsertCompetence(ent.Id, ent.ReceiveDeptId, ent.ReceiveDeptName);
                break;

            case RequestActionEnum.Insert:
            case RequestActionEnum.Create:
                ent = this.GetPostedData <VideoNews>();
                ent.HomePagePopup = RequestData.Get <string>("HomePagePopup");
                ent.CreateId      = UserInfo.UserID;
                ent.CreateName    = UserInfo.Name;
                ent.CreateTime    = DateTime.Now;
                ent.State         = "1";
                if (RequestData["param"] + "" == "tj")
                {
                    ent.PostUserId   = UserInfo.UserID;
                    ent.PostUserName = UserInfo.Name;
                    ent.PostTime     = DateTime.Now;
                    ent.State        = "2";
                }
                ent.CreateAndFlush();

                SaveDetail(ent.Id, ent.ShowImg);
                InsertCompetence(ent.Id, ent.ReceiveDeptId, ent.ReceiveDeptName);
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <VideoNews>();
                ent.DeleteAndFlush();
                this.SetMessage("删除成功!");
                break;
            }

            if (RequestActionString == "ImportFile")
            {
                string fileIds = RequestData.Get <string>("fileIds");
                if (!string.IsNullOrEmpty(fileIds))
                {
                    string sql = @"select * from BJKY_Portal..FileItem where PatIndex('%'+Id+'%','{0}')>0";
                    sql = string.Format(sql, fileIds);
                    PageState.Add("Result", DataHelper.QueryDictList(sql));
                }
            }

            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent    = VideoNews.Find(id);
                    typeid = ent.TypeId;
                    //详细列表数据
                    PageState.Add("DetailList", VideoNewDetail.FindAllByProperty(VideoNewDetail.Prop_PId, ent.Id));
                }

                this.SetFormData(ent);
            }
            else
            {
                string    sql = "select DeptId,ChildDeptName,ParentId,ParentDeptName,len(Path) LenPath from  dbo.View_SysUserGroup where UserId='" + UserInfo.UserID + "' and Type=2";
                DataTable dtt = DataHelper.QueryDataTable(sql);
                if (dtt.Rows.Count > 0)
                {
                    var DeptInfo = new { groupId = dtt.Rows[0]["DeptId"] + "", groupName = dtt.Rows[0]["ChildDeptName"] + "", deptId = dtt.Rows[0]["ParentId"] + "", deptName = dtt.Rows[0]["ParentDeptName"] + "" };
                    PageState.Add("DeptInfo", DeptInfo);
                }
            }

            if (!String.IsNullOrEmpty(typeid))
            {
                NewsType newsType = NewsType.TryFind(typeid);
                PageState.Add("NewsType", newsType);
            }
            EasyDictionary es = new EasyDictionary();
            DataTable      dt = DataHelper.QueryDataTable("select Id,TypeName from NewsType where IsEfficient='1'");

            foreach (DataRow row in dt.Rows)
            {
                es.Add(row["Id"].ToString(), row["TypeName"].ToString());
            }
            PageState.Add("NewsTypeEnum", es);
        }