//第1頁
MsSqlConnectionFirstPage.prototype._AutomaticName_ = function()
{
	var Table = $("#Main_Center-Content").find(".Body").eq(0).find(".Table").eq(0);
	var Index = 1;
	var object = jQuery.parseJSON(JSON.stringify(Global_MsSqlConnection));
	var number = Object.keys(object);
	var Name, NameArray=new Array();
	for(var i=0; i<number.length; i++)
	{
		NameArray.push(object[number[i]]["IdentificationName"]);
	}
	while(true)
	{
		Name = "Name"+Index;
		if(NameArray.indexOf(Name) == -1)
		{
			break;
		}
		Index++;
	}
	Table.find(".Row").eq(1).find(".Text").val(Name);
}

MsSqlConnectionFirstPage.prototype._BuildMsSqlConnectionObject_ = function(that)
{
	var number = Object.keys(Global_MsSqlConnection);
	if(number.length == 0)
	{
		number=1;
	}
	else if(number.length>0)
	{
		number = Math.max.apply(null,number)+1;
	}
	if(typeof(Global_MsSqlConnection[number]) == "undefined")
	{
		Global_MsSqlConnection[number] = new Object();
		Global_MsSqlConnection[number]["IdentificationName"] = $(that).closest(".Row").find(".Column").eq(2).find(".Text").val();
		Global_MsSqlConnection[number]["Driver"] = "MSSQL";
		Global_MsSqlConnection[number]["DatabaseName"] = "DatabaseName";
		Global_MsSqlConnection[number]["TableName"] = "TableName";
		Global_MsSqlConnection[number]["ServerName"] = "127.0.0.1\\SQLEXPRESS";
		Global_MsSqlConnection[number]["Port"] = 1433;
		Global_MsSqlConnection[number]["Account"] = "root";
		Global_MsSqlConnection[number]["Password"] = "root";
		Global_MsSqlConnection[number]["DatabaseMode"] = "Cycle";
		Global_MsSqlConnection[number]["Deadband"] = 0;
		Global_MsSqlConnection[number]["IntervalSeconds"] = 5;
		Global_MsSqlConnection[number]["DateTimeFormat"] = "yyyy-MM-dd,HH:mm:ss";
		Global_MsSqlConnection[number]["Enable"] = true;
	}
}

MsSqlConnectionFirstPage.prototype._ShowTable_ = function(number, DisplayNumber)
{
	var html = $(".Dynamic").html();  var PageNumber = $("#Toolbar").find(".Text").val();
	Id = "#MsSqlConnectionTable";
	$(Id).find(".DynamicRow").remove();
	var Start = (PageNumber-1)*DisplayNumber;
	if((number.length-Start)>DisplayNumber){
		var End = Start + DisplayNumber;
	}
	else{
		var End = number.length;
	}
	var index = 0;  var Variable = Global_MsSqlConnection;
	for(var i=Start; i<End && End!=0; i++)
	{
		$(Id).append(html);
		$(Id).find(".DynamicRow").eq(index).find(".Column").eq(0).text(number[i]);
		$(Id).find(".DynamicRow").eq(index).find(".Column").eq(2).text(Variable[number[i]]["IdentificationName"]);
		$(Id).find(".DynamicRow").eq(index).find(".Column").eq(3).find(".Label").hide();
		if(Variable[number[i]]["Enable"] == false){
			$(Id).find(".DynamicRow").eq(index).find(".Column").eq(3).find(".Label").eq(1).show();
		}
		else if(Variable[number[i]]["Enable"] == true){
			$(Id).find(".DynamicRow").eq(index).find(".Column").eq(3).find(".Label").eq(0).show();
		}
		index++;
	}
}

MsSqlConnectionFirstPage.prototype._UpdateTableToolbar_ = function(number, DisplayNumber)
{
	var NumberOfPages = Math.ceil(number.length/DisplayNumber);
	var Id = "#Toolbar";
	$(Id).find("label").eq(1).text(NumberOfPages);
	var CurrentlyPage = $(Id).find(".Text").val();
	CurrentlyPage = parseInt(CurrentlyPage);
	if(CurrentlyPage>NumberOfPages)
	{
		$(Id).find(".Text").val(NumberOfPages);
	}
	else if(CurrentlyPage<=0 || isNaN(CurrentlyPage)==true)
	{
		$(Id).find(".Text").val(1);
	}
	else
	{
		$(Id).find(".Text").val(CurrentlyPage);
	}
}

