Пример #1
0
        protected void Depart_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Depart.SelectedValue == "")
            {
                this.YwyCode.Items.Clear();
                this.YwyCode.SelectedValue = "";
            }
            else
            {
                BaseDao   baseDao = new BaseDao();
                Hashtable ht      = new Hashtable();
                XtmDepart de      = new XtmDepart();
                de.DepartCode = Depart.SelectedValue;
                IList <XtmDepart> depL = baseDao.List(de);
                if (depL != null && depL.Count > 0)
                {
                    ht.Add("depart", depL[0].Did);
                    WebUiProcess.InitDropDownList(this.YwyCode, "ddlCbYwy", ht, ref errmsg);
                }
            }


            //if (Depart.SelectedValue == "")
            //{
            //    this.YwyCode.Items.Clear();
            //    this.YwyCode.SelectedValue = "";
            //}
            //else
            //{
            //    Hashtable ht = new Hashtable();
            //    ht.Add("depart", Depart.SelectedValue);
            //    WebUiProcess.InitDropDownList(this.YwyCode, "ddlCbYwy", ht, ref errmsg);
            //}
        }
Пример #2
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);
        }
Пример #3
0
        private void CreateRow(IRow row, XtmDepart temp)
        {
            int   index  = 0;
            ICell cellxh = row.CreateCell(index + 0);

            cellxh.SetCellType(CellType.String);
            cellxh.SetCellValue(temp.DepartCode);

            ICell cellnf = row.CreateCell(index + 1);

            cellnf.SetCellType(CellType.String);
            cellnf.SetCellValue(temp.DepartName);
        }
Пример #4
0
        public IWorkbook ExportData(ref string errmsg)
        {
            XtmDepart    param = new XtmDepart();
            XSSFWorkbook book  = new XSSFWorkbook();
            ISheet       sheet = book.CreateSheet("departExport");
            IRow         row   = sheet.CreateRow(0);

            CreateHead(row);
            IList <XtmDepart> list = baseDao.List(param);
            int i = 0;

            foreach (XtmDepart temp in list)
            {
                i += 1;
                IRow rowT = sheet.CreateRow(i);
                CreateRow(rowT, temp);
            }
            return(book);
        }
Пример #5
0
        private bool Delete(Framework.Task.Task task, ref string errmsg)
        {
            XtmDepart delModel = new XtmDepart();

            delModel.SysKey = task.CommandArgument;
            BaseDao   baseDao = new BaseDao();
            XtmDepart temp    = new XtmDepart();

            temp.ParentId = delModel.Did;
            int count = baseDao.Count(temp);

            if (count > 0)
            {
                errmsg = "该部门底下挂有子部门,不允许删除";
                return(false);
            }
            XtmUser userM = new XtmUser();

            userM.DepartId = delModel.Did;
            count          = baseDao.Count(userM);
            if (count > 0)
            {
                errmsg = "该部门底下挂有人员,不允许删除";
                return(false);
            }
            try
            {
                baseDao.Delete(delModel);
            }
            catch (Exception ex)
            {
                errmsg = ex.Message;
                return(false);
            }
            if (errmsg != "")
            {
                return(false);
            }
            errmsg      = "删除成功";
            task.Rebind = true;
            return(true);
        }
Пример #6
0
        private string LoadDepartJson()
        {
            BaseDao   baseDao = new BaseDao();
            XtmDepart modelT  = new XtmDepart();

            modelT.UserId = int.Parse(Request.QueryString["id"]);
            IList <XtmDepart> list     = baseDao.ListUdf("XtmDepartLoad", modelT);
            ArrayList         jsonList = new System.Collections.ArrayList();
            string            result   = "[";

            for (int i = 0; i < list.Count; i++)
            {
                XtmDepart menuT = list[i];
                NodeData  mt    = new NodeData();
                mt.id   = menuT.Did.ToString();
                mt.code = menuT.DepartCode;
                mt.pid  = menuT.ParentId.ToString();
                mt.name = menuT.DepartName;
                mt.open = true;
                if (menuT.Pri == "y")
                {
                    mt.@checked = true;
                }
                else
                {
                    mt.@checked = false;
                }
                if (i == list.Count - 1)
                {
                    result += JsonHelper.JsonSerializer <NodeData>(mt);
                }
                else
                {
                    result += JsonHelper.JsonSerializer <NodeData>(mt) + ",";
                }
            }
            result += "]";
            return(result);
        }
Пример #7
0
        public bool Validate(string type, XtmDepart entity, ref string errmsg)
        {
            switch (type)
            {
            case "all":
                #region validate all
                if (entity.DepartCode == "")
                {
                    errmsg = "机构编码不能为空";
                    return(false);
                }
                if (entity.DepartName == "")
                {
                    errmsg = "机构名称不能为空";
                    return(false);
                }

                #endregion
                break;
            }
            return(true);
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string Cxcs = System.Configuration.ConfigurationManager.AppSettings["Cxcs"].Trim();
                WebUiProcess.InitDropDownList(this.Cxcs, Cxcs, ref errmsg);

                WebUiProcess.InitDropDownList(this.Depart, "ddlCbDepart", null, ref errmsg);
                if (Entity.Depart != null && Entity.Depart != "")
                {
                    BaseDao   baseDao = new BaseDao();
                    Hashtable ht      = new Hashtable();
                    XtmDepart de      = new XtmDepart();
                    de.DepartCode = Entity.Depart;
                    IList <XtmDepart> depL = baseDao.List(de);
                    if (depL != null && depL.Count > 0)
                    {
                        ht.Add("depart", depL[0].Did);
                        WebUiProcess.InitDropDownList(this.Ywy, "ddlCbYwy", ht, ref errmsg);
                    }
                }
            }
        }