?? add.aspx.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 + -