MsSqlConnectionFirstPage.prototype._RedisplayUi_ = function()
{
	var DisplayNumber = 10;
	var number = Object.keys(Global_MsSqlConnection);
	MsSqlConnectionFirstPage.prototype._UpdateTableToolbar_(number, DisplayNumber);
	MsSqlConnectionFirstPage.prototype._ShowTable_(number, DisplayNumber);
	var Id = "#MsSqlConnectionTable";
	$(Id).find(".Row").eq(0).find(":checkbox").prop("checked",false);
}

MsSqlConnectionFirstPage.prototype._AddNewRow_ = function(that)
{
	MsSqlConnectionFirstPage.prototype._CheckIdentificationName_();
	var Id = "#MsSqlConnectionTable";
	var ShowErrorMessage = $(Id).find(".Row").eq(0).find(".Message").is(":visible");
	if(ShowErrorMessage == true)	{return 0;}
	MsSqlConnectionFirstPage.prototype._BuildMsSqlConnectionObject_(that);
	MsSqlConnectionFirstPage.prototype._RedisplayUi_();
	MsSqlConnectionFirstPage.prototype._AutomaticName_();
}

MsSqlConnectionFirstPage.prototype._ShowPreviousPage_ = function()
{
	var Id = "#Toolbar";
	var CurrentlyPage = $(Id).find(".Text").val();
	$(Id).find(".Text").val(parseInt(CurrentlyPage)-1);
	MsSqlConnectionFirstPage.prototype._RedisplayUi_();
}

MsSqlConnectionFirstPage.prototype._ShowNextPage_ = function()
{
	var Id = "#Toolbar";
	var CurrentlyPage = $(Id).find(".Text").val();
	$(Id).find(".Text").val(parseInt(CurrentlyPage)+1);
	MsSqlConnectionFirstPage.prototype._RedisplayUi_();
}

MsSqlConnectionFirstPage.prototype._RemoveRtuToMsSql_ = function(number)
{
	var Variable = Global_RtuToMsSqlVariable;
	var ModuleIndex=Object.keys(Variable);
	for(var i=0; i<ModuleIndex.length; i++)
	{
		var SystemVariable = Object.keys(Variable[ModuleIndex[i]]);
		for(var j=0; j<SystemVariable.length; j++)
		{
			if(number = Variable[ModuleIndex[i]][SystemVariable[j]]["DatabaseIndex"])
			{
				Variable[ModuleIndex[i]][SystemVariable[j]]["DatabaseIndex"] = "";
			}
		}
	}
}

MsSqlConnectionFirstPage.prototype._RemoveMqttToMsSql_ = function(number)
{
	var Variable = Global_MqttToMsSqlVariable;
	var ModuleIndex=Object.keys(Variable);
	for(var i=0; i<ModuleIndex.length; i++)
	{
		var SystemVariable = Object.keys(Variable[ModuleIndex[i]]);
		for(var j=0; j<SystemVariable.length; j++)
		{
			if(number = Variable[ModuleIndex[i]][SystemVariable[j]]["DatabaseIndex"])
			{
				Variable[ModuleIndex[i]][SystemVariable[j]]["DatabaseIndex"] = "";
			}
		}
	}
}

MsSqlConnectionFirstPage.prototype._RemoveTcpToMsSql_ = function(number)
{
	var Variable = Global_TcpToMsSqlVariable;
	var ModuleIndex=Object.keys(Variable);
	for(var i=0; i<ModuleIndex.length; i++)
	{
		var SystemVariable = Object.keys(Variable[ModuleIndex[i]]);
		for(var j=0; j<SystemVariable.length; j++)
		{
			if(number = Variable[ModuleIndex[i]][SystemVariable[j]]["DatabaseIndex"])
			{
				Variable[ModuleIndex[i]][SystemVariable[j]]["DatabaseIndex"] = "";
			}
		}
	}
}

MsSqlConnectionFirstPage.prototype._RemoveGlobalVariable_ = function(number)
{
	Global_MsSqlConnection[number] = null;	delete Global_MsSqlConnection[number];
	MsSqlConnectionFirstPage.prototype._RemoveRtuToMsSqlConnection_(number);
	MsSqlConnectionFirstPage.prototype._RemoveTcpToMsSqlConnection_(number);
}

