Ejemplo n.º 1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     String[] units  = txtUnitName.Text.Trim().Split(new char[] { '\n' });
     String[] admins = txtAdminName.Text.Trim().Split(new char[] { '\n' });
     if (units.Length != admins.Length)
     {
         UtilHelper.AlertMsg("error");
     }
     else
     {
         DataClassesDataContext dc = new DataClassesDataContext();
         for (int i = 0; i < units.Length; i++)
         {
             ApplicantUnit unit = new ApplicantUnit();
             unit.F_ID     = UnitService.GetID();
             unit.F_name   = units[i];
             unit.F_status = RoleType.Authoried;
             unit.F_seq    = UnitService.GetSeq();
             admins[i]     = admins[i].Trim();
             EducationV2.User user = new EducationV2.User();
             user.F_ID       = Guid.NewGuid().ToString();
             user.F_userName = admins[i];
             if (dc.User.SingleOrDefault(_user => _user.F_userName.Equals(admins[i])) != null)
             {
                 Response.Write("重复");
                 return;
             }
             user.F_realName     = admins[i];
             user.F_pwd          = UtilHelper.MD5Encrypt("000000");
             user.F_status       = RoleType.Authoried;
             user.F_Role         = RoleType.SchoolAdmin;
             user.F_belongUnitID = unit.F_ID;
             dc.ApplicantUnit.InsertOnSubmit(unit);
             dc.User.InsertOnSubmit(user);
             dc.SubmitChanges();
         }
     }
 }