User.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:41k
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Configuration;
- using System.Data.SqlClient;
- using System.Data;
- using System.Collections;
- using com.etong.DBUtility;
- using com.etong.Inform;
- using com.etong.SqlDataConnect;
- using com.etong.BusinessRule.Zwf;
- using com.etong.Model;
- using System.Xml;
- namespace com.etong.user
- {
- public class AllUser
- {
- //设置连接字符串
- private SqlDataConnect.MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- public AllUser()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- /*************************************************************************************************************
- * Module: 用户登陆管理
- * Desc: 检验、保存、查询
- * Author:徐秀梅
- * Date: 2007-03
- **************************************************************************************************************/
- //根据用户ID返回RoleID
- public ArrayList GetRoleID(int userid)
- {
- ArrayList list = new ArrayList();
- string str = "select RoleID from Tb_Sys_UserRole where UserID="+userid;
- DataSet ds = new DataSet();
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "");
- if (ds.Tables[0].Rows.Count > 0)
- {
- for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
- {
- list.Add(ds.Tables[0].Rows[i][0].ToString());
- }
- }
- return list;
- }
- //根据用户名返回EmpID
- public int GetEmpID(int UserID)
- {
- //MSDA.Open();
- int EmpID=0;
- string str = "select EmpID from Tb_Sys_User where UserID=" + UserID;
- DataSet ds = new DataSet();
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "");
- if (ds.Tables[0].Rows.Count>0)
- {
- if (ds.Tables[0].Rows[0]["EmpID"].ToString() != "")
- {
- EmpID = Convert.ToInt32(ds.Tables[0].Rows[0]["EmpID"].ToString());
- }
- }
- MSDA.Close();
- return EmpID;
- }
- //检查用户名和密码(带三个参数)
- public CheckUserInfo PCheckUser(int UserID, string UserPwd,string UserIP)
- {
- MSDA.Open();
- //bool flag = false;
- CheckUserInfo checkuserinfo = null;
- string str = "select IsIPBound,IPAddress,isLock from Tb_Sys_User where UserID=" + UserID + " and UserPwd='" + UserPwd + "'";
- DataSet ds = new DataSet();
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "");
- if (ds.Tables[0].Rows.Count> 0)
- {
- if (Convert.ToInt16(ds.Tables[0].Rows[0]["isLock"].ToString()) == 1)
- return checkuserinfo;
-
- if (Convert.ToInt16(ds.Tables[0].Rows[0]["IsIPBound"].ToString()) == 0)
- {
- checkuserinfo = GetCheckUserInfo(UserID);
- }
- else
- {
- if (Convert.ToInt16(ds.Tables[0].Rows[0]["IsIPBound"].ToString()) == 1)
- {
- if (ds.Tables[0].Rows[0]["IPAddress"].ToString() == UserIP)
- {
- checkuserinfo = GetCheckUserInfo(UserID);
- try
- {
- checkuserinfo.UserID = Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"]);
- }
- catch
- {
- checkuserinfo.UserID = -1;
- }
- }
- }
- }
- }
- MSDA.Close();
- return checkuserinfo;
- }
- //检查用户名和密码(带两个参数)
- public bool PCheckUser(int UserID, string UserPwd)
- {
- MSDA.Open();
- bool flag=false;
- string str="select * from Tb_Sys_User where UserID=" + UserID + " and UserPwd='" + UserPwd + "'";
- SqlDataReader dr = MSDA.ExecuteReader(CommandType.Text, str, null);
- if (dr.Read())
- {
- flag = true;
- }
- MSDA.Close();
- return flag;
- }
- //检查用户名和密码(返回用户名,部门,用户权限)
- public CheckUserInfo GetCheckUserInfo(int UserID)
- {
- CheckUserInfo checkuserinfo = null;
- int EmpID = GetEmpID(UserID);
- string UserAccount = GetUserAccount(UserID);
- MSDA.Open();
- if (EmpID != 0||(EmpID==0&&UserAccount=="admin"))
- {
- checkuserinfo = new CheckUserInfo();
- checkuserinfo.UserAccount = UserAccount;
- checkuserinfo.UserID = UserID;
- checkuserinfo.EmpID = EmpID;
- DataSet ds = new DataSet();
- string str="select EmpName,PrimaryOrgID from Tb_Sys_Employee where EmpID="+ EmpID;
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "");
- if (ds.Tables[0].Rows.Count > 0)
- {
- checkuserinfo.EmpName = ds.Tables[0].Rows[0]["EmpName"].ToString();
- checkuserinfo.OrgID = Convert.ToInt32(ds.Tables[0].Rows[0]["PrimaryOrgID"]);
- str = "select OrgName from Tb_Sys_Organization where OrgID=" + checkuserinfo.OrgID;
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "orgname");
- if (ds.Tables["orgname"].Rows.Count > 0)
- {
- checkuserinfo.OrgName = ds.Tables["orgname"].Rows[0]["OrgName"].ToString();
- }
- }
- str = "select RoleID from Tb_Sys_User,Tb_Sys_UserRole where Tb_Sys_User.UserID=Tb_Sys_UserRole.UserID and EmpID=" + EmpID;
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "roleid");
- if (ds.Tables["roleid"].Rows.Count > 0)
- {
- if (ds.Tables["roleid"].Rows[0]["RoleID"].ToString() != "")
- {
- checkuserinfo.RoleID = Convert.ToInt32(ds.Tables["roleid"].Rows[0]["RoleID"].ToString());
- }
- }
- else
- {
- if (UserAccount != "admin")
- {
- checkuserinfo.RoleID = -1;
- }
- }
- }
- MSDA.Close();
- return checkuserinfo;
- }
- //根据用户名修改用户密码
- public int PModifyPwd(int UserID, string OldPwd, string NewPwd)
- {
- int i = -2;
- bool flag = PCheckUser(UserID, OldPwd);
- MSDA.Open();
- string str = "update Tb_Sys_User set UserPwd='" + NewPwd + "'where UserID=" + UserID ;
- if (flag)
- {
- i = MSDA.ExecuteNonQuery(CommandType.Text, str, null);
- if (i != -1)
- {
- i = 1;
- }
- }
- MSDA.Close();
- return i;
- }
- //根据职工取UserID
- public DataSet GetUserID(string Empname)
- {
- MSDA.Open();
- string str = "select EmpID from tb_sys_Employee where EmpName='"+Empname+"'";
- DataSet ds1 = null;
- DataSet ds = new DataSet();
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "EmpID");
- if (ds.Tables[0].Rows.Count > 0)
- {
- int EmpID = Convert.ToInt32(ds.Tables["EmpID"].Rows[0]["EmpID"].ToString());
- str = "select UserID,UserAccount,OrgName from tb_sys_User a,tb_sys_Employee b,Tb_Sys_Organization c where a.EmpID="
- + EmpID+" and a.EmpID=b.EmpID and b.PrimaryOrgID=c.OrgID";
- ds1 = new DataSet();
- ds1 = MSDA.ExecuteDataset(CommandType.Text, str, null, ds1, "UserID");
- }
- MSDA.Close();
- return ds1;
- }
- //根据用户名取UserID
- public DataSet GetUserIDFAccount(string Account)
- {
- MSDA.Open();
- DataSet ds = new DataSet();
- string str = "";
- if (Account != "admin")
- {
- str = "select UserID,EmpName,OrgName from tb_sys_User a,tb_sys_Employee b,Tb_Sys_Organization c where a.UserAccount like '"
- + Account + "%'and a.EmpID=b.EmpID and b.PrimaryOrgID=c.OrgID";
- }
- else
- {
- str = "select UserID from tb_sys_User where UserAccount='admin'";
- }
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "UserID");
- MSDA.Close();
- return ds;
- }
- //根据用户ID取用户名
- public string GetUserAccount(int UserID)
- {
- DataSet ds = new DataSet();
- string str = "select UserAccount from tb_sys_User where UserID=" + UserID;
- ds = MSDA.ExecuteDataset(CommandType.Text, str, null, ds, "Account");
- string UserAccount = ds.Tables["Account"].Rows[0]["UserAccount"].ToString();
- MSDA.Close();
- return UserAccount;
- }
- }
- public class Audit
- {
- private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- public Audit()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- /*************************************************************************************************************
- * Module: 访问审核控制信息
- * Desc: 添加、查询、删除
- * Author:徐秀梅
- * Date: 2007-04
- **************************************************************************************************************/
- /// <summary>
- /// 保存访问信息
- /// </summary>
- /// <returns>返回一bool类型值</returns>
- public bool AuditAdd(string ipaddress, string operation, DateTime editdate, string useraccount,
- DateTime accesstime,string serviceactionname, int callingresult, string callingmodule, int logcate,string empname,string orgname)
- {
- QueryParameterCollection Params = new QueryParameterCollection();
- Params.Clear();
- Params.Add("@ipaddress", ipaddress);
- Params.Add("@operation", operation);
- Params.Add("@editdate", editdate);
- Params.Add("@useraccount", useraccount);
- Params.Add("@accesstime", accesstime);
- Params.Add("@serviceactionname", serviceactionname);
- Params.Add("@callingresult", callingresult);
- Params.Add("@callingmodule", callingmodule);
- Params.Add("@logcate", logcate);
- Params.Add("@empname", empname);
- Params.Add("@orgname", orgname);
- string sql = "insert into Tb_Sys_Audit values (@ipaddress,'',@operation,@editdate,@useraccount,@accesstime,'localhost',@serviceactionname,'localhost',@callingresult,@callingmodule,@logcate,@empname,@orgname)";
- MSDA.Open();
- NewObj obj = new NewObj();
- bool returnvalue = obj.insert(sql, Params, CommandType.Text);
- MSDA.Close();
- return returnvalue;
- }
- /// <summary>
- /// 删除访问信息
- /// </summary>
- public void AuditDelete(int auditid)
- {
- string sql = "delete from Tb_Sys_Audit where [AuditID]='" + auditid + "'";
- MSDA.Open();
- MSDA.ExecuteNonQuery(CommandType.Text, sql, null);
- MSDA.Close();
- }
- /// <summary>
- /// 查找指定或全部物资代码记录
- /// </summary>
- /// <param name="SearchTxt">查找内容</param>
- /// <param name="i">查找关键字,例:1:IP地址;2:用户帐号;3:用户名称;4:组织机构;5:访问时间;非1,2,3,4,5且SearchTxt为空:查找全部</param>
- public DataView AuditSearch(string SearchTxt, string i, DateTime StartTime, DateTime EndTime)
- {
- string sql = "select * from Tb_Sys_Audit";
- if (i == "1" && SearchTxt != "")
- {
- sql = sql + " where [IPAddress]='" + SearchTxt + "'";
- }
- if (i == "2" && SearchTxt != "")
- {
- sql = sql + " where [UserAccount]='" + SearchTxt + "'";
- }
- if (i == "3" && SearchTxt != "")
- {
- sql = sql + " where [EmpName]='" + SearchTxt + "'";
- }
- if (i == "4" && SearchTxt != "")
- {
- sql = sql + " where [OrgName]='" + SearchTxt + "'";
- }
- if (i=="5" && StartTime != null && EndTime != null)
- {
- sql = sql + " where [AccessTime] between '" + StartTime + "'and '" + EndTime + "'";
- }
- DataSet ds = new DataSet();
- MSDA.Open();
- NewObj newobject = new NewObj();
- DataView dv = newobject.Search(sql, null, CommandType.Text).Tables[0].DefaultView;
- MSDA.Close();
- return dv;
- }
- }
- public class Notice
- {
- private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- public Notice()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- /*************************************************************************************************************
- * Module: 工作流公告管理
- * Desc: 添加、更新、删除、查询记录
- * Author:徐秀梅
- * Date: 2007-04
- **************************************************************************************************************/
- /// <summary>
- /// 添加工作流公告
- /// </summary>
- /// <returns>返回一bool类型值</returns>
- public bool NoticeAdd(string noticetitle,string noticecontent,DateTime invaiddate,DateTime noticedate,int createuserid,int assroleid,int assuserid)
- {
- QueryParameterCollection Params = new QueryParameterCollection();
- Params.Clear();
- Params.Add("@noticetitle", noticetitle);
- Params.Add("@noticecontent", noticecontent);
- Params.Add("@invaiddate", invaiddate);
- Params.Add("@noticedate", noticedate);
- Params.Add("@createuserid", createuserid);
- Params.Add("@assroleid", assroleid);
- Params.Add("@assuserid", assuserid);
- string sSQL = "insert into tb_Notice([NoticeTitle],[NoticeContent],[InvaidDate],[NoticeDate],[CreateUserID],[AssRoleID],[AssUserID]) values(" +
- "@noticetitle ,@noticecontent,@invaiddate,@noticedate,@createuserid,@assroleid,@assuserid)";
- MSDA.Open();
- NewObj newobject = new NewObj();
- bool returnvalue = newobject.insert(sSQL, Params, CommandType.Text);
- MSDA.Close();
- return returnvalue;
- }
- /// <summary>
- /// 更新工作流公告记录
- /// </summary>
- /// <returns>返回bool类型参数</returns>
- public bool NoticeUpdate(int noticeid,string noticetitle, string noticecontent, DateTime invaiddate, int assroleid, int assuserid)
- {
- QueryParameterCollection Params = new QueryParameterCollection();
- Params.Clear();
- Params.Add("@noticeid", noticeid);
- Params.Add("@noticetitle", noticetitle);
- Params.Add("@noticecontent", noticecontent);
- Params.Add("@invaiddate", invaiddate);
- //Params.Add("@noticedate", noticedate);
- //Params.Add("@createuserid", createuserid);
- Params.Add("@assroleid", assroleid);
- Params.Add("@assuserid", assuserid);
- string sSQL = "update Tb_Notice Set NoticeTitle=@noticetitle,NoticeContent=@noticecontent,InvaidDate=@invaiddate,AssRoleID=@assroleid,AssUserID=@assuserid where NoticeID=@noticeid";
- MSDA.Open();
- NewObj newobject = new NewObj();
- bool returnvalue = newobject.Update(sSQL, Params, CommandType.Text);
- MSDA.Close();
- return returnvalue;
- }
- /// <summary>
- /// 删除工作流公告记录
- /// </summary>
- /// <param name="userid">公告ID</param>
- public void NoticeDelete(int NoticeID)
- {
- string sSQL = "delete from Tb_Notice where [NoticeID]='" + NoticeID + "'";
- MSDA.Open();
- MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
- MSDA.Close();
- }
- public void NoticeDelete(int UserID,DateTime starttime,DateTime endtime)
- {
- string sSQL = "delete from Tb_Notice where [NoticeDate] between '" + starttime + "'and '"+endtime+"'";
- if (UserID != 0)
- {
- sSQL += " and [CreateUserID]=" + UserID;
- }
- MSDA.Open();
- MSDA.ExecuteNonQuery(CommandType.Text, sSQL, null);
- MSDA.Close();
- }
- /// <summary>
- /// 查找工作流公告记录
- /// </summary>
- public DataView NoticeSearch(int createuserid,int NoticeID)//查找可以修改删除的
- {
- SqlParameter[] paramters ={
- new SqlParameter ("@Param_UserID",SqlDbType.Int ,4),
- new SqlParameter ("@Param_NoticID",SqlDbType.Int ,4)
- };
- paramters[0].Value = createuserid;
- paramters[1].Value = NoticeID;
- MSDA.Open();
- DataSet ds =SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetDataNotic", paramters);
- DataView dv = ds.Tables[0].DefaultView;
- MSDA.Close();
- return dv;
- }
- public DataSet NoticeSearch(DateTime start,DateTime end)//查找某时间段的记录
- {
- 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";
- DataSet ds = new DataSet();
- MSDA.Open();
- ds = MSDA.ExecuteDataset(CommandType.Text, sSQL, null, ds, "");
- MSDA.Close();
- return ds;
- }
- public DataTable NoticeSearch(int userid,DateTime invaiddate)//查找用户可以浏览的
- {
- string sSQL = "select [NoticeTitle],[NoticeContent],[NoticeDate],[CreateUserID] from Tb_Notice where "
- +"AssRoleID in (select roleid from Tb_Sys_UserRole where userid = "+userid+") or AssUserID="+userid+" or AssUserID=-1 and InvaidDate>='" + invaiddate+"'";
- DataTable dt = new DataTable();
- MSDA.Open();
- NewObj newobject = new NewObj();
- dt = newobject.Search(sSQL, null, CommandType.Text).Tables[0];
- MSDA.Close();
- return dt;
- }
- /// <summary>
- /// 根据角色查找职工记录
- /// </summary>
- public DataView GetUser(int RoleID)
- {
- string sSQL = "select b.userid,empname from tb_sys_employee a,tb_sys_user b,tb_sys_userrole c " +
- "where a.empid=b.empid and b.userid=c.userid and c.roleid=" + RoleID;
- DataSet ds = new DataSet();
- MSDA.Open();
- NewObj newobject = new NewObj();
- DataView dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
- MSDA.Close();
- return dv;
- }
- /// <summary>
- /// 根据用户ID查找职工姓名(EmpName)
- /// </summary>
- public string GetEmpName(int UserID)
- {
- string empname = "";
- string sSQL = "select Empname from tb_sys_employee where empid = (select empid from tb_sys_user where userid=" + UserID+")";
- MSDA.Open();
- DataSet ds = new DataSet();
- ds = MSDA.ExecuteDataset(CommandType.Text, sSQL, null, ds, "EmpName");
- if (ds.Tables[0].Rows.Count > 0)
- {
- empname = ds.Tables[0].Rows[0]["EmpName"].ToString();
- }
- MSDA.Close();
- return empname;
- }
- }
- /*************************************************************************************************************
- * Module: 验收工作流项目状态查询
- * Author:徐秀梅
- * Date: 2007-05
- **************************************************************************************************************/
- public class Status
- {
- private MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- public Status()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <returns>返回一dataview类型值</returns>
- public DataView StatusSearch()
- {
- MSDA.Open();
- DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetStatusProject", null);
- DataView dv = ds.Tables[0].DefaultView;
- MSDA.Close();
- return dv;
- }
- /// <summary>
- /// 验收流程查询
- /// </summary>
- /// <returns>返回一dataview类型值</returns>
- public DataView StatusSearch1()
- {
- MSDA.Open();
- DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetStatusProject1", null);
- DataView dv = ds.Tables[0].DefaultView;
- MSDA.Close();
- return dv;
- }
- /// <summary>
- /// 废旧物质流程查询
- /// </summary>
- /// <returns>返回一dataview类型值</returns>
- public DataView OldMatStatusSearch()
- {
- MSDA.Open();
- DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetOldMatStatusProject", null);
- DataView dv = ds.Tables[0].DefaultView;
- MSDA.Close();
- return dv;
- }
- /// <summary>
- /// 查询Prj
- /// </summary>
- /// <returns>返回一dataset类型值</returns>
- public DataSet AllStatusSearch(int PrjID)
- {
- MSDA.Open();
- SqlParameter paramter = new SqlParameter("@PrjID", SqlDbType.Int, 4);
- paramter.Value = PrjID;
- DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetAllStatus", paramter);
- MSDA.Close();
- return ds;
- }
- /// <summary>
- /// 查询验收Prj
- /// </summary>
- /// <returns>返回一dataset类型值</returns>
- public DataSet AllStatusSearch1(int PrjID)
- {
- MSDA.Open();
- SqlParameter paramter = new SqlParameter("@PrjID", SqlDbType.Int, 4);
- paramter.Value = PrjID;
- DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_GetAllStatus1", paramter);
- MSDA.Close();
- return ds;
- }
- /// <summary>
- /// 查询废旧物质Prj
- /// </summary>
- /// <returns>返回一dataset类型值</returns>
- public DataSet OldMatAllStatusSearch(int PrjID)
- {
- MSDA.Open();
- SqlParameter paramter = new SqlParameter("@PrjID", SqlDbType.Int, 4);
- paramter.Value = PrjID;
- DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.StoredProcedure, "P_OldMatGetAllStatus", paramter);
- MSDA.Close();
- return ds;
- }
- //项目查询根据状态和类型
- public DataView PrjQuery(int type,int status)
- {
- DataView dv = new DataView();
- string strSQL="";
- MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- if (status < -1)
- {
- status = -212; //没有数据
- }
- switch(type)
- {
- case 1://项目施工流程
- strSQL = "select * from tb_construct";
- break;
- case 2://项目施工工程变更和调整
- strSQL = "select * from tb_PrjAlert";
- break;
- case 3://工程管理验收流程
- strSQL = "select * from tb_PrjCheck";
- break;
- case 4://废旧物资管理流程
- strSQL = "select * from tb_PrjOldMat";
- break;
- case 5://项目工程流程
- strSQL = "select * from tb_Project";
- break;
- }
- if (status != -1)
- {
- strSQL = strSQL + " where Status=" + status;
- }
- try
- {
- MSDA.Open();
- dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- MSDA.Close();
- }
- return dv;
- }
- //项目查询依据项目代码
- //public DataView PrjQureyData()
- //{
- // DataView dv = new DataView();
- // string strSQL;
- // MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- // strSQL = "select * from tb_Project where ProjectID=" + this.m_pID;
- // try
- // {
- // MSDA.Open();
- // dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
- // }
- // catch (Exception ex)
- // {
- // throw ex;
- // }
- // finally
- // {
- // MSDA.Close();
- // }
- // return dv;
- //}
- }
- /*==============================================================================================
- * 工程管理验收流程
- * ==============================================================================================*/
- public class PrjCheck
- {
- private SqlDataConnect.MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- /// <summary>
- /// 添加项目验收信息,返回"0"表示添加失败,否则成功
- /// </summary>
- /// <param name="prjcheckinfo"></param>
- /// <returns></returns>
- public int AddPrjCheck(PrjCheckInfo prjcheckinfo)
- {
- SqlParameter[] parameters ={
- new SqlParameter("@PrjChID",SqlDbType.Int,4),
- new SqlParameter("@PrjChName",SqlDbType.VarChar,200),
- new SqlParameter("@PrjChSort",SqlDbType.VarChar,2),
- new SqlParameter("@JcTransactor",SqlDbType.VarChar,30),
- new SqlParameter("@JcCKName",SqlDbType.VarChar,100),
- new SqlParameter("@JcRKName",SqlDbType.VarChar,100),
- new SqlParameter("@JcQDName",SqlDbType.VarChar,100),
- new SqlParameter("@JcHZName",SqlDbType.VarChar,100),
- new SqlParameter("@CwTransactor",SqlDbType.VarChar,30),
- new SqlParameter("@CwFName",SqlDbType.VarChar,100),
- new SqlParameter("@WzTransatctor",SqlDbType.VarChar,30),
- new SqlParameter("@WzFName",SqlDbType.VarChar,100),
- new SqlParameter("@ZgTransactor",SqlDbType.VarChar,30),
- new SqlParameter("@ZgZlFName",SqlDbType.VarChar,100),
- new SqlParameter("@ZgTzFName",SqlDbType.VarChar,100),
- new SqlParameter("@ZgHtFName",SqlDbType.VarChar,100),
- new SqlParameter("@ZgWzFName",SqlDbType.VarChar,100),
- new SqlParameter("@ZgQTFName",SqlDbType.VarChar,100),
- new SqlParameter("@GcglTransactor",SqlDbType.VarChar,30),
- new SqlParameter("@GcglFName",SqlDbType.VarChar,100),
- new SqlParameter("@GcglGdTransactor",SqlDbType.VarChar,30),
- new SqlParameter("@GcglGdContect",SqlDbType.VarChar,100),
- new SqlParameter("@ZgGdTransactor",SqlDbType.VarChar,30),
- new SqlParameter("@ZgGdContect",SqlDbType.VarChar,100),
- new SqlParameter("@status",SqlDbType.Int,4),
- new SqlParameter("@nf",SqlDbType.VarChar,4),
- new SqlParameter("@jd",SqlDbType.VarChar,1),
- new SqlParameter("@hz",SqlDbType.VarChar,1),
- };
- parameters[0].Direction = ParameterDirection.Output;
- parameters[1].Value = prjcheckinfo.PrjChName;
- parameters[2].Value = prjcheckinfo.PrjChSort;
- parameters[3].Value = prjcheckinfo.JcTransactor;
- parameters[4].Value = prjcheckinfo.JcCKName;
- parameters[5].Value = prjcheckinfo.JcRKName;
- parameters[6].Value = prjcheckinfo.JcQDName;
- parameters[7].Value = prjcheckinfo.JcHZName;
- parameters[8].Value = prjcheckinfo.CwTransactor;
- parameters[9].Value = prjcheckinfo.CwFName;
- parameters[10].Value = prjcheckinfo.WzTransatctor;
- parameters[11].Value = prjcheckinfo.WzFName;
- parameters[12].Value = prjcheckinfo.ZgTransactor;
- parameters[13].Value = prjcheckinfo.ZgZlFName;
- parameters[14].Value = prjcheckinfo.ZgTzFName;
- parameters[15].Value = prjcheckinfo.ZgHtFName;
- parameters[16].Value = prjcheckinfo.ZgWzFName;
- parameters[17].Value = prjcheckinfo.ZgQTFName;
- parameters[18].Value = prjcheckinfo.GcglTransactor;
- parameters[19].Value = prjcheckinfo.GcglFName;
- parameters[20].Value = prjcheckinfo.GcglGdTransactor;
- parameters[21].Value = prjcheckinfo.GcglGdContect;
- parameters[22].Value = prjcheckinfo.ZgGdTransactor;
- parameters[23].Value = prjcheckinfo.ZgGdContect;
- parameters[24].Value = prjcheckinfo.Status;
- parameters[25].Value = prjcheckinfo.NF;
- parameters[26].Value = prjcheckinfo.JD;
- parameters[27].Value = prjcheckinfo.HZ;
- SqlHelper.ExecuteScalar(SqlHelper.connectionString, CommandType.StoredProcedure, "p_Prjcheck_ADD", parameters);
- return (int)parameters[0].Value;
- }
- public DataTable GetOpid(int ParentOrgID)
- {
- string strsqltext = "select * from [TB_Sys_OpRole] where [OpID]=" + ParentOrgID;
- return SqlHelper.ExecuteDataTable(SqlHelper.connectionString, CommandType.Text, strsqltext, null);
- }
- public string GetEmpType(int EmpID)
- {
- string strEmpType = "";
- DataView dv = SqlHelper.ExecuteDataTable(SqlHelper.connectionString, CommandType.Text, "select [EmpType] from [Tb_Sys_Employee] where [EmpID]=" + EmpID, null).DefaultView;
- if (dv.Count > 0)
- {
- strEmpType = dv[0]["EmpType"].ToString();
- }
- return strEmpType;
- }
- public DataTable GetParentStatus(int PrjID, int ActivityID)
- {
- string strsqltext = "select * from tb_wf_actins where wfinstanceid in" +
- "( select wfinstanceid from tb_wf_instance where prjid=" + PrjID + " and status=3) and activityid in " +
- "(select parentactid from tb_colony_user where activityid =" + ActivityID + ")";
- return SqlHelper.ExecuteDataTable(SqlHelper.connectionString, CommandType.Text, strsqltext, null);
- }
- public bool UpDatePrjch(int PrjChID)
- {
- string sSQL = "update tb_PrjCheck Set status=2 where PrjChID=" + PrjChID;
- MSDA.Open();
- NewObj newobject = new NewObj();
- bool returnvalue = newobject.Update(sSQL, null, CommandType.Text);
- MSDA.Close();
- return returnvalue;
- }
- //符合要求的未汇总的所有文档
- public DataView GetWord(int PrjChID)
- {
- string str = "select * from tb_PrjCheck where PrjChID=" + PrjChID + " and hz='1'";
- DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.Text, str, null);
- return ds.Tables[0].DefaultView;
- }
- //判断下级活动是否已经产生
- public DataView GetActinsid(int PrjChID, int ActivityID)
- {
- //string str ="select * from tb_wf_actins where activityid=(select parentactid from tb_colony_user where activityid="+
- //ActivityID + ") and wfinstanceid=" + WfInstanceID;
- string str = "select * from tb_wf_actins where wfinstanceid in (select wfinstanceid from tb_wf_instance where prjid=" + PrjChID +
- "and status=3) and activityid in (select activityid from tb_colony_user where parentactid =" + ActivityID + ")";
- DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.connectionString, CommandType.Text, str, null);
- return ds.Tables[0].DefaultView;
- }
- //汇总后修改汇总状态
- public int UpdateHZ(int PrjChID)
- {
- string str = "update tb_PrjCheck set hz='2' where PrjChID=" + PrjChID;
- return SqlHelper.ExecuteNonQuery(SqlHelper.connectionString, CommandType.Text, str, null);
- }
- /// <summary>
- /// 获取上级活动记录
- /// </summary>
- /// <param name="activityid">当前活动事例ID</param>
- /// <returns></returns>
- public DataView GetByActInsId(int ActInsID, int PrjChID)
- {
- 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 " +
- " in(select AC.ActivityID from tb_wf_actins AC where AC.ActInsID='" + ActInsID + "')) and wfinstanceid in " +
- "(select wfinstanceid from tb_wf_instance where prjid=" + PrjChID + " and status=3)";
- DataView dv = null;
- try
- {
- MSDA.Open();
- dv = SqlHelper.ExecuteDataTable(SqlHelper.connectionString, CommandType.Text, sSQL, null).DefaultView;
- MSDA.Close();
- }
- catch
- {
- dv = null;
- }
- return dv;
- }
- /// <summary>
- ///返回工程项目预算表(电子文档)
- /// </summary>
- /// <returns></returns>
- public DataView GetSFileName(int activityid)
- {
- string sSQL = "select * from [tb_Sys_FileName] where [FID] in (select FID from tb_Colony_FileName1 where ActivityID=" + activityid + ")";
- DataView dv = null;
- MSDA.Open();
- try
- {
- NewObj newobject = new NewObj();
- dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
- }
- catch (Exception ex)
- {
- dv = null;
- throw ex;
- }
- finally
- {
- MSDA.Close();
- }
- return dv;
- }
- //查询上级用户
- public DataView GetUser(int ActID,int WFActInsID)
- {
- string sSQL = "select EmpName,UserID from tb_sys_employee a ,tb_sys_user b where a.empid=b.empid and a.empid in" +
- "(select empid from tb_sys_user where userid in" +
- "(select userid from tb_wf_actins where activityid in" +
- "(select parentactid from tb_colony_user where activityid in" +
- "(select activityid from tb_wf_actins where actinsid=" + ActID + ")) and wfinstanceid=" + WFActInsID + "))";
- DataView dv = null;
- MSDA.Open();
- try
- {
- NewObj newobject = new NewObj();
- dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
- }
- catch (Exception ex)
- {
- dv = null;
- throw ex;
- }
- finally
- {
- MSDA.Close();
- }
- return dv;
- }
- //查找用户类型
- public DataView GetEmptype(int UserID)
- {
- string sSQL = "select [EmpType] from [Tb_Sys_Employee] where [EmpID] in (select [EmpID] from tb_sys_user where userid=" + UserID + ")";
- DataView dv = null;
- MSDA.Open();
- try
- {
- NewObj newobject = new NewObj();
- dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
- }
- catch (Exception ex)
- {
- dv = null;
- throw ex;
- }
- finally
- {
- MSDA.Close();
- }
- return dv;
- }
- //查找是否是回退活动
- public DataView GetStatus(int ActID)
- {
- string sSQL = "select * from tb_wf_actins where ActInsID="+ActID;
- DataView dv = null;
- MSDA.Open();
- try
- {
- NewObj newobject = new NewObj();
- dv = newobject.Search(sSQL, null, CommandType.Text).Tables[0].DefaultView;
- }
- catch (Exception ex)
- {
- dv = null;
- throw ex;
- }
- finally
- {
- MSDA.Close();
- }
- return dv;
- }
- }
- /*==============================================================================================
- * 工程管理验收流程状态
- * ==============================================================================================*/
- public class WFPrjCh
- {
- private SqlDataConnect.MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- //说明-----全部的值为-1 tb_Project
- private int prjchid; //PrjChID
- private string prjchname; //PrjChName
- private int prjchsort; //PrjChSort
- private int status; //Status
-
- //项目代码
- public int PrjChID
- {
- set { prjchid = value; }
- get { return prjchid; }
- }
- //项目名称
- public string PrjChName
- {
- set { prjchname = value; }
- get { return prjchname; }
- }
- //项目流水号
- public int PrjChSort
- {
- set { prjchsort = value; }
- get { return prjchsort; }
- }
- //项目编号
- public int Status
- {
- set { status = value; }
- get { return status; }
- }
- //项目查询根据状态和类型
- public DataView PrjChQuery()
- {
- DataView dv = new DataView();
- string strSQL;
- MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- if (this.prjchsort < -1 || this.prjchsort == 0)
- {
- this.prjchsort = -212; //没有数据
- }
- if (this.status < -1)
- {
- this.status = -212; //没有数据
- }
- strSQL = "select * from tb_PrjCheck";
- if (this.prjchsort != -1)
- strSQL = strSQL + " where PrjChSort=" + this.prjchsort;
- if (this.status != -1)
- {
- if (this.prjchsort != -1)
- strSQL = strSQL + " and status=" + this.status;
- else
- strSQL = strSQL + " where status=" + this.status;
- }
- try
- {
- MSDA.Open();
- dv = MSDA.ExecuteDataView(CommandType.Text, strSQL, null);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- MSDA.Close();
- }
- return dv;
- }
-
- }
- }