MsSqlConnectionFirstPage.prototype._RemoveTickedMsSqlConnection_ = function()
{
	var Id = "#MsSqlConnectionTable";
	var element = $(Id).find(".DynamicRow").find(":checked");
	var CheckedLength = element.length;
	for(var i=0; i<CheckedLength; i++)
	{
		var number = element.eq(i).closest(".DynamicRow").find(".Column").eq(0).text();
		MsSqlConnectionFirstPage.prototype._RemoveGlobalVariable_(number);
	}
}

MsSqlConnectionFirstPage.prototype._DeleteMsSqlConnection_ = function()
{
	MsSqlConnectionFirstPage.prototype._RemoveTickedMsSqlConnection_();
	MsSqlConnectionFirstPage.prototype._RedisplayUi_();
}

MsSqlConnectionFirstPage.prototype._IsNameRepeat_ = function(Name)
{
	var Return=false;
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var CurrentlyNumber = Row.eq(0).find(".Text").val();
	var number = Object.keys(Global_MsSqlConnection);
	for(var i=0; i<number.length; i++)
	{
		if(Name == Global_MsSqlConnection[number[i]]["IdentificationName"])
		{
			Return=true;
			break;
		}
	}
	return Return;
}

MsSqlConnectionFirstPage.prototype._IsTickedMsSqlConnection_ = function()
{
	var Return=false;
	var Id = "#MsSqlConnectionTable";
	if($(Id).find(".DynamicRow").find(":checked").length >0)
	{
		Return=true;
	}
	return Return;
}

MsSqlConnectionFirstPage.prototype._Initialization_ = function()
{
	MsSqlConnectionFirstPage.prototype._RedisplayUi_();
}

MsSqlConnectionFirstPage.prototype._CheckIdentificationName_ = function()
{
	var Id = "#MsSqlConnectionTable";
	$(Id).find(".Message").hide();
	var Row=$(Id).find(".Row");
	var Name = Row.eq(1).find(".Text").val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(Name) == false)
	{
		Row.eq(0).find(".Message").eq(0).show();
	}
	if(MsSqlConnectionFirstPage.prototype._IsNameRepeat_(Name) == true)
	{
		Row.eq(0).find(".Message").eq(1).show();
	}
}

MsSqlConnectionFirstPage.prototype._SaveStart_ = function(that, ssocket)
{
	ssocket.emit("BackgroundExecution");
	ssocket.on("BackgroundExecution", function (Return) {
	if(Return == true)
	{
		var Callback0 = function(){MsSqlConnectionFirstPage.prototype._SaveFinished_(that, ssocket);}
		
		var GetClass = new GetValue();
		var Callback1 = GetClass.TcpToMsSqlVariableCallback(ssocket, Callback0);
		var Callback2 = GetClass.RtuToMsSqlVariableCallback(ssocket, Callback1);

		var JsonString1 = JSON.stringify(Global_MsSqlConnection);
		$(that).closest('.Row').find(".Message").hide();
		$(that).closest('.Row').find(".Loading").show();
		var Class = new Transmission();
		Class.TransmissionJson(ssocket, "SaveMsSqlConnection", JsonString1, Callback2);
	}
	});
}

MsSqlConnectionFirstPage.prototype._SaveFinished_ = function(that, ssocket)
{
	$(that).closest('.Row').find(".Loading").hide();
	$(that).closest('.Row').find(".Message").eq(1).show();
	ssocket.emit("SaveFinished");
	ssocket.on("SaveFinished", function (Return) {
		if(Return == true)
		{
			$(that).closest('.Row').find(".Message").hide();
			$(that).closest('.Row').find(".Message").eq(0).show();
		}
		else
		{
			$(that).closest('.Row').find(".Message").hide();
			$(that).closest('.Row').find(".Message").eq(2).show();
		}
		ssocket.emit("SocketClose");
	});
}

MsSqlConnectionFirstPage.prototype._EditButton_ = function(that)
{
	$("#Main_Center-Content").find(".Body").eq(1).find(".Message").hide();
	var number = $(that).closest(".DynamicRow").find(".Column").eq(0).text();
	$("#Main_Center-Content").find(".Body").eq(0).hide();	
	var Name = $("#Main_Center-Content").find(".Body").eq(1).find(".FormTitle").eq(0).text();
	$("#Main_Center-Content").find(".Body").eq(1).show();
	var Class = new Path();
	Class.LoadPathHtml(Name, 2);
	Class = null;
	MsSqlConnectionSecondPage.prototype._SetInitialValue_(number);
}

