public ActionResult OperateEmployee(EmployeeInfoContract ec, FormCollection fc)
        {
            #region 绑定 注:如果是企业自身编辑,这些数据是企业无法修改的,只能是超级管理员才能修改。

            //当前登录人的权限 1系统管理员,2 企业

            if ((Session["user"] as UsersContract).RoleID == 1)
            {
                #region 系统管理员
                List<BranchInfoContract> list = new List<BranchInfoContract>();
                DataSet dsBranch = bs.FindIsFBranch(20);
                for (int i = 0; i < dsBranch.Tables[0].Rows.Count; i++)
                {
                    BranchInfoContract branch = new BranchInfoContract();
                    branch.BranchID = Convert.ToInt32(dsBranch.Tables[0].Rows[i]["BranchID"].ToString());
                    branch.BranchName = "├-" + CommonHelper.getListName(dsBranch.Tables[0].Rows[i]["BranchName"].ToString(), dsBranch.Tables[0].Rows[i]["Temp1"].ToString());

                    list.Add(branch);

                }

                ViewData["FatherBranch"] = new SelectList(list, "BranchID", "BranchName");
                //查询用户组
                ViewData["role"] = new SelectList(rolesServices.GetRoles(), "RoleID", "RoleName");

                List<positionInfo> polist = ps.GetPoList();
                ViewData["Group"] = new SelectList(polist, "positionId", "positionName");

                #endregion
            }
            else
            {
                #region 企业及其他

                List<BranchInfoContract> list = new List<BranchInfoContract>();
                BranchInfoContract Branch = bs.GetBranchByBranchID(ec.BranchID);
                list.Add(Branch);

                ViewData["FatherBranch"] = new SelectList(list, "BranchID", "BranchName");
                //查询用户组
                List<RolesContract> listRole = new List<RolesContract>();
                ViewData["role"] = new SelectList(listRole, "RoleID", "RoleName");

                List<PositionInfoContract> polist = new List<PositionInfoContract>();
                polist.Add(ps.GetPositionByPositionID(ec.positionId));
                ViewData["Group"] = new SelectList(polist, "positionId", "positionName");

                #endregion
            }
            #endregion

            var operateType = Request.QueryString["operateType"];
            #region 获取信息

            employeeData empdata = new employeeData()
            {
                Address = fc["add"],
                Tel = fc["Telphone"],
                zuobiao = fc["zuobiao"],
                Photo = fc["photo"]
            };
            #endregion
            if (ModelState.IsValid)
            {

                if (fc["EId"] == null || fc["EId"] == "0")
                {
                    //ADD
                    #region Add Emp Info
                    Users user = new Users();
                    user.UserName = fc["UserID"];
                    user.RoleID = int.Parse(fc["RoleID"]);
                    ec.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    if (es.InsertEmp(ec, user, empdata) > 0)
                    {
                        // Success
                        ViewData["msg"] = "添加成功!";
                        ViewData["url"] = Url.Action("OperateEmployee", new { id = ec.EId });
                        return View("Success");
                    }
                    else
                    {
                        return View(ec);
                    }
                    #endregion
                }
                else
                {
                    //Edit
                    #region Edit Info

                    if (es.EditEmp(ec) == 1)
                    {
                        if (empdata.Address.Length > 1)
                        {
                            empdata.eid = ec.EId;
                            empDataBll.Insert(empdata);
                        }
                        // Success
                        ViewData["msg"] = "修改成功!";
                        ViewData["url"] = Url.Action("OperateEmployee", new { id = ec.EId });
                        return View("Success");
                    }
                    else
                    {

                        return View(ec);
                    }
                    #endregion
                }
            }
            return View();
        }
        /// <summary>
        /// 添加和编辑员工
        /// </summary>
        /// <param name="id">员工编号</param>
        /// <param name="operate">标示,判断是否是从员工详细页面跳转到本页面的</param>
        /// <returns></returns>
        public ActionResult OperateEmployee(string id, string operate)
        {
            var operateType = Request.QueryString["operateType"];
            ViewData["operate"] = operate;
            EmployeeInfoContract ec = new EmployeeInfoContract();
            #region 绑定 注:如果是企业自身编辑,这些数据是企业无法修改的,只能是超级管理员才能修改。
            if (id != null)  //编辑员工操作
            {
                //根据员工编号查询员工信息的方法
                ec = es.GetEmpInfoByEId(int.Parse(id));
                //查询企业的店铺信息
                ViewData["empdata"] = empDataBll.GetEmpData(int.Parse(id));
            }
            //当前登录人的权限 1系统管理员,2 企业

            if ((Session["user"] as UsersContract).RoleID == 1)
            {
                #region 系统管理员
                List<BranchInfoContract> list = new List<BranchInfoContract>();
                DataSet dsBranch = bs.FindIsFBranch(20);
                for (int i = 0; i < dsBranch.Tables[0].Rows.Count; i++)
                {
                    BranchInfoContract branch = new BranchInfoContract();
                    branch.BranchID = Convert.ToInt32(dsBranch.Tables[0].Rows[i]["BranchID"].ToString());
                    branch.BranchName = "├-" + CommonHelper.getListName(dsBranch.Tables[0].Rows[i]["BranchName"].ToString(), dsBranch.Tables[0].Rows[i]["Temp1"].ToString());

                    list.Add(branch);

                }

                ViewData["FatherBranch"] = new SelectList(list, "BranchID", "BranchName");
                //查询用户组
                ViewData["role"] = new SelectList(rolesServices.GetRoles(), "RoleID", "RoleName");

                List<positionInfo> polist = ps.GetPoList();
                ViewData["Group"] = new SelectList(polist, "positionId", "positionName");

                #endregion
            }
            else
            {
                #region 企业及其他

                List<BranchInfoContract> list = new List<BranchInfoContract>();
                BranchInfoContract Branch = bs.GetBranchByBranchID(ec.BranchID);
                list.Add(Branch);

                ViewData["FatherBranch"] = new SelectList(list, "BranchID", "BranchName");
                //查询用户组
                List<RolesContract> listRole = new List<RolesContract>();
                ViewData["role"] = new SelectList(listRole, "RoleID", "RoleName");

                List<PositionInfoContract> polist = new List<PositionInfoContract>();
                polist.Add(ps.GetPositionByPositionID(ec.positionId));
                ViewData["Group"] = new SelectList(polist, "positionId", "positionName");

                #endregion
            }
            #endregion
            switch (operateType)
            {
                case "add":
                    ViewBag.pTitle = "添加员工信息";
                    return View(new EmployeeInfoContract());
                default:
                    ViewBag.pTitle = "编辑员工信息";
                    return View(ec);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 修改员工的方法
 /// </summary>
 /// <param name="emp">员工实体</param>
 /// <param name="nowPosIds">职位编号</param>
 /// <returns></returns>
 public int UpdateEmpInfo(EmployeeInfoContract emp, string nowPosIds)
 {
     employeeInfo employee = emp.ToPO<employeeInfo>();
     return ed.UpdateEmpInfo(employee, nowPosIds);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Edit
 /// </summary>
 /// <param name="emp"></param>
 public int EditEmp(EmployeeInfoContract emp)
 {
     return  ed.EditEmp(emp.ToPO<employeeInfo>());
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <param name="emp"></param>
 public int InsertEmp(EmployeeInfoContract emp,Users user,employeeData empdata)
 {
     return ed.InsertEmp(emp.ToPO<employeeInfo>(),user,empdata);
 }