예제 #1
0
        /// <summary>
        /// 查看详细信息
        /// </summary>
        /// <param name="officeId">办公编码</param>
        /// <returns></returns>
        public ActionResult OfficeDetail(int officeId)
        {
            BLL.Office.Office office = new BLL.Office.Office();

            TOffice cot = office.GetOffice(officeId);

            this.ViewData["entity"]   = cot;
            this.ViewData["officeId"] = officeId;
            this.ViewData["title"]    = cot.标题;
            this.ViewData["type"]     = cot.办公类型编码;

            //this.ViewData["pageNumber"] = pageNumber;
            //this.ViewData["startTime"] = startTime;
            //this.ViewData["_type"] = type;
            //this.ViewData["_title"] = title; //查询条件中的标题
            //this.ViewData["_writer"] = writer == string.Empty ? "" : writer; //查询条件中的作者

            if (cot.发送类型编码 == 1)
            {
                this.ViewData["receive"] = cot.接收人;
            }
            else if (cot.发送类型编码 == 2)
            {
                this.ViewData["receive"] = cot.接收部门;
            }
            else
            {
                this.ViewData["receive"] = cot.接收人;
            }
            this.ViewData["content"] = cot.内容;

            Anchor.FA.BLL.Office.Office.UpdateRec(officeId, CurrentUser.ID.ToString());
            return(View());
        }
예제 #2
0
        /// <summary>
        /// 编辑页面
        /// </summary>
        /// <param name="id">办公编码</param>
        /// <param name="type">办公类型编码</param>
        /// <returns></returns>
        public ActionResult OfficeEdit(int pageNumber, int?officeId, string type, string startTime, string endTime, string title, string writer)
        {
            BLL.Office.Office office = new BLL.Office.Office();

            this.ViewData["pageNumber"] = pageNumber;
            this.ViewData["startTime"]  = startTime;
            //this.ViewData["endTime"] = endTime;
            this.ViewData["_type"]   = type;
            this.ViewData["_title"]  = title;  //查询条件中的标题
            this.ViewData["_writer"] = writer; //查询条件中的作者姓名

            TOffice cot = office.GetOffice(officeId);

            this.ViewData["entity"]   = cot;
            this.ViewData["title"]    = cot.标题;
            this.ViewData["content"]  = cot.内容;
            this.ViewData["sendType"] = officeId == null ? 1 : cot.发送类型编码;
            this.ViewData["officeId"] = cot.编码;
            this.ViewData["receive"]  = cot.接收部门编码;

            this.ViewData["type"]     = cot.办公类型编码;
            this.ViewData["writerID"] = officeId == null?User.Identity.Name.Split('|')[0] : cot.发送人编码; //作者ID

            this.ViewData["writer"] = officeId == null?User.Identity.Name.Split('|')[1] : cot.作者;      //作者姓名

            this.ViewData["receivePerN"] = cot.接收人编码;
            this.ViewData["receivePer"]  = cot.接收人;
            return(View());
        }
예제 #3
0
        [ValidateInput(false)]      //当页面提交具有html标签时不进行验证
        public ActionResult OfficeSave(TOffice entity, string editor)
        {
            BLL.Office.Office office = new BLL.Office.Office();

            entity.内容 = Request.Form["editor"];

            switch (entity.发送类型编码)
            {
            case 1:
                entity.接收人编码  = "allworker";
                entity.接收人    = "全体人员";
                entity.接收部门编码 = null;
                entity.接收部门   = null;
                break;

            case 2:
                entity.接收人编码  = null;
                entity.接收人    = null;
                entity.接收部门编码 = Request.Form["receive"];
                break;

            case 3:
                //entity.接收人编码 = "allworker";
                //entity.接收人 = "全体人员";
                entity.接收部门编码 = null;
                entity.接收部门   = null;
                break;

            default:
                break;
            }

            //entity.创建时间 = DateTime.Now;

            if (ModelState.IsValid)
            {
                bool save = office.Save(entity);

                if (save)
                {
                    return(Json(new { IsSuccess = true, Message = "保存成功" }, "text/html", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { IsSuccess = false, Message = "保存失败" }, "text/html", JsonRequestBehavior.AllowGet));
                }
            }

            return(View());
        }