MsSqlConnectionFirstPage.prototype._SaveButton_ = function(that)
{
	$(that).closest('.Row').find(".Loading").hide();
	$(that).closest('.Row').find(".Message").hide();
	var ssocket = io.connect();
	MsSqlConnectionFirstPage.prototype._SaveStart_(that, ssocket);
}




















//第2頁
MsSqlConnectionSecondPage.prototype._CheckIdentificationName_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Name = $(that).val();
	if(Name == "")
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
	}
	if(MsSqlConnectionSecondPage.prototype._IsNameRepeat_(Name) == true)
	{
		$(that).closest(".Row").find(".Message").eq(1).show();
	}
}

MsSqlConnectionSecondPage.prototype._CheckDatabaseName_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var DatabaseName = $(that).val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(DatabaseName) == false)
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
	}
	Class = null;
}

MsSqlConnectionSecondPage.prototype._CheckTableName_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var TableName = $(that).val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(TableName) == false)
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
	}
	Class = null;
}

MsSqlConnectionSecondPage.prototype._CheckServerName_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var ServerName = $(that).val();
	if(ServerName == "")
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
		return 0;
	}
	var array = ServerName.split("\\");
	var Class = new Type();
	if(Class.CheckIp(array[0]) == false || array[1] == "" || typeof(array[1]) == "undefined")
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
	}
	Class = null;
}

MsSqlConnectionSecondPage.prototype._CheckAccount_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Account = $(that).val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(Account) == false)
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
	}
	Class = null;
}

MsSqlConnectionSecondPage.prototype._CheckPassword_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Password = $(that).val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(Password) == false)
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
	}
	Class = null;
}

MsSqlConnectionSecondPage.prototype._CheckIntervalSeconds_ = function(that)
{
	$(that).closest(".RightColumn").find(".Message").hide();
	var IntervalSeconds = $(that).val();
	IntervalSeconds = parseInt(IntervalSeconds);
	var Class = new Type();
	if(Class.CheckPositiveIntegers(IntervalSeconds) == false)
	{
		$(that).val(5);
		return;
	}
	if(IntervalSeconds < 5)
	{
		$(that).val(5);
		return;
	}
	$(that).val(IntervalSeconds);
	Class = null;
}

MsSqlConnectionSecondPage.prototype._CheckGlobalVariableValueExist_ = function(number)
{
	if(typeof(Global_MsSqlConnection[number]["DatabaseMode"]) == "undefined")
	{
		Global_MsSqlConnection[number]["DatabaseMode"] = "Cycle";
	}
	if(typeof(Global_MsSqlConnection[number]["DateTimeFormat"]) == "undefined")
	{
		Global_MsSqlConnection[number]["DateTimeFormat"] = "yyyy-MM-dd,HH:mm:ss";
	}
}

MsSqlConnectionSecondPage.prototype._CheckDeadbandValue_ = function(that)
{
	var Class = new Type();
	var Deadband =  $(that).val();
	if( Class.CheckFloat(Deadband) == false )
	{
		$(that).val(0);
		Class = null;
		return 0;
	}
	if( Deadband.indexOf("-") != -1 )
	{
		Deadband = Deadband.replace("-", "");
		$(that).val(Deadband);
		Class = null;
		return 0;
	}
	Class = null;
}

MsSqlConnectionSecondPage.prototype._IsNameRepeat_ = function(Name)
{
	var Return=false;
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var CurrentlyNumber = Row.eq(0).find(".Text").val();
	var number = Object.keys(Global_MsSqlConnection);
	for(var i=0; i<number.length; i++)
	{
		if(number[i] == CurrentlyNumber)
		{
			continue;
		}	
		if(Name == Global_MsSqlConnection[number[i]]["IdentificationName"])
		{
			Return=true;
			break;
		}
	}
	return Return;
}

MsSqlConnectionSecondPage.prototype._ClearForm_ = function()
{
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	Row.eq(0).find(".Text").val("");
	Row.eq(1).find(".Text").val("");
	Row.eq(2).find(".TextArea").val("");
	Row.eq(3).find(".Text").val("");
	$("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Message").hide();
}

