RTX 部門管理用例代碼

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using RTXSAPILib; using System.Runtime.InteropServices; namespace DeptmanagerObj { public partial class DeptUserfrm : Form { RTXSAPILib.RTXSAPIRootObj RootObj; //聲明一個根對象 RTXSAPILib.RTXSAPIDeptManager DeptManagerObj; //聲明一個部門管理對象 public DeptUserfrm() { InitializeComponent(); RootObj = new RTXSAPIRootObj(); //創建根對象 DeptManagerObj = RootObj.DeptManager; //通過根對象創建部門管理對象 } private void btnGetDeptUsers_Click(object sender, EventArgs e) { try { string deptUsers = DeptManagerObj.GetDeptUsers(txtDeptName.Text); //查看部門下的用戶列表 MessageBox.Show(deptUsers); } catch (COMException ex) { MessageBox.Show(ex.Message); } } private void btnGetUserDepts_Click(object sender, EventArgs e) { try { string depts = DeptManagerObj.GetUserDepts(txtUserName.Text); //查看用戶所屬部門 MessageBox.Show(depts); } catch (COMException ex) { MessageBox.Show(ex.Message); } } private void btnAddUserToDept_Click(object sender, EventArgs e) { string SrcDeptName; if (txtSrcDeptName.Text == "") SrcDeptName = null; else SrcDeptName = txtSrcDeptName.Text; try { DeptManagerObj.AddUserToDept(txtUser.Text, SrcDeptName, txtDesDeptName.Text, false); //添加用戶進某個部門,如果用戶沒有所屬部門,源部門名爲null即可。 MessageBox.Show("添加成功"); } catch (COMException ex) { MessageBox.Show(ex.Message); } } private void btnDelUserFromDept_Click(object sender, EventArgs e) { try { DeptManagerObj.DelUserFromDept(txtdelUser.Text, txtDept.Text); //從某個部門下刪除用戶 MessageBox.Show("刪除成功"); } catch (COMException ex) { MessageBox.Show(ex.Message); } } //通常不需要用到該方法,該方法主要應用場景是有些用戶同時屬於多個部門,想把主要部門顯示在前面。 //最多能設置前三個部門 private void btnSetUserMainDept_Click(object sender, EventArgs e) { try { DeptManagerObj.SetUserMainDepts(txtMainDeptUser.Text, txtDept1.Text, txtDept2.Text, txtDept3.Text); MessageBox.Show("設置成功"); } catch (COMException ex) { MessageBox.Show(ex.Message); } } } } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章