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

📄 com_systemaccount.asmx.cs

📁 ASP.NET的一些开发实例,有论坛管理系统等
💻 CS
📖 第 1 页 / 共 2 页
字号:
			{
				switch (EditType)
				{
					case "0":
						sReturn = "修改成功";
						break;
					case "1":
						sReturn = "修改成功";
						break;
					case "2":
						sReturn = str_acc_num;
						break;
				}
				
			}
			if(nErr !=1)
			{
				myTrans.Commit();
				this.SqlConn.Close();
			}
			
		}

		[WebMethod]
		public void DeleteData(string WhereString,ref string sReturn)
		{
			SqlCommand mySqlCommand = new SqlCommand();
			SqlTransaction myTrans;
			string SqlString = WhereString;

			this.SqlConn.Open();//启动连接
			myTrans = this.SqlConn.BeginTransaction();//建立事务
			mySqlCommand.Connection = this.SqlConn;//建立sql命令连接
			mySqlCommand.Transaction = myTrans;//绑定事务

			string str_TableName = "system_account";
			int nErr = this.COM_BASE.DeleteTableBase(ref mySqlCommand,ref SqlConn,ref myTrans,str_TableName,ref SqlString);
			if (nErr == 1)
			{
				sReturn = "删除失败";
			}
			else
			{
				sReturn = "删除成功";
			}
			if(nErr !=1)
			{
				myTrans.Commit();
				this.SqlConn.Close();
			}
		}

		[WebMethod]
		public DataSet CheckPassWord(string[] FieldValue,ref string sReturn)
		{
			string str_Sql=string.Format("select * from system_account where acc_name='{0}' and acc_password='{1}'",FieldValue[0],FieldValue[1]);
			DataSet ds=this.COM_BASE.CreateDataSetFromSql(str_Sql);
			if(ds.Tables[0].Rows.Count>0)
			{
				foreach(DataRow row in ds.Tables[0].Rows)
				{
					sReturn=row["acc_emp"].ToString();
				}
			}
			else
			{
				sReturn="1";
			}
			return ds;
		}

		[WebMethod]
		public void EditPassword()
		{
			string[] FieldValue = {};
			DataSet dsPs = this.DsMainListForAll(FieldValue);
			for(int i=0;i<dsPs.Tables[0].Rows.Count;i++)
			{
				dsPs = this.DsMainListForAll(FieldValue);
			A: string password = this.CreatePassword();
				string unique = this.DRUnique(password,dsPs.Tables[0]);
				if(unique =="0")
				{
					string strsql = string.Format(" update system_account set acc_password = '{0}' where acc_num = '{1}'",password,dsPs.Tables[0].Rows[i]["acc_num"].ToString());
					this.COM_BASE.CreateDataSetFromSql(strsql);
				}
				else
				{
					goto A;
				}
			}			
		}

		private string DRUnique(string accps,DataTable dt)
		{
			foreach(DataRow dr2 in dt.Rows)
			{
				if(accps == dr2["acc_password"].ToString())
				{
					return "1";
				}
			}
			return "0";
		}

		[WebMethod]
		public string CreatePassword()
		{
			string password;
			Random ran = new Random();
			string num = ran.Next(000,999).ToString();
			password = this.CreateRandomString(3);
			password = string.Format("{0}{1}",password,num);
			return password;
		}

		private string CreateRandomString(int length)
		{
			Encoding encoding = Encoding.ASCII;
			byte[] buf = new Byte[encoding.GetByteCount(new string(' ', length))];
			for (;;)
			{
				Random r = new Random();
				for(int i=0;i<length;i++)
				{
					int ASCIINum = r.Next(97,122);
					buf[i] = (byte)ASCIINum;
				}				
				try
				{
					return new string(encoding.GetChars(buf));
				}
				catch(Exception)
				{
				}
			}
		}

		[WebMethod]
		public DataSet DsAccUnderRes(string accname,string depNum)
		{
			DataSet dsUnRes = new DataSet();
			string strsql = string.Format(" select * from system_account where acc_name = '{0}'",accname);
			DataSet ds = this.COM_BASE.CreateDataSetFromSql(strsql);
			if(ds.Tables[0].Rows.Count == 1)
			{
				string under_res = ds.Tables[0].Rows[0]["under_res"].ToString();
				if(under_res.Trim() != "[ALL]")
				{
					//					under_res = under_res.Replace("[",string.Empty);
					//					under_res = under_res.Replace("]",string.Empty);
					//					string[] acc_name = under_res.Split(new char[]{','});							
					//					for(int j=0;j<acc_name.Length;j++)
					//					{
					//						strsql = string.Format(" {0} acc_name = '{1}' or ",strsql,acc_name[j]);
					//					}
					//					strsql = strsql.Remove(strsql.Length-3,3);
					//					strsql = string.Format(" select * from system_account where {0}",strsql);
					under_res = under_res.Replace("[","'");
					under_res = under_res.Replace("]","'");
					strsql = string.Format(" acc_name in ({0})",under_res);
					strsql = string.Format(" select * from system_account where {0}",strsql);
				}
				else
				{
					strsql = string.Format(" select * from system_account");
				}

				dsUnRes = this.COM_BASE.CreateDataSetFromSql(strsql);
				if(depNum.Trim() != string.Empty)
				{
					string sqlwhere = string.Format("dep_num <> '{0}'",depNum);
					DataRow[] dr = dsUnRes.Tables[0].Select(sqlwhere,"",DataViewRowState.CurrentRows);
					foreach(DataRow row in dr)
					{
						dsUnRes.Tables[0].Rows.Remove(row);
					}
				}
			}
			return dsUnRes;
		}

		[WebMethod]
		public DataSet GetRoleForUser(string UserSchema,string UserRole)
		{
			UserSchema=UserSchema.Replace("[","'");
			UserSchema=UserSchema.Replace("]","'");

			DataSet ds=this.COM_BASE.CreateDataSetFromSql("select schema_role from system_schema where schema_num in ("+UserSchema+")");
			DataTable dt=new DataTable();
			dt.Columns.Add(new DataColumn("role_num",typeof(string)));
			DataRow dr;

			//插入角色权限数据
			foreach(DataRow row in ds.Tables[0].Rows)
			{
				string[] arr_Role=row["schema_role"].ToString().Split(new char[]{','});
				for(int i=0;i<arr_Role.Length;i++)
				{
					DataRow[] CurrentRow=dt.Select("role_num='"+arr_Role[i]+"'",null,DataViewRowState.CurrentRows);
					if(CurrentRow.Length==0)
					{
						dr=dt.NewRow();
						dr["role_num"]=arr_Role[i];
						dt.Rows.Add(dr);
					}
				}
			}

			//插入用户权限数据
			if(UserRole!=null&&UserRole.Trim()!="")
			{
				string[] arr_Role1=UserRole.Split(new char[]{','});
				for(int i=0;i<arr_Role1.Length;i++)
				{
					DataRow[] CurrentRow=dt.Select("role_num='"+arr_Role1[i]+"'",null,DataViewRowState.CurrentRows);
					if(CurrentRow.Length==0)
					{
						dr=dt.NewRow();
						dr["role_num"]=arr_Role1[i];
						dt.Rows.Add(dr);
					}
				}
			}

			//整理数据
			foreach(DataRow row in dt.Rows)
			{
				row["role_num"]=row["role_num"].ToString().Replace("[","'");
				row["role_num"]=row["role_num"].ToString().Replace("]","'");
			}
			DataRow[] CurrentRow1=dt.Select("role_num='' or role_num=null",null,DataViewRowState.CurrentRows);
			foreach(DataRow row in CurrentRow1)
			{
				dt.Rows.Remove(row);
			}

			DataSet dsRole=new DataSet();
			dsRole.Tables.Add(dt);
			return dsRole;
		}

		[WebMethod]
		public DataSet DsAcc(string accname,string accemp)
		{
			DataSet ds = new DataSet();
			string sqlwhere = string.Empty;
			if(accname.Trim() !=string.Empty)
			{
				sqlwhere = string.Format("acc_name like '%{0}%'",accname);
			}
			if(accemp.Trim() !=string.Empty && accname.Trim() ==string.Empty)
			{
				sqlwhere = string.Format("acc_emp like '%{0}%'",accemp);
			}
			if(sqlwhere.Trim() != string.Empty)
			{
				sqlwhere = string.Format("select acc_name,acc_emp,isnull(t_topic_count,0) as t_topic_count,isnull(t_reply_count,0) as t_reply_count from system_account where {0}",sqlwhere);
				ds= this.COM_BASE.CreateDataSetFromSql(sqlwhere);
			}
			return ds;
		}

	}
}

⌨️ 快捷键说明

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