⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deletecheck.cs

📁 企业管理信息化之财务管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using com.unicafe.common;
using com.unicafe.workflow;
using System.Collections;

namespace com.ascs.plp.publics
{
	/// <summary>
	/// DeleteCheck 的摘要说明。
	/// </summary>
	public class DeleteCheck
	{
		public DeleteCheck()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

		/// **************************************************************************
		/// BEIGIN
		/// <summary>
		/// 库房删除检查:当返回true时,才能执行删除动作
		/// 	1、库存台帐表中没有对应的库房信息检测  2、调拨申请中未完成单据的库房检测
		/// </summary>
		/// /// <param name="SqlConnection">SqlConnection cn对象</param>
		/// <param name="KFDM">库房代码</param>
		/// <returns>bool</returns>
		/// **************************************************************************
		public static bool KFDelCheck(SqlConnection cn,string KFDM)
		{
			if(KFDM==null || KFDM.Length<1)
				return true;

			try
			{	
				string sql = "select count(*) from kctzb where ckdm='" + KFDM + "'";
				SqlCommand cmd = new SqlCommand(sql, cn);		
				
				int iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());
				
				if(iGetNum==0)
				{
					sql = "Select count(*) From DBD Where ZT in ('0','2','3') and (DRK='"+KFDM+"' OR DCK='"+KFDM+"')";
					cmd = new SqlCommand(sql, cn);	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());
					
					if(iGetNum==0)
						return true;
					else
						return false;
				}
				else
					return false;

			}
			catch(Exception e)
			{
				LogService.Write ("com.ascs.plp.publics.DeleteCheck:  KFDelCheck(string KFDM)");
				LogService.Write (e.Message);
				return false;
			}
		}
		/// **************************************************************************
		/// END
		/// **************************************************************************

		/// **************************************************************************
		/// BEIGIN
		/// <summary>
		/// 机构删除检查:当返回true时,才能执行删除动作
		/// 	该机构下所有的部门为不可用状态
		/// </summary>
		/// /// <param name="SqlConnection">SqlConnection cn对象</param>
		/// <param name="JGDM">机构代码</param>
		/// <returns>bool</returns>
		/// **************************************************************************
		public static bool JGDelCheck(SqlConnection cn,string JGDM)
		{
			if(JGDM==null || JGDM.Length<1)
				return true;

			try
			{	
				string sql = "select COUNT(*) from DEPARTMENTS WHERE JGDM='" + JGDM + "'";
				SqlCommand cmd = new SqlCommand(sql, cn);		
				
				int iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());
				
				if(iGetNum==0)
					return true;
				else
					return false;

			}
			catch(Exception e)
			{
				LogService.Write ("com.ascs.plp.publics.DeleteCheck: JGDelCheck(SqlConnection cn,string JGDM)");
				LogService.Write (e.Message);
				return false;
			}
		}
		/// **************************************************************************
		/// END
		/// **************************************************************************


		/// **************************************************************************
		/// BEIGIN
		/// <summary>
		/// 部门删除检查: 当返回true时,才能执行删除动作
		/// 	需要对应的下属人员都已经为不可用的状态
		/// </summary>
		/// /// <param name="SqlConnection">SqlConnection cn对象</param>
		/// <param name="DEPTID">部门代码</param>
		/// <returns>bool</returns>
		/// **************************************************************************
		public static bool DEPTDelCheck(SqlConnection cn,string DEPTID)
		{
			if(DEPTID==null || DEPTID.Length<1)
				return true;

			try
			{	
				string sql = "select COUNT(B.DEPTID) from EMPLOYEES A,EMPLDEPT B WHERE A.EMPLENABLED='1' AND A.EMPLID=B.EMPLID AND B.DEPTID='" + DEPTID + "'";
				SqlCommand cmd = new SqlCommand(sql, cn);		
				
				int iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());
				
				if(iGetNum==0)
					return true;
				else
					return false;

			}
			catch(Exception e)
			{
				LogService.Write ("com.ascs.plp.publics.DeleteCheck:  DEPTDelCheck(SqlConnection cn,string DEPTID)");
				LogService.Write (e.Message);
				return false;
			}
		}
		/// **************************************************************************
		/// END
		/// **************************************************************************



		/// **************************************************************************
		/// BEIGIN
		/// <summary>
		/// 人员删除检查: 当返回true时,才能执行删除动作
		/// 	1客户信息中的销售员身份检查
		///		2销售员信息表的检查 
		///		3未完成销售订单中销售员、
		///		4未完成销售订单细目的 库存保管员的记录数检查
		///		5未处理的采购申请中申请人的记录数检查
		///		6未审核的采购订单中采购员的记录数检查	
		///		7未完成的采购收货单中对应信息的检测:收货单细目表库存保管员
		///		8未完成的采购退货中负责人的检测
		///		9库房负责人的检测	
		///		10外部库房负责人的检测	
		///		11出入库单细目中未处理的单据中负责人的检测
		///		12未完成的库存调拨中审核人的检测	
		///		13讨论区类别中版主的检测
		/// </summary>
		/// /// <param name="SqlConnection">SqlConnection cn对象</param>
		/// <param name="EmplID">人员代码</param>
		/// <returns>bool</returns>
		/// **************************************************************************
		public static bool EMPLDelCheck(SqlConnection cn,string EmplID)
		{
			bool bReturn=true;

			if(EmplID==null || EmplID.Length<1)
				return true;

			try
			{	
				SqlCommand cmd = cn.CreateCommand();

				//1客户信息中的销售员身份检查
				string sql = "select count(*) from khxx where xsy=@emplID";
				cmd.CommandText = sql;
				cmd.Parameters.Add("@emplID",EmplID);				
				int iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());				
				if(iGetNum>0)
					bReturn=false;
				
				//2销售员信息表的检查 
				if(bReturn)
				{
					sql = "select count(*) from xsy where xsydm=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				
				//3未完成销售订单中销售员、
				if(bReturn)
				{
					sql = "select count(*) from xsdd where XSDDZT<>'7' and XSYDM=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				//4未完成销售订单细目的 库存保管员的记录数检查
				if(bReturn)
				{
					sql = "select count(*) from xsdd a,xsddxm b where a.XSDDZT<>'7' and a.xsddh=b.xsddh and b.CKBGY=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}

				//5未处理的采购申请中申请人的记录数检查
				if(bReturn)
				{
					sql = "select count(*) from cgsqd where SQRDM=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				//6未审核的采购订单中采购员的记录数检查	
				if(bReturn)
				{
					sql = "select count(*) from cgsqd where SHBJ<>'2' and SQRDM=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				//7未完成的采购收货单中对应信息的检测:收货单细目表库存保管员
				if(bReturn)
				{
					sql = "select count(*) from SHDB a,shdxmb b where a.shdbid=b.shdbid and a.RKFLAG='0' and b.KCBGY=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				
				//8未完成的采购退货中负责人的检测	
				if(bReturn)
				{
					sql = "select COUNT(*) from cgthd where CKBJ='0' and FZR=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				
				///	9库房负责人的检测	
				if(bReturn)
				{
					sql = "select count(*) from ckb where fzr=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				///10外部库房负责人的检测	
				if(bReturn)
				{
					sql = "select count(*) from wbkf where fzr=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				
				///	11出入库单细目中未处理的单据中负责人的检测
				if(bReturn)
				{
					sql = "select count(*) from crkd a,crkdxm b where a.wcbz<>'1' and a.crkdh=b.crkdh and b.zrr=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}
				
				///		12未完成的库存调拨中审核人的检测	
				///		13讨论区类别中版主的检测
				if(bReturn)
				{
					sql = "select count(*) from TLQLB where bz=@emplID";
					cmd.CommandText = sql;	
					iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());					
					if(iGetNum>0)						
						return false;
				}		
		
				return bReturn;

			}
			catch(Exception e)
			{
				LogService.Write ("com.ascs.plp.publics.DeleteCheck:  EMPLDelCheck(SqlConnection cn,string EmplID)");
				LogService.Write (e.Message);
				return false;
			}
		}
		/// **************************************************************************
		/// END
		/// **************************************************************************



		/// **************************************************************************
		/// BEIGIN
		/// <summary>
		/// 机构类型删除检查:当返回true时,才能执行删除动作
		/// 机构信息表中没有使用该机构类型的信息。
		/// </summary>
		/// /// <param name="SqlConnection">SqlConnection cn对象</param>
		/// <param name="JGDM">机构类型</param>
		/// <returns>bool</returns>
		/// **************************************************************************
		public static bool JGLXDelCheck(SqlConnection cn,string JGLX)
		{
			if(JGLX==null || JGLX.Length<1)
				return true;

			try
			{ 
				string sql = "select COUNT(*) from JGXX WHERE JGLXDM='" + JGLX + "'";
				SqlCommand cmd = new SqlCommand(sql, cn); 

				int iGetNum = Convert.ToInt16(cmd.ExecuteScalar().ToString());

				if(iGetNum==0)
					return true;
				else
					return false;

			}
			catch(Exception e)
			{
				LogService.Write ("com.ascs.plp.publics.DeleteCheck:   DelCheck(SqlConnection cn,string JGLXDM)");
				LogService.Write (e.Message);
				return false;
			}
		}
		/// **************************************************************************
		/// END
		/// **************************************************************************



		/// **************************************************************************
		/// BEIGIN
		/// <summary>
		/// 角色删除检查:当返回true时,才能执行删除动作
		/// 即当流程模板中没有使用该角色时,才能删除。
		/// </summary>		
		/// <param name="roleid">角色ID</param>		
		/// <returns>bool</returns>
		/// **************************************************************************
		public static bool RolesDelCheck(int roleid)
		{
			bool bRetrun=true;
			try
			{
				WorkflowMgr wMgr = new WorkflowMgr();
				ArrayList templateList =  wMgr.ListTemplates();
				for(int i=0;i<templateList.Count;i++)
				{
					Message t_msg = (Message)templateList[i];
     
					if (t_msg==null)
						continue;
					ArrayList nodeList = (ArrayList)wMgr.FindNodes(t_msg.MessageID);
					if (nodeList!=null && nodeList.Count>0)
					{
						for(int j=0;j<nodeList.Count;j++)
						{
							Node t_node = (Node)nodeList[j];
							if (t_node==null)
								continue;
							if(handlerAddressParser(t_node.HandlerAddress,roleid))
							{
								bRetrun = false;
								break;
							}
						}
					}
				}
			}
			catch(Exception e)
			{
				LogService.WriteLog("com.ascs.plp.publics.DeleteCheck: RolesDelCheck(int roleid)");
				LogService.WriteLog(e.Message);
				return false;
			}
		return bRetrun;
		}
 

		public static bool handlerAddressParser(string Address,int roleid)
		{
			try
			{
				if (Address == "")
				{
					return false;
				}
 
				// 是否申请者
				if (Address == "appl" || Address == "申请人")
					return false;
 
				// 取得操作者字符串中的冒号位置
				int n = Address.IndexOf(":");
				string p = "";
				string v = "";
 
				if (n > 0)
				{
					// 取得冒号前面的协议
					p = Address.Substring(0,n);
					// 取得冒号后面的值
					v = Address.Substring(n+1);
				}
				else
				{
					// 如果没有冒号,使用默认协议,即该字符串表示本系统中的用户
					p = "user";
					v = Address;
				}
 
				string [] param;
 
				switch (p)
				{
					case "user": // 操作者指向用户名
						return false;      
					case "group": // 操作者指向组
						return false;
					case "pos":  // 操作者指向部门、职位或角色,格式 pos:[部门],[角色],[职位]
						param = v.Split(',');
						string DeptID = param[0];
						int RoleID = int.Parse(param[1]);
						int PosID = int.Parse(param[2]);
						if (RoleID==roleid)
							return true;
						else
							return false;
				}
				return false;
			}
			catch(Exception e)
			{
				LogService.WriteLog("handlerAddressParser:");
				LogService.WriteLog(e.Message);
				return false;
			}
		}


	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -