Exemplo n.º 1
0
 protected void btnInportDepts_Click(object sender, EventArgs e)
 {
     ApolloOaDataContext ctx = new ApolloOaDataContext(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString);
     var depts = ctx.ExecuteQuery<_tempClass>(@"select a.Text Text1,b.Text Text2 from Depts a,Depts b where a.Pid=b.Id;");
     try
     {
         foreach (_tempClass v in depts)
         {
             DeptManagerObj.AddDept(v.Text1, v.Text2); //添加部门,如果用户没有上级部门,txtParentDept不需填写,为空即可
         }
     }
     catch (COMException ex)
     {
         Response.Write(ex.Message);
     }
     Response.Write("部门导入成功");
 }
Exemplo n.º 2
0
 protected void btnInportUsers_Click(object sender, EventArgs e)
 {
     ApolloOaDataContext ctx = new ApolloOaDataContext(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString);
     var depts = ctx.ExecuteQuery<_tempClass>(@"with t as(select EmpId,MIN(PosId) posId from EmpDepPositions group by EmpId)
     select e.JobNo Text1,d.Text Text2 from EmpDepPositions a,t,Depts d,Employee e
     where a.EmpId=t.EmpId and a.PosId=t.posId and a.DeptId=d.Id and a.EmpId=e.Id and e.LeaveDate is null;");
     foreach (_tempClass v in depts)
     {
         string jobNo = v.Text1.ToUpper();
         try
         {
             UserManagerObj.AddUser(jobNo, 0);
             UserManagerObj.SetUserPwd(jobNo, "123456");
             DeptManagerObj.AddUserToDept(jobNo, null, v.Text2, false); //添加用户进某个部门,如果用户没有所属部门,源部门名为null即可。
         }
         catch (COMException ex)
         {
             Response.Write(ex.Message + "_" + jobNo + "_" + v.Text2 + "<br/>");
         }
     }
     Response.Write("用户导入成功");
 }