MsSqlConnectionSecondPage.prototype._GetSettingFormValue_ = function()
{
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var number = Row.eq(0).find(".Text").val();
	Global_MsSqlConnection[number]["IdentificationName"] = Row.eq(1).find(".RightColumn").find(".Text").val();
	Global_MsSqlConnection[number]["Driver"]             = Row.eq(2).find(".RightColumn").find(".Select").val();
	Global_MsSqlConnection[number]["DatabaseName"]       = Row.eq(3).find(".RightColumn").find(".Text").val();
	Global_MsSqlConnection[number]["TableName"]          = Row.eq(4).find(".RightColumn").find(".Text").val();
	Global_MsSqlConnection[number]["ServerName"]         = Row.eq(5).find(".RightColumn").find(".Text").val();
	Global_MsSqlConnection[number]["Port"]               = Row.eq(6).find(".RightColumn").find(".Text").val();
	Global_MsSqlConnection[number]["Account"]            = Row.eq(7).find(".RightColumn").find(".Text").val();
	Global_MsSqlConnection[number]["Password"]           = Row.eq(8).find(".RightColumn").find(".Text").val();
	Global_MsSqlConnection[number]["DatabaseMode"]       = Row.eq(9).find(".RightColumn").find(".Select").val();
	Global_MsSqlConnection[number]["Deadband"]           = parseFloat(Row.eq(10).find(".RightColumn").find(".Text").val());
	Global_MsSqlConnection[number]["IntervalSeconds"]    = parseInt(Row.eq(11).find(".RightColumn").find(".Text").val());
	Global_MsSqlConnection[number]["DateTimeFormat"]     = Row.eq(12).find(".RightColumn").find(".Select").val();
	Global_MsSqlConnection[number]["Enable"]             = Row.eq(13).find(".RightColumn").find(":checkbox").prop("checked");
}

MsSqlConnectionSecondPage.prototype._SetFormInitialValue_ = function(number)
{
	var Name=Global_MsSqlConnection[number]["IdentificationName"];
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	Row.eq(0).find(".Text").val(number);
	Row.eq(1).find(".Text").val(Name);
	Row.eq(2).find(".Text").val(Global_MsSqlConnection[number]["Driver"]);
	Row.eq(3).find(".Text").val(Global_MsSqlConnection[number]["DatabaseName"]);
	Row.eq(4).find(".Text").val(Global_MsSqlConnection[number]["TableName"]);
	Row.eq(5).find(".Text").val(Global_MsSqlConnection[number]["ServerName"]);
	Row.eq(6).find(".Text").val(Global_MsSqlConnection[number]["Port"]);
	Row.eq(7).find(".Text").val(Global_MsSqlConnection[number]["Account"]);
	Row.eq(8).find(".Text").val(Global_MsSqlConnection[number]["Password"]);
	Row.eq(9).find(".Select").val(Global_MsSqlConnection[number]["DatabaseMode"]);
	Row.eq(10).find(".Text").val(Global_MsSqlConnection[number]["Deadband"]);
	Row.eq(11).find(".Text").val(Global_MsSqlConnection[number]["IntervalSeconds"]);
	Row.eq(12).find(".Select").val(Global_MsSqlConnection[number]["DateTimeFormat"]);
	Row.eq(13).find(":checkbox").prop("checked", Global_MsSqlConnection[number]["Enable"]);
}

MsSqlConnectionSecondPage.prototype._SetInitialValue_ = function(number)
{
	MsSqlConnectionSecondPage.prototype._ClearForm_();
	MsSqlConnectionSecondPage.prototype._CheckGlobalVariableValueExist_(number);
	MsSqlConnectionSecondPage.prototype._SetFormInitialValue_(number);
	MsSqlConnectionSecondPage.prototype._ChangeCss_(number);
}

MsSqlConnectionSecondPage.prototype._ConfirmButton_ = function(that)
{
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	for(var i=0; i<(Row.length -1); i++)
	{
		var Message = Row.eq(i).find(".Message");
		for(var j=0; j<Message.length; j++)
		{
			if(Message.eq(j).is(":visible") == true && Message.eq(i).css("color") != "rgb(34, 119, 0)")
			{
				$(that).closest(".Form").find(".Message").eq(1).show();
				return 0;
			}
		}
	}

	MsSqlConnectionSecondPage.prototype._GetSettingFormValue_();

	$("#Main_Center-Content").find(".Body").eq(1).hide();
	$("#Main_Center-Content").find(".Body").eq(0).show();
	MsSqlConnectionFirstPage.prototype._RedisplayUi_();
	var Class = new Path();
	Class.LoadPathHtml($("#Left-List-MsSqlConnection").text(), 1, "main_PathMsSqlConnection_click(this)");
	Class = null;
}

