TransferWorkItems.aspx.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:4k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.HtmlControls;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. namespace OThinker.H3.Portal
  12. {
  13.     public partial class TransferWorkItems : PortalPage
  14.     {
  15.         protected void Page_Load(object sender, EventArgs e)
  16.         {
  17.             if (!this.IsPostBack)
  18.             {
  19.                 // 验证是否具有管理员权限
  20.                 if (!this.UserValidator.ValidateAdministrator())
  21.                 {
  22.                     this.NotifyMessage(LackOfAuth);
  23.                 }
  24.             }
  25.         }
  26.         protected void lnkQuery_Click(object sender, EventArgs e)
  27.         {
  28.             if (this.txtSource.SelectedUser == null || this.txtSource.SelectedUser == "")
  29.             {
  30.                 this.NotifyMessage("没有选中转移谁的工作项");
  31.             }
  32.             // 查询可转移的工作项
  33.             OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(
  34.                 OThinker.H3.Configs.Config.Current.DataBase.DBType,
  35.                 OThinker.H3.Configs.Config.Current.DataBase.DBConnString);
  36.             OThinker.Data.Database.ICommand command = factory.CreateCommand();
  37.             System.Data.DataTable table = command.ExecuteDataTable(
  38.                 "SELECT * FROM " + OThinker.H3.WorkItem.WorkItem.TableName + " " +
  39.                 "WHERE " +
  40.                 OThinker.H3.WorkItem.WorkItem.PropertyName_Receiptor + "='" + this.txtSource.SelectedUser + "' OR " +
  41.                 "(" + OThinker.H3.WorkItem.WorkItem.PropertyName_Participant + "='" + this.txtSource.SelectedUser + "' AND " + WorkItem.WorkItem.PropertyName_Receiptor + " IS NULL)");
  42.             this.WorkItemGrid.BindDataGrid(table);
  43.         }
  44.         protected void lnkOk_Click(object sender, EventArgs e)
  45.         {
  46.             string source = this.txtSource.SelectedUser;
  47.             if (source == null || source == "")
  48.             {
  49.                 this.NotifyMessage("没有选中转移谁的工作项");
  50.             }
  51.             string receiptor = this.txtReceiptor.SelectedUser;
  52.             if (receiptor == null || receiptor == "")
  53.             {
  54.                 this.NotifyMessage("没有选中转移的接收人");
  55.             }
  56.             // 查询可转移的工作项
  57.             OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(
  58.                 OThinker.H3.Configs.Config.Current.DataBase.DBType,
  59.                 OThinker.H3.Configs.Config.Current.DataBase.DBConnString);
  60.             OThinker.Data.Database.ICommand command = factory.CreateCommand();
  61.             System.Data.DataTable table = command.ExecuteDataTable(
  62.                 "SELECT [" + WorkItem.WorkItem.PropertyName_ObjectID + "] FROM " + OThinker.H3.WorkItem.WorkItem.TableName + " " +
  63.                 "WHERE " +
  64.                 OThinker.H3.WorkItem.WorkItem.PropertyName_Receiptor + "='" + source + "' OR " +
  65.                 "(" + OThinker.H3.WorkItem.WorkItem.PropertyName_Participant + "='" + source + "' AND " + WorkItem.WorkItem.PropertyName_Receiptor + " IS NULL)");
  66.             // 转移工作项
  67.             int successCount = 0;
  68.             foreach (System.Data.DataRow row in table.Rows)
  69.             {
  70.                 string itemId = (string)row[0];
  71.                 long result = OThinker.H3.Server.Engine.WorkItemManager.Transfer(itemId, this.txtReceiptor.SelectedUser);
  72.                 if (result == ErrorCode.SUCCESS)
  73.                 {
  74.                     successCount++;
  75.                 }
  76.             }
  77.             this.NotifyMessage("成功转移" + successCount + "项工作项,总共需要转移" + table.Rows.Count + "项工作项。从用户" + OThinker.H3.Server.Engine.Organization.GetFullName(source) + "到用户" + OThinker.H3.Server.Engine.Organization.GetFullName(receiptor));
  78.         }
  79.     }
  80. }