Пример #1
0
        public ActionResult PostEdit(int id = 0, int parentId = 0)
        {
            string   childs = "";
            Sys_Post model  = AllPosts.Find(p => p.PostId == id);

            if (model == null)
            {
                model = new Sys_Post {
                    PostId = id, ParentId = parentId, PostCode = "", PostName = "", Remark = ""
                }
            }
            ;
            else
            {
                var list = new List <int>();
                GetChildPostIds(model.PostId, list);
                childs = list.Aggregate("", (current, postId) => current + (postId + ","));
            }
            if (model.ParentId == 0)
            {
                model.parentPostName = CommonLanguage.ParentPost;
            }
            else
            {
                model.parentPostName = AllPosts.Find(p => p.PostId == model.ParentId).PostNameShow;
            }
            ViewBag.model  = model;
            ViewBag.childs = childs;
            return(View());
        }
Пример #2
0
        /// <summary>
        ///     更改上级
        /// </summary>
        /// <param name="postId"></param>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public bool ChangeParent(int postId, int parentId)
        {
            Sys_Post post = _postDB.Get(postId);

            post.ParentId = parentId;
            return(_postDB.Update(post));
        }
Пример #3
0
        public JsonResult SavePost(int postId, string postCode, string postName, string postDesc, int postLevel,
                                   int parentId)
        {
            try
            {
                if (postBL.Exists(postCode, postName, postId))
                {
                    return(Json(new { result = 0, content = "岗位代码或岗位名称重复!" }, JsonRequestBehavior.AllowGet));
                }

                Sys_Post model = AllPosts.Find(p => p.PostId == postId);
                if (model == null)
                {
                    model = new Sys_Post();
                }
                model.PostId   = postId;
                model.PostCode = postCode;
                model.PostName = postName;
                model.Remark   = postDesc;
                if (postLevel == -1)
                {
                    model.PostLevel = null;
                }
                else
                {
                    model.PostLevel = postLevel;
                }
                model.ParentId = parentId;
                if (model.PostId == 0)
                {
                    postBL.Add(model);
                    AllPosts.Add(model);
                }
                else
                {
                    postBL.Update(model);
                }
                lock (lockobj)
                {
                    RefreshPostCache();
                }
                return(Json(new { result = 1, content = "保存成功" }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { result = 0, content = "保存失败" }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #4
0
        /// <summary>
        ///     增加一条数据
        /// </summary>
        /// <param name="model"></param>
        public void Add(Sys_Post model)
        {
            using (IDbConnection conn = OpenConnection())
            {
                const string sqlwhere =
                    @"insert into Sys_Post(PostCode,PostName,ParentId,Remark,PostLevel) values(@PostCode,@PostName,@ParentId,@Remark,@PostLevel)
                SELECT @@Identity AS ID
";
                var param = new
                {
                    model.PostCode,
                    model.PostName,
                    model.ParentId,
                    model.Remark,
                    model.PostLevel
                };
                decimal id = conn.Query <decimal>(sqlwhere, param).FirstOrDefault();
                model.PostId = decimal.ToInt32(id);
            }
        }
Пример #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType    = "text/plain";
            context.Request.ContentEncoding = Encoding.GetEncoding("UTF-8");
            StringBuilder sb       = new StringBuilder();
            string        parentId = string.Empty;

            if (!string.IsNullOrEmpty(context.Request.QueryString["id"]))
            {
                parentId = context.Request.QueryString["id"];
            }
            if (!string.IsNullOrEmpty(parentId))
            {
                Sys_UserInfo entity = bll.Get(p => p.UserInfoID == parentId);
                if (entity != null)
                {
                    string            post     = "";
                    string            postN    = "";
                    string            name     = entity.UserInfo_FullName;
                    string            ment     = entity.UserInfo_DepCode;
                    Sys_DepartmentBLL mentsbll = new Sys_DepartmentBLL();
                    Sys_Department    ments    = mentsbll.Get(p => p.Department_Code == ment);
                    post = entity.UserInfo_Post;
                    Sys_Post po = pobll.Get(p => p.PostID == post);
                    if (po != null)
                    {
                        postN = po.Post_Name;
                    }
                    string mentss = ments.Department_Name;


                    var    Data       = new { name = name, mentss = mentss, post = post, postN = postN };
                    string jsonPerson = JsonConvert.SerializeObject(Data);
                    context.Response.Write(jsonPerson);
                }
            }
            else
            {
                context.Response.Write("{\"data\":\"error\"}");
            }
        }
Пример #6
0
        /// <summary>
        /// /
        /// </summary>
        public void show()
        {
            Sys_DepartmentBLL depbll = new Sys_DepartmentBLL();

            if (!string.IsNullOrEmpty(id))
            {
                Sys_PostBLL bllPost = new Sys_PostBLL();

                modelGwxx = bllPost.Get(p => p.PostID == id);
                if (modelGwxx != null)
                {
                    this.txtGwName.Text = modelGwxx.Post_Name;
                    this.txtpx.Text     = modelGwxx.Post_Sort.ToString();
                    depmodel            = depbll.Get(p => p.Department_Code == modelGwxx.Post_DepCode);
                    if (depmodel != null)
                    {
                        this.txt_depName.Text = depmodel.Department_Name;
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(hid_DepCode))
                {
                    depmodel = depbll.Get(p => p.Department_Code == hid_DepCode);
                    if (depmodel != null)
                    {
                        this.txt_depName.Text = depmodel.Department_Name;
                    }
                }
                else
                {
                    depmodel = depbll.Get(p => p.Department_Code == "001");
                    if (depmodel != null)
                    {
                        this.txt_depName.Text = depmodel.Department_Name;
                    }
                }
            }
        }
Пример #7
0
        /// <summary>
        ///     更新一条数据
        /// </summary>
        /// <param name="model">要更新的实体对象</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool Update(Sys_Post model)
        {
            using (IDbConnection conn = OpenConnection())
            {
                const string sqlwhere =
                    @"update Sys_Post set PostCode=@PostCode,PostName=@PostName,ParentId=@ParentId,Remark=@Remark,PostLevel=@PostLevel where PostId=@PostId

UPDATE Sys_User SET PostId=@PostId,PostCode=@PostCode,PostName=@PostName,PostLevel=@PostLevel WHERE PostId=@PostId
";
                var param = new
                {
                    model.PostCode,
                    model.PostName,
                    model.ParentId,
                    model.Remark,
                    model.PostLevel,
                    model.PostId
                };
                int result = conn.Execute(sqlwhere, param);
                return(result > 0);
            }
        }
Пример #8
0
        private void InsertUserList(List <Sys_User> listUser, ref string userTempID, ref string chongfu)
        {
            List <Sys_User> listUserSql = userBL.GetList(" Sys_User.IsDelete = 0 ");

            foreach (Sys_User item in listUser)
            {
                try
                {
                    Sys_User model = listUserSql.Find(p => p.JobNum == item.JobNum);
                    if (model != null)
                    {
                        #region 系统已存在用户,做修改操作    但是被无知的人说,这个不需要;那这个就被邪恶的我干掉了。。。不要怪我哦

                        //model.Realname = item.Realname;
                        //model.Sex = item.Sex;
                        //model.Birthday = item.Birthday;
                        //model.Email = item.Email;
                        //model.Telephone = item.Telephone;
                        //model.Fax = item.Fax;
                        //model.JobTitle = item.JobTitle;
                        //model.Ename = item.Ename;

                        //Sys_Department dep = AllDepartments.Find(p => p.DeptCode == item.DeptCode);
                        //if (dep != null)
                        //{
                        //    item.DeptCode = dep.DeptCode;
                        //    item.DeptName = dep.DeptName;
                        //    item.DeptId = dep.DepartmentId;
                        //}
                        //else
                        //{
                        //    item.DeptCode = "";
                        //    item.DeptName = "";
                        //    item.DeptId = -1;
                        //}

                        //Sys_Post post = AllPosts.Find(p => p.PostCode == item.PostCode);
                        //if (post != null)
                        //{
                        //    item.PostCode = post.PostCode;
                        //    item.PostName = post.PostName;
                        //    item.PostLevel = post.PostLevel;
                        //    item.PostId = post.PostId;
                        //}
                        //else
                        //{
                        //    item.PostLevel = null;
                        //    item.PostName = "";
                        //    item.PostCode = "";
                        //    item.PostId = -1;
                        //}

                        //model.Status = item.Status;
                        //model.FreezeTime = null;

                        //userBL.Update(model);

                        #endregion

                        if (chongfu != "")
                        {
                            chongfu = chongfu + "," + item.Username;
                        }
                        else
                        {
                            chongfu = item.Username;
                        }
                    }
                    else
                    {
                        if (item.Status < 2)
                        {
                            Sys_Department dep = AllDepartments.Find(p => p.DeptCode == item.DeptCode);
                            if (dep != null)
                            {
                                item.DeptCode = dep.DeptCode;
                                item.DeptName = dep.DeptName;
                                item.DeptId   = dep.DepartmentId;
                            }
                            else
                            {
                                item.DeptCode = "";
                                item.DeptName = "";
                                item.DeptId   = -1;
                            }

                            Sys_Post post = AllPosts.Find(p => p.PostCode == item.PostCode);
                            if (post != null)
                            {
                                item.PostCode = post.PostCode;
                                item.PostName = post.PostName;
                                //item.PostLevel = post.PostLevel;
                                item.PostId = post.PostId;
                            }
                            else
                            {
                                item.PostLevel = null;
                                item.PostName  = "";
                                item.PostCode  = "";
                                item.PostId    = -1;
                            }

                            userBL.Add(item);
                        }
                    }
                }
                catch
                {
                    if (userTempID != "")
                    {
                        userTempID = userTempID + "," + item.Username;
                    }
                    else
                    {
                        userTempID = item.Username;
                    }
                }
            }
        }
Пример #9
0
        /// 保存
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object obj, EventArgs e)
        {
            Sys_PostBLL bllPost = new Sys_PostBLL();

            if (string.IsNullOrEmpty(id))
            {
                modelGwxx.PostID          = Guid.NewGuid().ToString();
                modelGwxx.Post_AddUserId  = "1";// base.CurrUserInfo().UserID;
                modelGwxx.Post_AddTime    = DateTime.Now;
                modelGwxx.Post_Name       = txtGwName.Text.Trim();
                modelGwxx.Post_Sort       = int.Parse(txtpx.Text.Trim());
                modelGwxx.Post_DepCode    = hid_DepCode;
                modelGwxx.Post_IsDelete   = false;
                modelGwxx.Post_EditTime   = DateTime.Now;
                modelGwxx.Post_EditUserId = "1";//base.CurrUserInfo().UserID;
                modelGwxx.Post_Sort       = 0;
                bool IsPost = bllPost.Add(modelGwxx);
                if (IsPost)
                {
                    //Risk_PostRiskLib modelGwfxk = new Risk_PostRiskLib();
                    //modelGwfxk.PostRiskLibID = Guid.NewGuid().ToString();
                    //modelGwfxk.PostRiskLib_EvaluateLevel = "";
                    //modelGwfxk.PostRiskLib_Score = 0;
                    //modelGwfxk.PostRiskLib_AddUserId = base.CurrUserInfo().UserID;
                    //modelGwfxk.PostRiskLib_AddTime = DateTime.Now;
                    //modelGwfxk.PostRiskLib_PostID = modelGwxx.PostID;
                    //bllGwfxk.Add(modelGwfxk, out msg);

                    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('添加成功!');coed('1')", true);
                    // MessageBox.Show(this, "添加成功");
                }
                else
                {
                    MessageBox.Show(this, "保存出错");
                }
            }
            else
            {
                //string ids = " PostID ='" + hid_GwValue.Value + "'";
                //modelGwxx = bllPost.FindWhere(ids)[0];
                modelGwxx = bllPost.Get(p => p.PostID == id);
                //modelGwxx.Post_DepCode = this.hid_DepCode.Value;
                modelGwxx.Post_Name = txtGwName.Text.Trim();
                modelGwxx.Post_Sort = int.Parse(txtpx.Text.Trim());
                if (bllPost.Update(modelGwxx))
                {
                    ////var lis = bllGwfxk.FindWhere(" PostRiskLib_PostID='" + modelGwxx.PostID + "'");
                    //var lis = bllGwfxk.FindWhere(p => p.PostRiskLib_PostID == modelGwxx.PostID);
                    //if (lis.Count == 0)
                    //{
                    //    Risk_PostRiskLib modelGwfxk = new Risk_PostRiskLib();
                    //    modelGwfxk.PostRiskLibID = Guid.NewGuid().ToString();
                    //    modelGwfxk.PostRiskLib_EvaluateLevel = "";
                    //    modelGwfxk.PostRiskLib_Score = 0;
                    //    modelGwfxk.PostRiskLib_AddUserId = base.CurrUserInfo().UserID;
                    //    modelGwfxk.PostRiskLib_AddTime = DateTime.Now;
                    //    modelGwfxk.PostRiskLib_PostID = modelGwxx.PostID;
                    //    bllGwfxk.Add(modelGwfxk, out msg);
                    //}

                    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('修改成功!');coed('2')", true);
                    //MessageBox.Show(this, "添加成功");
                }
                else
                {
                    MessageBox.Show(this, "保存出错");
                }
            }
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpPostedFile postedFile = Request.Files["File1"];
            string         depCode    = Request["depCode"];

            if (string.IsNullOrEmpty(depCode))
            {
                depCode = "001";
            }
            try
            {
                if (postedFile.FileName != "")
                {
                    string tempPath      = UploadFileCommon.CreateDir("Uplod"); //获取保存文件夹路径。
                    string savepath      = Server.MapPath(tempPath);            //获取保存路径
                    string fileExtension = System.IO.Path.GetExtension(postedFile.FileName).ToLower();
                    if (!Directory.Exists(savepath))                            //查看当前文件夹是否存在
                    {
                        Directory.CreateDirectory(savepath);
                    }
                    string sNewFileName      = DateTime.Now.ToString("yyyyMMddhhmmsfff");//上传后的文件名字
                    string fname             = tempPath + sNewFileName + fileExtension;
                    string allowedExtensions = ".xlsx|.xls";
                    if (!allowedExtensions.Contains(fileExtension))
                    {
                        //this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('请选择Excel文件!');col()", true);
                        MessageBox.Show(this, "请选择Excel文件");
                        return;
                    }
                    postedFile.SaveAs(Server.MapPath(fname));
                    string     filename = Server.MapPath(fname);
                    ImportExcl excl     = new ImportExcl();
                    DataTable  dt       = excl.ExcelToDataSet(filename);
                    if (dt != null)
                    {
                        int a = dt.Rows.Count;
                        List <Sys_UserInfo> listUsermodel = new List <Sys_UserInfo>();
                        List <Sys_Post>     listpostmodel = new List <Sys_Post>();
                        for (int i = 0; i < a; i++)
                        {
                            Sys_UserInfo sysmodel = new Sys_UserInfo();
                            sysmodel.UserInfoID        = Guid.NewGuid().ToString();
                            sysmodel.UserInfo_FullName = dt.Rows[i][1].ToString();
                            string   Post_Name = dt.Rows[i][2].ToString();
                            Sys_Post postmodel = postbll.Find(p => p.Post_Name == Post_Name && p.Post_DepCode == depCode);
                            Sys_Post post      = new Sys_Post();
                            if (postmodel == null)
                            {
                                post.PostID            = Guid.NewGuid().ToString();
                                post.Post_Name         = dt.Rows[i][2].ToString();
                                post.Post_DepCode      = depCode;
                                post.Post_AddUserID    = CurrUserInfo().UserID;
                                post.Post_AddTime      = DateTime.Now;
                                sysmodel.UserInfo_Post = post.PostID;
                                listpostmodel.Add(post);
                            }
                            else
                            {
                                sysmodel.UserInfo_Post = postmodel.PostID;
                            }
                            sysmodel.UserInfo_Position      = dt.Rows[i][3].ToString();
                            sysmodel.UserInfo_PhoneNumber   = dt.Rows[i][4].ToString();
                            sysmodel.UserInfo_PositionLevel = dt.Rows[i][5].ToString();
                            string       DataDict_Name = dt.Rows[i][6].ToString();
                            Sys_DataDict DataDictmodel = DataDictbll.Find(p => p.DataDict_Name == DataDict_Name);
                            if (DataDictmodel != null)
                            {
                                sysmodel.UserInfo_Type = DataDictmodel.DataDict_Code;
                            }
                            else
                            {
                                sysmodel.UserInfo_Type = "0403";
                            }
                            sysmodel.UserInfo_LoginUserName = dt.Rows[i][1].ToString();
                            sysmodel.UserInfo_LoginUserPwd  = DESEncrypt.Encrypt("111111");
                            sysmodel.UserInfo_DepCode       = depCode;
                            sysmodel.UserInfo_RoleID        = "02f13817-9f74-4169-b279-4b00cc741a91";
                            sysmodel.UserInfo_Status        = "0301";
                            sysmodel.UserInfo_Sequence      = int.Parse(dt.Rows[i][0].ToString());
                            listUsermodel.Add(sysmodel);
                        }
                        bool u = userbll.AddLists(listpostmodel, listUsermodel);
                        if (u)
                        {
                            this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('导入成功!');col()", true);
                        }
                        else
                        {
                            MessageBox.Show(this, "导入失败!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, "导入失败!");
                }
            }
            catch {  }
        }
Пример #11
0
 /// <summary>
 ///     更新一条数据
 /// </summary>
 public bool Update(Sys_Post model)
 {
     return(_postDB.Update(model));
 }
Пример #12
0
 /// <summary>
 ///     增加一条数据
 /// </summary>
 public void Add(Sys_Post model)
 {
     _postDB.Add(model);
 }