private void attach_Users(Users entity)
		{
			this.SendPropertyChanging();
			entity.Roles = this;
		}
		private void detach_Users(Users entity)
		{
			this.SendPropertyChanging();
			entity.Roles = null;
		}
 partial void DeleteUsers(Users instance);
		private void detach_Users(Users entity)
		{
			this.SendPropertyChanging();
			entity.employeeInfo = null;
		}
 partial void InsertUsers(Users instance);
 partial void UpdateUsers(Users instance);
 /// <summary>
 /// 更新用户
 /// </summary>
 /// <param name="users"></param>
 /// <returns></returns>
 public bool UpdateUsers(Users users)
 {
     try
     {
         SqlParameter[] parameter = new SqlParameter[]
         {
             new SqlParameter("@userId",users.UserID),
             new SqlParameter("@roleId",users.RoleID)
         };
         SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_UpdateUsers", parameter);
     }
     catch (SqlException)
     {
         return false;
     }
     return true;
 }
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="users"></param>
 /// <returns></returns>
 public DataSet InsertUsers(Users users)
 {
     try
     {
         SqlParameter[] parameter = new SqlParameter[]
         {
             new SqlParameter("@employeeID",users.EmployeeID),
             new SqlParameter("@roleID",users.RoleID),
             new SqlParameter("@userName",users.UserName)
         };
         return SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "proc_InsertUser", parameter);
     }
     catch (SqlException)
     {
         return null;
     }
 }
        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();
        }
예제 #10
0
        /// <summary>
        /// Insert
        /// </summary>
        /// <param name="emp"></param>
        public int InsertEmp(employeeInfo emp,Users user,employeeData empdata)
        {
            db.employeeInfo.InsertOnSubmit(emp);
            db.SubmitChanges();
            user.EmployeeID = emp.Eid;
            user.Password = "******";//初始密码,123456
            user.Status = 0;
            user.CreateTime = DateTime.Now;
            empdata.eid = emp.Eid;
            db.employeeData.InsertOnSubmit(empdata);
            db.Users.InsertOnSubmit(user);

            db.SubmitChanges();
            return emp.Eid;
        }
예제 #11
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);
 }