예제 #4
0
        private static void InsertReceiver(TOffice entity, MainDataContext dbContext)
        {
            //再插入人员接收反馈表
            if (entity.发送类型编码 == 3)
            {
                IEnumerable <string> personIDs   = entity.接收人编码.Split(',').Distinct();
                IEnumerable <string> personNames = entity.接收人.Split(',').Distinct();
                //IEnumerable<string> personIDs = entity.接收人编码.Split(',');
                //IEnumerable<string> personNames = entity.接收人.Split(',');

                entity.接收人编码 = string.Join(",", personIDs);
                entity.接收人   = string.Join(",", personNames);


                var query1 = from am in dbContext.TOfficeReceive
                             select am.编码;
                int code = 0;
                if (query1.Any())
                {
                    code = query1.Max() + 1;
                }
                else
                {
                    code = 1;
                }

                TOfficeReceive or;
                List <string>  pid = personIDs.ToList <string>();
                for (int i = 0; i < pid.Count(); i++)
                {
                    or       = new TOfficeReceive();
                    or.编码    = code + i;
                    or.办公编码  = entity.编码;
                    or.查阅时间  = null;
                    or.接收人编码 = pid[i];
                    or.是否已阅  = false;
                    dbContext.TOfficeReceive.InsertOnSubmit(or);
                }
            }
        }
예제 #5
0
        public static TOffice GetOffice(int?officeId)
        {
            using (MainDataContext dbContext = new MainDataContext())
            {
                if (officeId != null) // 修改
                {
                    return(dbContext.TOffice.FirstOrDefault(t => t.编码 == officeId));
                }
                else   //新增
                {
                    var     list   = dbContext.TOffice.Select(t => t.编码);
                    TOffice entity = new TOffice();
                    entity.编码     = PrimaryKeyCreater.getIntPrimaryKey("TOffice");
                    entity.接收人    = string.Empty;
                    entity.办公类型编码 = string.Empty;
                    entity.标题     = string.Empty;
                    entity.作者     = string.Empty;
                    entity.内容     = string.Empty;
                    entity.创建时间   = DateTime.Now;

                    return(entity);
                }
            }
        }
예제 #6
0
 public bool Save(TOffice entity)
 {
     return(DAL.Office.Office.Save(entity));
 }
예제 #7
0
        public static bool Save(TOffice entity)
        {
            using (MainDataContext dbContext = new MainDataContext())
            {
                try
                {
                    var model = dbContext.TOffice.FirstOrDefault(t => t.编码 == entity.编码);
                    if (model == null)  //添加
                    {
                        //添加到数据库
                        InsertReceiver(entity, dbContext);
                        dbContext.TOffice.InsertOnSubmit(entity);
                    }
                    else  //修改
                    {
                        //再插入人员接收反馈表

                        #region 发送目的地信息
                        ////先删除发送目的地信息
                        //var lisS = from b in dbContext.TOfficeSend
                        //           where b.办公编码 == entity.编码
                        //           select b;
                        //foreach (var l in lisS)
                        //{
                        //    dbContext.TOfficeSend.Remove(l);
                        //}

                        ////再插入发送目的地表
                        //var squery = from am in dbContext.TOfficeSend
                        //    select am.编码;
                        //int scode = 0;
                        //if (squery.Any())
                        //    scode = squery.Max() + 1;
                        //else
                        //    scode = 1;
                        ////int scode = 0;//主键
                        //int j = 0;
                        //TOfficeSend s;
                        //switch (entity.发送类型编码)
                        //{
                        //    case 2:
                        //        string[] branchIDs = entity.接收部门编码.Split(',');
                        //        foreach (string branchID in branchIDs)
                        //        {
                        //            s = new TOfficeSend();
                        //            s.编码 = scode + j;
                        //            s.办公编码 = entity.编码;
                        //            s.发送类型编码 = 2;
                        //            s.目的地编码 = branchID;
                        //            dbContext.TOfficeSend.Add(s);
                        //            j++;
                        //        }
                        //        break;
                        //    case 3:
                        //        foreach (string personID in personIDs)
                        //        {
                        //            s = new TOfficeSend();
                        //            s.编码 = scode + j;
                        //            s.办公编码 = entity.编码;
                        //            s.发送类型编码 = 3;
                        //            s.目的地编码 = personID;
                        //            dbContext.TOfficeSend.Add(s);
                        //            j++;
                        //        }
                        //        break;
                        //    default:
                        //        break;
                        //}
                        #endregion

                        #region 接收反馈信息
                        //先删除人员接收反馈信息
                        var lisR = from b in dbContext.TOfficeReceive
                                   where b.办公编码 == entity.编码
                                   select b;
                        foreach (var l in lisR)
                        {
                            dbContext.TOfficeReceive.DeleteOnSubmit(l);
                        }

                        InsertReceiver(entity, dbContext);
                        #endregion

                        ReflectionUtility.CopyObjectProperty <TOffice>(entity, model);
                    }

                    dbContext.SubmitChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    Log4Net.LogError("Office Save", ex.ToString());

                    return(false);
                }
            }
        }