Esempio n. 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List <SQL> Save(T_Users model, string uRoles_ID)
        {
            tuser = model;
            if (model.uUsers_ID.To_Guid().Equals(Guid.Empty))
            {
                if (string.IsNullOrEmpty(tuser.cUsers_LoginPwd))
                {
                    tuser.cUsers_LoginPwd = "123456"; //Tools.MD5Encrypt("123456");
                }
                else
                {
                    tuser.cUsers_LoginPwd = model.cUsers_LoginPwd;//Tools.MD5Encrypt(model.cUsers_LoginPwd);
                }
                model.uUsers_ID = db.Add(tuser, li).To_Guid();
                if (model.uUsers_ID.To_Guid().Equals(Guid.Empty))
                {
                    throw new MessageBox(db.ErrorMessge);
                }
                //用户角色
                tuserrole.uUsersRoles_UsersID = tuser.uUsers_ID;
                tuserrole.uUsersRoles_RoleID  = Tools.getGuid(uRoles_ID);
                if (db.Add(tuserrole, li).To_Guid().Equals(Guid.Empty))
                {
                    throw new MessageBox(db.ErrorMessge);
                }
            }
            else
            {
                //如果 密码字段为空,则设置忽略字段
                if (string.IsNullOrEmpty(tuser.cUsers_LoginPwd))
                {
                    tuser.AddNoDbField(f => new { f.cUsers_LoginPwd });
                }
                if (!db.Edit <T_Users>(tuser, w => w.uUsers_ID == tuser.uUsers_ID, li))
                {
                    throw new MessageBox(db.ErrorMessge);
                }

                //用户角色
                if (!db.Delete <T_UsersRoles>(w => w.uUsersRoles_UsersID == tuser.uUsers_ID, li))
                {
                    throw new MessageBox(db.ErrorMessge);
                }
                if (db.Add <T_UsersRoles>(() => new T_UsersRoles()
                {
                    uUsersRoles_UsersID = tuser.uUsers_ID,
                    uUsersRoles_RoleID = uRoles_ID.To_Guid()
                }, li).To_Guid().Equals(Guid.Empty))
                {
                    throw new MessageBox(db.ErrorMessge);
                }
            }
            return(li);
        }
Esempio n. 2
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public List <SQL> Save(T_Function model)
 {
     tf = model;
     if (Tools.getGuid(model.uFunction_ID).Equals(Guid.Empty))
     {
         model.uFunction_ID = Tools.getGuid(db.Add(tf, li));
         if (Tools.getGuid(model.uFunction_ID).Equals(Guid.Empty))
         {
             throw new MessageBox(db.ErrorMessge);
         }
     }
     else
     {
         if (!db.Edit <T_Function>(tf, w => w.uFunction_ID == tf.uFunction_ID, li))
         {
             throw new MessageBox(db.ErrorMessge);
         }
     }
     return(li);
 }
Esempio n. 3
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public List <SQL> Save(T_Roles model)
 {
     troles = model;
     if (Tools.getGuid(model.uRoles_ID).Equals(Guid.Empty))
     {
         model.uRoles_ID = Tools.getGuid(db.Add(troles, li));
         if (model.uRoles_ID.Equals(Guid.Empty))
         {
             throw new MessageBox(db.ErrorMessge);
         }
     }
     else
     {
         if (!db.Edit(troles, item => item.uRoles_ID == troles.uRoles_ID, li))
         {
             throw new MessageBox(db.ErrorMessge);
         }
     }
     return(li);
 }