tp_sys.sql
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:165k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using com.etong.SqlDataConnect;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Collections;
  8. using System.Xml;
  9. namespace com.etong.DAL.FC
  10. {
  11.     /// <summary>
  12.     /// 系统维护(职工和组织机构)
  13.     /// </summary>
  14.     public class EtongFlyChou
  15.     {
  16.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  17.         public EtongFlyChou()
  18.         {
  19.             //
  20.             // TODO: 在此处添加构造函数逻辑
  21.             //
  22.         }
  23.         /// <summary>
  24.         ///读取所有组织机构的数据
  25.         /// </summary>
  26.         /// <param name="sExcelFile">excel文件路径</param>
  27.         /// <param name="strXslSheet">sheet页名称</param>
  28.         /// <param name="SQLTableName">SQL中表名</param>
  29.         /// <param name="Arr">Excel中字段和SQL中表字段的对应,由ListItem组成的ArrayList</param>
  30.         public DataView ReadOrgData()
  31.         {
  32.             DataSet ds = new DataSet();
  33.             string strSQL = "select * from Tb_Sys_Organization order by OrgLevel,ParentOrgID,OrgID";
  34.             MSDA.Open();
  35.             MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  36.             MSDA.Close();
  37.             return ds.Tables[0].DefaultView;
  38.         }
  39.         /// <summary>
  40.         /// 读取职工树数据
  41.         /// </summary>
  42.         /// <returns>dataview</returns>
  43.         public DataView ReadEmpData()
  44.         {
  45.             DataSet ds = new DataSet();
  46.             string strSQL = "select EmpID,EmpName,PrimaryOrgID,OrgLevel from Tb_Sys_Employee,Tb_Sys_Organization where OrgID=PrimaryOrgID order by PrimaryOrgID";
  47.             MSDA.Open();
  48.             MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  49.             MSDA.Close();
  50.             return ds.Tables[0].DefaultView;
  51.         }
  52.         /// <summary>
  53.         /// 读取职工与组织机构的关系
  54.         /// </summary>
  55.         /// <returns></returns>
  56.         public DataView ReadEmpOrg()
  57.         {
  58.             DataSet ds = new DataSet();
  59.             string StrSQL = "select EmpName,OrgLevel,Tb_Sys_Organization.OrgID from Tb_Sys_Employee,Tb_Sys_EmpOrg,Tb_Sys_Organization where Tb_Sys_EmpOrg.EmpID=Tb_Sys_Employee.EmpID and Tb_Sys_Organization.OrgID=Tb_Sys_EmpOrg.OrgID order by PrimaryOrgID";
  60.             MSDA.Open();
  61.             MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  62.             MSDA.Close();
  63.             return ds.Tables[0].DefaultView;
  64.         }
  65.         /// <summary>
  66.         /// 获取职工编号
  67.         /// </summary>
  68.         /// <returns>int 职工编号</returns>
  69.         public int GetMaxEmpID()
  70.         {
  71.             string MaxEmp = "0";
  72.             int iMaxEmp;
  73.             string StrSQL = "select max(EmpID) as MaxEmp from Tb_Sys_Employee";
  74.             MSDA.Open();
  75.             SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, StrSQL, null);
  76.             if (dr.Read())
  77.             {
  78.                 if (dr["MaxEmp"] != null && dr["MaxEmp"].ToString().Trim() != "")
  79.                 {
  80.                     MaxEmp = dr["MaxEmp"].ToString().Trim();
  81.                 }
  82.                 else
  83.                 {
  84.                     MaxEmp = "0";
  85.                 }
  86.             }
  87.             iMaxEmp = Convert.ToInt32(MaxEmp) + 1;
  88.             dr.Close();
  89.             MSDA.Close();
  90.             return iMaxEmp;
  91.         }
  92.         /// <summary>
  93.         /// 获取组织机构编号
  94.         /// </summary>
  95.         /// <returns> int 组织机构编号</returns>
  96.         public int GetMaxOrgzationID()
  97.         {
  98.             string SMaxID = "0";
  99.             int iMaxID;
  100.             string StrSQL = "select max(OrgID) as SMaxID from Tb_Sys_Organization";
  101.             MSDA.Open();
  102.             SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, StrSQL, null);
  103.             if (dr.Read())
  104.             {
  105.                 if (dr["SMaxID"] != null && dr["SMaxID"].ToString().Trim() != "")
  106.                 {
  107.                     SMaxID = dr["SMaxID"].ToString().Trim();
  108.                 }
  109.                 else
  110.                 {
  111.                     SMaxID = "0";
  112.                 }
  113.             }
  114.             iMaxID = Convert.ToInt32(SMaxID) + 1;
  115.             dr.Close();
  116.             MSDA.Close();
  117.             return iMaxID;
  118.         }
  119.         /// <summary>
  120.         /// 新建职工
  121.         /// </summary>
  122.         /// <param name="EmpName">职工姓名</param>
  123.         /// <param name="OrgID">所属组织机构代码</param>
  124.         /// <param name="Email">Email(电子邮件)</param>
  125.         /// <param name="PhNum">电话号码</param>
  126.         /// <param name="TmpFlag">是否是临时员工(0、雇佣;1、临时职工)</param>
  127.         /// <returns>true:保存成功!false:保存失败!</returns>
  128.         public bool AddEmpData(string EmpName, string OrgID, string Email, string PhNum, int TmpFlag,int iType,ArrayList al,int iPEmpID)
  129.         {
  130.             bool bl=false;
  131.             if (TmpFlag != 0 && TmpFlag != 1) return bl;
  132.             int iOrgID, iEmpID;
  133.             iOrgID = Convert.ToInt32(OrgID);
  134.             iEmpID = GetMaxEmpID();
  135.             DateTime EditDate = new DateTime();
  136.             EditDate = System.DateTime.Now;
  137.             string StrSQL = "insert into Tb_Sys_Employee values(" + iEmpID + ",'" + EmpName + "'," +
  138.                 iOrgID + "," + iType + ",'" + Email + "','" + PhNum + "','" + EditDate + "'," + TmpFlag + "," + iPEmpID + ")";
  139.             MSDA.Open();
  140.             SqlTransaction tran = MSDA.BeginTransaction();
  141.             try
  142.             {
  143.                 MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  144.                 for (int i = 0; i < al.Count; i++)
  145.                 {
  146.                     StrSQL = "insert into Tb_Sys_EmpOpRole values(" + iEmpID + "," + Convert.ToInt32(al[i].ToString()) + ")";
  147.                     MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  148.                 }
  149.                 tran.Commit();
  150.                 bl= true;
  151.             }
  152.             catch (Exception ex)
  153.             {
  154.                 tran.Rollback();
  155.                 throw ex;
  156.             }
  157.             finally
  158.             {
  159.                 MSDA.Close();
  160.             }
  161.             return bl;
  162.             
  163.         }
  164.         /// <summary>
  165.         /// 等到所属组织机构代码
  166.         /// </summary>
  167.         /// <param name="sEmpID">职工代码</param>
  168.         /// <returns>string 组织机构代码</returns>
  169.         public string GetEmpParentOrgID(string sEmpID)
  170.         {
  171.             string StrParentOrg = "";
  172.             int iEmpID = 0;
  173.             iEmpID = Convert.ToInt32(sEmpID);
  174.             string StrSQL;
  175.             DataSet ds = new DataSet();
  176.             MSDA.Open();
  177.             if (iEmpID > 0)
  178.             {
  179.                 StrSQL = "select PrimaryOrgID from Tb_Sys_Employee where EmpID=" + iEmpID;
  180.                 ds.Clear();
  181.                 MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  182.                 StrParentOrg = ds.Tables[0].Rows[0][0].ToString();
  183.             }
  184.             MSDA.Close();
  185.             return StrParentOrg;
  186.         }
  187.         /// <summary>
  188.         /// 得到组织机构的全路径名
  189.         /// </summary>
  190.         /// <param name="SOrgID">组织机构ID</param>
  191.         /// <returns>组织机构的全路径</returns>
  192.         public string GetAddressName(string SOrgID)
  193.         {
  194.             string StrOrgPath = "";
  195.             int OrgID = 0;
  196.             OrgID = Convert.ToInt32(SOrgID);
  197.             string StrSQL;
  198.             DataSet ds = new DataSet();
  199.             MSDA.Open();
  200.             for (; OrgID > 0; )
  201.             {
  202.                 StrSQL = "select ParentOrgID,OrgName from Tb_Sys_Organization where OrgID=" + OrgID;
  203.                 ds.Clear();
  204.                 MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  205.                 OrgID = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
  206.                 if (StrOrgPath == "")
  207.                 {
  208.                     StrOrgPath = ds.Tables[0].Rows[0][1].ToString();
  209.                 }
  210.                 else
  211.                 {
  212.                     StrOrgPath = ds.Tables[0].Rows[0][1].ToString() + "/" + StrOrgPath;
  213.                 }
  214.             }
  215.             MSDA.Close();
  216.             return StrOrgPath;
  217.         }
  218.         /// <summary>
  219.         /// 得到组织机构名称
  220.         /// </summary>
  221.         /// <param name="SOrgID">组织机构ID</param>
  222.         /// <returns>组织机构名称</returns>
  223.         public string GetOrgzationName(string SOrgID)
  224.         {
  225.             string StrOrgName;
  226.             int OrgID;
  227.             OrgID = Convert.ToInt32(SOrgID);
  228.             string StrSQL = "select OrgName from Tb_Sys_Organization where OrgID=" + OrgID;
  229.             DataSet ds = new DataSet();
  230.             MSDA.Open();
  231.             MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  232.             if (ds.Tables[0].Rows.Count > 0)
  233.                 StrOrgName = ds.Tables[0].Rows[0][0].ToString();
  234.             else
  235.                 StrOrgName = "未知";
  236.             MSDA.Close();
  237.             return StrOrgName;
  238.         }
  239.         /// <summary>
  240.         /// 同名检测
  241.         /// </summary>
  242.         /// <param name="StrEmpName">职工名称</param>
  243.         /// <returns>相同为true,不同为false</returns>
  244.         public bool HomonymyCheck(string StrEmpName)
  245.         {
  246.             string StrSQL = "select EmpID from Tb_Sys_Employee where EmpName='" + StrEmpName + "'";
  247.             DataSet ds = new DataSet();
  248.             MSDA.Open();
  249.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  250.             MSDA.Close();
  251.             if (ds.Tables[0].Rows.Count > 0)
  252.             {
  253.                 return false;
  254.             }
  255.             return true;
  256.         }
  257.         /// <summary>
  258.         /// 的到父节点树的内容
  259.         /// </summary>
  260.         /// <param name="StrOrgID">父节点id</param>
  261.         /// <returns>string</returns>
  262.         public string GetParentNode(string StrOrgID)
  263.         {
  264.             int iOrgID;
  265.             string StrSQL, StrOrgName;
  266.             DataSet ds = new DataSet();
  267.             iOrgID = Convert.ToInt32(StrOrgID);
  268.             StrSQL = "select OrgPath from Tb_Sys_Organization where OrgID=" + iOrgID;
  269.             MSDA.Open();
  270.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  271.             MSDA.Close();
  272.             StrOrgName = ds.Tables[0].Rows[0][0].ToString();
  273.             return StrOrgName;
  274.         }
  275.         /// <summary>
  276.         /// 等到父节点树的内容
  277.         /// </summary>
  278.         /// <param name="StrOrgID">父节点id</param>
  279.         /// <returns>string</returns>
  280.         public string GetParentID(string StrOrgID)
  281.         {
  282.             int iOrgID;
  283.             string StrSQL, StrOrgName;
  284.             DataSet ds = new DataSet();
  285.             iOrgID = Convert.ToInt32(StrOrgID);
  286.             StrSQL = "select ParentOrgID from Tb_Sys_Organization where OrgID=" + iOrgID;
  287.             MSDA.Open();
  288.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  289.             MSDA.Close();
  290.             StrOrgName = ds.Tables[0].Rows[0][0].ToString();
  291.             return StrOrgName;
  292.         }
  293.         /// <summary>
  294.         /// 新增组织机构
  295.         /// </summary>
  296.         /// <param name="ParentID">父ID</param>
  297.         /// <param name="OrgName">名称</param>
  298.         /// <param name="OrgDesc">描述</param>
  299.         /// <param name="Level">级别</param>
  300.         /// <param name="OrgPath">全路径</param>
  301.         /// <returns>bool</returns>
  302.         public void AddOrgzation(string ParentID, string OrgName, string OrgDesc, string Level, string OrgPath,string strCID)
  303.         {
  304.             int iParentID, iOrgID, iLevel;
  305.             string OrgType = "1";
  306.             iParentID = Convert.ToInt32(ParentID);
  307.             iOrgID = GetMaxOrgzationID();
  308.             iLevel = Convert.ToInt32(Level) + 1;
  309.             DateTime EditDate = new DateTime();
  310.             EditDate = System.DateTime.Now;
  311.             OrgPath = OrgPath + "/" + Convert.ToString(iOrgID);
  312.             //string scid = GetOrgMaxCID();
  313.             string StrSQL = "insert into Tb_Sys_Organization values(" + iOrgID + "," + iParentID + ",'" +
  314.                 OrgName + "','" + OrgDesc + "'," + 1 + "," + iLevel + ",'" + EditDate + "','" + OrgType + "','" +
  315.                 OrgPath + "','" + strCID + "')";
  316.             MSDA.Open();
  317.             SqlTransaction tran = MSDA.BeginTransaction();
  318.             try
  319.             {
  320.                 MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  321.                 tran.Commit();
  322.             }
  323.             catch (Exception ex)
  324.             {
  325.                 tran.Rollback();
  326.                 throw ex;
  327.             }
  328.             finally
  329.             {
  330.                 MSDA.Close();
  331.             }
  332.         }
  333.         /// <summary>
  334.         /// 获取职工全部内容
  335.         /// </summary>
  336.         /// <param name="SEmpID">职工ID</param>
  337.         /// <returns>DataView</returns>
  338.         public DataView GetEmp(string SEmpID)
  339.         {
  340.             int iEmpID;
  341.             iEmpID = Convert.ToInt32(SEmpID);
  342.             DataSet ds = new DataSet();
  343.             string StrSQL = "select * from Tb_Sys_Employee where EmpID=" + iEmpID;
  344.             MSDA.Open();
  345.             MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  346.             MSDA.Close();
  347.             return ds.Tables[0].DefaultView;
  348.         }
  349.         /// <summary>
  350.         /// 修改职工信息
  351.         /// </summary>
  352.         /// <param name="iEmpID">职工ID</param>
  353.         /// <param name="EmpName">职工姓名</param>
  354.         /// <param name="PNum">电话号码</param>
  355.         /// <param name="Email">电子邮件</param>
  356.         /// <param name="iCheck">身份(临时或正式)</param>
  357.         /// <param name="iType">职工类型</param>
  358.         /// <returns>bool</returns>
  359.         public bool UpEmp(int iEmpID, string EmpName, string PNum, string Email, int iCheck,int iType,ArrayList al,int iPEmpID)
  360.         {
  361.             DateTime EditDate = new DateTime();
  362.             EditDate = System.DateTime.Now;
  363.             string StrSQL = "update Tb_Sys_Employee set EmpName='" + EmpName + "',EMail='" +
  364.                 Email + "',PhoneNumber='" + PNum + "',EditDate='" + EditDate + "',TempFlag=" +
  365.                 iCheck + ",EmpType=" + iType + ",ParentEmp=" + iPEmpID + " where EmpID = " + iEmpID;
  366.             MSDA.Open();
  367.             SqlTransaction tran = MSDA.BeginTransaction();
  368.             try
  369.             {
  370.                 MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  371.                 StrSQL = "delete from Tb_Sys_EmpOpRole where EmpID=" + iEmpID;
  372.                 MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  373.                 for (int i = 0; i < al.Count; i++)
  374.                 {
  375.                     StrSQL = "insert into Tb_Sys_EmpOpRole values(" + iEmpID + "," + Convert.ToInt32(al[i].ToString()) + ")";
  376.                     MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  377.                 }
  378.                 tran.Commit();
  379.                 return true;
  380.             }
  381.             catch
  382.             {
  383.                 tran.Rollback();
  384.                 return false;
  385.             }
  386.             finally
  387.             {
  388.                 MSDA.Close();
  389.             }
  390.         }
  391.         /// <summary>
  392.         /// 通过组织机构ID获取组织机构全部信息
  393.         /// </summary>
  394.         /// <param name="sOrgID">组织机构ID</param>
  395.         /// <returns>DataView组织机构信息</returns>
  396.         public DataView GetOrganzation(string sOrgID)
  397.         {
  398.             int iOrgID;
  399.             iOrgID = Convert.ToInt32(sOrgID);
  400.             DataSet ds = new DataSet();
  401.             string StrSQL = "select * from Tb_Sys_Organization where OrgID=" + iOrgID;
  402.             MSDA.Open();
  403.             MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  404.             MSDA.Close();
  405.             return ds.Tables[0].DefaultView;
  406.         }
  407.         /// <summary>
  408.         /// 修改组织机构信息
  409.         /// </summary>
  410.         /// <param name="iOrgID">组织机构ID</param>
  411.         /// <param name="OrgName">组织机构名称</param>
  412.         /// <param name="OrgDesc">组织机构描述</param>
  413.         /// <returns>bool</returns>
  414.         public void UpOrg(int iOrgID, string OrgName, string OrgDesc, string strCID)
  415.         {
  416.             DateTime EditDate = new DateTime();
  417.             EditDate = System.DateTime.Now;
  418.             string StrSQL = "update Tb_Sys_Organization set OrgName='" + OrgName + "',OrgDesc='" +
  419.                 OrgDesc + "',OrgCID='" + strCID  + "' where OrgID = " + iOrgID;
  420.             MSDA.Open();
  421.             SqlTransaction tran = MSDA.BeginTransaction();
  422.             try
  423.             {
  424.                 MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  425.                 tran.Commit();
  426.             }
  427.             catch (Exception ex)
  428.             {
  429.                 tran.Rollback();
  430.                 throw ex;
  431.             }
  432.             finally
  433.             {
  434.                 MSDA.Close();
  435.             }
  436.         }
  437.         /// <summary>
  438.         /// 删除职工信息
  439.         /// </summary>
  440.         /// <param name="iEmpID">职工ID</param>
  441.         /// <returns>bool</returns>
  442.         public bool DelEmp(int iEmpID)
  443.         {
  444.             string StrSQL = "delete from Tb_Sys_Employee where EmpID=" + iEmpID;
  445.             MSDA.Open();
  446.             SqlTransaction tran = MSDA.BeginTransaction();
  447.             try
  448.             {
  449.                 MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  450.                 tran.Commit();
  451.                 return true;
  452.             }
  453.             catch
  454.             {
  455.                 tran.Rollback();
  456.                 return false;
  457.             }
  458.             finally
  459.             {
  460.                 MSDA.Close();
  461.             }
  462.         }
  463.         /// <summary>
  464.         /// 判断职工是否已被使用
  465.         /// </summary>
  466.         /// <param name="iEmpID">职工ID</param>
  467.         /// <returns>bool</returns>
  468.         public bool BlEmpUser(int iEmpID)
  469.         {
  470.             string StrSQL = "select * from Tb_Sys_User where EmpID=" + iEmpID;
  471.             DataSet ds = new DataSet();
  472.             MSDA.Open();
  473.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  474.             MSDA.Close();
  475.             if (ds.Tables[0].Rows.Count > 0)
  476.             {
  477.                 ds.Clear();
  478.                 return false;
  479.             }
  480.             ds.Clear();
  481.             return true;
  482.         }
  483.         /// <summary>
  484.         /// 判断是否有子组织
  485.         /// </summary>
  486.         /// <param name="iOrgParent">组织机构ID</param>
  487.         /// <returns>bool</returns>
  488.         public bool BlOrgParent(int iOrgParent)
  489.         {
  490.             string StrSQL = "select * from Tb_Sys_Organization where ParentOrgID=" + iOrgParent;
  491.             DataSet ds = new DataSet();
  492.             MSDA.Open();
  493.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  494.             MSDA.Close();
  495.             if (ds.Tables[0].Rows.Count > 0)
  496.             {
  497.                 ds.Clear();
  498.                 return false;
  499.             }
  500.             ds.Clear();
  501.             return true;
  502.         }
  503.         /// <summary>
  504.         /// 判断是否有子职工
  505.         /// </summary>
  506.         /// <param name="iEmpParent">所属组织机构代码</param>
  507.         /// <returns>bool</returns>
  508.         public bool BlEmpParent(int iEmpParent)
  509.         {
  510.             string StrSQL = "select * from Tb_Sys_Employee where PrimaryOrgID=" + iEmpParent;
  511.             DataSet ds = new DataSet();
  512.             MSDA.Open();
  513.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  514.             MSDA.Close();
  515.             if (ds.Tables[0].Rows.Count > 0)
  516.             {
  517.                 ds.Clear();
  518.                 return false;
  519.             }
  520.             ds.Clear();
  521.             return true;
  522.         }
  523.         /// <summary>
  524.         /// 删除组织机构信息
  525.         /// </summary>
  526.         /// <param name="iOrgID">组织机构ID</param>
  527.         /// <returns>bool</returns>
  528.         public bool DelOrg(int iOrgID)
  529.         {
  530.             string StrSQL = "delete from Tb_Sys_Organization where OrgID=" + iOrgID;
  531.             MSDA.Open();
  532.             SqlTransaction tran = MSDA.BeginTransaction();
  533.             try
  534.             {
  535.                 MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  536.                 tran.Commit();
  537.                 return true;
  538.             }
  539.             catch
  540.             {
  541.                 tran.Rollback();
  542.                 return false;
  543.             }
  544.             finally
  545.             {
  546.                 MSDA.Close();
  547.             }
  548.         }
  549.         /// <summary>
  550.         /// 职工转移组织机构
  551.         /// </summary>
  552.         /// <param name="iEmpID">职工ID</param>
  553.         /// <param name="iOrgID">组织机构ID</param>
  554.         /// <returns>bool</returns>
  555.         public bool UpEmpParent(int iEmpID, int iOrgID)
  556.         {
  557.             string StrSQL = "update Tb_Sys_Employee set PrimaryOrgID=" + iOrgID + " where EmpID=" + iEmpID;
  558.             MSDA.Open();
  559.             SqlTransaction tran = MSDA.BeginTransaction();
  560.             try
  561.             {
  562.                 MSDA.ExecuteNonQuery(CommandType.Text, StrSQL, null);
  563.                 tran.Commit();
  564.                 return true;
  565.             }
  566.             catch
  567.             {
  568.                 tran.Rollback();
  569.                 return false;
  570.             }
  571.             finally
  572.             {
  573.                 MSDA.Close();
  574.             }
  575.         }
  576.         /// <summary>
  577.         /// 获取角色名
  578.         /// </summary>
  579.         /// <param name="iRoleID">角色ID</param>
  580.         /// <returns>角色名</returns>
  581.         public string GetRoleName(int iRoleID)
  582.         {
  583.             string StrSQL, sRoleName;
  584.             StrSQL = "select RoleName from Tb_Sys_Role where RoleID=" + iRoleID;
  585.             MSDA.Open();
  586.             DataSet ds = new DataSet();
  587.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  588.             MSDA.Close();
  589.             if (ds.Tables[0].Rows.Count > 0)
  590.             {
  591.                 sRoleName = ds.Tables[0].Rows[0][0].ToString();
  592.             }
  593.             else
  594.             {
  595.                 sRoleName = "未知";
  596.             }
  597.             return sRoleName;
  598.         }
  599.         /// <summary>
  600.         /// 获取组织机构字符ID
  601.         /// </summary>
  602.         /// <returns>组织机构字符ID</returns>
  603.         public string GetOrgMaxCID()
  604.         {
  605.             string MaxCID;
  606.             int iMax;
  607.             string strSQL = "select max(OrgcID) as MaxCID from Tb_Sys_Organization where len(OrgcID) > 1";
  608.             MSDA.Open();
  609.             SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, strSQL, null);
  610.             
  611.             if (dr.Read())
  612.             {
  613.                 if (dr["MaxCID"] != null && dr["MaxCID"].ToString().Trim() != "")
  614.                 {
  615.                     MaxCID = dr["MaxCID"].ToString().Trim();
  616.                     if (MaxCID.Substring(1, 1) == "z")
  617.                     {
  618.                         iMax = Convert.ToInt32(MaxCID.Substring(0, 1), 16) + 1;
  619.                         MaxCID = iMax.ToString() + MaxCID.Substring(1, 1).ToString();
  620.                     }
  621.                     else
  622.                     {
  623.                         
  624.                         iMax = Convert.ToInt32(MaxCID.Substring(1, 1), 16) + 1;
  625.                         //MaxCID =Convert.ToString( iMax & 0x00ff);
  626.                         MaxCID = MaxCID.Substring(0, 1).ToString() + GetCharString(iMax);
  627.                         
  628.                     }
  629.                     dr.Close();
  630.                     MSDA.Close();
  631.                     return MaxCID;
  632.                 }
  633.                 else
  634.                 {
  635.                     dr.Close();
  636.                     strSQL = "select max(OrgcID) as MaxCID from Tb_Sys_Organization";
  637.                     dr = MSDA.ExecuteReader(CommandType.Text, strSQL, null);
  638.                     if (dr.Read())
  639.                     {
  640.                         if (dr["MaxCID"] != null && dr["MaxCID"].ToString().Trim() != "")
  641.                         {
  642.                             MaxCID = dr["MaxCID"].ToString().Trim();
  643.                             if (MaxCID == "z")
  644.                             {
  645.                                 MaxCID = "aa";
  646.                             }
  647.                             else if (MaxCID == "0")
  648.                             {
  649.                                 MaxCID = "a";
  650.                             }
  651.                             else
  652.                             {
  653.                                 iMax = Convert.ToInt32(MaxCID, 16) + 1;
  654.                                 //MaxCID =Convert.ToString( iMax & 0x00ff);
  655.                                 MaxCID = GetCharString(iMax);
  656.                             }
  657.                         }
  658.                         else
  659.                         {
  660.                             MaxCID = "a";
  661.                         }
  662.                     }
  663.                     else
  664.                     {
  665.                         MaxCID = "a";
  666.                     }//end read
  667.                     dr.Close();
  668.                     MSDA.Close();
  669.                     return MaxCID;
  670.                 }
  671.             }//end dr
  672.             dr.Close();
  673.             MSDA.Close();
  674.             return MaxCID="a";
  675.         }
  676.         /// <summary>
  677.         /// int转换字符
  678.         /// </summary>
  679.         /// <param name="i">int</param>
  680.         /// <returns>字符串</returns>
  681.         public string GetCharString(int i)
  682.         {
  683.             string s = "";
  684.             switch (i)
  685.             {
  686.                 case 10:
  687.                     s = "a";
  688.                     break;
  689.                 case 11:
  690.                     s = "b";
  691.                     break;
  692.                 case 12:
  693.                     s = "c";
  694.                     break;
  695.                 case 13:
  696.                     s = "d";
  697.                     break;
  698.                 case 14:
  699.                     s = "e";
  700.                     break;
  701.                 case 15:
  702.                     s = "f";
  703.                     break;
  704.                 case 16:
  705.                     s = "g";
  706.                     break;
  707.                 case 17:
  708.                     s = "h";
  709.                     break;
  710.                 case 18:
  711.                     s = "i";
  712.                     break;
  713.                 case 19:
  714.                     s = "j";
  715.                     break;
  716.                 case 20:
  717.                     s = "k";
  718.                     break;
  719.                 case 21:
  720.                     s = "l";
  721.                     break;
  722.                 case 22:
  723.                     s = "m";
  724.                     break;
  725.                 case 23:
  726.                     s = "n";
  727.                     break;
  728.                 case 24:
  729.                     s = "o";
  730.                     break;
  731.                 case 25:
  732.                     s = "p";
  733.                     break;
  734.                 case 26:
  735.                     s = "q";
  736.                     break;
  737.                 case 27:
  738.                     s = "r";
  739.                     break;
  740.                 case 28:
  741.                     s = "s";
  742.                     break;
  743.                 case 29:
  744.                     s = "t";
  745.                     break;
  746.                 case 30:
  747.                     s = "u";
  748.                     break;
  749.                 case 31:
  750.                     s = "v";
  751.                     break;
  752.                 case 32:
  753.                     s = "w";
  754.                     break;
  755.                 case 33:
  756.                     s = "x";
  757.                     break;
  758.                 case 34:
  759.                     s = "y";
  760.                     break;
  761.                 case 35:
  762.                     s = "z";
  763.                     break;
  764.                 default:
  765.                     s=i.ToString();
  766.                     break;
  767.             }
  768.             return s;
  769.         }
  770.         public DataView GetAllEmp()
  771.         {
  772.             string strSQL = "select * from Tb_Sys_Employee ";
  773.             DataView dv = new DataView();
  774.             try
  775.             {
  776.                 MSDA.Open();
  777.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  778.             }
  779.             catch (Exception ex)
  780.             {
  781.                 throw ex;
  782.             }
  783.             finally
  784.             {
  785.                 MSDA.Close();
  786.             }
  787.             return dv;
  788.         }
  789.         public DataView GetEmpType()
  790.         {
  791.             string strSQL = "select * from tb_Sys_Sort ";
  792.             DataView dv = new DataView();
  793.             try
  794.             {
  795.                 MSDA.Open();
  796.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  797.             }
  798.             catch (Exception ex)
  799.             {
  800.                 throw ex;
  801.             }
  802.             finally
  803.             {
  804.                 MSDA.Close();
  805.             }
  806.             return dv;
  807.         }
  808.         public int GetEmpTypeEmp(int iEmpID)
  809.         {
  810.             string strSQL = "select EmpType from Tb_Sys_Employee where EmpID=" + iEmpID;
  811.             DataView dv = new DataView();
  812.             try
  813.             {
  814.                 MSDA.Open();
  815.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  816.             }
  817.             catch (Exception ex)
  818.             {
  819.                 throw ex;
  820.             }
  821.             finally
  822.             {
  823.                 MSDA.Close();
  824.             }
  825.             return dv.Table.Rows.Count > 0 ? Convert.ToInt32(dv.Table.Rows[0][0].ToString()):-1;
  826.         }
  827.     }
  828.     /// <summary>
  829.     /// 工作流
  830.     /// </summary>
  831.     public class EtongFlyChouWF
  832.     {
  833.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  834.         private QueryParameterCollection Params = new QueryParameterCollection();
  835.         public EtongFlyChouWF()
  836.         {
  837.             //
  838.             // TODO: 在此处添加构造函数逻辑
  839.             //
  840.         }
  841.         /// <summary>
  842.         /// 获取启动工作流的内容
  843.         /// </summary>
  844.         /// <returns>工作流的名称、描述、状态和地址dataview</returns>
  845.         public DataView GetWFStartData(int iEmpID)
  846.         {
  847.             DataSet ds = new DataSet();
  848.             string StrSQL = "select distinct(WFID),KindName,WFName,WFDesc,Status,PageUrl,activityid,s.MustChooseItem,StartUpType from tb_WF_Kind k,tb_workflow w,tb_WF_Activity a,tb_WF_StaticPage s";
  849.             StrSQL = StrSQL + " where w.Status=1 and k.KindID=w.KindID and a.workflowid=w.wfid and a.StartEnd=0 and s.StaticPageID=a.PageID and w.StartUpType in (";
  850.             StrSQL = StrSQL + "select OpID from Tb_Sys_EmpOpRole where EmpID =" + iEmpID + ")";
  851.             MSDA.Open();
  852.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  853.             MSDA.Close();
  854.             return ds.Tables[0].DefaultView;
  855.         }
  856.         /// <summary>
  857.         /// 获取待办事宜和公共事宜等
  858.         /// 1、待办;2、公共;3、其他
  859.         /// </summary>
  860.         /// <param name="iUserID">用户ID</param>
  861.         /// <param name="iStatus">工作状态</param>
  862.         /// <returns>DataView工作流的事宜信息</returns>
  863.         public DataView GetWFWaitData(int UserIDflag, int iUserID, int Roleid, int iStatus0, int Status2,int iEmpType)
  864.         {
  865.             Params.Clear();
  866.             Params.Add("@Param_UserIDflag", UserIDflag);
  867.             Params.Add("@Param_UserID", iUserID);
  868.             Params.Add("@Param_RoleID", Roleid);
  869.             Params.Add("@Param_Status0", iStatus0);
  870.             Params.Add("@Param_Status2", Status2);
  871.             Params.Add("@Param_EmpType", iEmpType);
  872.             string strSQL = "P_GetWaitProject";
  873.             DataView dv = new DataView();
  874.             MSDA.Open();
  875.             dv = MSDA.ExecuteDataView(CommandType.StoredProcedure, strSQL, Params);
  876.             MSDA.Close();
  877.             return dv;
  878.         }
  879.         /// <summary>
  880.         /// 获取工作流种类
  881.         /// </summary>
  882.         /// <returns>工作流种类编号和名称</returns>
  883.         public DataView GetWFKind()
  884.         {
  885.             string strSQL = "P_GetWFKind";
  886.             DataView dv = new DataView();
  887.             MSDA.Open();
  888.             dv = MSDA.ExecuteDataView(CommandType.StoredProcedure, strSQL, null);
  889.             MSDA.Close();
  890.             return dv;
  891.         }
  892.         /// <summary>
  893.         /// 获取工作流页面
  894.         /// </summary>
  895.         /// <returns>页面编号和页面</returns>
  896.         public DataView GetWFStaticPage()
  897.         {
  898.             string strSQL = "P_GetWFStaticPage";
  899.             DataView dv = new DataView();
  900.             MSDA.Open();
  901.             dv = MSDA.ExecuteDataView(CommandType.StoredProcedure, strSQL, null);
  902.             MSDA.Close();
  903.             return dv;
  904.         }
  905.         /// <summary>
  906.         /// 获取页面名称
  907.         /// </summary>
  908.         /// <param name="iPage">页面ID</param>
  909.         /// <returns>DataView</returns>
  910.         public string GetWFStaticPageName(int iPage)
  911.         {
  912.             string strSQL, strName;
  913.             strSQL = "select PageName from tb_WF_StaticPage where StaticPageID=" + iPage ;
  914.             DataSet ds = new DataSet();
  915.             MSDA.Open();
  916.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  917.             MSDA.Close();
  918.             if (ds.Tables[0].Rows.Count > 0)
  919.             {
  920.                 strName = ds.Tables[0].Rows[0][0].ToString();
  921.             }
  922.             else
  923.             {
  924.                 strName = "未知";
  925.             }
  926.             return strName;
  927.         }
  928.         /// <summary>
  929.         /// 更新工作流定义
  930.         /// </summary>
  931.         /// <param name="iWFID">工作流ID(-1:新增)</param>
  932.         /// <param name="sWFDesc">工作流描述</param>
  933.         /// <param name="sWFName">工作流名称</param>
  934.         /// <param name="iStatus">工作流状态</param>
  935.         /// <param name="sUnit">工作流使用单位</param>
  936.         /// <param name="iKindID">工作流所属种类</param>
  937.         /// <param name="iStartRouterID">起始页(-1:新增和修改)</param>
  938.         /// <param name="sStartDesc">关联表单</param>
  939.         /// <param name="iStartUpType">工作流启动类型</param>
  940.         /// <param name="iReadIncColonyID">同类型ID</param>
  941.         /// <param name="iReadtype">是否读取同类型ID</param>
  942.         /// <returns>bool</returns>
  943.         public bool InsertUpWF(int iWFID, string sWFDesc, string sWFName, int iStatus, string sUnit, int iKindID, int iStartRouterID, string sStartDesc, int iStartUpType, int iReadIncColonyID, int iReadtype)
  944.         {
  945.             DateTime LastUpdateDate = new DateTime();
  946.             DateTime CreateDate = new DateTime();
  947.             int OwnExcColonyID = 0, OwnIncColonyID =0, ReadExcColonyID = 0;
  948.             string sStartName="开始";
  949.             int PanelY = 0,PanelX=0;
  950.             string sCodeName="01";
  951.             int iX=0,iY =0;
  952.             string strSQL = "";
  953.             LastUpdateDate = System.DateTime.Now;
  954.             if (iWFID == -1)  //insert
  955.             {
  956.                 CreateDate = System.DateTime.Now;
  957.                 strSQL = "insert into tb_WorkFlow values('" + LastUpdateDate + "','" + sWFDesc + "','" + sWFName + "'," +
  958.                     iStatus + ",'" + CreateDate + "'," + iStartUpType + ",'" + sUnit + "'," + OwnExcColonyID + "," +
  959.                     OwnIncColonyID + "," + ReadExcColonyID + "," + iReadIncColonyID + "," + iReadtype + "," + iKindID + ",'" +
  960.                     sStartDesc + "','" + sStartName + "'," + iX  + "," + iY  + "," + iStartRouterID + "," +
  961.                     PanelX + "," + PanelY + ",'" + sCodeName + "')";
  962.             }
  963.             else
  964.             {
  965.                 if (iStartRouterID != -1)
  966.                 {
  967.                     strSQL = "update tb_WorkFlow set StartRouterID=" + iStartRouterID + " where WFID=" + iWFID;
  968.                 }
  969.                 else
  970.                 {
  971.                     strSQL = "update tb_WorkFlow set LastUpdateDate='" + LastUpdateDate + "',WFDesc='" + sWFDesc
  972.                         + "',WFName='" + sWFName + "',StartUpType=" + iStartUpType + ",Unit='" + sUnit + "',KindID="
  973.                         + iKindID + ",StartDesc='" + sStartDesc + "',Status=" + iStatus + ",StartX=" + iX 
  974.                         + ",StartY=" + iY + " where WFID=" + iWFID;
  975.                 }
  976.             }
  977.             if (strSQL == "" || strSQL == null)
  978.             {
  979.                 return false;
  980.             }
  981.             MSDA.Open();
  982.             SqlTransaction tran = MSDA.BeginTransaction();
  983.             try
  984.             {
  985.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  986.                 tran.Commit();
  987.                 return true;
  988.             }
  989.             catch
  990.             {
  991.                 tran.Rollback();
  992.                 return false;
  993.             }
  994.             finally
  995.             {
  996.                 MSDA.Close();
  997.             }
  998.         }
  999.         /// <summary>
  1000.         /// 返回关联表单
  1001.         /// </summary>
  1002.         /// <param name="scode">表单类型</param>
  1003.         /// <returns>dataview</returns>
  1004.         public DataView GetWFDataTable(string scode)
  1005.         {
  1006.             if (scode != "1" && scode != "0")
  1007.             {
  1008.                 scode = "1";
  1009.             }
  1010.             Params.Clear();
  1011.             Params.Add("@Param_IsCode", scode);
  1012.             string strSQL = "P_GetDataTable";
  1013.             DataView dv = new DataView();
  1014.             MSDA.Open();
  1015.             dv = MSDA.ExecuteDataView(CommandType.StoredProcedure, strSQL, Params);
  1016.             MSDA.Close();
  1017.             return dv;
  1018.         }
  1019.         /// <summary>
  1020.         /// 获取已存在的表单信息
  1021.         /// </summary>
  1022.         /// <param name="iDtID">表单ID</param>
  1023.         /// <param name="scode">表单ID</param>
  1024.         /// <returns>DataView</returns>
  1025.         public DataView GetWFOldTable(int iDtID, string scode)
  1026.         {
  1027.             if (scode != "1" && scode != "0")
  1028.             {
  1029.                 scode = "1";
  1030.             }
  1031.             Params.Clear();
  1032.             Params.Add("@Param_IsCode", scode);
  1033.             Params.Add("@Param_DTID", iDtID);
  1034.             string strSQL = "P_GetOldTable";
  1035.             DataView dv = new DataView();
  1036.             MSDA.Open();
  1037.             dv = MSDA.ExecuteDataView(CommandType.StoredProcedure, strSQL, Params);
  1038.             MSDA.Close();
  1039.             return dv;
  1040.         }
  1041.         /// <summary>
  1042.         /// 获取已存在工作流
  1043.         /// </summary>
  1044.         /// <returns>dataview工作流要素</returns>
  1045.         public DataView GetWFNewData()
  1046.         {
  1047.             DataSet ds = new DataSet();
  1048.             string StrSQL = "select WFID,KindName,WFName,WFDesc,Status from tb_WF_Kind,tb_workflow";
  1049.             StrSQL = StrSQL + " where tb_workflow.KindID=tb_WF_Kind.KindID";
  1050.             MSDA.Open();
  1051.             ds = MSDA.ExecuteDataset(CommandType.Text, StrSQL, null, ds, "");
  1052.             MSDA.Close();
  1053.             return ds.Tables[0].DefaultView;
  1054.         }
  1055.         /// <summary>
  1056.         /// 获取指定工作流信息
  1057.         /// </summary>
  1058.         /// <param name="iWFID"></param>
  1059.         /// <returns></returns>
  1060.         public DataView GetWFOldData(int iWFID)
  1061.         {
  1062.             string strSQL;
  1063.             strSQL = "select WFID,KindName,WFName,WFDesc,Status,Unit,StartUpType,ReadIncColonyID,Readtype,StartDesc from tb_workflow,tb_WF_Kind";
  1064.             strSQL = strSQL + " where tb_workflow.KindID=tb_WF_Kind.KindID and WFID=" + iWFID;
  1065.             DataSet ds = new DataSet();
  1066.             MSDA.Open();
  1067.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1068.             MSDA.Close();
  1069.             return ds.Tables[0].DefaultView;
  1070.         }
  1071.         /// <summary>
  1072.         /// 获取工作流活动
  1073.         /// </summary>
  1074.         /// <param name="iWFID">工作流ID</param>
  1075.         /// <returns>Dataview</returns>
  1076.         public DataView GetActivityContent(int iWFID)
  1077.         {
  1078.             Params.Clear();
  1079.             Params.Add("@Param_WFID", iWFID);
  1080.             string strSQL = "P_ZFGetWFTask";
  1081.             DataView dv = new DataView();
  1082.             MSDA.Open();
  1083.             dv = MSDA.ExecuteDataView(CommandType.StoredProcedure, strSQL, Params);
  1084.             MSDA.Close();
  1085.             return dv;
  1086.         }
  1087.         /// <summary>
  1088.         /// 分页使用
  1089.         /// </summary>
  1090.         /// <param name="iWFID"></param>
  1091.         /// <param name="PageNum"></param>
  1092.         /// <param name="RowInPage"></param>
  1093.         /// <returns></returns>
  1094.         public DataView GetActivityContentPage(int iWFID, int PageNum, int RowInPage)
  1095.         {
  1096.             Params.Clear();
  1097.             Params.Add("@Param_WFID", iWFID);
  1098.             Params.Add("@page_num", PageNum);
  1099.             Params.Add("@row_in_page", RowInPage);
  1100.             string strSQL = "P_ZFGetWFTaskPage";
  1101.             DataView dv = new DataView();
  1102.             MSDA.Open();
  1103.             dv = MSDA.ExecuteDataView(CommandType.StoredProcedure, strSQL, Params);
  1104.             MSDA.Close();
  1105.             //for (int i = (PageNum - 1) * RowInPage; i > 0; i--)
  1106.             //{
  1107.             //    dv.Delete(i-1);
  1108.             //}
  1109.             return dv;
  1110.         }
  1111.         /// <summary>
  1112.         /// 获取活动名
  1113.         /// </summary>
  1114.         /// <param name="iActID">活动ID</param>
  1115.         /// <returns>活动名称</returns>
  1116.         public string GetActivityName(int iActID)
  1117.         {
  1118.             string strSQL,strName;
  1119.             strSQL = "select ActName from tb_WF_Activity where ActivityID=" + iActID;
  1120.             DataSet ds = new DataSet();
  1121.             MSDA.Open();
  1122.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1123.             MSDA.Close();
  1124.             if (ds.Tables[0].Rows.Count > 0)
  1125.             {
  1126.                 strName = ds.Tables[0].Rows[0][0].ToString();
  1127.             }
  1128.             else
  1129.             {
  1130.                 strName = "";
  1131.             }
  1132.             return strName;
  1133.         }
  1134.         /// <summary>
  1135.         /// 获取工作流任务的所有任务
  1136.         /// </summary>
  1137.         /// <param name="iWFID">工作流ID</param>
  1138.         /// <param name="iMode">协调方式</param>
  1139.         /// <returns></returns>
  1140.         public DataView GetParentAcivity(int iWFID,int iMode)
  1141.         {
  1142.             Params.Clear();
  1143.             Params.Add("@Param_WFID", iWFID);
  1144.             Params.Add("@Param_ModeFlag", iMode);
  1145.             string strSQL;
  1146.             strSQL = "P_ZFGetParentTask2";
  1147.             DataSet ds = new DataSet();
  1148.             MSDA.Open();
  1149.             ds = MSDA.ExecuteDataset(CommandType.StoredProcedure, strSQL, Params, ds, "");
  1150.             MSDA.Close();
  1151.             return ds.Tables[0].DefaultView;
  1152.         }
  1153.         /// <summary>
  1154.         /// 判断任务要素
  1155.         /// </summary>
  1156.         /// <param name="iWFID">工作流编号</param>
  1157.         /// <param name="iStrat">任务标志</param>
  1158.         /// <param name="sTableFiled">表字段</param>
  1159.         /// <returns>true:已存在;false:不存在</returns>
  1160.         public bool BlStartTask(int iWFID,int iStrat,string sTableFiled)
  1161.         {
  1162.             string strSQL = "select * from tb_WF_Activity where WorkFlowID=" +iWFID +" and " + sTableFiled + "=" + iStrat;
  1163.             DataSet ds = new DataSet();
  1164.             MSDA.Open();
  1165.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1166.             MSDA.Close();
  1167.             if (ds.Tables[0].Rows.Count > 0)
  1168.             {
  1169.                 return true;
  1170.             }
  1171.             return false;
  1172.         }
  1173.         /// <summary>
  1174.         /// 判断内容是否存在
  1175.         /// </summary>
  1176.         /// <param name="iNum">数</param>
  1177.         /// <param name="sTableFiled">字段名</param>
  1178.         /// <param name="sTable">表名</param>
  1179.         /// <returns>true:已存在;false:不存在</returns>
  1180.         public bool BlTask(int iNum, string sTableFiled,string sTable)
  1181.         {
  1182.             string strSQL;
  1183.             strSQL = "select * from " + sTable + " where " + sTableFiled + "=" + iNum;
  1184.             DataSet ds = new DataSet();
  1185.             MSDA.Open();
  1186.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1187.             MSDA.Close();
  1188.             if (ds.Tables[0].Rows.Count > 0)
  1189.             {
  1190.                 return true;
  1191.             }
  1192.             return false;
  1193.         }
  1194.         /// <summary>
  1195.         /// 新增工作流活动
  1196.         /// </summary>
  1197.         /// <param name="iActID">活动ID</param>
  1198.         /// <param name="sUnit">使用单位</param>
  1199.         /// <param name="sActName">活动名称</param>
  1200.         /// <param name="iWFID">工作流ID</param>
  1201.         /// <param name="iPage">关联页面</param>
  1202.         /// <param name="iStart">任务类型</param>
  1203.         /// <param name="iBlock">阻塞方式</param>
  1204.         /// <param name="iShunt">分流方式</param>
  1205.         /// <param name="iMode">协调方式</param>
  1206.         /// <param name="iRole">角色</param>
  1207.         /// <param name="iParent">上级活动</param>
  1208.         /// <returns></returns>
  1209.         public bool InsertWFAct(int iActID,string sUnit,string sActName,int iWFID,int iPage,int iStart,int iBlock,int iShunt,int iMode,Int64 iRole,int[] iParent,string[] sDoc)
  1210.         {
  1211.             string strSQL;
  1212.             strSQL = "insert into tb_WF_Activity values('" + sUnit + "',1,'','" + sActName + "',"
  1213.                 + iWFID + "," + iPage + ",'',''," + iStart + "," + iBlock + ","
  1214.                 + iShunt + "," + iMode + ")";
  1215.             MSDA.Open();
  1216.             SqlTransaction tran = MSDA.BeginTransaction();
  1217.             try
  1218.             {
  1219.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1220.                 tran.Commit();
  1221.             }
  1222.             catch
  1223.             {
  1224.                 tran.Rollback();
  1225.                 return false;
  1226.             }
  1227.             finally
  1228.             {
  1229.                 MSDA.Close();
  1230.             }
  1231.             strSQL = "select max(ActivityID) as maxcode from tb_WF_Activity";
  1232.             DataSet ds = new DataSet();
  1233.             MSDA.Open();
  1234.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1235.             MSDA.Close();
  1236.             int iMaxCode;
  1237.             try
  1238.             {
  1239.                 iMaxCode = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
  1240.             }
  1241.             catch
  1242.             {
  1243.                 iMaxCode = 1;
  1244.             }
  1245.             for (int i=0;i<iParent.Length;i++)
  1246.             {
  1247.                 strSQL = "insert into tb_Colony_User values(" + iMaxCode + "," + iParent[i] + "," + iRole + ")";
  1248.                 MSDA.Open();
  1249.                 SqlTransaction trans = MSDA.BeginTransaction();
  1250.                 try
  1251.                 {
  1252.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1253.                     trans.Commit();
  1254.                 }
  1255.                 catch
  1256.                 {
  1257.                     trans.Rollback();
  1258.                     strSQL = "delete from tb_WF_Activity where ActivityID=" + iMaxCode;
  1259.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1260.                     return false;
  1261.                 }
  1262.                 finally
  1263.                 {
  1264.                     MSDA.Close();
  1265.                 }
  1266.             }
  1267.             for (int j = 0; j < sDoc.Length; j++)
  1268.             {
  1269.                 if (sDoc[j].Length > 0)
  1270.                 {
  1271.                     strSQL = "insert into tb_Colony_FileName values(" + iMaxCode + ",'" + sDoc[j] + "',1,1" + ")";
  1272.                     MSDA.Open();
  1273.                     SqlTransaction trans = MSDA.BeginTransaction();
  1274.                     try
  1275.                     {
  1276.                         MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1277.                         trans.Commit();
  1278.                     }
  1279.                     catch
  1280.                     {
  1281.                         trans.Rollback();
  1282.                         strSQL = "delete from tb_WF_Activity where ActivityID=" + iMaxCode;
  1283.                         MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1284.                         return false;
  1285.                     }
  1286.                     finally
  1287.                     {
  1288.                         MSDA.Close();
  1289.                     }
  1290.                 }
  1291.             }
  1292.             return true;
  1293.         }
  1294.         public bool InsertWFAct1(int iActID, string sUnit, string sActName, int iWFID, int iPage, int iStart, int iBlock, int iShunt, int iMode, Int64 iRole, int[] iParent, string[] sDoc)
  1295.         {
  1296.             string strSQL;
  1297.             strSQL = "insert into tb_WF_Activity values('" + sUnit + "',1,'','" + sActName + "',"
  1298.                 + iWFID + "," + iPage + ",'',''," + iStart + "," + iBlock + ","
  1299.                 + iShunt + "," + iMode + ")";
  1300.             MSDA.Open();
  1301.             SqlTransaction tran = MSDA.BeginTransaction();
  1302.             try
  1303.             {
  1304.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1305.                 tran.Commit();
  1306.             }
  1307.             catch
  1308.             {
  1309.                 tran.Rollback();
  1310.                 return false;
  1311.             }
  1312.             finally
  1313.             {
  1314.                 MSDA.Close();
  1315.             }
  1316.             strSQL = "select max(ActivityID) as maxcode from tb_WF_Activity";
  1317.             DataSet ds = new DataSet();
  1318.             MSDA.Open();
  1319.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1320.             MSDA.Close();
  1321.             int iMaxCode;
  1322.             try
  1323.             {
  1324.                 iMaxCode = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
  1325.             }
  1326.             catch
  1327.             {
  1328.                 iMaxCode = 1;
  1329.             }
  1330.             for (int i = 0; i < iParent.Length; i++)
  1331.             {
  1332.                 strSQL = "insert into tb_Colony_User values(" + iMaxCode + "," + iParent[i] + "," + iRole + ")";
  1333.                 MSDA.Open();
  1334.                 SqlTransaction trans = MSDA.BeginTransaction();
  1335.                 try
  1336.                 {
  1337.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1338.                     trans.Commit();
  1339.                 }
  1340.                 catch
  1341.                 {
  1342.                     trans.Rollback();
  1343.                     strSQL = "delete from tb_WF_Activity where ActivityID=" + iMaxCode;
  1344.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1345.                     return false;
  1346.                 }
  1347.                 finally
  1348.                 {
  1349.                     MSDA.Close();
  1350.                 }
  1351.             }
  1352.             for (int j = 0; j < sDoc.Length; j++)
  1353.             {
  1354.                 if (sDoc[j].Length > 0)
  1355.                 {
  1356.                     strSQL = "insert into tb_Colony_FileName1 values(" + iMaxCode + "," + Convert.ToInt32(sDoc[j]) + ")";
  1357.                     MSDA.Open();
  1358.                     SqlTransaction trans = MSDA.BeginTransaction();
  1359.                     try
  1360.                     {
  1361.                         MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1362.                         trans.Commit();
  1363.                     }
  1364.                     catch
  1365.                     {
  1366.                         trans.Rollback();
  1367.                         strSQL = "delete from tb_WF_Activity where ActivityID=" + iMaxCode;
  1368.                         MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1369.                         return false;
  1370.                     }
  1371.                     finally
  1372.                     {
  1373.                         MSDA.Close();
  1374.                     }
  1375.                 }
  1376.             }
  1377.             return true;
  1378.         }
  1379.         /// <summary>
  1380.         /// 修改活动任务
  1381.         /// </summary>
  1382.         /// <param name="iActID">活动ID</param>
  1383.         /// <param name="sUnit">使用单位</param>
  1384.         /// <param name="sActName">活动名称</param>
  1385.         /// <param name="iWFID">工作流ID</param>
  1386.         /// <param name="iPage">关联页面</param>
  1387.         /// <param name="iStart">任务类型</param>
  1388.         /// <param name="iBlock">阻塞方式</param>
  1389.         /// <param name="iShunt">分流方式</param>
  1390.         /// <param name="iMode">协调方式</param>
  1391.         /// <param name="iRole">角色</param>
  1392.         /// <param name="iParent">上级活动</param>
  1393.         /// <param name="flag">修改标志</param>
  1394.         /// <returns></returns>
  1395.         public bool UpWFAct(int iActID, string sUnit, string sActName, int iWFID, int iPage, int iStart, int iBlock, int iShunt, int iMode, Int64 iRole, int[] iParent, int flag,string[] sDoc)
  1396.         {
  1397.             string strSQL;
  1398.             if (flag == 1)
  1399.             {
  1400.                 strSQL = "update tb_WF_Activity set Unit='" + sUnit + "',ActName='" + sActName + "',PageID="
  1401.                     + iPage + ",StartEnd=" + iStart + ",BlockFlag=" + iBlock + ",ShuntFlag="
  1402.                     + iShunt + ",ModeFlag=" + iMode + " where WorkFlowID=" + iWFID + " and ActivityID=" + iActID;
  1403.             }
  1404.             else
  1405.             {
  1406.                 strSQL = "";
  1407.             }
  1408.             MSDA.Open();
  1409.             SqlTransaction tran = MSDA.BeginTransaction();
  1410.             try
  1411.             {
  1412.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1413.                 strSQL = "update tb_Colony_User set RoleID=" + iRole + " where ActivityID=" + iActID;
  1414.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1415.                 strSQL = "delete from tb_Colony_FileName where ActivityID=" + iActID;
  1416.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1417.                 for (int j = 0; j < sDoc.Length; j++)
  1418.                 {
  1419.                     strSQL = "insert into tb_Colony_FileName values(" + iActID + ",'" + sDoc[j] + "',1,1" + ")";
  1420.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1421.                 }
  1422.                 tran.Commit();
  1423.                 return true;
  1424.             }
  1425.             catch
  1426.             {
  1427.                 tran.Rollback();
  1428.                 return false;
  1429.             }
  1430.             finally
  1431.             {
  1432.                 MSDA.Close();
  1433.             }
  1434.         }
  1435.         public bool UpWFAct1(int iActID, string sUnit, string sActName, int iWFID, int iPage, int iStart, int iBlock, int iShunt, int iMode, Int64 iRole, int[] iParent, int flag, string[] sDoc)
  1436.         {
  1437.             string strSQL;
  1438.             if (flag == 1)
  1439.             {
  1440.                 strSQL = "update tb_WF_Activity set Unit='" + sUnit + "',ActName='" + sActName + "',PageID="
  1441.                     + iPage + ",StartEnd=" + iStart + ",BlockFlag=" + iBlock + ",ShuntFlag="
  1442.                     + iShunt + ",ModeFlag=" + iMode + " where WorkFlowID=" + iWFID + " and ActivityID=" + iActID;
  1443.             }
  1444.             else
  1445.             {
  1446.                 strSQL = "";
  1447.             }
  1448.             MSDA.Open();
  1449.             SqlTransaction tran = MSDA.BeginTransaction();
  1450.             try
  1451.             {
  1452.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1453.                 strSQL = "update tb_Colony_User set RoleID=" + iRole + " where ActivityID=" + iActID;
  1454.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1455.                 strSQL = "delete from tb_Colony_FileName where ActivityID=" + iActID;
  1456.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1457.                 for (int j = 0; j < sDoc.Length; j++)
  1458.                 {
  1459.                     strSQL = "insert into tb_Colony_FileName1 values(" + iActID + "," +Convert.ToInt32(sDoc[j]) + ")";
  1460.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1461.                 }
  1462.                 tran.Commit();
  1463.                 return true;
  1464.             }
  1465.             catch
  1466.             {
  1467.                 tran.Rollback();
  1468.                 return false;
  1469.             }
  1470.             finally
  1471.             {
  1472.                 MSDA.Close();
  1473.             }
  1474.         }
  1475.         /// <summary>
  1476.         /// 获取活动模板
  1477.         /// </summary>
  1478.         /// <param name="iActID"></param>
  1479.         /// <returns></returns>
  1480.         public DataView GetActFName(int iActID)
  1481.         {
  1482.             string strSQL = "select SFileName from tb_Colony_FileName where ActivityID=" + iActID ;
  1483.             DataView dv = new DataView();
  1484.             try
  1485.             {
  1486.                 MSDA.Open();
  1487.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1488.             }
  1489.             catch (Exception ex)
  1490.             {
  1491.                 throw ex;
  1492.             }
  1493.             finally
  1494.             {
  1495.                 MSDA.Close();
  1496.             }
  1497.             return dv;
  1498.         }
  1499.         /// <summary>
  1500.         /// 获取已知活动内容
  1501.         /// </summary>
  1502.         /// <param name="iWFID">工作流ID</param>
  1503.         /// <param name="iActID">活动ID</param>
  1504.         /// <returns>Dataview</returns>
  1505.         public DataView GetActivityEdit(int iWFID, int iActID)
  1506.         {
  1507.             string strSQL;
  1508.             strSQL = "select * from tb_WF_Activity a,tb_Colony_User u where WorkFlowID=" + iWFID;
  1509.             strSQL = strSQL + " and a.ActivityID=" + iActID + " and u.ActivityID=a.ActivityID";
  1510.             DataSet ds = new DataSet();
  1511.             MSDA.Open();
  1512.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1513.             MSDA.Close();
  1514.             return ds.Tables[0].DefaultView;
  1515.         }
  1516.         /// <summary>
  1517.         /// 获取活动名
  1518.         /// </summary>
  1519.         /// <param name="iActID">活动ID</param>
  1520.         /// <returns>活动名称</returns>
  1521.         public string GetActName(int iActID)
  1522.         {
  1523.             string strSQL, strName;
  1524.             strSQL = "select ActName from tb_WF_Activity where ActivityID=" + iActID;
  1525.             DataSet ds = new DataSet();
  1526.             MSDA.Open();
  1527.             MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1528.             MSDA.Close();
  1529.             if (ds.Tables[0].Rows.Count < 1)
  1530.             {
  1531.                 strName = "起始";
  1532.             }
  1533.             else
  1534.             {
  1535.                 strName = ds.Tables[0].Rows[0][0].ToString();
  1536.             }
  1537.             return strName;
  1538.         }
  1539.         /// <summary>
  1540.         /// 删除任务活动
  1541.         /// </summary>
  1542.         /// <param name="iWFID">工作流ID</param>
  1543.         /// <param name="iActID">活动ID</param>
  1544.         /// <returns>bool</returns>
  1545.         public bool DelActivity(int iWFID, int iActID)
  1546.         {
  1547.             string strSQL, strSQL1;
  1548.             strSQL = "delete from tb_Colony_User where ActivityID =" + iActID;
  1549.             strSQL1 = "delete from tb_WF_Activity where ActivityID =" + iActID + " and WorkFlowID=" + iWFID;
  1550.             MSDA.Open();
  1551.             SqlTransaction tran = MSDA.BeginTransaction();
  1552.             try
  1553.             {
  1554.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1555.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL1, null);
  1556.                 tran.Commit();
  1557.                 return true;
  1558.             }
  1559.             catch
  1560.             {
  1561.                 tran.Rollback();
  1562.                 return false;
  1563.             }
  1564.             finally
  1565.             {
  1566.                 MSDA.Close();
  1567.             }
  1568.         }
  1569.         /// <summary>
  1570.         /// 获取工作流分流条件种类
  1571.         /// </summary>
  1572.         /// <returns>获取工作流分流条件种类编号和名称</returns>
  1573.         public DataView GetConditionWFKind()
  1574.         {
  1575.             string strSQL = "select * from tb_WorkFlowRouter";
  1576.             DataView dv = new DataView();
  1577.             try
  1578.             {
  1579.                 MSDA.Open();
  1580.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1581.             }
  1582.             catch (Exception ex)
  1583.             {
  1584.                 throw ex;
  1585.             }
  1586.             finally
  1587.             {
  1588.                 MSDA.Close();
  1589.             }
  1590.             return dv;
  1591.         }
  1592.         /// <summary>
  1593.         /// 查询工作流分流条件种类
  1594.         /// </summary>
  1595.         /// <param name="id">工作流分流条件种类ID</param>
  1596.         /// <param name="sname">工作流分流条件种类名称</param>
  1597.         /// <returns></returns>
  1598.         public DataView GetConditionWFKindBy(int id,string sname)
  1599.         {
  1600.             string strSQL = "select * from tb_WorkFlowRouter";
  1601.             if (id > -2)
  1602.             {
  1603.                 strSQL = strSQL + " where RouID=" + id;
  1604.             }
  1605.             else if (sname.Length > 0)
  1606.             {
  1607.                 strSQL = strSQL + " where RouName='" + sname + "'";
  1608.             }
  1609.             DataView dv = new DataView();
  1610.             try
  1611.             {
  1612.                 MSDA.Open();
  1613.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1614.             }
  1615.             catch (Exception ex)
  1616.             {
  1617.                 throw ex;
  1618.             }
  1619.             finally
  1620.             {
  1621.                 MSDA.Close();
  1622.             }
  1623.             return dv;
  1624.         }
  1625.         /// <summary>
  1626.         /// 更新工作流分流条件种类
  1627.         /// </summary>
  1628.         /// <param name="id">工作流分流条件种类ID</param>
  1629.         /// <param name="name">name</param>
  1630.         /// <param name="iwf">wfid</param>
  1631.         /// <returns></returns>
  1632.         public void UpConditionWFKindBy(int id,string name,int iwf)
  1633.         {
  1634.             string strSQL = "update tb_WorkFlowRouter set RouName='" + name + "',wfid=" + iwf + " where rouid=" + id ;
  1635.             try
  1636.             {
  1637.                 MSDA.Open();
  1638.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1639.             }
  1640.             catch (Exception ex)
  1641.             {
  1642.                 throw ex;
  1643.             }
  1644.             finally
  1645.             {
  1646.                 MSDA.Close();
  1647.             }
  1648.         }
  1649.         /// <summary>
  1650.         /// 根据条件获取所有工作流
  1651.         /// </summary>
  1652.         /// <returns>工作流编号和名称</returns>
  1653.         public DataView GetWFByCondition(int wfid)
  1654.         {
  1655.             string strSQL = "select * from tb_WorkFlow";
  1656.             if (wfid > -1)
  1657.             {
  1658.                 strSQL = strSQL + " where wfid<>" + wfid;
  1659.             }
  1660.             DataView dv = new DataView();
  1661.             try
  1662.             {
  1663.                 MSDA.Open();
  1664.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1665.             }
  1666.             catch (Exception ex)
  1667.             {
  1668.                 throw ex;
  1669.             }
  1670.             finally
  1671.             {
  1672.                 MSDA.Close();
  1673.             }
  1674.             return dv;
  1675.         }
  1676.     }
  1677.     /// <summary>
  1678.     /// 代码表内容
  1679.     /// </summary>
  1680.     public class EtongFlyChouCode
  1681.     {
  1682.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  1683.         private QueryParameterCollection Params = new QueryParameterCollection();
  1684.         public EtongFlyChouCode()
  1685.         {
  1686.             //
  1687.             // TODO: 在此处添加构造函数逻辑
  1688.             //
  1689.         }
  1690.         /// <summary>
  1691.         /// 获取所有种类方式
  1692.         /// </summary>
  1693.         /// <returns>DataView</returns>
  1694.         public DataView BlockCodeAll(string sTableName)
  1695.         {
  1696.             string strSQL = "select * from " + sTableName;
  1697.             DataSet ds = new DataSet();
  1698.             MSDA.Open();
  1699.             ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1700.             MSDA.Close();
  1701.             return ds.Tables[0].DefaultView;
  1702.         }
  1703.         public DataView BStringSelect(string sTField, string sTable, int i)
  1704.         {
  1705.             string strSQL = "select " + sTField + " from " + sTable;
  1706.             DataSet ds = new DataSet();
  1707.             if (i == 2)
  1708.             {
  1709.                 MSSqlDataAccess MSDA2 = new MSSqlDataAccess(i);
  1710.                 MSDA2.Open();
  1711.                 ds = MSDA2.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1712.                 MSDA2.Close();
  1713.             }
  1714.             else
  1715.             {
  1716.                 MSDA.Open();
  1717.                 ds = MSDA.ExecuteDataset(CommandType.Text, strSQL, null, ds, "");
  1718.                 MSDA.Close();
  1719.             }
  1720.             return ds.Tables[0].DefaultView;
  1721.         }
  1722.         public string GetShuntByID(int iShunt)
  1723.         {
  1724.             string sret = "";
  1725.             DataView dv = new DataView();
  1726.             try
  1727.             {
  1728.                 MSDA.Open();
  1729.                 string sSQL = "select ShuntName from tb_Shunt where ShuntID=" + iShunt;
  1730.                 dv = MSDA.ExecuteDataView(CommandType.Text, sSQL, null);
  1731.                 sret = dv.Table.Rows.Count > 0 ? dv.Table.Rows[0][0].ToString() : "未知";
  1732.             }
  1733.             catch (Exception ex)
  1734.             {
  1735.                 throw ex;
  1736.             }
  1737.             finally
  1738.             {
  1739.                 MSDA.Close();
  1740.             }
  1741.             return sret;
  1742.         }
  1743.         public string GetSortByID(string iSort)
  1744.         {
  1745.             string sret = "";
  1746.             DataView dv = new DataView();
  1747.             try
  1748.             {
  1749.                 MSDA.Open();
  1750.                 string sSQL = "select name from tb_Sys_Sort where id=" + iSort;
  1751.                 dv = MSDA.ExecuteDataView(CommandType.Text, sSQL, null);
  1752.                 sret = dv.Table.Rows.Count > 0 ? dv.Table.Rows[0][0].ToString() : "未知";
  1753.             }
  1754.             catch (Exception ex)
  1755.             {
  1756.                 throw ex;
  1757.             }
  1758.             finally
  1759.             {
  1760.                 MSDA.Close();
  1761.             }
  1762.             return sret;
  1763.         }
  1764.     }
  1765.     /// <summary>
  1766.     /// 工作流流程分析
  1767.     /// </summary>
  1768.     public class EtongFlyChouWFTask
  1769.     {
  1770.         private int m_tID;          //ActivityID
  1771.         private int m_pID;          //ParentActID
  1772.         private string m_tName;     //ActName
  1773.         private int m_wID;          //WFID
  1774.         private int m_type;         //startend
  1775.         private string m_tUnit;     //Unit
  1776.         //任务代码
  1777.         public int TaskID
  1778.         {
  1779.             set { m_tID = value; }
  1780.             get { return m_tID; }
  1781.         }
  1782.         //流程代码
  1783.         public int ProcessID
  1784.         {
  1785.             set { m_pID = value; }
  1786.             get { return m_pID; }
  1787.         }
  1788.         //任务类型 0:起始任务;1:后续任务;2:最终任务
  1789.         public int TaskType
  1790.         {
  1791.             set { m_type = value; }
  1792.             get { return m_type; }
  1793.         }
  1794.         //任务名称
  1795.         public string TaskName
  1796.         {
  1797.             set { m_tName = value; }
  1798.             get { return m_tName; }
  1799.         }
  1800.         //使用单位
  1801.         public string TaskUnit
  1802.         {
  1803.             set { m_tUnit = value; }
  1804.             get { return m_tUnit; }
  1805.         }
  1806.         //所属工作流ID
  1807.         public int TaskWFID
  1808.         {
  1809.             set { m_wID = value; }
  1810.             get { return m_wID; }
  1811.         }
  1812.         //以下方法用于绘制流程图所用
  1813.         //得到起始任务
  1814.         public static EtongFlyChouWFTask GetInitTask(int iWFID)
  1815.         {
  1816.             string strSQL;
  1817.             EtongFlyChouWFTask tsk = new EtongFlyChouWFTask();
  1818.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  1819.             strSQL = "select * from tb_WF_Activity where StartEnd=0 and WorkFlowID=" + iWFID;
  1820.             try
  1821.             {
  1822.                 MSDA.Open();
  1823.                 SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, strSQL, null);
  1824.                 if (dr.Read() == true)
  1825.                 {
  1826.                     tsk.m_tID = Convert.ToInt32(dr["ActivityID"]);
  1827.                     tsk.m_wID = Convert.ToInt32(dr["WorkFlowID"]);
  1828.                     tsk.m_pID = -1;
  1829.                     tsk.m_tName = Convert.ToString(dr["ActName"]);
  1830.                     tsk.m_tUnit = Convert.ToString(dr["Unit"]);
  1831.                     tsk.m_type = Convert.ToInt32(dr["StartEnd"]);
  1832.                 }
  1833.                 dr.Close();
  1834.             }
  1835.             finally
  1836.             {
  1837.                 MSDA.Close();
  1838.             }
  1839.             return tsk;
  1840.         }
  1841.         //得到下一步任务
  1842.         public ArrayList GetNextTask()
  1843.         {
  1844.             ArrayList al = new ArrayList();
  1845.             string strSQL;
  1846.             EtongFlyChouWFTask tsk;
  1847.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  1848.             strSQL = "select a.*,ParentActID from tb_WF_Activity a,tb_Colony_User u where a.ActivityID=u.ActivityID"
  1849.                 + " and u.ParentActID=" + this.m_tID + " and a.WorkFlowID=" + this.m_wID;
  1850.             try
  1851.             {
  1852.                 MSDA.Open();
  1853.                 SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, strSQL, null);
  1854.                 while (dr.Read() == true)
  1855.                 {
  1856.                     tsk = new EtongFlyChouWFTask();
  1857.                     tsk.m_tID = Convert.ToInt32(dr["ActivityID"]);
  1858.                     tsk.m_wID = Convert.ToInt32(dr["WorkFlowID"]);
  1859.                     tsk.m_pID = Convert.ToInt32(dr["ParentActID"]);
  1860.                     tsk.m_tName = Convert.ToString(dr["ActName"]);
  1861.                     tsk.m_tUnit = Convert.ToString(dr["Unit"]);
  1862.                     tsk.m_type = Convert.ToInt32(dr["StartEnd"]);
  1863.                     al.Add(tsk);
  1864.                 }
  1865.                 dr.Close();
  1866.                 ////由于SqlDataReader独占Connection
  1867.                 //for (i=0;i<al.Count;i++)
  1868.                 //{
  1869.                 //    tsk = al[i] as EtongFlyChouWFTask;
  1870.                 //}
  1871.             }
  1872.             finally
  1873.             {
  1874.                 MSDA.Close();
  1875.             }
  1876.             return al;
  1877.         }
  1878.         //得到上一步任务
  1879.         public ArrayList GetPrevioueTasks()
  1880.         {
  1881.             ArrayList al = new ArrayList();
  1882.             string strSQL;
  1883.             EtongFlyChouWFTask tsk;
  1884.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  1885.             strSQL = "select a.* from tb_WF_Activity a,tb_Colony_User u where u.ActivityID = " + this.m_tID + " and a.ActivityID = u.ActivityID";
  1886.             try
  1887.             {
  1888.                 MSDA.Open();
  1889.                 SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, strSQL, null);
  1890.                 while (dr.Read() == true)
  1891.                 {
  1892.                     tsk = new EtongFlyChouWFTask();
  1893.                     tsk.m_tID = Convert.ToInt32(dr["ActivityID"]);
  1894.                     tsk.m_wID = Convert.ToInt32(dr["WorkFlowID"]);
  1895.                     tsk.m_tName = Convert.ToString(dr["ActName"]);
  1896.                     tsk.m_tUnit = Convert.ToString(dr["Unit"]);
  1897.                     tsk.m_type = Convert.ToInt32(dr["StartEnd"]);
  1898.                     al.Add(tsk);
  1899.                 }
  1900.                 dr.Close();
  1901.             }
  1902.             finally
  1903.             {
  1904.                 MSDA.Close();
  1905.             }
  1906.             return al;
  1907.         }
  1908.     }
  1909.     /// <summary>
  1910.     /// 项目查询
  1911.     /// </summary>
  1912.     public class EtongFlyChouWFPrj
  1913.     {
  1914.         //说明-----全部的值为-1  tb_Project
  1915.         private int m_pID;                      //ProjectID
  1916.         private string m_pName;                //ProjectName
  1917.         private string m_pLsh;                  //ProjcetLsh
  1918.         private string m_pNum;                  //ProjectNumber
  1919.         private DateTime m_pDate;               //CreateDate
  1920.         private string m_pEditUint;             //EditUnit
  1921.         private string m_pManager;              //ProjectManager
  1922.         private string m_pTran;                 //Transactor
  1923.         private int m_pType;                    //ProjectType
  1924.         private int m_pStatus;                  //Status
  1925.         private decimal m_pPlan;                //PlanCharge
  1926.         private decimal m_pFact;                //FactCharge
  1927.         private DateTime m_pSucc;               //SuccessedDate
  1928.         //日志tb_Project_Log
  1929.         private int m_lID;                      //LogID
  1930.         private string m_lWriter;               //Writer
  1931.         private DateTime m_lDate;               //WriteDate
  1932.         private string m_lInfo;                 //WriteInfo
  1933.         //实例tb_WF_Instance
  1934.         private int m_iID;                      //WfInstanceID
  1935.         private DateTime m_iDate;               //CreateDate
  1936.         private int m_iUser;                    //CreateUserID
  1937.         private int m_iRole;                    //TargetRoleID
  1938.         private int m_iStatus;                  //status(1、项目申请2、项目施工3、验收4、变更5、废旧物资6、汇总)
  1939.         //实例活动tb_WF_ActIns
  1940.         private int m_sID;                      //ActInsID
  1941.         private int m_sUser;                    //UserID
  1942.         private int m_sStatus;                  //Status
  1943.         private string m_sBlockReason;          //BlockReason
  1944.         //工作流tb_WorkFlow
  1945.         private int m_wID;                      //WFID
  1946.         private string m_wName;                 //WFName
  1947.         //权限
  1948.         private int m_DeptID;                   //
  1949.         private int m_EmpID;                    //
  1950.         //业务角色
  1951.         private string m_Must;
  1952.         private int m_EmpType;
  1953.         private string m_cDID;
  1954.         private Int16 m_Psort;
  1955.         private int m_Ndept;
  1956.         private string m_OpName;
  1957.         private int m_OpID;
  1958.         private ArrayList m_OpPerm;
  1959.         private string m_OpDesc;
  1960.         //活动表tb_wf_activity
  1961.         private int m_aID;
  1962.         private int m_aStart;
  1963.         //项目代码
  1964.         public int PrjID
  1965.         {
  1966.             set { m_pID = value; }
  1967.             get { return m_pID; }
  1968.         }
  1969.         //项目名称
  1970.         public string PrjName
  1971.         {
  1972.             set { m_pName = value; }
  1973.             get { return m_pName; }
  1974.         }
  1975.         //项目流水号
  1976.         public string PrjLsh
  1977.         {
  1978.             set { m_pLsh = value; }
  1979.             get { return m_pLsh; }
  1980.         }
  1981.         //项目编号
  1982.         public string PrjNum
  1983.         {
  1984.             set { m_pNum = value; }
  1985.             get { return m_pNum; }
  1986.         }
  1987.         //任务创建日期
  1988.         public DateTime PrjCDate
  1989.         {
  1990.             set { m_pDate = value; }
  1991.             get { return m_pDate; }
  1992.         }
  1993.         //项目编报单位
  1994.         public string PrjUnit
  1995.         {
  1996.             set { m_pEditUint = value; }
  1997.             get { return m_pEditUint; }
  1998.         }
  1999.         //项目负责人
  2000.         public string PrjManager
  2001.         {
  2002.             set { m_pManager = value; }
  2003.             get { return m_pManager; }
  2004.         }
  2005.         //项目经办人
  2006.         public string PrjTran
  2007.         {
  2008.             set { m_pTran = value; }
  2009.             get { return m_pTran; }
  2010.         }
  2011.         //项目所属类型
  2012.         public int PrjType
  2013.         {
  2014.             set { m_pType = value; }
  2015.             get { return m_pType; }
  2016.         }
  2017.         //项目状态
  2018.         public int PrjStatus
  2019.         {
  2020.             set { m_pStatus = value; }
  2021.             get { return m_pStatus; }
  2022.         }
  2023.         //项目计划费用
  2024.         public decimal PrjPlan
  2025.         {
  2026.             set { m_pPlan = value; }
  2027.             get { return m_pPlan; }
  2028.         }
  2029.         //项目实际费用
  2030.         public decimal PrjFact
  2031.         {
  2032.             set { m_pFact = value; }
  2033.             get { return m_pFact; }
  2034.         }
  2035.         //项目实际完成时间
  2036.         public DateTime PrjSucc
  2037.         {
  2038.             set { m_pSucc = value; }
  2039.             get { return m_pSucc; }
  2040.         }
  2041.         //日志代码
  2042.         public int LogID
  2043.         {
  2044.             set { m_lID = value; }
  2045.             get { return m_lID; }
  2046.         }
  2047.         //日志填写人
  2048.         public string LogWriter
  2049.         {
  2050.             set { m_lWriter = value; }
  2051.             get { return m_lWriter; }
  2052.         }
  2053.         //日志填写日期
  2054.         public DateTime LogDate
  2055.         {
  2056.             set { m_lDate = value; }
  2057.             get { return m_lDate; }
  2058.         }
  2059.         //日志信息
  2060.         public string LogInfo
  2061.         {
  2062.             set { m_lInfo = value; }
  2063.             get { return m_lInfo; }
  2064.         }
  2065.         //实例tb_WF_Instance
  2066.         public int iID
  2067.         {
  2068.             set { m_iID = value; }
  2069.             get { return m_iID; }
  2070.         }
  2071.         public DateTime iDate
  2072.         {
  2073.             set { m_iDate = value; }
  2074.             get { return m_iDate; }
  2075.         }
  2076.         public int iUser
  2077.         {
  2078.             set { m_iUser = value; }
  2079.             get { return m_iUser; }
  2080.         }
  2081.         public int iRole
  2082.         {
  2083.             set { m_iRole = value; }
  2084.             get { return m_iRole; }
  2085.         }
  2086.         public int iStatus
  2087.         {
  2088.             set { m_iStatus = value; }
  2089.             get { return m_iStatus; }
  2090.         }
  2091.         //实例活动tb_WF_ActIns
  2092.         public int sID
  2093.         {
  2094.             set { m_sID = value; }
  2095.             get { return m_sID; }
  2096.         }
  2097.         public int sUser
  2098.         {
  2099.             set { m_sUser = value; }
  2100.             get { return m_sUser; }
  2101.         }
  2102.         public int sStatus
  2103.         {
  2104.             set { m_sStatus = value; }
  2105.             get { return m_sStatus; }
  2106.         }
  2107.         public string sBlockReason
  2108.         {
  2109.             set { m_sBlockReason =value;}
  2110.             get {return m_sBlockReason;}
  2111.         }
  2112.         //工作流tb_WorkFlow
  2113.         public int wID
  2114.         {
  2115.             set { m_wID = value; }
  2116.             get { return m_wID; }
  2117.         }
  2118.         public string wName
  2119.         {
  2120.             set { m_wName = value; }
  2121.             get { return m_wName; }
  2122.         }
  2123.         //权限
  2124.         public int DeptID
  2125.         {
  2126.             set {m_DeptID =value;}
  2127.             get {return m_DeptID;}
  2128.         }
  2129.         public int EmpID
  2130.         {
  2131.             set {m_EmpID =value;}
  2132.             get {return m_EmpID;}
  2133.         }
  2134.         public string Must
  2135.         {
  2136.             set { m_Must = value; }
  2137.             get { return m_Must; }
  2138.         }
  2139.         public int EmpType
  2140.         {
  2141.             set {m_EmpType=value;}
  2142.             get {return m_EmpType;}
  2143.         }
  2144.         public string CdID
  2145.         {
  2146.             set { m_cDID = value; }
  2147.             get { return m_cDID; }
  2148.         }
  2149.         public Int16 Psort
  2150.         {
  2151.             set { m_Psort = value; }
  2152.             get { return m_Psort; }
  2153.         }
  2154.         public int Ndept
  2155.         {
  2156.             set { m_Ndept = value; }
  2157.             get { return m_Ndept; }
  2158.         }
  2159.         public string OpName
  2160.         {
  2161.             set { m_OpName = value; }
  2162.             get { return m_OpName; }
  2163.         }
  2164.         public int OpID
  2165.         {
  2166.             set { m_OpID = value; }
  2167.             get { return m_OpID; }
  2168.         }
  2169.         public ArrayList OpPerm
  2170.         {
  2171.             set { m_OpPerm = value; }
  2172.             get { return m_OpPerm; }
  2173.         }
  2174.         public string OpDesc
  2175.         {
  2176.             set { m_OpDesc = value; }
  2177.             get { return m_OpDesc; }
  2178.         }
  2179.         //活动表tb_wf_activity
  2180.         public int aID
  2181.         {
  2182.             set { m_aID = value; }
  2183.             get { return m_aID; }
  2184.         }
  2185.         public int aStart
  2186.         {
  2187.             set { m_aStart = value; }
  2188.             get { return m_aStart; }
  2189.         }
  2190.         //创建新项目
  2191.         public EtongFlyChouWFPrj CreateNewPrj()
  2192.         {
  2193.             return new EtongFlyChouWFPrj();
  2194.         }
  2195.         //项目查询根据状态和类型
  2196.         public DataView PrjQuery()
  2197.         {
  2198.             DataView dv = new DataView();
  2199.             string strSQL;
  2200.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  2201.             if (this.m_pType < -1 || this.m_pType == 0)
  2202.             {
  2203.                 this.m_pType = -212;              //没有数据
  2204.             }
  2205.             if (this.m_pStatus < -1)
  2206.             {
  2207.                 this.m_pStatus = -212;            //没有数据
  2208.             }
  2209.             strSQL = "select * from tb_Project";
  2210.             if (this.m_pType != -1)
  2211.                 strSQL = strSQL + " where ProjectType=" + this.m_pType;
  2212.             if (this.m_pStatus != -1)
  2213.             {
  2214.                 if (this.m_pType != -1)
  2215.                     strSQL = strSQL + " and Status=" + this.m_pStatus;
  2216.                 else
  2217.                     strSQL = strSQL + " where Status=" + this.m_pStatus;
  2218.             }
  2219.             try
  2220.             {
  2221.                 MSDA.Open();
  2222.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  2223.             }
  2224.             catch (Exception ex)
  2225.             {
  2226.                 throw ex;
  2227.             }
  2228.             finally
  2229.             {
  2230.                 MSDA.Close();
  2231.             }
  2232.             return dv;
  2233.         }
  2234.         //项目查询依据项目代码
  2235.         public DataView PrjQureyData()
  2236.         {
  2237.             DataView dv = new DataView();
  2238.             string strSQL;
  2239.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  2240.             strSQL = "select * from tb_Project where ProjectID=" + this.m_pID;
  2241.             try
  2242.             {
  2243.                 MSDA.Open();
  2244.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  2245.             }
  2246.             catch (Exception ex)
  2247.             {
  2248.                 throw ex;
  2249.             }
  2250.             finally
  2251.             {
  2252.                 MSDA.Close();
  2253.             }
  2254.             return dv;
  2255.         }
  2256.         //项目日志                               
  2257.         public DataView LogQuery()
  2258.         {
  2259.             string strSQL;
  2260.             DataView dv = new DataView();
  2261.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  2262.             strSQL = "select * from tb_Project_Log where ProjectID=" + this.m_pID;
  2263.             try
  2264.             {
  2265.                 MSDA.Open();
  2266.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  2267.             }
  2268.             catch (Exception ex)
  2269.             {
  2270.                 throw ex;
  2271.             }
  2272.             finally
  2273.             {
  2274.                 MSDA.Close();
  2275.             }
  2276.             return dv;
  2277.         }
  2278.         //项目日志新建
  2279.         public void LogInsert()
  2280.         {
  2281.             string strSQL;
  2282.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  2283.             strSQL = "insert into tb_Project_Log values('" + this.m_lWriter + "','" + this.m_lDate + "','"
  2284.                 + this.m_lInfo + "'," + this.m_pID;
  2285.             MSDA.Open();
  2286.             SqlTransaction tran = MSDA.BeginTransaction();
  2287.             try
  2288.             {
  2289.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  2290.                 tran.Commit();
  2291.             }
  2292.             catch (Exception ex)
  2293.             {
  2294.                 tran.Rollback();
  2295.                 throw ex;
  2296.             }
  2297.             finally
  2298.             {
  2299.                 MSDA.Close();
  2300.             }
  2301.         }
  2302.         //已办工作查询
  2303.         public DataView PrjQureyAlreadyDo()
  2304.         {
  2305.             string strSQL;
  2306.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  2307.             QueryParameterCollection Params = new QueryParameterCollection();
  2308.             DataView dv = new DataView();
  2309.             strSQL = "P_ZFGetAlreadyDo";
  2310.             Params.Clear();
  2311.             Params.Add("@Param_User", this.m_sUser);
  2312.             try
  2313.             {
  2314.                 MSDA.Open();
  2315.                 dv = MSDA.ExecuteDataView(CommandType.StoredProcedure, strSQL, Params);
  2316.             }
  2317.             catch (Exception ex)
  2318.             {
  2319.                 throw ex;
  2320.             }
  2321.             finally
  2322.             {
  2323.                 MSDA.Close();
  2324.             }
  2325.             return dv;
  2326.         }
  2327.         //工作流权限
  2328.         public DataView PrjGetPermission()
  2329.         {
  2330.             int err =-1;
  2331.             string strSQL = "select OpID from Tb_Sys_EmpOpRole where EmpID=" + this.m_EmpID;
  2332.             DataView dv = new DataView();
  2333.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  2334.             try 
  2335.             {
  2336.                 MSDA.Open();
  2337.                 dv = MSDA.ExecuteDataView(CommandType.Text,strSQL,null);
  2338.             }
  2339.             catch (Exception ex)
  2340.             {
  2341.                 err =1;
  2342.                 throw ex;
  2343.             }
  2344.             finally 
  2345.             {
  2346.                 MSDA.Close();
  2347.             }
  2348.             if (err ==1) return null;
  2349.             ArrayList al = new ArrayList();
  2350.             for (int i = 0; i < dv.Table.Rows.Count; i++)
  2351.             {
  2352.                 DataView dv2 = new DataView();
  2353.                 try
  2354.                 {
  2355.                     strSQL = "select PermID from tb_Op_Role where OpID=" + Convert.ToInt32(dv.Table.Rows[i]["OpID"]);
  2356.                     MSDA.Open();
  2357.                     dv2 = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  2358.                     for (int j = 0; j < dv2.Table.Rows.Count; j++)
  2359.                     {
  2360.                         int s=0;
  2361.                         for (int k = 0; k < al.Count; k++)
  2362.                         {
  2363.                             if (dv2.Table.Rows[j]["PermID"].ToString().Trim() == al[k].ToString()) s = 1;
  2364.                         }
  2365.                         if (s == 0) al.Add(dv2.Table.Rows[j]["PermID"].ToString());
  2366.                     }
  2367.                 }
  2368.                 catch (Exception ex)
  2369.                 {
  2370.                     err = 1;
  2371.                     throw ex;
  2372.                 }
  2373.                 finally
  2374.                 {
  2375.                     MSDA.Close();
  2376.                 }
  2377.                 if (err==1)return null;
  2378.             }
  2379.             DataView dv1 = new DataView();
  2380.             if (al.Count > 0)