MsSqlConnectionSecondPage.prototype._NoConfirmButton_ = function()
{
	$("#Main_Center-Content").find(".Body").eq(1).hide();
	$("#Main_Center-Content").find(".Body").eq(0).show();
	var Class = new Path();
	Class.LoadPathHtml($("#Left-List-MsSqlConnection").text(), 1, "main_PathMsSqlConnection_click(this)");
	Class = null;
}

MsSqlConnectionSecondPage.prototype._TestConnection_ = function(that)
{
	var Form = $(that).closest(".Form");
	var Row = Form.find(".Row");
	var Driver   = Row.eq(2).find(".Select").val();
	var IP       = Row.eq(5).find(".Text").val();
	var Port     = Row.eq(6).find(".Text").val();
	var Account  = Row.eq(7).find(".Text").val();
	var Password = Row.eq(8).find(".Text").val();
	var array = new Array(Driver, IP, Port, Account, Password);
	$(that).closest(".RightColumn").find(".Loading").show();
	$(that).closest(".RightColumn").find(".Message").hide();
	var ssocket = io.connect();
	ssocket.emit("MsSqlConnectionTest", array);
	ssocket.on("MsSqlConnectionTest", function (Return){
		$(that).closest(".RightColumn").find(".Loading").hide();
		if(Return == "Success")
		{
			$(that).closest(".RightColumn").find(".Message").eq(0).show();
		}
		else if(Return == "Check server name"){
			$(that).closest(".RightColumn").find(".Message").eq(1).show();
		}
		else if(Return == "Check account password"){
			$(that).closest(".RightColumn").find(".Message").eq(2).show();
		}
		else{
			$(that).closest(".RightColumn").find(".Message").eq(3).text(Return);
			$(that).closest(".RightColumn").find(".Message").eq(3).show();
		}
		ssocket.emit("SocketClose");
	});
}

MsSqlConnectionSecondPage.prototype._SelectRecordMode_ = function(that)
{
	var RecordMode = $(that).val();
	if( RecordMode == "Cycle" )
	{
		MsSqlConnectionSecondPage.prototype._HideDeadbandRow_();
		MsSqlConnectionSecondPage.prototype._ShowIntervalSecond_();
	}
	else if( RecordMode == "DataChange" )
	{
		MsSqlConnectionSecondPage.prototype._ShowDeadbandRow_();
		MsSqlConnectionSecondPage.prototype._ShowSamplingIntervalSecond_();
	}
}

MsSqlConnectionSecondPage.prototype._HideDeadbandRow_ = function()
{
	var Row = $("#Main_Center-Content").find(".Form").eq(0).find(".Row");
	Row.eq(10).hide();
}

MsSqlConnectionSecondPage.prototype._ShowDeadbandRow_ = function()
{
	var Row = $("#Main_Center-Content").find(".Form").eq(0).find(".Row");
	Row.eq(10).show();
}

MsSqlConnectionSecondPage.prototype._ShowIntervalSecond_ = function()
{
	var Row = $("#Main_Center-Content").find(".Form").eq(0).find(".Row");
	Row.eq(11).find(".LeftColumn").eq(0).show();
	Row.eq(11).find(".LeftColumn").eq(1).hide();
}

MsSqlConnectionSecondPage.prototype._ShowSamplingIntervalSecond_ = function()
{
	var Row = $("#Main_Center-Content").find(".Form").eq(0).find(".Row");
	Row.eq(11).find(".LeftColumn").eq(1).show();
	Row.eq(11).find(".LeftColumn").eq(0).hide();
}

MsSqlConnectionSecondPage.prototype._ChangeCss_ = function(number)
{
	if( Global_MsSqlConnection[number]["DatabaseMode"] == "Cycle" )
	{
		MsSqlConnectionSecondPage.prototype._HideDeadbandRow_();
	}
	else if( Global_MsSqlConnection[number]["DatabaseMode"] == "DataChange" )
	{
		MsSqlConnectionSecondPage.prototype._ShowDeadbandRow_();
	}
}