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

📄 add.aspx.cs

📁 c#做的WEB disk
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;

namespace ConfirmWebDisk.friendshare
{
	/// <summary>
	/// add 的摘要说明。
	/// </summary>
	public class add : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.Button addBtn;
		protected System.Web.UI.WebControls.Table iDeskShareListTable;
		public string iHiveId,HiveId,typesize,AttachHiveID;
			webihClass.iHiveIDClass iHive = new webihClass.iHiveIDClass();
		public string iH_wwwServer;
		public string mail,rss,collection,search,web,tool;
		protected System.Web.UI.WebControls.ListBox FriendUserListBox;
		protected System.Web.UI.WebControls.Button ToDelBtn;
		protected System.Web.UI.WebControls.Button ToFriendBtn;
		protected System.Web.UI.WebControls.Button delBtn;
		protected System.Web.UI.WebControls.ListBox DeleteUserListBox;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			bool IsAuthen;
			iHiveId = Request.Params[0].ToString();//我的蜂盘号码
			Session["persondiskid"] = iHiveId;
			HiveId = Request.Params[1].ToString();//蜂盘验证号码
			typesize = Request.Params[2].ToString();//蜂盘大小
			AttachHiveID = Request.Params[3].ToString();//附加验证码
			iH_wwwServer = iH_ServerAddr(iHiveId);
			if(!IsPostBack)
			{			

				BindListData(iHiveId);
				IsAuthen = iHive.IsAuthiHiveID( iHiveId,typesize,HiveId );
				if( IsAuthen == true )
				{
					
					DataSet ds = new DataSet();
					APP.DataBase DB = new ConfirmWebDisk.friendshare.APP.DataBase();
					ds = DB.ExecuteStoreProc("JL_APPWeb");
					Random rd = new Random(10000);
					mail = ds.Tables[0].Rows[0][0].ToString()+"?Uid="+Session["persondiskid"].ToString()+"&id="+rd.Next().ToString()+"&pid="+(((Convert.ToUInt64(Session["persondiskid"].ToString())+49)*2-1001)*3).ToString();
					rss  = ds.Tables[0].Rows[1][0].ToString()+"?Uid="+Session["persondiskid"].ToString()+"&id="+rd.Next().ToString()+"&pid="+(((Convert.ToUInt64(Session["persondiskid"].ToString())+49)*2-1001)*3).ToString();
					collection = ds.Tables[0].Rows[2][0].ToString()+"?Uid="+Session["persondiskid"].ToString()+"&id="+rd.Next().ToString()+"&pid="+(((Convert.ToUInt64(Session["persondiskid"].ToString())+49)*2-1001)*3).ToString();
					search = ds.Tables[0].Rows[3][0].ToString()+"?Uid="+Session["persondiskid"].ToString()+"&id="+rd.Next().ToString()+"&pid="+(((Convert.ToUInt64(Session["persondiskid"].ToString())+49)*2-1001)*3).ToString();
					web = ds.Tables[0].Rows[4][0].ToString()+"?Uid="+Session["persondiskid"].ToString()+"&id="+rd.Next().ToString()+"&pid="+(((Convert.ToUInt64(Session["persondiskid"].ToString())+49)*2-1001)*3).ToString();
					tool = ds.Tables[0].Rows[5][0].ToString()+"?Uid="+Session["persondiskid"].ToString()+"&id="+rd.Next().ToString()+"&pid="+(((Convert.ToUInt64(Session["persondiskid"].ToString())+49)*2-1001)*3).ToString();
				}
			}// 在此处放置用户代码以初始化页面
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.addBtn.Click += new System.EventHandler(this.addBtn_Click);
			this.ToDelBtn.Click += new System.EventHandler(this.ToDelBtn_Click);
			this.ToFriendBtn.Click += new System.EventHandler(this.ToFriendBtn_Click);
			this.delBtn.Click += new System.EventHandler(this.delBtn_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void BindListData(string iHiveId)
		{
			SqlConnection Connection = new SqlConnection( ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand Command = new SqlCommand("JL_FriendList",Connection);
			Command.CommandType = CommandType.StoredProcedure;

			Command.Parameters.Add("@UserID",SqlDbType.BigInt,16,"UserID");
			Command.Parameters["@UserID"].Value = Convert.ToInt64(iHiveId);

			Connection.Open();
			SqlDataReader reader = Command.ExecuteReader();
			while( reader.Read() )
			{
				ListItem li = new ListItem();
				li.Text = GetLoginID( reader["FriendUserID"].ToString() );
				li.Value = reader["FriendUserID"].ToString();
				FriendUserListBox.Items.Add(li);
			}
			Connection.Close();
			
			
		}
		private string GetLoginID(string vdiskid)
		{
			string loginId;
			SqlConnection Connection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand Command = new SqlCommand("Select loginID From JL_Tv_UserInfo Where vdiskid='"+vdiskid+"'",Connection);
			Connection.Open();
			loginId = Command.ExecuteScalar().ToString();
			Connection.Close();

			return loginId;
		}


		private void addBtn_Click(object sender, System.EventArgs e)
		{
			SqlConnection Connection = new SqlConnection( ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand Command = new SqlCommand("JL_AddFriend",Connection);
			Command.CommandType = CommandType.StoredProcedure;

			Command.Parameters.Add("@loginID",SqlDbType.VarChar,50,"loginID");
			Command.Parameters["@loginID"].Value = TextBox1.Text;
			Command.Parameters.Add("@userid",SqlDbType.BigInt,12,"userid");
			Command.Parameters["@userid"].Value = Convert.ToInt64(Session["persondiskid"].ToString());
			int result = -1;
			Connection.Open();
			try
			{
				result = Command.ExecuteNonQuery();
			}
			catch
			{
				result = 0;
			}
			finally
			{
				Connection.Close();
			}
			if( result == -1 )
				Response.Write("<script>alert('好友授权失败')</script>");
			else
				Response.Write("<script>alert('好友授权成功');location.href='index.aspx?UID="+iHiveId+"&iHiveid="+HiveId+"&typesize="+typesize+"&attachHiveID="+AttachHiveID+"'</script>");
		}
		private string iH_ServerAddr(string iHiveID)//我的蜂盘服务地址
		{
			string iHiveServerAddr = "http://jlwt.1g.cn/webdisk/";
			SqlConnection Connection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand Command = new SqlCommand("Select Hive_www From HD_ServerList",Connection);
			Connection.Open();
			iHiveServerAddr = Command.ExecuteScalar().ToString();
			Connection.Close();
			/*SqlConnection Connection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand Command = new SqlCommand("SP_iHiveServerAddr",Connection);
			Command.CommandType = CommandType.StoredProcedure;

			Command.Parameters.Add("@iHiveID",SqlDbType.Int,4);
			Command.Parameters.Add("@iH_www",SqlDbType.VarChar,50,"iH_www");

			Command.Parameters["@iH_www"].Direction = ParameterDirection.Output;
			Command.Parameters["@iHiveID"].Value = iHiveID;
			
			Connection.Open();
			Command.ExecuteNonQuery();
			iHiveServerAddr = Command.Parameters["@iH_www"].Value.ToString();
			Connection.Close();*/

			return iHiveServerAddr;

		}

		private void ToDelBtn_Click(object sender, System.EventArgs e)
		{
			for( int i =0 ;i <FriendUserListBox.Items.Count; i++)
			{
				if( FriendUserListBox.Items[i].Selected == true )
				{
					DeleteUserListBox.Items.Add( FriendUserListBox.Items[i]);
				}
			}
				
		}

		private void ToFriendBtn_Click(object sender, System.EventArgs e)
		{
			DeleteUserListBox.Items.Clear();
		}

		private void delBtn_Click(object sender, System.EventArgs e)
		{
			foreach(ListItem li in DeleteUserListBox.Items)
			{
				deleteFriendUser( iHiveId ,li.Value );
			}
			Response.Write("<script>location.href='index.aspx?UID="+iHiveId+"&iHiveid="+HiveId+"&typesize="+typesize+"&attachHiveID="+AttachHiveID+"'</script>");
		}
		private void deleteFriendUser(string userid ,string friendUserId)
		{
			SqlConnection Connection = new SqlConnection( ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand Command = new SqlCommand("JL_DeleteFriend",Connection);
			Command.CommandType = CommandType.StoredProcedure;

			Command.Parameters.Add("@UserID",SqlDbType.BigInt,16,"UserID");
			Command.Parameters["@UserID"].Value = Convert.ToInt64(userid);
			Command.Parameters.Add("@FriendUserID",SqlDbType.BigInt,16,"FriendUserID");
			Command.Parameters["@FriendUserID"].Value = Convert.ToInt64( friendUserId );

			Connection.Open();
			Command.ExecuteNonQuery();
			Connection.Close();
		}

	}
}

⌨️ 快捷键说明

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