Exemplo n.º 1
0
        public static bool Regsister(string username, string password, string name, string sex, DateTime birthday, string tel, string part, DateTime worktime, string address, string content, string status = "注册")
        {
            if (QcUser.Users.Any(t => t.UserName == username || t.姓名 == name))
            {
                return(false);
            }
            QcUser user = new QcUser();

            user.UserName  = username;
            user.部门        = part;
            user.姓名        = name;
            user["用户密码"]   = password;
            user["性别"]     = sex;
            user["出生日期"]   = birthday.ToQcDateString();
            user["参加工作时间"] = worktime.ToQcDateString();
            user["联系电话"]   = tel;
            user["通讯地址"]   = address;
            user["备注"]     = content;
            user.UserID    = QcUser.GetNextCode();
            user["状态"]     = status;
            //user["状态"] = "启用";
            bool ret = user.Update();

            if (ret)
            {
                user.AddRole("项目负责人");
                user.AddRole("任务负责人");
                user.AddRole("作业员");
            }
            //if (QcProject.GetProjects("").Any(t => t.Name == "快速项目") == false)
            //{
            //    QcProject prj = new QcProject();
            //    prj["项目名称"] = "快速项目";
            //    prj["项目负责人"] = "sys";
            //    prj["承担部门"] = "临时";
            //    prj["项目来源"] = "其它";
            //    prj["项目类型"] = "其它";
            //    prj["创建人"] = "sys";
            //    if (prj.Update())
            //    {
            //        QcTask task = new QcTask(prj);
            //        task.Name = "快速任务";
            //        task["任务负责人"] = "sys";
            //        task["创建人"] = "sys";
            //        task["任务优先级"] = "1";
            //        task["任务状态"] = "未启动";
            //        task.Update();
            //    }
            //}
            QcTask.Get_CreatQuickTask();
            QcMsgPoster.PostMeassage(user.Code, user.tablename, user.CodeField, NodeChangeType.Create);
            return(ret);
        }
Exemplo n.º 2
0
        public override bool Update(QcDbTransaction trans = null)
        {
            if (IsNew())
            {
                this.Code    = QcUser.GetNextCode();
                this["用户密码"] = QcEncrypt.Md5Hash(this.UserName + QcEncrypt.Md5Hash(this["用户密码"]));
            }
            bool ret = base.Update(trans);

            //子节点调用AddRole 和RemoveRole进行同步,此处不管
            if (ret == false && IsNew())
            {
                this.Code = "";
            }
            if (ret && !Users.Contains(this))
            {
                Users.Add(this);
            }
            //if (ret && !Users.Any(t=>t.UserName==this.UserName)) Users.Add(this);
            return(ret);
        }