コード例 #1
0
        private bool Save(Framework.Task.Task task, ref string errmsg)
        {
            bool             result  = true;
            BaseDao          baseDao = new BaseDao();
            XtmDepart        entity  = task.Entity as XtmDepart;
            XtmDepartService service = new XtmDepartService();

            result = service.Validate("all", entity, ref errmsg);
            if (result == false)
            {
                return(false);
            }
            if (entity.Did != 0 && entity.ParentId != 0)
            {
                if (entity.Did == entity.ParentId)
                {
                    errmsg = "自己不能为自己的隶属机构";
                    return(false);
                }
            }

            if (entity.ParentId == 0)
            {
                entity.DepartLayer = 1;
            }
            else
            {
                XtmDepart parDep = new XtmDepart();
                parDep.Did         = entity.ParentId;
                parDep             = baseDao.Get(parDep);
                entity.DepartLayer = parDep.DepartLayer + 1;
            }
            if (entity.Did > 0)
            {
                baseDao.Update(entity);
            }
            else
            {
                XtmDepart temp = new XtmDepart();
                temp.DepartCode = entity.DepartCode;
                int count = baseDao.Count(temp);
                if (count > 0)
                {
                    errmsg = "该机构代码已经被使用";
                    return(false);
                }
                baseDao.Insert(entity);
            }

            if (result == true)
            {
                errmsg            = "保存成功";
                task.ParentRebind = true;
                task.IsClose      = true;
            }
            return(result);
        }
コード例 #2
0
        private void Export(Framework.Task.Task task, ref string errmsg)
        {
            XtmDepartService service1 = new XtmDepartService();
            IWorkbook        book     = service1.ExportData(ref errmsg);

            if (task.paralist == null)
            {
                task.paralist = new System.Collections.ArrayList();
            }
            task.paralist.Add(book);
        }