Пример #1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(YJUI.Model.ui_user model)
 {
     if (dal.GetList("account='" + model.account + "' and ID<>'" + model.id + "'").Tables[0].Rows.Count > 0)
     {
         Exception ex = new Exception("账号重复!");
         throw ex;
     }
     return(dal.Update(model));
 }
Пример #2
0
        /// <summary>
        /// 插入用户和用户的 角色、组织
        /// </summary>
        /// <param name="model">用户</param>
        /// <param name="user_role">角色</param>
        /// <param name="user_org">组织</param>
        /// <returns></returns>
        public bool Add(YJUI.Model.ui_user model, string user_role, string user_org)
        {
            if (dal.ExistsUser(model.account))
            {
                Exception ex = new Exception("账号重复!");
                throw ex;
            }


            List <Model.ui_user_role> T_ui_role = new List <ui_user_role>();
            List <Model.ui_user_org>  T_ui_org  = new List <ui_user_org>();

            if (!string.IsNullOrEmpty(user_role))
            {
                for (int i = 0; i < user_role.Split(',').Length; i++)
                {
                    Model.ui_user_role model_user_role = new ui_user_role();
                    model_user_role.ui_user_id = model.id;
                    model_user_role.ui_role_id = new Guid(user_role.Split(',')[i]);
                    model_user_role.crdate     = DateTime.Now;
                    T_ui_role.Add(model_user_role);
                }
            }

            if (!string.IsNullOrEmpty(user_org))
            {
                for (int i = 0; i < user_org.Split(',').Length; i++)
                {
                    Model.ui_user_org model_user_org = new ui_user_org();
                    model_user_org.ui_user_id = model.id;
                    model_user_org.ui_org_id  = new Guid(user_org.Split(',')[i]);
                    model_user_org.crdate     = DateTime.Now;
                    T_ui_org.Add(model_user_org);
                }
            }
            return(dal.Add(model, T_ui_role, T_ui_org));
        }
Пример #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(YJUI.Model.ui_user model)
 {
     return(dal.Add(model));
 }