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

.net编程

开发平台:

C#

  1.             {
  2.                 try
  3.                 {
  4.                     MSDA.Open();
  5.                     string stral = "";
  6.                     for (int x = 0; x < al.Count; x++)
  7.                     {
  8.                         if (x == 0) stral = stral + al[x].ToString();
  9.                         else stral = stral + "," + al[x].ToString();
  10.                     }
  11.                     strSQL = "select PermID,DefaultPage,DisplayName from Tb_Sys_Permission where PermID in (" + stral + ")";
  12.                     dv1 = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  13.                     //for (int x = 0; x < al.Count; x++)
  14.                     //{
  15.                     //    strSQL = "select DefaultPage,DisplayName from Tb_Sys_Permission where PermID=" + Convert.ToInt32(al[x]);
  16.                     //    if (x == 0) dv1 = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  17.                     //    else
  18.                     //    {
  19.                     //        DataSet ds = new DataSet();
  20.                     //        dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  21.                     //        DataRow rows;
  22.                     //        rows = dv1.Table.NewRow();
  23.                     //        rows.ItemArray = dv.Table.Rows[0].ItemArray;
  24.                     //        dv1.Table.Rows.Add(rows);
  25.                     //        //dv1.Table.Rows[dv1.Table.Rows.Count -1]["DefaultPage"]
  26.                     //    }
  27.                     //}
  28.                 }
  29.                 catch (Exception ex)
  30.                 {
  31.                     throw ex;
  32.                 }
  33.                 finally
  34.                 {
  35.                     MSDA.Close();
  36.                 }
  37.             }
  38.             return dv1;
  39.         }
  40.         //工作流下一级的业务角色
  41.         public void PrjGetOpRole()
  42.         {
  43.             int err = -1;
  44.             if (this.m_Must != "0")
  45.             {
  46.                 try
  47.                 {
  48.                     this.PrjGetEmpType();
  49.                 }
  50.                 catch (Exception ex)
  51.                 {
  52.                     err = 1;
  53.                     throw ex;
  54.                 }
  55.                 if (err == 1) return;
  56.             }
  57.             try
  58.             {
  59.                 this.PrjGetOrgCID();
  60.             }
  61.             catch (Exception ex)
  62.             {
  63.                 err = 1;
  64.                 throw ex;
  65.             }
  66.             if (err == 1) return;
  67.             string strSQL = "select NDeptID from tb_Task_Role where MustChooseItem='" + this.m_Must +
  68.                 "' and ODeptID=" + this.m_DeptID + " and EmpType=" + this.m_EmpType + " and CID='" +
  69.                 this.m_cDID + "' and Prj=" + this.m_Psort;
  70.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  71.             DataView dv = new DataView();
  72.             try
  73.             {
  74.                 MSDA.Open();
  75.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  76.             }
  77.             catch (Exception ex)
  78.             {
  79.                 err = 1;
  80.                 throw ex;
  81.             }
  82.             finally
  83.             {
  84.                 MSDA.Close();
  85.             }
  86.             if (err == 1) return;
  87.             if (dv.Table.Rows.Count != 1) { this.Ndept = -1; return; }  //未找到
  88.             this.Ndept = Convert.ToInt32(dv.Table.Rows[0]["NDeptID"]);
  89.             
  90.         }
  91.         public void PrjGetEmpType()
  92.         {
  93.             int err=-1;
  94.             //int iEmpType;
  95.             string strSQL= "select EmpType from Tb_Sys_Employee where EmpID=" + this.m_EmpID;
  96.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  97.             DataView dv = new DataView();
  98.             try
  99.             {
  100.                 MSDA.Open();
  101.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  102.             }
  103.             catch (Exception ex)
  104.             {
  105.                 err = 1;
  106.                 throw ex;
  107.             }
  108.             finally
  109.             {
  110.                 MSDA.Close();
  111.             }
  112.             if (err == 1) return;        
  113.             if (dv.Table.Rows.Count != 1) return;
  114.             //iEmpType = Convert.ToInt32(dv.Table.Rows[0]["EmpType"]);
  115.             this.EmpType = Convert.ToInt32(dv.Table.Rows[0]["EmpType"]);
  116.         }
  117.         public void PrjGetOrgCID()
  118.         {
  119.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  120.             DataView dv = new DataView();
  121.             int err = -1;
  122.             string strSQL = "select OrgLevel,OrgcID,ParentOrgID from Tb_Sys_Organization where OrgID=" + this.m_DeptID;
  123.             try
  124.             {
  125.                 MSDA.Open();
  126.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  127.             }
  128.             catch (Exception ex)
  129.             {
  130.                 err = 1;
  131.                 throw ex;
  132.             }
  133.             finally
  134.             {
  135.                 MSDA.Close();
  136.             }
  137.             if (err == 1) return;
  138.             if (dv.Table.Rows.Count != 1) return;
  139.             int iLevel, iPID;
  140.             string sCID;
  141.             iLevel = Convert.ToInt32(dv.Table.Rows[0]["OrgLevel"]);
  142.             if (iLevel <= 2) sCID = dv.Table.Rows[0]["OrgcID"].ToString();
  143.             else
  144.             {
  145.                 iPID = Convert.ToInt32(dv.Table.Rows[0]["ParentOrgID"]);
  146.                 strSQL = "select OrgcID from Tb_Sys_Organization where OrgID=" + iPID;
  147.                 try
  148.                 {
  149.                     MSDA.Open();
  150.                     dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  151.                 }
  152.                 catch (Exception ex)
  153.                 {
  154.                     err = 1;
  155.                     throw ex;
  156.                 }
  157.                 finally
  158.                 {
  159.                     MSDA.Close();
  160.                 }
  161.                 if (err == 1) return;
  162.                 if (dv.Table.Rows.Count != 1) return;
  163.                 sCID = dv.Table.Rows[0]["OrgcID"].ToString();
  164.             }
  165.             this.CdID = sCID;
  166.         }
  167.         public void PrjUpdateActStatus()
  168.         {
  169.             string strSQL = "update tb_wf_actins set status=0 where ActinsID=" + this.m_sID ;
  170.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  171.             MSDA.Open();
  172.             SqlTransaction tran = MSDA.BeginTransaction();
  173.             try
  174.             {
  175.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  176.                 tran.Commit();
  177.             }
  178.             catch (Exception ex)
  179.             {
  180.                 tran.Rollback();
  181.                 throw ex;
  182.             }
  183.             finally
  184.             {
  185.                 MSDA.Close();
  186.             }
  187.         }
  188.         //获取所有的业务角色
  189.         public DataView GetAllOpRole()
  190.         {
  191.             DataView dv = new DataView();
  192.             string strSQL = "select * from Tb_Sys_OpRole";
  193.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  194.             try
  195.             {
  196.                 MSDA.Open();
  197.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  198.             }
  199.             catch (Exception ex)
  200.             {
  201.                 throw ex;
  202.             }
  203.             finally
  204.             {
  205.                 MSDA.Close();
  206.             }
  207.             return dv;
  208.         }
  209.         //获取指定职工的业务角色
  210.         public DataView GetAssignOpRole()
  211.         {
  212.             string strSQL = "select * from Tb_Sys_EmpOpRole where EmpID=" + this.m_EmpID;
  213.             DataView dv = new DataView();
  214.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  215.             try
  216.             {
  217.                 MSDA.Open();
  218.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  219.             }
  220.             catch (Exception ex)
  221.             {
  222.                 throw ex;
  223.             }
  224.             finally
  225.             {
  226.                 MSDA.Close();
  227.             }
  228.             return dv;
  229.         }
  230.         //获取指定工作流的业务角色
  231.         public DataView GetWFAssignOpRole()
  232.         {
  233.             string strSQL = "select * from Tb_WF_OpRole where WFID=" + this.m_wID ;
  234.             DataView dv = new DataView();
  235.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  236.             try
  237.             {
  238.                 MSDA.Open();
  239.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  240.             }
  241.             catch (Exception ex)
  242.             {
  243.                 throw ex;
  244.             }
  245.             finally
  246.             {
  247.                 MSDA.Close();
  248.             }
  249.             return dv;
  250.         }
  251.         //获取指定业务角色的名称
  252.         public void GetOpName()
  253.         {
  254.             string strSQL = "select OpName from Tb_Sys_OpRole where OpID=" + this.m_OpID;
  255.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  256.             DataView dv = new DataView();
  257.             try
  258.             {
  259.                 MSDA.Open();
  260.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  261.                 if (dv.Table.Rows.Count > 0)
  262.                     this.m_OpName = dv.Table.Rows[0]["OpName"].ToString();
  263.             }
  264.             catch (Exception ex)
  265.             {
  266.                 throw ex;
  267.             }
  268.             finally
  269.             {
  270.                 MSDA.Close();
  271.             }
  272.         }
  273.         //获取指定业务角色权限
  274.         public DataView GetOpPerm()
  275.         {
  276.             DataView dv = new DataView();
  277.             string strSQL = "select PermID from tb_Op_Role where OpID=" + this.OpID;
  278.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  279.             try
  280.             {
  281.                 MSDA.Open();
  282.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  283.             }
  284.             catch (Exception ex)
  285.             {
  286.                 throw ex;
  287.             }
  288.             finally
  289.             {
  290.                 MSDA.Close();
  291.             }
  292.             return dv;
  293.         }
  294.         //获取所有业务权限
  295.         public DataView GetOpPermAll()
  296.         {
  297.             DataView dv = new DataView();
  298.             string strSQL = "select PermID,DisplayName from Tb_Sys_Permission where ParentresCode='2'";
  299.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  300.             try
  301.             {
  302.                 MSDA.Open();
  303.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  304.             }
  305.             catch (Exception ex)
  306.             {
  307.                 throw ex;
  308.             }
  309.             finally
  310.             {
  311.                 MSDA.Close();
  312.             }
  313.             return dv;
  314.         }
  315.         //获取指定业务角色
  316.         public DataView GetOpRoleByOp()
  317.         {
  318.             string strSQL = "select * from Tb_Sys_OpRole where OpID=" + this.m_OpID;
  319.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  320.             DataView dv = new DataView();
  321.             try
  322.             {
  323.                 MSDA.Open();
  324.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  325.             }
  326.             catch (Exception ex)
  327.             {
  328.                 throw ex;
  329.             }
  330.             finally
  331.             {
  332.                 MSDA.Close();
  333.             }
  334.             return dv;
  335.         }
  336.         //更新业务角色和权限
  337.         public void UpOpPerm()
  338.         {
  339.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  340.             string strSQL = "update Tb_Sys_OpRole set OpName='" + this.m_OpName + "',OrgDesc='" + this.m_OpDesc + "' where OpID=" + this.m_OpID;
  341.             MSDA.Open();
  342.             SqlTransaction tran = MSDA.BeginTransaction();
  343.             try
  344.             {
  345.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  346.                 strSQL = "delete from tb_Op_Role where OpID=" + this.m_OpID;
  347.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  348.                 for (int i = 0; i < this.m_OpPerm.Count; i++)
  349.                 {
  350.                     strSQL = "insert into tb_Op_Role values(" + this.m_OpID + "," + Convert.ToInt32(this.m_OpPerm[i]) + ")";
  351.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  352.                 }
  353.                 tran.Commit();
  354.             }
  355.             catch (Exception ex)
  356.             {
  357.                 tran.Rollback();
  358.                 throw ex;
  359.             }
  360.             finally
  361.             {
  362.                 MSDA.Close();
  363.             }
  364.         }
  365.         //查询业务角色
  366.         public DataView CheckOpByCondition()
  367.         {
  368.             string strSQL = "select * from Tb_Sys_OpRole";
  369.             if (this.m_OpID > 0)
  370.             {
  371.                 strSQL = strSQL + " where OpID=" + this.m_OpID;
  372.             }
  373.             if (this.m_OpName == null || this.m_OpName == "") ;
  374.             else 
  375.             {
  376.                 strSQL = strSQL + " where OpName='" + this.m_OpName + "'";
  377.             }
  378.             DataView dv = new DataView();
  379.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  380.             try
  381.             {
  382.                 MSDA.Open();
  383.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  384.             }
  385.             catch (Exception ex)
  386.             {
  387.                 throw ex;
  388.             }
  389.             finally
  390.             {
  391.                 MSDA.Close();
  392.             }
  393.             return dv;
  394.         }
  395.         /*判断工作流上级活动是否走完
  396.         传入参数( actinsid       m_sid)
  397.          ( prjid       m_pid)
  398.          ( workflowid       m_wid)
  399.          ( status       m_istatus)(1、项目申请2、项目施工3、验收4、变更5、废旧物资6、汇总)*/
  400.         public bool CheckUpActComplete()
  401.         {
  402.             bool bl = true;
  403.             DataView dv = new DataView();
  404.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  405.             try
  406.             {
  407.                 MSDA.Open();
  408.                 string sSQL = "SELECT status from tb_wf_actins where ActInsID<>" + this.m_sID +
  409.                     " and WfInstanceID in ( select WfInstanceID from tb_WF_Instance where WorkFlowID=" +
  410.                     this.m_wID + " and PrjID=" + this.m_pID + " and status=" + this.m_iStatus + ")";
  411.                 dv = MSDA.ExecuteDataView(CommandType.Text, sSQL, null);
  412.                 if (dv.Table.Rows.Count > 0)
  413.                 {
  414.                     for (int i = 0; i < dv.Table.Rows.Count; i++)
  415.                     {
  416.                         if (Convert.ToInt32(dv.Table.Rows[i][0].ToString()) == 0) bl = false;
  417.                     }
  418.                 }
  419.                 else
  420.                 {
  421.                     bl = false;
  422.                 }
  423.             }
  424.             catch (Exception ex)
  425.             {
  426.                 bl = false;
  427.                 throw ex;
  428.             }
  429.             finally
  430.             {
  431.                 MSDA.Close();
  432.             }
  433.             return bl;
  434.         }
  435.         /*判断工作流上级所属(同类型的)活动是否走完
  436.         传入参数( actinsid       m_sid)
  437.          ( prjid       m_pid)
  438.          ( workflowid       m_wid)
  439.          ( status       m_istatus)(1、项目申请2、项目施工3、验收4、变更5、废旧物资6、汇总)
  440.          (BlockReason   m_sBlockReason)所属部门*/
  441.         public bool CheckUpActCompleteSort()
  442.         {
  443.             bool bl = true;
  444.             DataView dv = new DataView();
  445.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  446.             try
  447.             {
  448.                 MSDA.Open();
  449.                 string sSQL = "SELECT status from tb_wf_actins where ActInsID<>" + this.m_sID +
  450.                     " and BlockReason='" + this.m_sBlockReason + "' and WfInstanceID in ( select WfInstanceID from tb_WF_Instance where WorkFlowID=" +
  451.                     this.m_wID + " and PrjID=" + this.m_pID + " and status=" + this.m_iStatus + ")";
  452.                 dv = MSDA.ExecuteDataView(CommandType.Text, sSQL, null);
  453.                 if (dv.Table.Rows.Count > 0)
  454.                 {
  455.                     for (int i = 0; i < dv.Table.Rows.Count; i++)
  456.                     {
  457.                         if (Convert.ToInt32(dv.Table.Rows[i][0].ToString()) == 0) bl = false;
  458.                     }
  459.                 }
  460.                 else
  461.                 {
  462.                     bl = false;
  463.                 }
  464.             }
  465.             catch (Exception ex)
  466.             {
  467.                 bl = false;
  468.                 throw ex;
  469.             }
  470.             finally
  471.             {
  472.                 MSDA.Close();
  473.             }
  474.             return bl;
  475.         }
  476.         /*判断工作流上级活动是否走完
  477.         传入参数( activityid       m_aid)
  478.          ( wfinstanceid       m_iid)
  479.          ( status       m_istatus)(1、项目申请2、项目施工3、验收4、变更5、废旧物资6、汇总)
  480.          return false为未完成  true 为已完成*/
  481.         public bool GetPrevioueTasksStatus()
  482.         {
  483.             bool bl = true;
  484.             DataView dv = new DataView();
  485.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  486.             try
  487.             {
  488.                 MSDA.Open();
  489.                 ArrayList al = new ArrayList();
  490.                 al.Add(this.m_aID.ToString());
  491.                 for (int j=0;j<al.Count;j++ )
  492.                 {
  493.                     //获取上级任务
  494.                     string strSQL = "select parentActID from tb_Colony_User where ActivityID = " + Convert.ToInt32(al[j].ToString());
  495.                     dv=MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  496.                     if (dv.Table.Rows.Count < 1) return false;
  497.                     for (int i = 0; i < dv.Table.Rows.Count; i++)
  498.                     {
  499.                         //获取本级任务的状态
  500.                         string sSQL = "select status from tb_wf_actins where wfinstanceid=" + this.iID +
  501.                             " and activityid=" + Convert.ToInt32(dv.Table.Rows[i][0].ToString());
  502.                         DataView dv1 = new DataView();
  503.                         dv1 = MSDA.ExecuteDataView(CommandType.Text, sSQL, null);
  504.                         if (dv1.Table.Rows.Count == 0)
  505.                         {
  506.                             //增加新的未有生成的activityid
  507.                             al.Add(dv.Table.Rows[i][0].ToString());
  508.                         }
  509.                         else
  510.                         {
  511.                             //判断已生成的工作流实例状态
  512.                             for (int k = 0; k < dv1.Table.Rows.Count; k++)
  513.                             {
  514.                                 if (Convert.ToInt32(dv1.Table.Rows[k][0].ToString()) == 0) return false;
  515.                             }
  516.                         }
  517.                     }
  518.                 }
  519.             }
  520.             catch (Exception ex)
  521.             {
  522.                 bl = false;
  523.                 throw ex;
  524.             }
  525.             finally
  526.             {
  527.                 MSDA.Close();
  528.             }
  529.             return bl;
  530.         }
  531.     }
  532.     //工作流
  533.     public class EtongFlyChouWFNTask
  534.     {
  535.         private int m_pID;                                  //ParentActID          TB_CONOLY_USER
  536.         private int m_tID;                                  //ActivityID
  537.         private ArrayList m_rID;                            //RoleID
  538.         private string m_tUnit;                             //Unit                  TB_WF_ACTIVITY
  539.         private string m_tName;                             //ActName
  540.         private int m_tWFID;                                //WorkFlowID
  541.         private int m_tPageID;                              //PageID
  542.         private int m_tStart;                               //StartEnd
  543.         private int m_tBlock;                               //BlockFlag
  544.         private int m_tShunt;                               //ShuntFlag
  545.         private int m_tMode;                                //ModeFlag
  546.         private string m_wDesc;                             //WFDesc                TB_WORKFOLW
  547.         private string m_wName;                             //WFName
  548.         private int m_wStatus;                              //Status
  549.         private int m_wStart;                               //StartUpType
  550.         private string m_wUnit;                             //Unit
  551.         private int m_wKind;                                //KindID
  552.         private string m_wStDesc;                           //StartDesc
  553.         private int m_wStID;                                //StartRouterID
  554.         private int m_iID;                                  //WFInstanceID          TB_WF_INSTANCE
  555.         private int m_iUser;                                //CreateUserID
  556.         private int m_iRole;                                //TargetRoleID
  557.         private int m_iStatus;                              //Status
  558.         private DateTime m_iEnd;                            //TheoryEndDate
  559.         private int m_iPrjID;                               //PrjID
  560.         private int m_aID;                                  //ActInsID              TB_WF_ACTINS
  561.         private DateTime m_aCreate;                         //CreateDate
  562.         private DateTime m_aReal;                           //RealEndDate
  563.         private int m_aStatus;                              //Status
  564.         private DateTime m_aTheory;                         //TheoryEndDate
  565.         private string m_aBlock;                            //BlockReason
  566.         private int m_aUser;                                //UserID
  567.         private int m_aRole;                                //RoleID
  568.         
  569.         
  570.         //上一级活动代码
  571.         public int TaskPID
  572.         {
  573.             set { m_pID = value; }
  574.             get { return m_pID; }
  575.         }
  576.         //流程活动代码
  577.         public int TaskID
  578.         {
  579.             set { m_tID = value; }
  580.             get { return m_tID; }
  581.         }
  582.         //用户列表
  583.         public ArrayList RolesID
  584.         {
  585.             set { m_rID = value; }
  586.             get { return m_rID; }
  587.         }
  588.         //流程活动单位
  589.         public string TaskUnit
  590.         {
  591.             set { m_tUnit = value; }
  592.             get { return m_tUnit; }
  593.         }
  594.         //流程活动名
  595.         public string TaskName
  596.         {
  597.             set { m_tName = value; }
  598.             get { return m_tName; }
  599.         }
  600.         //流程活动工作流代码
  601.         public int TaskWFID
  602.         {
  603.             set { m_tWFID = value; }
  604.             get { return m_tWFID; }
  605.         }
  606.         //流程活动页面代码
  607.         public int TaskPage
  608.         {
  609.             set { m_tPageID = value; }
  610.             get { return m_tPageID; }
  611.         }
  612.         //流程活动任务标志
  613.         public int TaskStart
  614.         {
  615.             set { m_tStart = value; }
  616.             get { return m_tStart; }
  617.         }
  618.         //流程活动阻塞标志
  619.         public int TaskBlock
  620.         {
  621.             set { m_tBlock = value; }
  622.             get { return m_tBlock; }
  623.         }
  624.         //流程活动分流
  625.         public int TaskShunt
  626.         {
  627.             set { m_tShunt = value; }
  628.             get { return m_tShunt; }
  629.         }
  630.         //流程活动工作方式
  631.         public int TaskMode
  632.         {
  633.             set { m_tMode = value; }
  634.             get { return m_tMode; }
  635.         }
  636.         //工作流描述
  637.         public string TaskWDecs
  638.         {
  639.             set { m_wDesc = value; }
  640.             get { return m_wDesc; }
  641.         }
  642.         //工作流名称
  643.         public string TaskWName
  644.         {
  645.             set { m_wName = value; }
  646.             get { return m_wName; }
  647.         }
  648.         //工作流状态
  649.         public int TaskWStatus
  650.         {
  651.             set { m_wStatus = value; }
  652.             get { return m_wStatus; }
  653.         }
  654.         //工作流启动类型
  655.         public int TaskWStart
  656.         {
  657.             set { m_wStart = value; }
  658.             get { return m_wStart; }
  659.         }
  660.         //工作流使用单位
  661.         public string TaskWUnit
  662.         {
  663.             set { m_wUnit = value; }
  664.             get { return m_wUnit; }
  665.         }
  666.         //工作流种类
  667.         public int TaskWKind
  668.         {
  669.             set { m_wKind = value; }
  670.             get { return m_wKind; }
  671.         }
  672.         //工作流关联表
  673.         public string TaskWStDesc
  674.         {
  675.             set { m_wStDesc = value; }
  676.             get { return m_wStDesc; }
  677.         }
  678.         //工作流任务启动位置
  679.         public int TaskWStID
  680.         {
  681.             set { m_wStID = value; }
  682.             get { return m_wStID; }
  683.         }
  684.         //工作流实例代码
  685.         public int TaskIID
  686.         {
  687.             set { m_iID = value; }
  688.             get { return m_iID; }
  689.         }
  690.         //工作流实例接受者用户代码
  691.         public int TaskIUser
  692.         {
  693.             set { m_iUser = value; }
  694.             get { return m_iUser; }
  695.         }
  696.         //工作流实例接受者角色代码
  697.         public int TaskIRole
  698.         {
  699.             set { m_iRole = value; }
  700.             get { return m_iRole; }
  701.         }
  702.         //工作流实例状态
  703.         public int TaskIStatus
  704.         {
  705.             set { m_iStatus = value; }
  706.             get { return m_iStatus; }
  707.         }
  708.         //工作流实例计划结束时间
  709.         public DateTime TaskIEnd
  710.         {
  711.             set { m_iEnd = value; }
  712.             get { return m_iEnd; }
  713.         }
  714.         //工作流实例项目代码
  715.         public int TaskIPrj
  716.         {
  717.             set { m_iPrjID = value; }
  718.             get { return m_iPrjID; }
  719.         }
  720.         //工作流活动实例
  721.         public int TaskIAID
  722.         {
  723.             set { m_aID = value; }
  724.             get { return m_aID; }
  725.         }
  726.         //工作流活动实例创建时间
  727.         public DateTime TaskACreate
  728.         {
  729.             set { m_aCreate = value; }
  730.             get { return m_aCreate; }
  731.         }
  732.         //工作流活动实例实际结束时间
  733.         public DateTime TaskAReal
  734.         {
  735.             set { m_aReal = value; }
  736.             get { return m_aReal; }
  737.         }
  738.         //工作流活动实例状态
  739.         public int TaskAStatus
  740.         {
  741.             set { m_aStatus = value; }
  742.             get { return m_aStatus; }
  743.         }
  744.         //工作流活动实例计划完成时间
  745.         public DateTime TaskATheory
  746.         {
  747.             set { m_aTheory = value; }
  748.             get { return m_aTheory; }
  749.         }
  750.         //工作流活动实例耽误原因
  751.         public string TaskABlock
  752.         {
  753.             set { m_aBlock = value; }
  754.             get { return m_aBlock; }
  755.         }
  756.         //工作流活动实例受理用户
  757.         public int TaskAUser
  758.         {
  759.             set { m_aUser = value; }
  760.             get { return m_aUser; }
  761.         }
  762.         //工作流活动实例受理角色
  763.         public int TaskARole
  764.         {
  765.             set { m_aRole = value; }
  766.             get { return m_aRole; }
  767.         }
  768.         //创建新任务
  769.         public EtongFlyChouWFNTask CreateNewTask()
  770.         {
  771.             return new EtongFlyChouWFNTask();
  772.         }
  773.         //删除工作流
  774.         public void WFDelete()
  775.         {
  776.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  777.             string strSQL;
  778.             strSQL = "delete from tb_WorkFlow where WFID=" + this.m_tWFID;
  779.             try
  780.             {
  781.                 MSDA.Open();
  782.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  783.             }
  784.             catch (Exception ex)
  785.             {
  786.                 throw ex;
  787.             }
  788.             finally
  789.             {
  790.                 MSDA.Close();
  791.             }
  792.         }
  793.         //是否能删除该工作流
  794.         public bool IsCanWFDelete()
  795.         {
  796.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  797.             string strSQL;
  798.             bool result = true;
  799.             strSQL = "select count(*) as iNum from tb_WF_Activity where WorkFlowID=" + this.m_tWFID;
  800.             try
  801.             {
  802.                 MSDA.Open();
  803.                 SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, strSQL, null);
  804.                 if (dr.Read() == true)
  805.                 {
  806.                     if (Convert.ToInt32(dr["iNum"]) > 0) result = false;
  807.                 }
  808.                 dr.Close();
  809.             }
  810.             finally
  811.             {
  812.                 MSDA.Close();
  813.             }
  814.             return result;
  815.         }
  816.         
  817.     }
  818.     public class EtongFlyChouWFNM
  819.     {
  820.         private int m_ID;                      //CommID
  821.         private string m_Name;                 //CommName
  822.         private decimal m_Bud;                  //BudGetPrice
  823.         private decimal m_Diff;                 //DifferencePrice
  824.         private decimal m_DiffSum;              //DifferencePriceSum   Price
  825.         private decimal m_Mark;                 //MarketPrice
  826.         private string m_Size;                  //MeterialSize
  827.         private int m_Num;                      //Number
  828.         private string m_Unit;                  //UnitName  Memo
  829.         private int m_Prj;                      //ProjectID
  830.         private int m_wz;                       //WZID
  831.         private int m_UserID;                   //uSERID
  832.         private string m_UserName;              //UserName
  833.         private string m_Exp;                   //Explain
  834.         private string m_Field;                 //字段
  835.         private string m_Table;                 //表名
  836.         private string m_Condition;             //条件
  837.         private Int16 m_sstatus;                  //sstatus
  838.         private Int16 m_status;                   //status
  839.         //CommID
  840.         public int CommID
  841.         {
  842.             set { m_ID = value; }
  843.             get { return m_ID; }
  844.         }
  845.         public string CommName
  846.         {
  847.             set {m_Name =value;}
  848.             get { return m_Name; }
  849.         }
  850.         public decimal Bud
  851.         {
  852.             set { m_Bud = value; }
  853.             get { return m_Bud; }
  854.         }
  855.         public decimal Diff
  856.         {
  857.             set { m_Diff = value; }
  858.             get { return m_Diff; }
  859.         }
  860.         public decimal DiffSum
  861.         {
  862.             set { m_DiffSum = value; }
  863.             get { return m_DiffSum; }
  864.         }
  865.         public decimal Mark
  866.         {
  867.             set { m_Mark = value; }
  868.             get { return m_Mark; }
  869.         }
  870.         public string CommSize
  871.         {
  872.             set {m_Size =value;}
  873.             get {return m_Size;}
  874.         }
  875.         public int Num
  876.         {
  877.             set { m_Num = value; }
  878.             get { return m_Num; }
  879.         }
  880.         public string Unit
  881.         {
  882.             set { m_Unit = value; }
  883.             get { return m_Unit; }
  884.         }
  885.         public int Prj
  886.         {
  887.             set { m_Prj = value; }
  888.             get { return m_Prj; }
  889.         }
  890.         public int WZ
  891.         {
  892.             set { m_wz = value; }
  893.             get { return m_wz; }
  894.         }
  895.         public int UserID
  896.         {
  897.             set { m_UserID = value; }
  898.             get { return m_UserID; }
  899.         }
  900.         public string UserName
  901.         {
  902.             set { m_UserName = value; }
  903.             get { return m_UserName; }
  904.         }
  905.         public string Explain
  906.         {
  907.             set { m_Exp = value; }
  908.             get { return m_Exp; }
  909.         }
  910.         public string Filed
  911.         {
  912.             set { m_Field = value; }
  913.             get { return m_Field; }
  914.         }
  915.         public string Table
  916.         {
  917.             set { m_Table = value; }
  918.             get { return m_Table; }
  919.         }
  920.         public string Condition
  921.         {
  922.             set { m_Condition = value; }
  923.             get { return m_Condition; }
  924.         }
  925.         public Int16 sstatus
  926.         {
  927.             set { m_sstatus = value; }
  928.             get { return m_sstatus; }
  929.         }
  930.         public Int16 status
  931.         {
  932.             set { m_status = value; }
  933.             get { return m_status; }
  934.         }
  935.         private QueryParameterCollection Params = new QueryParameterCollection();
  936.         private MSSqlDataAccess MSDA2 = new MSSqlDataAccess(2);
  937.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  938.         
  939.         /// <summary>
  940.         /// 获取待办事宜等
  941.         /// 1、待办;2、其他
  942.         /// </summary>
  943.         /// <param name="iUserID">用户ID</param>
  944.         /// <param name="iStatus">工作状态</param>
  945.         /// <returns>DataView工作流的事宜信息</returns>
  946.         public DataView GetWaitList(int iFlag,int iUserID,int iDept,int iStatus0,int iStatus2)
  947.         {
  948.             Params.Clear();
  949.             Params.Add("@Param_UserIDflag", iFlag);
  950.             Params.Add("@Param_UserID", iUserID);
  951.             Params.Add("@Param_DeptID", iDept);
  952.             Params.Add("@Param_Status0", iStatus0);
  953.             Params.Add("@Param_Status2", iStatus2);
  954.             DataView dv = new DataView();
  955.             string strSQL = "P_GetWaitList";
  956.             MSDA.Open();
  957.             dv = MSDA.ExecuteDataView(CommandType.StoredProcedure,strSQL,Params);
  958.             MSDA.Close();
  959.             return dv;
  960.         }
  961.         
  962.         /// <summary>
  963.         /// 获取物资代码大类
  964.         /// </summary>
  965.         /// <returns>所有的物资代码</returns>
  966.         public DataView GetBigWZList()
  967.         {
  968.             string strSQL = "select wz_code1,wz_code2,wz_namecode2 from wz_code2";
  969.             DataView dv = new DataView();
  970.             try
  971.             {
  972.                 MSDA2.Open();
  973.                 dv = MSDA2.ExecuteDataView(CommandType.Text, strSQL, null);
  974.             }
  975.             catch
  976.             {
  977.             }
  978.             finally
  979.             {
  980.                 MSDA2.Close();
  981.             }
  982.             return dv;
  983.         }
  984.         /// <summary>
  985.         /// 设备费
  986.         /// </summary>
  987.         public DataView ProEquGetDataByPrj()
  988.         {
  989.             string strSQL = "select * from tb_Project_Equipment where ProjectID=" + this.m_Prj + " order by wz_id";
  990.             MSDA.Open();
  991.             DataView dv = new DataView();
  992.             try
  993.             {
  994.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  995.             }
  996.             catch (Exception ex)
  997.             {
  998.                 throw ex;
  999.             }
  1000.             finally
  1001.             {
  1002.                 MSDA.Close();
  1003.             }
  1004.             return dv;
  1005.         }
  1006.         public DataView ProEquGetData()
  1007.         {
  1008.             string strSQL = "select * from tb_Project_Equipment where ProjectID=" +
  1009.                 this.m_Prj + " and sstatus=" + this.m_sstatus + " order by wz_id";
  1010.             MSDA.Open();
  1011.             DataView dv = new DataView();
  1012.             try
  1013.             {
  1014.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1015.             }
  1016.             catch (Exception ex)
  1017.             {
  1018.                 throw ex;
  1019.             }
  1020.             finally
  1021.             {
  1022.                 MSDA.Close();
  1023.             }
  1024.             return dv;
  1025.         }
  1026.         public DataView ProEquGetDataByEqu()
  1027.         {
  1028.             string strSQL = "select * from tb_Project_Equipment where EquipmentID=" + this.CommID + " and sstatus=" + this.m_sstatus;
  1029.             MSDA.Open();
  1030.             DataView dv = new DataView();
  1031.             try
  1032.             {
  1033.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1034.             }
  1035.             catch (Exception ex)
  1036.             {
  1037.                 throw ex;
  1038.             }
  1039.             finally
  1040.             {
  1041.                 MSDA.Close();
  1042.             }
  1043.             return dv;
  1044.         }
  1045.         public int ProEquInsert()
  1046.         {
  1047.             int err = -1;
  1048.             string strSQL = "select * from tb_Project_Equipment where ProjectID=" +
  1049.                 this.m_Prj + " and wz_id=" + this.m_wz + " and sstatus=1";
  1050.             MSDA.Open();
  1051.             DataView dv = new DataView();
  1052.             try
  1053.             {
  1054.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1055.             }
  1056.             catch (Exception ex)
  1057.             {
  1058.                 err = -2;
  1059.                 throw ex;
  1060.             }
  1061.             if (err == -2)
  1062.             {
  1063.                 MSDA.Close();
  1064.                 return err;
  1065.             }
  1066.             if (dv.Table.Rows.Count > 0)
  1067.             {
  1068.                 MSDA.Close();
  1069.                 return -1;
  1070.             }
  1071.             strSQL = "insert into tb_Project_Equipment values('" + this.m_Unit + "'," + 
  1072.                 this.m_wz + ",'" + this.m_Name + "'," + this.m_Num + "," + this.m_Prj + "," +
  1073.                 this.m_Mark + ",'" + this.m_Size + "',1," + this.status + ",'" + this.m_UserName + "')";
  1074.             SqlTransaction tran = MSDA.BeginTransaction();
  1075.             try
  1076.             {
  1077.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1078.                 tran.Commit();
  1079.             }
  1080.             catch (Exception ex)
  1081.             {
  1082.                 tran.Rollback();
  1083.                 throw ex;
  1084.             }
  1085.             finally
  1086.             {
  1087.                 MSDA.Close();
  1088.             }
  1089.             return 1;
  1090.         }
  1091.         public int ProEquUpdate()
  1092.         {
  1093.             int err = -1;
  1094.             DataView dv = new DataView();
  1095.             try
  1096.             {
  1097.                 dv = this.ProEquGetDataByEqu();
  1098.             }
  1099.             catch (Exception ex)
  1100.             {
  1101.                 err = -2;
  1102.                 throw ex;
  1103.             }
  1104.             if (err == -2) return err;
  1105.             if (dv.Table.Rows.Count < 1)
  1106.             {
  1107.                 //ex.Message = "未找到要更新的内容,请查证后再试!";
  1108.                 err = 1;
  1109.                 return err;
  1110.             }
  1111.             bool bl=false;
  1112.             if (this.m_Unit.Trim() != dv.Table.Rows[0]["UnitName"].ToString().Trim()) bl = true;
  1113.             if (this.m_wz != Convert.ToInt32(dv.Table.Rows[0]["wz_id"].ToString())) bl = true;
  1114.             if (this.m_Name.Trim() != dv.Table.Rows[0]["EquipmentName"].ToString().Trim()) bl = true;
  1115.             if (this.m_Num != Convert.ToInt32(dv.Table.Rows[0]["Number"].ToString())) bl =true;
  1116.             if (this.m_Mark != decimal.Parse(dv.Table.Rows[0]["Price"].ToString())) bl = true;
  1117.             if (this.m_Size.Trim() != dv.Table.Rows[0]["EquipmentSize"].ToString().Trim()) bl = true;
  1118.             if (bl)
  1119.             {
  1120.                 string strSQL = "Update tb_Project_Equipment set sstatus=2 where EquipmentID=" + this.m_ID;
  1121.                 MSDA.Open();
  1122.                 SqlTransaction tran = MSDA.BeginTransaction();
  1123.                 try
  1124.                 {
  1125.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1126.                     strSQL = "insert into tb_Project_Equipment values('" + this.m_Unit + "'," +
  1127.                     this.m_wz + ",'" + this.m_Name + "'," + this.m_Num + "," + this.m_Prj + "," +
  1128.                     this.m_Mark + ",'" + this.m_Size + "',1," + this.status + ",'" + this.m_UserName + "')";
  1129.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1130.                     tran.Commit();
  1131.                     return err;
  1132.                 }
  1133.                 catch (Exception ex)
  1134.                 {
  1135.                     tran.Rollback();
  1136.                     err = -2;
  1137.                     throw ex;
  1138.                 }
  1139.                 finally
  1140.                 {
  1141.                     MSDA.Close();
  1142.                 }
  1143.             }
  1144.             else
  1145.             {
  1146.                 err = 2;
  1147.                 //ex.Message = "未发生变化无需更新,请查证后再试!";
  1148.             }
  1149.             return err;
  1150.         }
  1151.         public void ProEquDelete()
  1152.         {
  1153.             int err = -1;
  1154.             DataView dv = new DataView();
  1155.             try
  1156.             {
  1157.                 dv = this.ProEquGetDataByEqu();
  1158.             }
  1159.             catch (Exception ex)
  1160.             {
  1161.                 err = -2;
  1162.                 throw ex;
  1163.             }
  1164.             if (err == -2) return;
  1165.             if (dv.Table.Rows.Count < 1)
  1166.             {
  1167.                 //ex.Message = "未找到要更新的内容,请查证后再试!";
  1168.                 err = 1;
  1169.                 return;
  1170.             }
  1171.             string sSQL = "insert into tb_Project_Equipment values('" + dv.Table.Rows[0]["UnitName"].ToString().Trim() +
  1172.                 "'," + Convert.ToInt32(dv.Table.Rows[0]["wz_id"].ToString()) + ",'" + dv.Table.Rows[0]["EquipmentName"].ToString().Trim() +
  1173.                 "'," + Convert.ToInt32(dv.Table.Rows[0]["Number"].ToString()) + "," + dv.Table.Rows[0]["ProjectID"].ToString().Trim() +
  1174.                 "," + decimal.Parse(dv.Table.Rows[0]["Price"].ToString()) + ",'" + dv.Table.Rows[0]["EquipmentSize"].ToString().Trim() +
  1175.                 "',2,3,'" + this.m_UserName + "')";
  1176.             MSDA.Open();
  1177.             SqlTransaction tran = MSDA.BeginTransaction();
  1178.             try
  1179.             {
  1180.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  1181.                 sSQL = "Update tb_Project_Equipment set sstatus=2 where EquipmentID=" + this.m_ID;
  1182.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  1183.                 tran.Commit();
  1184.             }
  1185.             catch (Exception ex)
  1186.             {
  1187.                 tran.Rollback();
  1188.                 throw ex;
  1189.             }
  1190.             finally
  1191.             {
  1192.                 MSDA.Close();
  1193.             }
  1194.         }
  1195.         /// <summary>
  1196.         /// 材料费
  1197.         /// </summary>
  1198.         public int ProMaterialInsert()
  1199.         {
  1200.             int err = -1;
  1201.             string strSQL = "select * from tb_Project_Material where ProjectID=" +
  1202.                 this.m_Prj + " and wz_id=" + this.m_wz + " and sstatus=1";
  1203.             DataView dv = new DataView();
  1204.             MSDA.Open();
  1205.             try
  1206.             {
  1207.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1208.             }
  1209.             catch (Exception ex)
  1210.             {
  1211.                 err = -2;
  1212.                 throw ex;
  1213.             }
  1214.             if (err == -2)
  1215.             {
  1216.                 MSDA.Close();
  1217.                 return err;
  1218.             }
  1219.             if (dv.Table.Rows.Count > 0)
  1220.             {
  1221.                 MSDA.Close();
  1222.                 return -1;
  1223.             }
  1224.             strSQL = "insert into tb_Project_Material values(" + this.m_Bud + "," + this.m_Diff + "," +
  1225.                 this.m_DiffSum + "," + this.m_Mark + ",'" + this.m_Name + "','" +
  1226.                 this.m_Size + "'," + this.m_wz + "," + this.m_Num + ",'" + this.m_Unit + "'," +
  1227.                 this.m_Prj + ",1," + this.m_status + ",'" + this.m_UserName +  "')";
  1228.             SqlTransaction tran = MSDA.BeginTransaction();
  1229.             try
  1230.             {
  1231.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1232.                 tran.Commit();
  1233.             }
  1234.             catch (Exception ex)
  1235.             {
  1236.                 tran.Rollback();
  1237.                 throw ex;
  1238.             }
  1239.             finally
  1240.             {
  1241.                 MSDA.Close();
  1242.             }
  1243.             return 1;
  1244.         }
  1245.         public string ProMaterialGetMemo()
  1246.         {
  1247.             string strSQL = "select Memo from tb_Project_Material where MaterialID=" + this.m_ID ;
  1248.             MSDA.Open();
  1249.             DataView dv = MSDA.ExecuteDataView(CommandType.Text,strSQL,null);
  1250.             MSDA.Close();
  1251.             string sMemo="";
  1252.             if (dv.Table.Rows.Count > 0) sMemo = dv.Table.Rows[0][0].ToString();
  1253.             return sMemo;
  1254.         }
  1255.         public int ProMaterialUpdate()
  1256.         {
  1257.             int err = -1;
  1258.             DataView dv = new DataView();
  1259.             try
  1260.             {
  1261.                 dv = this.ProMaterialGetByMat();
  1262.             }
  1263.             catch (Exception ex)
  1264.             {
  1265.                 err = -2;
  1266.                 throw ex;
  1267.             }
  1268.             if (err == -2) return err;
  1269.             if (dv.Table.Rows.Count < 1)
  1270.             {
  1271.                 //ex.Message = "未找到要更新的内容,请查证后再试!";
  1272.                 err = 1;
  1273.                 return err;
  1274.             }
  1275.             bool bl = false;
  1276.             if (this.m_Bud != decimal.Parse(dv.Table.Rows[0]["BudGetPrice"].ToString())) bl = true;
  1277.             if (this.m_DiffSum != decimal.Parse(dv.Table.Rows[0]["DifferencePriceSum"].ToString())) bl = true;
  1278.             if (this.m_Mark != decimal.Parse(dv.Table.Rows[0]["MarketPrice"].ToString())) bl = true;
  1279.             if (this.m_Name.Trim() != dv.Table.Rows[0]["MeterialName"].ToString().Trim()) bl = true;
  1280.             if (this.m_Size.Trim() != dv.Table.Rows[0]["MeterialSize"].ToString().Trim()) bl = true;
  1281.             if (this.m_wz != Convert.ToInt32(dv.Table.Rows[0]["wz_id"].ToString())) bl = true;
  1282.             if (this.m_Num != Convert.ToInt32(dv.Table.Rows[0]["Number"].ToString())) bl = true;
  1283.             if (this.m_Unit.Trim() != dv.Table.Rows[0]["UnitName"].ToString().Trim()) bl = true;
  1284.             if (bl)
  1285.             {
  1286.                 string strSQL = "Update tb_Project_Material set sstatus=2 where MaterialID=" + this.m_ID;
  1287.                 MSDA.Open();
  1288.                 SqlTransaction tran = MSDA.BeginTransaction();
  1289.                 try
  1290.                 {
  1291.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1292.                     strSQL = "insert into tb_Project_Material values(" + this.m_Bud + "," + this.m_Diff + "," +
  1293.                     this.m_DiffSum + "," + this.m_Mark + ",'" + this.m_Name + "','" +
  1294.                     this.m_Size + "'," + this.m_wz + "," + this.m_Num + ",'" + this.m_Unit + "'," +
  1295.                     this.m_Prj + ",1," + this.m_status + ",'" + this.m_UserName + "')";
  1296.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1297.                     tran.Commit();
  1298.                     return err;
  1299.                 }
  1300.                 catch (Exception ex)
  1301.                 {
  1302.                     tran.Rollback();
  1303.                     err = -2;
  1304.                     throw ex;
  1305.                 }
  1306.                 finally
  1307.                 {
  1308.                     MSDA.Close();
  1309.                 }
  1310.             }
  1311.             else
  1312.             {
  1313.                 err = 2;
  1314.                 //ex.Message = "未发生变化无需更新,请查证后再试!";
  1315.             }
  1316.             return err;
  1317.         }
  1318.         public DataView ProMaterialGetByPrj()
  1319.         {
  1320.             string strSQL = "select * from tb_Project_Material where ProjectID=" + this.m_Prj + " order by wz_id";
  1321.             DataView dv = new DataView();
  1322.             try
  1323.             {
  1324.                 MSDA.Open();
  1325.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1326.             }
  1327.             catch (Exception ex)
  1328.             {
  1329.                 throw ex;
  1330.             }
  1331.             finally
  1332.             {
  1333.                 MSDA.Close();
  1334.             }
  1335.             return dv;
  1336.         }
  1337.         public DataView ProMaterialGetByPrjId()
  1338.         {
  1339.             string strSQL = "select * from tb_Project_Material where ProjectID=" +
  1340.                 this.m_Prj + " and sstatus=" + this.sstatus + " order by wz_id";
  1341.             DataView dv = new DataView();
  1342.             try
  1343.             {
  1344.                 MSDA.Open();
  1345.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1346.             }
  1347.             catch (Exception ex)
  1348.             {
  1349.                 throw ex;
  1350.             }
  1351.             finally
  1352.             {
  1353.                 MSDA.Close();
  1354.             }
  1355.             return dv;
  1356.         }
  1357.         public DataView ProMaterialGetByMat()
  1358.         {
  1359.             string strSQL = "select * from tb_Project_Material where MaterialID=" + this.CommID + " and sstatus=" + this.sstatus;
  1360.             DataView dv = new DataView();
  1361.             try
  1362.             {
  1363.                 MSDA.Open();
  1364.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1365.             }
  1366.             catch (Exception ex)
  1367.             {
  1368.                 throw ex;
  1369.             }
  1370.             finally
  1371.             {
  1372.                 MSDA.Close();
  1373.             }
  1374.             return dv;
  1375.         }
  1376.         public string ProBudGetPriceGetByWzId()
  1377.         {
  1378.             string strSQL = "select wz_plan from material_name where wz_id=" + this.m_wz;
  1379.             MSDA2.Open();
  1380.             DataView dv = MSDA2.ExecuteDataView(CommandType.Text, strSQL, null);
  1381.             MSDA2.Close();
  1382.             string wz_plan = "";
  1383.             if (dv.Table.Rows.Count > 0) wz_plan = dv.Table.Rows[0][0].ToString();
  1384.             return wz_plan;
  1385.         }
  1386.         public void ProMaterialDelete()
  1387.         {
  1388.             int err = -1;
  1389.             DataView dv = new DataView();
  1390.             try
  1391.             {
  1392.                 dv = this.ProMaterialGetByMat();
  1393.             }
  1394.             catch (Exception ex)
  1395.             {
  1396.                 err = -2;
  1397.                 throw ex;
  1398.             }
  1399.             if (err == -2) return;
  1400.             if (dv.Table.Rows.Count < 1)
  1401.             {
  1402.                 //ex.Message = "未找到要更新的内容,请查证后再试!";
  1403.                 err = 1;
  1404.                 return;
  1405.             }
  1406.             string sSQL = "insert into tb_Project_Material values(" + decimal.Parse(dv.Table.Rows[0]["BudGetPrice"].ToString()) +
  1407.                 "," + decimal.Parse(dv.Table.Rows[0]["DifferencePrice"].ToString()) + "," + decimal.Parse(dv.Table.Rows[0]["DifferencePriceSum"].ToString()) +
  1408.                 "," + decimal.Parse(dv.Table.Rows[0]["MarketPrice"].ToString()) + ",'" + dv.Table.Rows[0]["MeterialName"].ToString().Trim() +
  1409.                 "','" + dv.Table.Rows[0]["MeterialSize"].ToString().Trim() + "'," + Convert.ToInt32(dv.Table.Rows[0]["wz_id"].ToString()) +
  1410.                 "," + Convert.ToInt32(dv.Table.Rows[0]["Number"].ToString()) + ",'" + dv.Table.Rows[0]["UnitName"].ToString().Trim() +
  1411.                 "'," + Convert.ToInt32(dv.Table.Rows[0]["ProjectID"].ToString()) +
  1412.                 ",2,3,'" + this.m_UserName + "')";
  1413.             MSDA.Open();
  1414.             SqlTransaction tran= MSDA.BeginTransaction();
  1415.             try
  1416.             {
  1417.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  1418.                 sSQL = "Update tb_Project_Material set sstatus=2 where MaterialID=" + this.m_ID;
  1419.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  1420.                 tran.Commit();
  1421.             }
  1422.             catch (Exception ex)
  1423.             {
  1424.                 tran.Rollback();
  1425.                 throw ex;
  1426.             }
  1427.             finally
  1428.             {
  1429.                 MSDA.Close();
  1430.             }
  1431.         }
  1432.         /// <summary>
  1433.         /// 其他费用
  1434.         /// </summary>
  1435.         public DataView ProOtherGetByPrj()
  1436.         {
  1437.             string strSQL = "select * from tb_Project_Other where ProjectID=" + this.m_Prj;
  1438.             DataView dv = new DataView();
  1439.             try
  1440.             {
  1441.                 MSDA.Open();
  1442.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1443.             }
  1444.             catch (Exception ex)
  1445.             {
  1446.                 throw ex;
  1447.             }
  1448.             finally
  1449.             {
  1450.                 MSDA.Close();
  1451.             }
  1452.             return dv;
  1453.         }
  1454.         public DataView ProGetAllFee()
  1455.         {
  1456.             string strSQL = "select * from " + this.m_Table + " where " + this.m_Condition + "=" + this.m_Prj;
  1457.             DataView dv = new DataView();
  1458.             try
  1459.             {
  1460.                 MSDA.Open();
  1461.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1462.             }
  1463.             catch (Exception ex)
  1464.             {
  1465.                 throw ex;
  1466.             }
  1467.             finally
  1468.             {
  1469.                 MSDA.Close();
  1470.             }
  1471.             return dv;
  1472.         }
  1473.         public DataView ProOtherByPrj()
  1474.         {
  1475.             string strSQL = "select * from tb_Project_Other where ProjectID=" + this.m_Prj + " and sstatus=" + this.m_sstatus;
  1476.             DataView dv = new DataView();
  1477.             try
  1478.             {
  1479.                 MSDA.Open();
  1480.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1481.             }
  1482.             catch (Exception ex)
  1483.             {
  1484.                 throw ex;
  1485.             }
  1486.             finally
  1487.             {
  1488.                 MSDA.Close();
  1489.             }
  1490.             return dv;
  1491.         }
  1492.         public DataView ProOtherByOther()
  1493.         {
  1494.             string strSQL = "select * from tb_Project_Other where OtherID=" + this.m_ID + " and sstatus=" + this.m_sstatus;
  1495.             DataView dv = new DataView();
  1496.             try
  1497.             {
  1498.                 MSDA.Open();
  1499.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  1500.             }
  1501.             catch (Exception ex)
  1502.             {
  1503.                 throw ex;
  1504.             }
  1505.             finally
  1506.             {
  1507.                 MSDA.Close();
  1508.             }
  1509.             return dv;
  1510.         }
  1511.         public void ProOtherInsert()
  1512.         {
  1513.             string strSQL = "insert into tb_Project_Other values('" + this.m_Exp + "','" +
  1514.                 this.m_Name + "','" + this.m_Unit + "'," + this.m_DiffSum + "," + this.m_Prj +
  1515.                 ",1," + this.m_status + ",'" + this.m_UserName + "')";
  1516.             MSDA.Open();
  1517.             SqlTransaction tran = MSDA.BeginTransaction();
  1518.             try
  1519.             {
  1520.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1521.                 tran.Commit();
  1522.             }
  1523.             catch (Exception ex)
  1524.             {
  1525.                 tran.Rollback();
  1526.                 throw ex;
  1527.             }
  1528.             finally
  1529.             {
  1530.                 MSDA.Close();
  1531.             }
  1532.         }
  1533.         public int ProOtherUpdata()
  1534.         {
  1535.             int err = -1;
  1536.             DataView dv = new DataView();
  1537.             try
  1538.             {
  1539.                 dv = this.ProOtherByOther();
  1540.             }
  1541.             catch (Exception ex)
  1542.             {
  1543.                 err = -2;
  1544.                 throw ex;
  1545.             }
  1546.             if (err == -2) return err;
  1547.             if (dv.Table.Rows.Count < 1)
  1548.             {
  1549.                 //ex.Message = "未找到要更新的内容,请查证后再试!";
  1550.                 err = 1;
  1551.                 return err;
  1552.             }
  1553.             bool bl = false;
  1554.             if (this.Explain.Trim() != dv.Table.Rows[0]["Explain"].ToString().Trim()) bl = true;
  1555.             if (this.m_Name.Trim() != dv.Table.Rows[0]["OtherName"].ToString().Trim()) bl = true;
  1556.             if (this.m_Unit.Trim() != dv.Table.Rows[0]["Memo"].ToString().Trim()) bl = true;
  1557.             if (this.m_DiffSum != decimal.Parse(dv.Table.Rows[0]["Price"].ToString())) bl = true;
  1558.             if (bl)
  1559.             {
  1560.                 string strSQL = "Update tb_Project_Other set sstatus=2 where OtherID=" + this.m_ID;
  1561.                 MSDA.Open();
  1562.                 SqlTransaction tran = MSDA.BeginTransaction();
  1563.                 try
  1564.                 {
  1565.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1566.                     strSQL = "insert into tb_Project_Other values('" + this.m_Exp + "','" +
  1567.                     this.m_Name + "','" + this.m_Unit + "'," + this.m_DiffSum + "," + this.m_Prj +
  1568.                     ",1," + this.m_status + ",'" + this.m_UserName + "')";
  1569.                     MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1570.                     tran.Commit();
  1571.                     return err;
  1572.                 }
  1573.                 catch (Exception ex)
  1574.                 {
  1575.                     tran.Rollback();
  1576.                     err = -2;
  1577.                     throw ex;
  1578.                 }
  1579.                 finally
  1580.                 {
  1581.                     MSDA.Close();
  1582.                 }
  1583.             }
  1584.             else
  1585.             {
  1586.                 err = 2;
  1587.                 //ex.Message = "未发生变化无需更新,请查证后再试!";
  1588.             }
  1589.             return err;
  1590.         }
  1591.         public void ProOtherDelete()
  1592.         {
  1593.             int err = -1;
  1594.             DataView dv = new DataView();
  1595.             try
  1596.             {
  1597.                 dv = this.ProOtherByOther();
  1598.             }
  1599.             catch (Exception ex)
  1600.             {
  1601.                 err = -2;
  1602.                 throw ex;
  1603.             }
  1604.             if (err == -2) return;
  1605.             if (dv.Table.Rows.Count < 1)
  1606.             {
  1607.                 //ex.Message = "未找到要更新的内容,请查证后再试!";
  1608.                 return ;
  1609.             }
  1610.             string sSQL = "insert into tb_Project_Other values('" + dv.Table.Rows[0]["Explain"].ToString().Trim() +
  1611.                 "','" + dv.Table.Rows[0]["OtherName"].ToString().Trim() + "','" + dv.Table.Rows[0]["Memo"].ToString().Trim() +
  1612.                 "'," + decimal.Parse(dv.Table.Rows[0]["Price"].ToString()) + "," + decimal.Parse(dv.Table.Rows[0]["ProjectID"].ToString()) +
  1613.                 ",2,3,'" + this.m_UserName + "')";
  1614.             MSDA.Open();
  1615.             SqlTransaction tran = MSDA.BeginTransaction();
  1616.             try
  1617.             {
  1618.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  1619.                 sSQL = "Update tb_Project_Other set sstatus=2 where OtherID=" + this.m_ID;
  1620.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  1621.                 tran.Commit();
  1622.             }
  1623.             catch (Exception ex)
  1624.             {
  1625.                 tran.Rollback();
  1626.                 throw ex;
  1627.             }
  1628.             finally
  1629.             {
  1630.                 MSDA.Close();
  1631.             }
  1632.         }
  1633.     }
  1634.     //组织机构和职工初始化
  1635.     public class EtongFlyChouInit
  1636.     {
  1637.         private int m_ID;               //组织机构ID        EmpID                                               UserID
  1638.         private int m_pDI;              //上级ID            PrimaryOrgID                                        EmpID
  1639.         private string m_Name;          //名称              EmpName
  1640.         private string m_Decs;          //OrgDesc           EMail                                               UserDecs
  1641.         private Int16 m_Inal;           //OrgInal           TempFlag(0、非临时,1、临时)                        IsLock
  1642.         private int m_Level;            //OrgLevel          EmpType(1、普通员工2、部门主管3、公司领导4、其他)   OrdInal
  1643.         private DateTime m_Edit;        //EditTime          EditDate                                            EditDate
  1644.         private string m_Type;          //OrgType(TYPE2)                                                        IPAddress
  1645.         private string m_Path;          //OrgPath           PhoneNumber                                         UserCode
  1646.         private string m_CID;           //OrgcID(DEPT_ID)                                                       UserAccount
  1647.         private string m_Pwd;           //                                                                      UserPwd
  1648.         private Int16 m_Bound;          //                                                                      IsIPBound
  1649.         public int ID
  1650.         {
  1651.             set { m_ID = value; }
  1652.             get { return m_ID; }
  1653.         }
  1654.         public int PID
  1655.         {
  1656.             set { m_pDI = value; }
  1657.             get { return m_pDI; }
  1658.         }
  1659.         public string Name
  1660.         {
  1661.             set {m_Name =value;}
  1662.             get { return m_Name; }
  1663.         }
  1664.         public string Decs
  1665.         {
  1666.             set { m_Decs = value; }
  1667.             get { return m_Decs; }
  1668.         }
  1669.         public Int16 Inal
  1670.         {
  1671.             set { m_Inal = value; }
  1672.             get { return m_Inal; }
  1673.         }
  1674.         public int Level
  1675.         {
  1676.             set { m_Level = value; }
  1677.             get { return m_Level; }
  1678.         }
  1679.         public DateTime Edit
  1680.         {
  1681.             set { m_Edit = value; }
  1682.             get { return m_Edit; }
  1683.         }
  1684.         public string Type
  1685.         {
  1686.             set { m_Type = value; }
  1687.             get { return m_Type; }
  1688.         }
  1689.         public string Path
  1690.         {
  1691.             set { m_Path = value; }
  1692.             get { return m_Path; }
  1693.         }
  1694.         public string CID
  1695.         {
  1696.             set { m_CID = value; }
  1697.             get { return m_CID; }
  1698.         }
  1699.         public string Pwd
  1700.         {
  1701.             set { m_Pwd = value; }
  1702.             get { return m_Pwd; }
  1703.         }
  1704.         public Int16 Bound
  1705.         {
  1706.             set { m_Bound = value; }
  1707.             get { return m_Bound; }
  1708.         }
  1709.         private MSSqlDataAccess MSDA2 = new MSSqlDataAccess(2);
  1710.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  1711.         private QueryParameterCollection Params = new QueryParameterCollection();
  1712.         public void OrgInit()
  1713.         {
  1714.             string strSQL = "delete from Tb_Sys_Organization";
  1715.             string InSQL = "",SSQL="";
  1716.             MSDA.Open();
  1717.             SqlTransaction tran = MSDA.BeginTransaction();
  1718.             try
  1719.             {
  1720.                 MSDA2.Open();
  1721.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1722.                 strSQL = "insert into Tb_Sys_Organization values(1,-1,'供电公司','芜湖市供电公司',1,1,'2007-04-01','行政','1','0')";
  1723.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1724.                 strSQL = "select menuid,supermenuid,dept_name from usertype where actionpage1='#' and menuid>9999 order by supermenuid";
  1725.                 DataView dv = MSDA2.ExecuteDataView(CommandType.Text, strSQL, null);
  1726.                 int i = 1;
  1727.                 for (int j = 0; j < dv.Table.Rows.Count;j++ )
  1728.                 {
  1729.                     i++;
  1730.                     EtongFlyChouInit EFlyInit = new EtongFlyChouInit();
  1731.                     EFlyInit.m_ID = i;
  1732.                     if (dv.Table.Rows[j]["menuid"].ToString().Length == 6)
  1733.                     {
  1734.                         EFlyInit.m_pDI = 1;
  1735.                         EFlyInit.m_Level = 2;
  1736.                         EFlyInit.m_Path = "1/" + EFlyInit.m_ID.ToString();
  1737.                         switch (EFlyInit.m_ID)
  1738.                         {
  1739.                             case 2:
  1740.                                 EFlyInit.m_CID = "a";
  1741.                                 break;
  1742.                             case 3:
  1743.                                 EFlyInit.m_CID = "b";
  1744.                                 break;
  1745.                             case 4:
  1746.                                 EFlyInit.m_CID = "c";
  1747.                                 break;
  1748.                             case 5:
  1749.                                 EFlyInit.m_CID = "d";
  1750.                                 break;
  1751.                             case 6:
  1752.                                 EFlyInit.m_CID = "e";
  1753.                                 break;
  1754.                             default:
  1755.                                 EFlyInit.m_CID = "1";
  1756.                                 break;
  1757.                         }
  1758.                     }
  1759.                     else if (dv.Table.Rows[j]["menuid"].ToString().Length > 6)
  1760.                     {
  1761.                         Params.Clear();
  1762.                         SSQL = "P_GetOrgzationZF";
  1763.                         Params.Add("@param_menuid", Convert.ToInt32(dv.Table.Rows[j][1].ToString()));
  1764.                         DataView dv1=MSDA2.ExecuteDataView(CommandType.StoredProcedure, SSQL, Params);
  1765.                         //EFlyInit.m_pDI = Convert.ToInt32(dv.Table.Rows[0][0].ToString());
  1766.                         //if (dr["menuid"].ToString().Length == 8)
  1767.                         //{
  1768.                         EFlyInit.m_pDI = Convert.ToInt32(dv1.Table.Rows[0][0].ToString());
  1769.                         EFlyInit.m_Level = 3;
  1770.                         EFlyInit.m_Path = "1/" + EFlyInit.m_pDI.ToString() + "/" + EFlyInit.m_ID.ToString();
  1771.                         //}
  1772.                         //else
  1773.                         //{
  1774.                         //    EFlyInit.m_Level = 4;
  1775.                         //    EFlyInit.m_Path = "1/" + EFlyInit.m_pDI.ToString() + "/" + i.ToString();
  1776.                         //}
  1777.                         EFlyInit.m_CID = "1";
  1778.                     }
  1779.                     EFlyInit.m_Name = dv.Table.Rows[j]["dept_name"].ToString();
  1780.                     EFlyInit.m_Decs = "物资系统导入";
  1781.                     EFlyInit.m_Inal = 1;
  1782.                     EFlyInit.m_Edit = System.DateTime.Now;
  1783.                     EFlyInit.m_Type = dv.Table.Rows[j]["menuid"].ToString();
  1784.                     InSQL = "insert into Tb_Sys_Organization values(" + EFlyInit.m_ID + "," + EFlyInit.m_pDI + ",'" + EFlyInit.m_Name +
  1785.                         "','" + EFlyInit.m_Decs + "'," + EFlyInit.m_Inal + "," + EFlyInit.m_Level + ",'" + EFlyInit.m_Edit + "','" +
  1786.                         EFlyInit.m_Type + "','" + EFlyInit.m_Path + "','" + EFlyInit.m_CID + "')";
  1787.                     MSDA.ExecuteNonQuery(CommandType.Text, InSQL, null);
  1788.                 }
  1789.                 tran.Commit();
  1790.             }
  1791.             catch (Exception ex)
  1792.             {
  1793.                 tran.Rollback();
  1794.                 throw ex;
  1795.             }
  1796.             finally
  1797.             {
  1798.                 MSDA2.Close();
  1799.                 MSDA.Close();
  1800.             }
  1801.         }
  1802.         public void EmpInit()
  1803.         {
  1804.             string InSQL = "";
  1805.             string SSQL = "";
  1806.             string strSQL = "delete from Tb_Sys_Employee";
  1807.             MSDA.Open();
  1808.             SqlTransaction tran = MSDA.BeginTransaction();
  1809.             try
  1810.             {
  1811.                 MSDA2.Open();
  1812.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1813.                 strSQL = "delete from Tb_Sys_User";
  1814.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1815.                 strSQL = "insert into Tb_Sys_User values(NULL,'admin','NULL','系统用户',NULL,'111111',0,NULL,0,'2007-04-01','','')";
  1816.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1817.                 strSQL = "delete from Tb_Sys_UserRole";
  1818.                 MSDA.ExecuteNonQuery(CommandType.Text, strSQL, null);
  1819.                 strSQL = "select menuid,supermenuid,passwd,dept_name,pym from usertype where actionpage1='sys_person_main.asp' and pym<>''";
  1820.                 SqlDataReader dr = MSDA2.ExecuteReader(CommandType.Text, strSQL, null);
  1821.                 int i = 0;
  1822.                 while (dr.Read() == true)
  1823.                 {
  1824.                     EtongFlyChouInit EFlyInit = new EtongFlyChouInit();
  1825.                     i++;
  1826.                     EFlyInit.m_ID = i;
  1827.                     SSQL = "select OrgID from Tb_Sys_Organization where OrgType='" + dr["supermenuid"].ToString() + "'";
  1828.                     DataView dv = MSDA.ExecuteDataView(CommandType.Text, SSQL, null);
  1829.                     if (dv.Table.Rows.Count > 0) EFlyInit.m_pDI = Convert.ToInt32(dv.Table.Rows[0][0].ToString());
  1830.                     else EFlyInit.m_pDI = -1;
  1831.                     EFlyInit.m_Name = dr["dept_name"].ToString();
  1832.                     EFlyInit.m_Level = 1;
  1833.                     EFlyInit.m_Decs = "wz@wz.com";
  1834.                     EFlyInit.m_Path = "";
  1835.                     EFlyInit.m_Edit = System.DateTime.Now;
  1836.                     EFlyInit.m_Inal = 0;
  1837.                     InSQL = "insert into Tb_Sys_Employee values(" + EFlyInit.m_ID + ",'" + EFlyInit.m_Name + "'," + EFlyInit.m_pDI +
  1838.                         "," + EFlyInit.m_Level + ",'" + EFlyInit.m_Decs + "','" + EFlyInit.m_Path + "','" + EFlyInit.m_Edit + "'," +
  1839.                         EFlyInit.m_Inal + ")";
  1840.                     MSDA.ExecuteNonQuery(CommandType.Text, InSQL, null);
  1841.                     EFlyInit.m_pDI = i;
  1842.                     EFlyInit.m_CID = dr["pym"].ToString();
  1843.                     EFlyInit.m_Path = "";
  1844.                     EFlyInit.m_Decs = "物资系统导入";
  1845.                     EFlyInit.m_Level = 1;
  1846.                     EFlyInit.m_Pwd = dr["passwd"].ToString();
  1847.                     EFlyInit.m_Inal = 0;
  1848.                     EFlyInit.m_Type = "";
  1849.                     EFlyInit.m_Bound = 0;
  1850.                     InSQL = "insert into Tb_Sys_User values(" + EFlyInit.m_pDI +",'" + EFlyInit.m_CID + "','" +
  1851.                         EFlyInit.m_Path + "','" + EFlyInit.m_Decs + "','" + EFlyInit.m_Level + "','" +
  1852.                         EFlyInit.m_Pwd + "'," + EFlyInit.m_Inal + ",'" + EFlyInit.m_Type + "'," + 
  1853.                         EFlyInit.m_Bound + ",'" + EFlyInit.m_Edit + "','','')";
  1854.                     MSDA.ExecuteNonQuery(CommandType.Text, InSQL, null);
  1855.                 }
  1856.                 dr.Close();
  1857.                 tran.Commit();
  1858.             }
  1859.             catch (Exception ex)
  1860.             {
  1861.                 tran.Rollback();
  1862.                 throw ex;
  1863.             }
  1864.             finally
  1865.             {
  1866.                 MSDA.Close();
  1867.                 MSDA2.Close();
  1868.             }
  1869.         }
  1870.     }
  1871.     //Word编辑器
  1872.     public class EtongWord
  1873.     {
  1874.         private int m_FID;                  //文件ID
  1875.         private string m_FName;             //文件名称
  1876.         private string m_FDesc;             //文件描述
  1877.         private int m_Role;                 //业务角色
  1878.         private ArrayList m_AFID;           //文件ID数组
  1879.         private int m_ActID;                //活动ID
  1880.         private string m_Address;           //xml路径
  1881.         private string m_XmlNodesNames;     //xml节点名
  1882.         private string m_OpSort;            //类型(生产、营销等)
  1883.         private int m_sort;                 //类型是否要解析(-1不解析)
  1884.         public int FID
  1885.         {
  1886.             set { m_FID = value; }
  1887.             get { return m_FID; }
  1888.         }
  1889.         public string FName
  1890.         {
  1891.             set { m_FName = value; }
  1892.             get { return m_FName; }
  1893.         }
  1894.         public string FDesc
  1895.         {
  1896.             set { m_FDesc = value; }
  1897.             get { return m_FDesc; }
  1898.         }
  1899.         public int Role
  1900.         {
  1901.             set { m_Role = value; }
  1902.             get { return m_Role; }
  1903.         }
  1904.         public ArrayList AFID
  1905.         {
  1906.             set {m_AFID =value;}
  1907.             get {return m_AFID;}
  1908.         }
  1909.         public int ActID
  1910.         {
  1911.             set { m_ActID = value; }
  1912.             get { return m_ActID; }
  1913.         }
  1914.         public string Address
  1915.         {
  1916.             set { m_Address = value; }
  1917.             get { return m_Address; }
  1918.         }
  1919.         public string XmlNodesNames
  1920.         {
  1921.             set { m_XmlNodesNames = value; }
  1922.             get { return m_XmlNodesNames; }
  1923.         }
  1924.         public string opSort
  1925.         {
  1926.             set { m_OpSort = value; }
  1927.             get { return m_OpSort; }
  1928.         }
  1929.         public int sort
  1930.         {
  1931.             set { m_sort = value; }
  1932.             get { return m_sort; }
  1933.         }
  1934.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  1935.         private QueryParameterCollection Params = new QueryParameterCollection();
  1936.         public DataView GetAllFName()
  1937.         {
  1938.             DataView dv = new DataView();
  1939.             string sSQL = "select * from tb_sys_FileName";
  1940.             try
  1941.             {
  1942.                 MSDA.Open();
  1943.                 dv = MSDA.ExecuteDataView(CommandType.Text, sSQL, null);
  1944.             }
  1945.             catch (Exception ex)
  1946.             {
  1947.                 throw ex;
  1948.             }
  1949.             finally
  1950.             {
  1951.                 MSDA.Close();
  1952.             }
  1953.             return dv;
  1954.         }
  1955.         public DataView GetFNameByCondition()
  1956.         {
  1957.             DataView dv = new DataView();
  1958.             string sSQL = "select * from tb_sys_FileName";
  1959.             if (m_FID != 0)
  1960.             {
  1961.                 sSQL = sSQL + " where fid=" + m_FID;
  1962.             }
  1963.             else if (m_FName != null && m_FName !="")
  1964.             {
  1965.                 sSQL = sSQL + " where fname='" + m_FName + "'";
  1966.             }
  1967.             try
  1968.             {
  1969.                 MSDA.Open();
  1970.                 dv = MSDA.ExecuteDataView(CommandType.Text, sSQL, null);
  1971.             }
  1972.             catch (Exception ex)
  1973.             {
  1974.                 throw ex;
  1975.             }
  1976.             finally
  1977.             {
  1978.                 MSDA.Close();
  1979.             }
  1980.             return dv;
  1981.         }
  1982.         public void Insert()
  1983.         {
  1984.             string sSQL = "INSERT INTO tb_sys_FileName values('" + m_FName + "','" + m_FDesc + "')";
  1985.             try
  1986.             {
  1987.                 MSDA.Open();
  1988.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  1989.             }
  1990.             catch (Exception ex)
  1991.             {
  1992.                 throw ex;
  1993.             }
  1994.             finally
  1995.             {
  1996.                 MSDA.Close();
  1997.             }
  1998.         }
  1999.         public void Update()
  2000.         {
  2001.             string sSQL = "UPDATE tb_sys_FileName set FName='" + m_FName + "',FDesc='" + m_FDesc + "' where FID=" + m_FID;
  2002.             try
  2003.             {
  2004.                 MSDA.Open();
  2005.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  2006.             }
  2007.             catch (Exception ex)
  2008.             {
  2009.                 throw ex;
  2010.             }
  2011.             finally
  2012.             {
  2013.                 MSDA.Close();
  2014.             }
  2015.         }
  2016.         public void Delete()
  2017.         {
  2018.             try
  2019.             {
  2020.                 MSDA.Open();
  2021.                 string sSQL = "delete from tb_sys_FileName where FID=" + m_FID;
  2022.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  2023.             }
  2024.             catch (Exception ex)
  2025.             {
  2026.                 throw ex;
  2027.             }
  2028.             finally
  2029.             {
  2030.                 MSDA.Close();
  2031.             }
  2032.         }
  2033.         public DataView GetRoleFNameByCondition()
  2034.         {
  2035.             DataView dv = new DataView();
  2036.             string sSQL = "select * from tb_wf_RoleFName";
  2037.             if (m_Role !=0)
  2038.             {
  2039.                 sSQL = sSQL + " where opid=" + m_Role;
  2040.             }
  2041.             else if (m_FID !=0)
  2042.             {
  2043.                 sSQL = sSQL + " where fid=" + m_FID;
  2044.             }
  2045.             try
  2046.             {
  2047.                 MSDA.Open();
  2048.                 dv = MSDA.ExecuteDataView(CommandType.Text,sSQL,null);
  2049.             }
  2050.             catch (Exception ex)
  2051.             {
  2052.                 throw ex;
  2053.             }
  2054.             finally 
  2055.             {
  2056.                 MSDA.Close();
  2057.             }
  2058.             return dv;
  2059.         }
  2060.         public void RInsert()
  2061.         {
  2062.             string sSQL;
  2063.             MSDA.Open();
  2064.             SqlTransaction tran = MSDA.BeginTransaction();
  2065.             try
  2066.             {
  2067.                 
  2068.                 for (int i = 0; i < m_AFID.Count; i++)
  2069.                 {
  2070.                     sSQL = "insert into tb_WF_RoleFName values(" + Convert.ToInt32(m_AFID[i]) + "," + m_Role + ")";
  2071.                     MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  2072.                 }
  2073.                 tran.Commit();
  2074.             }
  2075.             catch (Exception ex)
  2076.             {
  2077.                 tran.Rollback();
  2078.                 throw ex;
  2079.             }
  2080.             finally
  2081.             {
  2082.                 MSDA.Close();
  2083.             }
  2084.         }
  2085.         public void RUpdate()
  2086.         {
  2087.             string sSQL = "";
  2088.             MSDA.Open();
  2089.             SqlTransaction tran = MSDA.BeginTransaction();
  2090.             try
  2091.             {
  2092.                 sSQL = "delete from tb_WF_RoleFName where opid=" + m_Role;
  2093.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  2094.                 for (int i = 0; i < m_AFID.Count; i++)
  2095.                 {
  2096.                     sSQL = "insert into tb_WF_RoleFName values(" + Convert.ToInt32(m_AFID[i]) + "," + m_Role + ")";
  2097.                     MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  2098.                 }
  2099.                 tran.Commit();
  2100.             }
  2101.             catch (Exception ex)
  2102.             {
  2103.                 tran.Rollback();
  2104.                 throw ex;
  2105.             }
  2106.             finally
  2107.             {
  2108.                 MSDA.Close();
  2109.             }
  2110.         }
  2111.         public void RDelete()
  2112.         {
  2113.             string sSQL = "delete from tb_WF_RoleFName where opid=" + m_Role;
  2114.             try
  2115.             {
  2116.                 MSDA.Open();
  2117.                 MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  2118.             }
  2119.             catch (Exception ex)
  2120.             {
  2121.                 throw ex;
  2122.             }
  2123.             finally
  2124.             {
  2125.                 MSDA.Close();
  2126.             }
  2127.         }
  2128.         public DataView GetFNameByActID()
  2129.         {
  2130.             string sSQL = "select * from tb_Sys_FileName where FID in (select FID from tb_Colony_FileName1 where ActivityID=" + m_ActID + ")";
  2131.             DataView dv = new DataView();
  2132.             try
  2133.             {
  2134.                 MSDA.Open();
  2135.                 dv = MSDA.ExecuteDataView(CommandType.Text, sSQL, null);
  2136.             }
  2137.             catch (Exception ex)
  2138.             {
  2139.                 throw ex;
  2140.             }
  2141.             finally
  2142.             {
  2143.                 MSDA.Close();
  2144.             }
  2145.             return dv;
  2146.         }
  2147.         public ArrayList ReadXMLFName()
  2148.         {
  2149.             
  2150.             ArrayList al = new ArrayList();
  2151.             XmlDocument XmlDoc = new XmlDocument();
  2152.             XmlDoc.Load(this.m_Address);
  2153.             XmlNodeList NodeList = XmlDoc.SelectSingleNode(this.m_XmlNodesNames).ChildNodes;
  2154.             foreach (XmlNode Xn in NodeList)
  2155.             {
  2156.                 XmlElement Xe = (XmlElement)Xn;
  2157.                 XmlNodeList NodeList1 = Xe.ChildNodes;
  2158.                 string FName = "", EmpName = "", OpSort = "", sDate = "";
  2159.                 foreach (XmlNode Xn1 in NodeList1)
  2160.                 {
  2161.                     XmlElement Xe1 = (XmlElement)Xn1;
  2162.                     switch (Xe1.Name)
  2163.                     {
  2164.                         case "DocFileName":
  2165.                             FName = Xe1.InnerText;
  2166.                             break;
  2167.                         case "EmpName":
  2168.                             EmpName = Xe1.InnerText;
  2169.                             break;
  2170.                         case "OpSort":
  2171.                             OpSort = Xe1.InnerText;
  2172.                             break;
  2173.                         case "Date":
  2174.                             sDate = Xe1.InnerText;
  2175.                             break;
  2176.                         default:
  2177.                             break;
  2178.                     }
  2179.                 }
  2180.                 if (this.m_sort == -1)
  2181.                 {
  2182.                     EtongXml EXml = new EtongXml();
  2183.                     EXml.DocFileName = FName;
  2184.                     EXml.EmpName = EmpName;
  2185.                     EXml.OpSort = opSort;
  2186.                     EXml.sDate = sDate;
  2187.                     al.Add(EXml);
  2188.                 }
  2189.                 else
  2190.                 {
  2191.                     if (OpSort.Trim() == this.opSort.Trim())
  2192.                     {
  2193.                         EtongXml EXml = new EtongXml();
  2194.                         EXml.DocFileName = FName;
  2195.                         EXml.EmpName = EmpName;
  2196.                         EXml.OpSort = opSort;
  2197.                         EXml.sDate = sDate;
  2198.                         al.Add(EXml);
  2199.                     }
  2200.                 }
  2201.             }
  2202.             return al;
  2203.         }
  2204.     }
  2205.     public class EtongXml
  2206.     {
  2207.         private string m_DocFileName;
  2208.         private string m_EmpName;
  2209.         private string m_OpSort;
  2210.         private string m_sDate;
  2211.         public string DocFileName
  2212.         {
  2213.             set { m_DocFileName=value;}
  2214.             get { return m_DocFileName;}
  2215.         }
  2216.         public string EmpName
  2217.         {
  2218.             set {m_EmpName =value;}
  2219.             get {return m_EmpName;}
  2220.         }
  2221.         public string OpSort
  2222.         {
  2223.             set {m_OpSort =value;}
  2224.             get {return m_OpSort;}
  2225.         }
  2226.         public string sDate
  2227.         {
  2228.             set {m_sDate =value;}
  2229.             get {return m_sDate;}
  2230.         }
  2231.                 
  2232.     }
  2233.     public class EtongFXml
  2234.     {
  2235.         private ArrayList m_NodesName;      //子节点名称
  2236.         private ArrayList m_Nodes;          //子节点内容
  2237.         private string m_Address;           //xml路径
  2238.         private string m_RootNodesName;     //根节点名
  2239.         public ArrayList NodesName
  2240.         {
  2241.             set { m_NodesName = value; }
  2242.             get { return m_NodesName; }
  2243.         }
  2244.         public ArrayList Nodes
  2245.         {
  2246.             set { m_Nodes = value; }
  2247.             get { return m_Nodes; }
  2248.         }
  2249.         public string Address
  2250.         {
  2251.             set { m_Address = value; }
  2252.             get { return m_Address; }
  2253.         }
  2254.         public string RootNodesName
  2255.         {
  2256.             set { m_RootNodesName = value; }
  2257.             get { return m_RootNodesName; }
  2258.         }
  2259.         /// <summary>
  2260.         /// 读取Xml
  2261.         /// </summary>
  2262.         /// 子节点名称:m_NodesName       NodesNmae
  2263.         /// xml路径   :m_Address         Address
  2264.         /// 根节点名  :m_RootNodesName   RootNodesName
  2265.         /// <returns>节点内容数组</returns>
  2266.         public ArrayList ReadXML()
  2267.         {
  2268.             ArrayList al = new ArrayList();
  2269.             XmlDocument XmlDoc = new XmlDocument();
  2270.             XmlDoc.Load(this.m_Address);
  2271.             XmlNodeList NodeList = XmlDoc.SelectSingleNode(this.m_RootNodesName).ChildNodes;
  2272.             foreach (XmlNode Xn in NodeList)
  2273.             {
  2274.                 XmlElement Xe = (XmlElement)Xn;
  2275.                 XmlNodeList NodeList1 = Xe.ChildNodes;
  2276.                 //指定命名空间的属性Xe.GetAttribute("")
  2277.                 string[] s = new string[this.NodesName.Count]; 
  2278.                 foreach (XmlNode Xn1 in NodeList1)
  2279.                 {
  2280.                     XmlElement Xe1 = (XmlElement)Xn1;
  2281.                     for (int k = 0; k < this.m_NodesName.Count; k++)
  2282.                     {
  2283.                         if (this.m_NodesName[k].ToString() == Xe1.Name)
  2284.                         {
  2285.                             s[k] = Xe1.InnerText;
  2286.                             break;
  2287.                         }
  2288.                     }
  2289.                     
  2290.                 }
  2291.                al.Add(s);
  2292.             }
  2293.             return al;
  2294.         }
  2295.         /// <summary>
  2296.         /// 写Xml
  2297.         /// </summary>
  2298.         /// 子节点名称:m_NodesName       NodesNmae
  2299.         /// 子节点内容:m_Nodes           Nodes
  2300.         /// xml路径   :m_Address         Address
  2301.         /// 根节点名  :m_RootNodesName   RootNodesName
  2302.         /// <returns>true 成功 :false 失败</returns>
  2303.         public bool WriteXML()
  2304.         {
  2305.             bool bl= true;
  2306.             try
  2307.             {
  2308.                 //初始化XML文档操作类
  2309.                 XmlDocument XmlDoc = new XmlDocument();
  2310.                 //加载指定的XML文件
  2311.                 XmlDoc.Load(this.Address);
  2312.                 if (this.m_Nodes.Count != this.m_NodesName.Count) bl = false;
  2313.                 else
  2314.                 {
  2315.                     //添加文件的节点-msgrecord
  2316.                     XmlNode newElem = XmlDoc.CreateNode("element", this.m_RootNodesName, "");
  2317.                     for (int i = 0; i < this.m_Nodes.Count; i++)
  2318.                     {
  2319.                         //添加元素-节点名称
  2320.                         XmlElement Xe = XmlDoc.CreateElement(this.m_NodesName[i].ToString());
  2321.                         //添加元素-节点内容
  2322.                         XmlText Xt = XmlDoc.CreateTextNode(this.m_Nodes[i].ToString());
  2323.                         //添加元素-生成Xml样式
  2324.                         newElem.AppendChild(Xe);
  2325.                         newElem.LastChild.AppendChild(Xt);
  2326.                     }
  2327.                     //将节点添加到文档中
  2328.                     XmlElement Xeroot = XmlDoc.DocumentElement;
  2329.                     Xeroot.AppendChild(newElem);
  2330.                     //保存所有修改
  2331.                     XmlDoc.Save(this.m_Address);
  2332.                 }
  2333.             }
  2334.             catch
  2335.             {
  2336.                 bl = false;
  2337.             }
  2338.             return bl;
  2339.         }
  2340.     }
  2341. }