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

.net编程

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Configuration;
  5. using System.Data.SqlClient;
  6. using System.Data;
  7. using System.Collections;
  8. using com.etong.DBUtility;
  9. using com.etong.Inform;
  10. using com.etong.SqlDataConnect;
  11. using com.etong.BusinessRule.Zwf;
  12. using com.etong.Model;
  13. using System.Xml;
  14. namespace com.etong.user
  15. {
  16.     public class AllUser
  17.     {
  18.         //设置连接字符串
  19.         private SqlDataConnect.MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  20.         public AllUser()
  21.         {
  22.             //
  23.             // TODO: 在此处添加构造函数逻辑
  24.             //
  25.         }
  26.         /*************************************************************************************************************  
  27.                                              * Module: 用户登陆管理
  28.                                              * Desc: 检验、保存、查询
  29.                                              * Author:徐秀梅
  30.                                              * Date: 2007-03
  31.         **************************************************************************************************************/     
  32.         //根据用户ID返回RoleID
  33.         public ArrayList GetRoleID(int userid)
  34.         {
  35.             ArrayList list = new ArrayList();
  36.             string str = "select RoleID from Tb_Sys_UserRole where UserID="+userid;
  37.             DataSet ds = new DataSet();
  38.             ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "");
  39.             if (ds.Tables[0].Rows.Count > 0)
  40.             {
  41.                 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  42.                 {
  43.                     list.Add(ds.Tables[0].Rows[i][0].ToString());
  44.                 }
  45.             }
  46.             return list; 
  47.         }
  48.         //根据用户名返回EmpID
  49.         public int GetEmpID(int UserID)
  50.         {
  51.             //MSDA.Open();
  52.             int EmpID=0;            
  53.             string str = "select EmpID from Tb_Sys_User where UserID=" + UserID;
  54.             DataSet ds = new DataSet();
  55.             ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "");
  56.             if (ds.Tables[0].Rows.Count>0)
  57.             {
  58.                 if (ds.Tables[0].Rows[0]["EmpID"].ToString() != "")
  59.                 {
  60.                     EmpID = Convert.ToInt32(ds.Tables[0].Rows[0]["EmpID"].ToString());
  61.                 }
  62.             }          
  63.             MSDA.Close();
  64.             return EmpID;
  65.         }
  66.         //检查用户名和密码(带三个参数)
  67.         public CheckUserInfo PCheckUser(int UserID, string UserPwd,string UserIP)
  68.         {
  69.             MSDA.Open();
  70.             //bool flag = false;
  71.             CheckUserInfo checkuserinfo = null;            
  72.             string str = "select IsIPBound,IPAddress,isLock from Tb_Sys_User where UserID=" + UserID + " and UserPwd='" + UserPwd + "'";
  73.             DataSet ds = new DataSet();
  74.             ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "");   
  75.             if (ds.Tables[0].Rows.Count> 0)
  76.             {
  77.                 if (Convert.ToInt16(ds.Tables[0].Rows[0]["isLock"].ToString()) == 1)
  78.                     return checkuserinfo;
  79.      
  80.                 if (Convert.ToInt16(ds.Tables[0].Rows[0]["IsIPBound"].ToString()) == 0)
  81.                 {
  82.                     checkuserinfo = GetCheckUserInfo(UserID);
  83.                 }
  84.                 else
  85.                 {
  86.                     if (Convert.ToInt16(ds.Tables[0].Rows[0]["IsIPBound"].ToString()) == 1)
  87.                     {
  88.                         if (ds.Tables[0].Rows[0]["IPAddress"].ToString() == UserIP)
  89.                         {
  90.                              checkuserinfo = GetCheckUserInfo(UserID);
  91.                              try
  92.                              {
  93.                                  checkuserinfo.UserID = Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"]);
  94.                              }
  95.                              catch
  96.                              {
  97.                                  checkuserinfo.UserID = -1;
  98.                              }
  99.                         }
  100.                     }
  101.                 }
  102.             }
  103.             MSDA.Close();          
  104.             return checkuserinfo;
  105.         }
  106.         //检查用户名和密码(带两个参数)
  107.         public bool PCheckUser(int UserID, string UserPwd)
  108.         {
  109.             MSDA.Open();
  110.             bool flag=false;
  111.             string str="select * from Tb_Sys_User where UserID=" + UserID + " and UserPwd='" + UserPwd + "'";
  112.             SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, str, null);
  113.             if (dr.Read())
  114.             {
  115.                 flag = true;
  116.             }
  117.             MSDA.Close();
  118.             return flag;
  119.         }
  120.         //检查用户名和密码(返回用户名,部门,用户权限)
  121.         public CheckUserInfo GetCheckUserInfo(int UserID)
  122.         { 
  123.             CheckUserInfo checkuserinfo = null;           
  124.             int EmpID = GetEmpID(UserID);
  125.             string UserAccount = GetUserAccount(UserID);
  126.             MSDA.Open();
  127.             if (EmpID != 0||(EmpID==0&&UserAccount=="admin"))
  128.             {
  129.                 checkuserinfo = new CheckUserInfo();
  130.                 checkuserinfo.UserAccount = UserAccount;
  131.                 checkuserinfo.UserID = UserID;
  132.                 checkuserinfo.EmpID = EmpID;
  133.                 DataSet ds = new DataSet();           
  134.                 string str="select EmpName,PrimaryOrgID from Tb_Sys_Employee where EmpID="+ EmpID;
  135.                 ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "");
  136.                 if (ds.Tables[0].Rows.Count > 0)
  137.                 {
  138.                     checkuserinfo.EmpName = ds.Tables[0].Rows[0]["EmpName"].ToString();
  139.                     checkuserinfo.OrgID = Convert.ToInt32(ds.Tables[0].Rows[0]["PrimaryOrgID"]);
  140.                     str = "select OrgName from Tb_Sys_Organization where OrgID=" + checkuserinfo.OrgID;
  141.                     ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "orgname");
  142.                     if (ds.Tables["orgname"].Rows.Count > 0)
  143.                     {
  144.                         checkuserinfo.OrgName = ds.Tables["orgname"].Rows[0]["OrgName"].ToString();
  145.                     }                    
  146.                 }
  147.                 str = "select RoleID from Tb_Sys_User,Tb_Sys_UserRole where Tb_Sys_User.UserID=Tb_Sys_UserRole.UserID and EmpID=" + EmpID;
  148.                 ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "roleid");
  149.                 if (ds.Tables["roleid"].Rows.Count > 0)
  150.                 {
  151.                     if (ds.Tables["roleid"].Rows[0]["RoleID"].ToString() != "")
  152.                     {
  153.                         checkuserinfo.RoleID = Convert.ToInt32(ds.Tables["roleid"].Rows[0]["RoleID"].ToString());
  154.                     }
  155.                 }
  156.                 else
  157.                 {
  158.                     if (UserAccount != "admin")
  159.                     {
  160.                         checkuserinfo.RoleID = -1;
  161.                     }
  162.                 }
  163.             }
  164.             MSDA.Close();
  165.             return checkuserinfo;
  166.         }        
  167.         //根据用户名修改用户密码
  168.         public int PModifyPwd(int UserID, string OldPwd, string NewPwd)
  169.         {           
  170.             int i = -2;                                 
  171.             bool flag = PCheckUser(UserID, OldPwd);
  172.             MSDA.Open();
  173.             string str = "update Tb_Sys_User set UserPwd='" + NewPwd + "'where UserID=" + UserID ;
  174.             if (flag)
  175.             {
  176.                 i = MSDA.ExecuteNonQuery(CommandType.Text, str, null);
  177.                 if (i != -1)
  178.                 {
  179.                     i = 1;
  180.                 }
  181.             }
  182.             MSDA.Close();
  183.             return i;
  184.         }
  185.         //根据职工取UserID
  186.         public DataSet GetUserID(string Empname)
  187.         {
  188.             MSDA.Open();
  189.             string str = "select EmpID from tb_sys_Employee where EmpName='"+Empname+"'";
  190.             DataSet ds1 = null;
  191.             DataSet ds = new DataSet();          
  192.             ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "EmpID");
  193.             if (ds.Tables[0].Rows.Count > 0)
  194.             {
  195.                 int EmpID = Convert.ToInt32(ds.Tables["EmpID"].Rows[0]["EmpID"].ToString());
  196.                 str = "select UserID,UserAccount,OrgName from tb_sys_User a,tb_sys_Employee b,Tb_Sys_Organization c where a.EmpID=" 
  197.                     + EmpID+" and a.EmpID=b.EmpID and b.PrimaryOrgID=c.OrgID";
  198.                 ds1 = new DataSet();
  199.                 ds1 = MSDA.ExecuteDataset(CommandType.Text, str, null, ds1, "UserID");
  200.             }
  201.             MSDA.Close();
  202.             return ds1;                           
  203.         }
  204.         //根据用户名取UserID
  205.         public DataSet GetUserIDFAccount(string Account)
  206.         {
  207.             MSDA.Open();
  208.             DataSet ds = new DataSet();
  209.             string str = "";
  210.             if (Account != "admin")
  211.             {
  212.                 str = "select UserID,EmpName,OrgName from tb_sys_User a,tb_sys_Employee b,Tb_Sys_Organization c where a.UserAccount like '"
  213.                               + Account + "%'and a.EmpID=b.EmpID and b.PrimaryOrgID=c.OrgID";
  214.             }
  215.             else
  216.             {
  217.                 str = "select UserID from tb_sys_User where UserAccount='admin'";
  218.             }
  219.             ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "UserID");
  220.             MSDA.Close();
  221.             return ds;
  222.         }
  223.         //根据用户ID取用户名
  224.         public string GetUserAccount(int UserID)
  225.         {
  226.             DataSet ds = new DataSet();
  227.             string str = "select UserAccount from tb_sys_User where UserID=" + UserID;
  228.             ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "Account");
  229.             string UserAccount = ds.Tables["Account"].Rows[0]["UserAccount"].ToString();
  230.             MSDA.Close();
  231.             return UserAccount;
  232.         }
  233.     }
  234.     public class Audit
  235.     { 
  236.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  237.         public Audit()
  238.         {
  239.             //
  240.             // TODO: 在此处添加构造函数逻辑
  241.             //
  242.         }
  243.         /*************************************************************************************************************  
  244.                                              * Module: 访问审核控制信息
  245.                                              * Desc: 添加、查询、删除
  246.                                              * Author:徐秀梅
  247.                                              * Date: 2007-04
  248.         **************************************************************************************************************/
  249.         /// <summary>
  250.         /// 保存访问信息
  251.         /// </summary>
  252.         /// <returns>返回一bool类型值</returns>
  253.         public bool AuditAdd(string ipaddress, string operation, DateTime editdate, string useraccount, 
  254.             DateTime accesstime,string serviceactionname, int callingresult, string callingmodule, int logcate,string empname,string orgname)
  255.         {
  256.             QueryParameterCollection Params = new QueryParameterCollection();
  257.             Params.Clear();
  258.             Params.Add("@ipaddress", ipaddress);            
  259.             Params.Add("@operation", operation);
  260.             Params.Add("@editdate", editdate);
  261.             Params.Add("@useraccount", useraccount);
  262.             Params.Add("@accesstime", accesstime);
  263.             Params.Add("@serviceactionname", serviceactionname);
  264.             Params.Add("@callingresult", callingresult);
  265.             Params.Add("@callingmodule", callingmodule);
  266.             Params.Add("@logcate", logcate);
  267.             Params.Add("@empname", empname);
  268.             Params.Add("@orgname", orgname);
  269.             string sql = "insert into Tb_Sys_Audit values (@ipaddress,'',@operation,@editdate,@useraccount,@accesstime,'localhost',@serviceactionname,'localhost',@callingresult,@callingmodule,@logcate,@empname,@orgname)";
  270.             MSDA.Open();
  271.             NewObj obj = new NewObj();
  272.             bool returnvalue = obj.insert(sql, Params, CommandType.Text);
  273.             MSDA.Close();
  274.             return returnvalue; 
  275.         }
  276.         /// <summary>
  277.         /// 删除访问信息
  278.         /// </summary>
  279.         public void AuditDelete(int auditid)
  280.         {
  281.             string sql = "delete from Tb_Sys_Audit where [AuditID]='" + auditid + "'";
  282.             MSDA.Open();
  283.             MSDA.ExecuteNonQuery(CommandType.Text, sql, null);
  284.             MSDA.Close();
  285.         }
  286.         /// <summary>
  287.         /// 查找指定或全部物资代码记录
  288.         /// </summary>
  289.         /// <param name="SearchTxt">查找内容</param>
  290.         /// <param name="i">查找关键字,例:1:IP地址;2:用户帐号;3:用户名称;4:组织机构;5:访问时间;非1,2,3,4,5且SearchTxt为空:查找全部</param>
  291.         public DataView AuditSearch(string SearchTxt, string i, DateTime StartTime, DateTime EndTime)
  292.         {
  293.             string sql = "select * from Tb_Sys_Audit";
  294.             if (i == "1" && SearchTxt != "")
  295.             {
  296.                 sql = sql + "  where [IPAddress]='" + SearchTxt + "'";
  297.             }
  298.             if (i == "2" && SearchTxt != "")
  299.             {
  300.                 sql = sql + " where [UserAccount]='" + SearchTxt + "'";
  301.             }
  302.             if (i == "3" && SearchTxt != "")
  303.             {
  304.                 sql = sql + " where [EmpName]='" + SearchTxt + "'";
  305.             }
  306.             if (i == "4" && SearchTxt != "")
  307.             {
  308.                 sql = sql + " where [OrgName]='" + SearchTxt + "'";
  309.             }
  310.             if (i=="5" && StartTime != null && EndTime != null)
  311.             {
  312.                 sql = sql + " where [AccessTime] between '" + StartTime + "'and '" + EndTime + "'";
  313.             }  
  314.             DataSet ds = new DataSet();
  315.             MSDA.Open();
  316.             NewObj newobject = new NewObj();
  317.             DataView dv = newobject.Search(sql, null, CommandType.Text).Tables[0].DefaultView;
  318.             MSDA.Close();
  319.             return dv;
  320.         }        
  321.     }
  322.     public class Notice
  323.     {
  324.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);    
  325.         public Notice()
  326.         {
  327.             //
  328.             // TODO: 在此处添加构造函数逻辑
  329.             //
  330.         }
  331.         /*************************************************************************************************************  
  332.                                              * Module: 工作流公告管理
  333.                                              * Desc: 添加、更新、删除、查询记录
  334.                                              * Author:徐秀梅
  335.                                              * Date: 2007-04
  336.         **************************************************************************************************************/
  337.         /// <summary>
  338.         /// 添加工作流公告
  339.         /// </summary>
  340.         /// <returns>返回一bool类型值</returns>
  341.         public bool NoticeAdd(string noticetitle,string noticecontent,DateTime invaiddate,DateTime noticedate,int createuserid,int assroleid,int assuserid)
  342.         {
  343.             QueryParameterCollection Params = new QueryParameterCollection();
  344.             Params.Clear();
  345.             Params.Add("@noticetitle", noticetitle);
  346.             Params.Add("@noticecontent", noticecontent);
  347.             Params.Add("@invaiddate", invaiddate);
  348.             Params.Add("@noticedate", noticedate);
  349.             Params.Add("@createuserid", createuserid);
  350.             Params.Add("@assroleid", assroleid);
  351.             Params.Add("@assuserid", assuserid);
  352.             string sSQL = "insert into tb_Notice([NoticeTitle],[NoticeContent],[InvaidDate],[NoticeDate],[CreateUserID],[AssRoleID],[AssUserID]) values(" +
  353.                            "@noticetitle ,@noticecontent,@invaiddate,@noticedate,@createuserid,@assroleid,@assuserid)";
  354.             MSDA.Open();
  355.             NewObj newobject = new NewObj();
  356.             bool returnvalue = newobject.insert(sSQL, Params, CommandType.Text);
  357.             MSDA.Close();
  358.             return returnvalue;
  359.         }
  360.         /// <summary>
  361.         /// 更新工作流公告记录
  362.         /// </summary>
  363.         /// <returns>返回bool类型参数</returns>
  364.         public bool NoticeUpdate(int noticeid,string noticetitle, string noticecontent, DateTime invaiddate, int assroleid, int assuserid)
  365.         {
  366.             QueryParameterCollection Params = new QueryParameterCollection();
  367.             Params.Clear();
  368.             Params.Add("@noticeid", noticeid);
  369.             Params.Add("@noticetitle", noticetitle);
  370.             Params.Add("@noticecontent", noticecontent);
  371.             Params.Add("@invaiddate", invaiddate);
  372.             //Params.Add("@noticedate", noticedate);
  373.             //Params.Add("@createuserid", createuserid);
  374.             Params.Add("@assroleid", assroleid);
  375.             Params.Add("@assuserid", assuserid);
  376.             string sSQL = "update Tb_Notice Set NoticeTitle=@noticetitle,NoticeContent=@noticecontent,InvaidDate=@invaiddate,AssRoleID=@assroleid,AssUserID=@assuserid where NoticeID=@noticeid";
  377.             MSDA.Open();
  378.             NewObj newobject = new NewObj();
  379.             bool returnvalue = newobject.Update(sSQL, Params, CommandType.Text);
  380.             MSDA.Close();
  381.             return returnvalue;
  382.         }
  383.         /// <summary>
  384.         /// 删除工作流公告记录
  385.         /// </summary>
  386.         /// <param name="userid">公告ID</param>
  387.         public void NoticeDelete(int NoticeID)
  388.         {
  389.             string sSQL = "delete from Tb_Notice where [NoticeID]='" + NoticeID + "'";
  390.             MSDA.Open();
  391.             MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  392.             MSDA.Close();
  393.         }
  394.         public void NoticeDelete(int UserID,DateTime starttime,DateTime endtime)
  395.         {
  396.             string sSQL = "delete from Tb_Notice where [NoticeDate] between '" + starttime + "'and '"+endtime+"'";
  397.             if (UserID != 0)
  398.             {
  399.                 sSQL += " and [CreateUserID]=" + UserID;
  400.             }
  401.             MSDA.Open();
  402.             MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
  403.             MSDA.Close();
  404.         }
  405.         /// <summary>
  406.         /// 查找工作流公告记录
  407.         /// </summary>      
  408.         public DataView NoticeSearch(int createuserid,int NoticeID)//查找可以修改删除的
  409.         {
  410.             SqlParameter[] paramters ={
  411.                 new SqlParameter ("@Param_UserID",SqlDbType.Int ,4),
  412.                 new SqlParameter ("@Param_NoticID",SqlDbType.Int ,4)
  413.             };
  414.             paramters[0].Value = createuserid;
  415.             paramters[1].Value = NoticeID;
  416.             MSDA.Open();
  417.             DataSet ds =SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetDataNotic", paramters);
  418.             DataView dv = ds.Tables[0].DefaultView;
  419.             MSDA.Close();
  420.             return dv; 
  421.         }
  422.         public DataSet NoticeSearch(DateTime start,DateTime end)//查找某时间段的记录
  423.         {
  424.             string sSQL = "select [NoticeID],[NoticeTitle],[NoticeContent],[InvaidDate],[NoticeDate],[CreateUserID],[AssRoleID],[AssUserID],[UserAccount] from Tb_Notice a,TB_Sys_User b where [NoticeDate] between '"+start+"' and '"+end+"' and a.CreateUserID=b.UserID";
  425.             DataSet ds = new DataSet();
  426.             MSDA.Open();
  427.             ds = MSDA.ExecuteDataset(CommandType.Text, sSQL, null, ds, "");
  428.             MSDA.Close();
  429.             return ds;          
  430.         }
  431.         public DataTable  NoticeSearch(int userid,DateTime invaiddate)//查找用户可以浏览的
  432.         {
  433.             string sSQL = "select [NoticeTitle],[NoticeContent],[NoticeDate],[CreateUserID] from Tb_Notice where "
  434.             +"AssRoleID in (select roleid from Tb_Sys_UserRole where userid = "+userid+") or AssUserID="+userid+" or AssUserID=-1 and InvaidDate>='" + invaiddate+"'";            
  435.             DataTable dt = new DataTable();           
  436.             MSDA.Open();
  437.             NewObj newobject = new NewObj();
  438.             dt = newobject.Search(sSQL, null, CommandType.Text).Tables[0];
  439.             MSDA.Close();
  440.             return dt;
  441.         }
  442.         /// <summary>
  443.         /// 根据角色查找职工记录
  444.         /// </summary>
  445.         public DataView GetUser(int RoleID)
  446.         {
  447.             string sSQL = "select b.userid,empname from tb_sys_employee a,tb_sys_user b,tb_sys_userrole c " +
  448.             "where a.empid=b.empid and b.userid=c.userid and c.roleid=" + RoleID;
  449.             DataSet ds = new DataSet();
  450.             MSDA.Open();
  451.             NewObj newobject = new NewObj();
  452.             DataView dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
  453.             MSDA.Close();
  454.             return dv; 
  455.         }
  456.         /// <summary>
  457.         /// 根据用户ID查找职工姓名(EmpName)
  458.         /// </summary>
  459.         public string GetEmpName(int UserID)
  460.         {
  461.             string empname = "";
  462.             string sSQL = "select Empname from tb_sys_employee where empid = (select empid from tb_sys_user where userid=" + UserID+")";
  463.             MSDA.Open();
  464.             DataSet ds = new DataSet();
  465.             ds = MSDA.ExecuteDataset(CommandType.Text, sSQL, null, ds, "EmpName");
  466.             if (ds.Tables[0].Rows.Count > 0)
  467.             {
  468.                 empname = ds.Tables[0].Rows[0]["EmpName"].ToString();
  469.             }
  470.             MSDA.Close();
  471.             return empname;
  472.         }               
  473.     }
  474.     /*************************************************************************************************************  
  475.                                            * Module: 验收工作流项目状态查询                                       
  476.                                            * Author:徐秀梅
  477.                                            * Date: 2007-05
  478.       **************************************************************************************************************/
  479.     public class Status
  480.     {
  481.         private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  482.         public Status()
  483.         {
  484.             //
  485.             // TODO: 在此处添加构造函数逻辑
  486.             //
  487.         }      
  488.         /// <summary>
  489.         /// 查询
  490.         /// </summary>
  491.         /// <returns>返回一dataview类型值</returns>
  492.         public DataView StatusSearch()
  493.         {            
  494.             MSDA.Open();
  495.             DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetStatusProject", null);
  496.             DataView dv = ds.Tables[0].DefaultView;
  497.             MSDA.Close();
  498.             return dv;                     
  499.         }
  500.         /// <summary>
  501.         /// 验收流程查询
  502.         /// </summary>
  503.         /// <returns>返回一dataview类型值</returns>
  504.         public DataView StatusSearch1()
  505.         {
  506.             MSDA.Open();
  507.             DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetStatusProject1", null);
  508.             DataView dv = ds.Tables[0].DefaultView;
  509.             MSDA.Close();
  510.             return dv;
  511.         }
  512.         /// <summary>
  513.         /// 废旧物质流程查询
  514.         /// </summary>
  515.         /// <returns>返回一dataview类型值</returns>
  516.         public DataView OldMatStatusSearch()
  517.         {
  518.             MSDA.Open();
  519.             DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetOldMatStatusProject", null);
  520.             DataView dv = ds.Tables[0].DefaultView;
  521.             MSDA.Close();
  522.             return dv;
  523.         }
  524.         /// <summary>
  525.         /// 查询Prj
  526.         /// </summary>
  527.         /// <returns>返回一dataset类型值</returns>
  528.         public DataSet AllStatusSearch(int PrjID)
  529.         {
  530.             MSDA.Open();
  531.             SqlParameter paramter = new SqlParameter("@PrjID", SqlDbType.Int, 4);
  532.             paramter.Value = PrjID;
  533.             DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetAllStatus", paramter); 
  534.             MSDA.Close();
  535.             return ds;
  536.         }
  537.         /// <summary>
  538.         /// 查询验收Prj
  539.         /// </summary>
  540.         /// <returns>返回一dataset类型值</returns>
  541.         public DataSet AllStatusSearch1(int PrjID)
  542.         {
  543.             MSDA.Open();
  544.             SqlParameter paramter = new SqlParameter("@PrjID", SqlDbType.Int, 4);
  545.             paramter.Value = PrjID;
  546.             DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetAllStatus1", paramter);
  547.             MSDA.Close();
  548.             return ds;
  549.         }
  550.         /// <summary>
  551.         /// 查询废旧物质Prj
  552.         /// </summary>
  553.         /// <returns>返回一dataset类型值</returns>
  554.         public DataSet OldMatAllStatusSearch(int PrjID)
  555.         {
  556.             MSDA.Open();
  557.             SqlParameter paramter = new SqlParameter("@PrjID", SqlDbType.Int, 4);
  558.             paramter.Value = PrjID;
  559.             DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_OldMatGetAllStatus", paramter);
  560.             MSDA.Close();
  561.             return ds;
  562.         }
  563.         //项目查询根据状态和类型
  564.         public DataView PrjQuery(int type,int status)
  565.         {
  566.             DataView dv = new DataView();
  567.             string strSQL="";
  568.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  569.             if (status < -1)
  570.             {
  571.                 status = -212;            //没有数据
  572.             }
  573.             switch(type)
  574.             {
  575.                 case 1://项目施工流程
  576.                     strSQL = "select * from tb_construct";
  577.                     break;
  578.                 case 2://项目施工工程变更和调整
  579.                     strSQL = "select * from tb_PrjAlert";
  580.                     break;
  581.                 case 3://工程管理验收流程
  582.                     strSQL = "select * from tb_PrjCheck";
  583.                     break;
  584.                 case 4://废旧物资管理流程
  585.                     strSQL = "select * from tb_PrjOldMat";
  586.                     break;
  587.                 case 5://项目工程流程
  588.                     strSQL = "select * from tb_Project";
  589.                     break;
  590.             }
  591.             if (status != -1)
  592.             {
  593.                 strSQL = strSQL + " where Status=" + status;
  594.             }
  595.             try
  596.             {
  597.                 MSDA.Open();
  598.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  599.             }
  600.             catch (Exception ex)
  601.             {
  602.                 throw ex;
  603.             }
  604.             finally
  605.             {
  606.                 MSDA.Close();
  607.             }
  608.             return dv;
  609.         }
  610.         //项目查询依据项目代码
  611.         //public DataView PrjQureyData()
  612.         //{
  613.         //    DataView dv = new DataView();
  614.         //    string strSQL;
  615.         //    MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  616.         //    strSQL = "select * from tb_Project where ProjectID=" + this.m_pID;
  617.         //    try
  618.         //    {
  619.         //        MSDA.Open();
  620.         //        dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  621.         //    }
  622.         //    catch (Exception ex)
  623.         //    {
  624.         //        throw ex;
  625.         //    }
  626.         //    finally
  627.         //    {
  628.         //        MSDA.Close();
  629.         //    }
  630.         //    return dv;
  631.         //}
  632.     }
  633.     /*==============================================================================================
  634.      *                               工程管理验收流程
  635.      * ==============================================================================================*/
  636.     public class PrjCheck
  637.     {
  638.         private SqlDataConnect.MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  639.         /// <summary>
  640.         /// 添加项目验收信息,返回"0"表示添加失败,否则成功
  641.         /// </summary>
  642.         /// <param name="prjcheckinfo"></param>
  643.         /// <returns></returns>
  644.         public int AddPrjCheck(PrjCheckInfo prjcheckinfo)
  645.         {
  646.             SqlParameter[] parameters ={ 
  647.                  new SqlParameter("@PrjChID",SqlDbType.Int,4),
  648.                  new SqlParameter("@PrjChName",SqlDbType.VarChar,200),
  649.                  new SqlParameter("@PrjChSort",SqlDbType.VarChar,2),
  650.                  new SqlParameter("@JcTransactor",SqlDbType.VarChar,30),
  651.                  new SqlParameter("@JcCKName",SqlDbType.VarChar,100),
  652.                  new SqlParameter("@JcRKName",SqlDbType.VarChar,100),
  653.                  new SqlParameter("@JcQDName",SqlDbType.VarChar,100),
  654.                  new SqlParameter("@JcHZName",SqlDbType.VarChar,100),
  655.                  new SqlParameter("@CwTransactor",SqlDbType.VarChar,30),
  656.                  new SqlParameter("@CwFName",SqlDbType.VarChar,100),
  657.                  new SqlParameter("@WzTransatctor",SqlDbType.VarChar,30),
  658.                  new SqlParameter("@WzFName",SqlDbType.VarChar,100),
  659.                  new SqlParameter("@ZgTransactor",SqlDbType.VarChar,30),
  660.                  new SqlParameter("@ZgZlFName",SqlDbType.VarChar,100),
  661.                  new SqlParameter("@ZgTzFName",SqlDbType.VarChar,100),
  662.                  new SqlParameter("@ZgHtFName",SqlDbType.VarChar,100),
  663.                  new SqlParameter("@ZgWzFName",SqlDbType.VarChar,100),
  664.                  new SqlParameter("@ZgQTFName",SqlDbType.VarChar,100),
  665.                  new SqlParameter("@GcglTransactor",SqlDbType.VarChar,30),
  666.                  new SqlParameter("@GcglFName",SqlDbType.VarChar,100),
  667.                  new SqlParameter("@GcglGdTransactor",SqlDbType.VarChar,30),
  668.                  new SqlParameter("@GcglGdContect",SqlDbType.VarChar,100),
  669.                  new SqlParameter("@ZgGdTransactor",SqlDbType.VarChar,30),
  670.                  new SqlParameter("@ZgGdContect",SqlDbType.VarChar,100),                 
  671.                  new SqlParameter("@status",SqlDbType.Int,4),
  672.                  new SqlParameter("@nf",SqlDbType.VarChar,4),
  673.                  new SqlParameter("@jd",SqlDbType.VarChar,1),
  674.                  new SqlParameter("@hz",SqlDbType.VarChar,1),
  675.              };
  676.             parameters[0].Direction = ParameterDirection.Output;
  677.             parameters[1].Value = prjcheckinfo.PrjChName;
  678.             parameters[2].Value = prjcheckinfo.PrjChSort;
  679.             parameters[3].Value = prjcheckinfo.JcTransactor;
  680.             parameters[4].Value = prjcheckinfo.JcCKName;
  681.             parameters[5].Value = prjcheckinfo.JcRKName;
  682.             parameters[6].Value = prjcheckinfo.JcQDName;
  683.             parameters[7].Value = prjcheckinfo.JcHZName;
  684.             parameters[8].Value = prjcheckinfo.CwTransactor;
  685.             parameters[9].Value = prjcheckinfo.CwFName;
  686.             parameters[10].Value = prjcheckinfo.WzTransatctor;
  687.             parameters[11].Value = prjcheckinfo.WzFName;
  688.             parameters[12].Value = prjcheckinfo.ZgTransactor;
  689.             parameters[13].Value = prjcheckinfo.ZgZlFName;
  690.             parameters[14].Value = prjcheckinfo.ZgTzFName;
  691.             parameters[15].Value = prjcheckinfo.ZgHtFName;
  692.             parameters[16].Value = prjcheckinfo.ZgWzFName;
  693.             parameters[17].Value = prjcheckinfo.ZgQTFName;
  694.             parameters[18].Value = prjcheckinfo.GcglTransactor;
  695.             parameters[19].Value = prjcheckinfo.GcglFName;
  696.             parameters[20].Value = prjcheckinfo.GcglGdTransactor;
  697.             parameters[21].Value = prjcheckinfo.GcglGdContect;
  698.             parameters[22].Value = prjcheckinfo.ZgGdTransactor;
  699.             parameters[23].Value = prjcheckinfo.ZgGdContect;
  700.             parameters[24].Value = prjcheckinfo.Status;
  701.             parameters[25].Value = prjcheckinfo.NF;
  702.             parameters[26].Value = prjcheckinfo.JD;
  703.             parameters[27].Value = prjcheckinfo.HZ;
  704.             SqlHelper.ExecuteScalar(SqlHelper.connectionString, CommandType.StoredProcedure, "p_Prjcheck_ADD", parameters);
  705.             return (int)parameters[0].Value;
  706.         }
  707.         public DataTable GetOpid(int ParentOrgID)
  708.         {
  709.             string strsqltext = "select * from [TB_Sys_OpRole] where [OpID]=" + ParentOrgID;
  710.             return SqlHelper.ExecuteDataTable(SqlHelper.connectionString, CommandType.Text, strsqltext, null);
  711.         }
  712.         public string GetEmpType(int EmpID)
  713.         {
  714.             string strEmpType = "";
  715.             DataView dv = SqlHelper.ExecuteDataTable(SqlHelper.connectionString, CommandType.Text, "select [EmpType] from [Tb_Sys_Employee] where [EmpID]=" + EmpID, null).DefaultView;
  716.             if (dv.Count > 0)
  717.             {
  718.                 strEmpType = dv[0]["EmpType"].ToString();
  719.             }
  720.             return strEmpType;
  721.         }
  722.         public DataTable GetParentStatus(int PrjID, int ActivityID)
  723.         {
  724.             string strsqltext = "select * from tb_wf_actins where wfinstanceid in" +
  725.                             "( select wfinstanceid from tb_wf_instance where prjid=" + PrjID + " and status=3) and activityid in " +
  726.                              "(select parentactid from tb_colony_user where activityid =" + ActivityID + ")";
  727.             return SqlHelper.ExecuteDataTable(SqlHelper.connectionString, CommandType.Text, strsqltext, null);
  728.         }
  729.         public bool UpDatePrjch(int PrjChID)
  730.         {
  731.             string sSQL = "update  tb_PrjCheck  Set status=2  where  PrjChID=" + PrjChID;
  732.             MSDA.Open();
  733.             NewObj newobject = new NewObj();
  734.             bool returnvalue = newobject.Update(sSQL, null, CommandType.Text);
  735.             MSDA.Close();
  736.             return returnvalue;
  737.         }
  738.         //符合要求的未汇总的所有文档
  739.         public DataView GetWord(int PrjChID)
  740.         {
  741.             string str = "select * from tb_PrjCheck where PrjChID=" + PrjChID + " and hz='1'";
  742.             DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.Text, str, null);
  743.             return ds.Tables[0].DefaultView;
  744.         }
  745.         //判断下级活动是否已经产生
  746.         public DataView GetActinsid(int PrjChID, int ActivityID)
  747.         {
  748.             //string str ="select * from tb_wf_actins where activityid=(select parentactid from tb_colony_user where activityid="+
  749.             //ActivityID + ") and wfinstanceid=" + WfInstanceID;
  750.             string str = "select * from tb_wf_actins where wfinstanceid in (select wfinstanceid from tb_wf_instance where prjid=" + PrjChID +
  751.                           "and status=3) and activityid in (select activityid from tb_colony_user where parentactid =" + ActivityID + ")";
  752.             DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.Text, str, null);
  753.             return ds.Tables[0].DefaultView;
  754.         }
  755.         //汇总后修改汇总状态
  756.         public int UpdateHZ(int PrjChID)
  757.         {
  758.             string str = "update tb_PrjCheck set hz='2' where PrjChID=" + PrjChID;
  759.             return SqlHelper.ExecuteNonQuery(SqlHelper.connectionString, CommandType.Text, str, null);
  760.         }
  761.         /// <summary>
  762.         /// 获取上级活动记录
  763.         /// </summary>
  764.         /// <param name="activityid">当前活动事例ID</param>
  765.         /// <returns></returns>
  766.         public DataView GetByActInsId(int ActInsID, int PrjChID)
  767.         {
  768.             string sSQL = "select AC1.ACtivityID PreviousActID,AC1.UserID PreviousUserID,AC1.RoleID PreviousRoleID  from tb_wf_actins AC1 where ActivityID in(select ParentActID from tb_Colony_User where  ActivityID " +
  769.                           " in(select AC.ActivityID from tb_wf_actins AC where AC.ActInsID='" + ActInsID + "')) and wfinstanceid in " +
  770.                           "(select wfinstanceid from tb_wf_instance where prjid=" + PrjChID + " and status=3)";
  771.             DataView dv = null;
  772.             try
  773.             {
  774.                 MSDA.Open();
  775.                 dv = SqlHelper.ExecuteDataTable(SqlHelper.connectionString, CommandType.Text, sSQL, null).DefaultView;
  776.                 MSDA.Close();
  777.             }
  778.             catch
  779.             {
  780.                 dv = null;
  781.             }
  782.             return dv;
  783.         }
  784.         /// <summary>
  785.         ///返回工程项目预算表(电子文档)
  786.         /// </summary>
  787.         /// <returns></returns>
  788.         public DataView GetSFileName(int activityid)
  789.         {
  790.             string sSQL = "select * from [tb_Sys_FileName]  where [FID]  in (select FID  from  tb_Colony_FileName1 where ActivityID=" + activityid + ")";
  791.             DataView dv = null;
  792.             MSDA.Open();
  793.             try
  794.             {
  795.                 NewObj newobject = new NewObj();
  796.                 dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
  797.             }
  798.             catch (Exception ex)
  799.             {
  800.                 dv = null;
  801.                 throw ex;
  802.             }
  803.             finally
  804.             {
  805.                 MSDA.Close();
  806.             }
  807.             return dv;
  808.         }
  809.         //查询上级用户
  810.         public DataView GetUser(int ActID,int WFActInsID)
  811.         {
  812.             string sSQL = "select EmpName,UserID from tb_sys_employee a ,tb_sys_user b where a.empid=b.empid and a.empid in" +
  813.                         "(select empid from tb_sys_user where userid in" +
  814.                         "(select userid from tb_wf_actins where activityid in" +
  815.                         "(select parentactid from tb_colony_user where activityid in" +
  816.                         "(select activityid from tb_wf_actins where actinsid=" + ActID + ")) and wfinstanceid=" + WFActInsID + "))";
  817.             DataView dv = null;
  818.             MSDA.Open();
  819.             try
  820.             {
  821.                 NewObj newobject = new NewObj();
  822.                 dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
  823.             }
  824.             catch (Exception ex)
  825.             {
  826.                 dv = null;
  827.                 throw ex;
  828.             }
  829.             finally
  830.             {
  831.                 MSDA.Close();
  832.             }
  833.             return dv;
  834.         }
  835.         //查找用户类型
  836.         public DataView GetEmptype(int UserID)
  837.         {
  838.             string sSQL = "select [EmpType] from [Tb_Sys_Employee] where [EmpID] in (select [EmpID] from tb_sys_user where userid=" + UserID + ")";
  839.             DataView dv = null;
  840.             MSDA.Open();
  841.             try
  842.             {
  843.                 NewObj newobject = new NewObj();
  844.                 dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
  845.             }
  846.             catch (Exception ex)
  847.             {
  848.                 dv = null;
  849.                 throw ex;
  850.             }
  851.             finally
  852.             {
  853.                 MSDA.Close();
  854.             }
  855.             return dv;
  856.         }
  857.         //查找是否是回退活动
  858.         public DataView GetStatus(int ActID)
  859.         {
  860.             string sSQL = "select * from tb_wf_actins where ActInsID="+ActID;
  861.             DataView dv = null;
  862.             MSDA.Open();
  863.             try
  864.             {
  865.                 NewObj newobject = new NewObj();
  866.                 dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
  867.             }
  868.             catch (Exception ex)
  869.             {
  870.                 dv = null;
  871.                 throw ex;
  872.             }
  873.             finally
  874.             {
  875.                 MSDA.Close();
  876.             }
  877.             return dv;
  878.         }
  879.     }
  880.      /*==============================================================================================
  881.      *                               工程管理验收流程状态
  882.      * ==============================================================================================*/
  883.     public class WFPrjCh
  884.     {
  885.         private SqlDataConnect.MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  886.         //说明-----全部的值为-1  tb_Project
  887.         private int prjchid;                      //PrjChID
  888.         private string prjchname;                //PrjChName
  889.         private int prjchsort;                  //PrjChSort
  890.         private int status;                  //Status
  891.        
  892.         //项目代码
  893.         public int PrjChID
  894.         {
  895.             set { prjchid = value; }
  896.             get { return prjchid; }
  897.         }
  898.         //项目名称
  899.         public string PrjChName
  900.         {
  901.             set { prjchname = value; }
  902.             get { return prjchname; }
  903.         }
  904.         //项目流水号
  905.         public int PrjChSort
  906.         {
  907.             set { prjchsort = value; }
  908.             get { return prjchsort; }
  909.         }
  910.         //项目编号
  911.         public int Status
  912.         {
  913.             set { status = value; }
  914.             get { return status; }
  915.         }
  916.         //项目查询根据状态和类型
  917.         public DataView PrjChQuery()
  918.         {
  919.             DataView dv = new DataView();
  920.             string strSQL;
  921.             MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
  922.             if (this.prjchsort < -1 || this.prjchsort == 0)
  923.             {
  924.                 this.prjchsort = -212;              //没有数据
  925.             }
  926.             if (this.status < -1)
  927.             {
  928.                 this.status = -212;            //没有数据
  929.             }
  930.             strSQL = "select * from tb_PrjCheck";
  931.             if (this.prjchsort != -1)
  932.                 strSQL = strSQL + " where PrjChSort=" + this.prjchsort;
  933.             if (this.status != -1)
  934.             {
  935.                 if (this.prjchsort != -1)
  936.                     strSQL = strSQL + " and status=" + this.status;
  937.                 else
  938.                     strSQL = strSQL + " where status=" + this.status;
  939.             }
  940.             try
  941.             {
  942.                 MSDA.Open();
  943.                 dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
  944.             }
  945.             catch (Exception ex)
  946.             {
  947.                 throw ex;
  948.             }
  949.             finally
  950.             {
  951.                 MSDA.Close();
  952.             }
  953.             return dv;
  954.         }
  955.        
  956.     }
  957. }