<%@ Page Language="C#" AutoEventWireup="true" Inherits="WebApp.Wpdcc.DBServiceList" CodeBehind="DBServiceList.aspx.cs" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>数据库服务器维护</title>
    <meta name="description" content="overview &amp; stats" />

    <!-- page specific plugin styles -->
    <link rel="stylesheet" href="../assets/css/jquery-ui.css" />
		
	<!--#include file = "../assets/head.htm" -->

</head>
<body class="no-skin">
    <form id="form1" runat="server">
    <div class="main-content-inner">
			<!-- #section:basics/content.breadcrumbs -->
			<div class="breadcrumbs" id="breadcrumbs">
				<script type="text/javascript">
					try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
				</script>

				<ul class="breadcrumb">
					<li>
						<i class="ace-icon fa fa-home home-icon"></i>
						主页
					</li>
					<li>站群基本信息</li>
					<li class="active"><asp:Label ID="lblTitle" runat="server"></asp:Label></li>
				</ul><!-- /.breadcrumb -->

				<!-- /section:basics/content.searchbox -->
			</div>
			<!-- /section:basics/content.breadcrumbs -->
			
			<div class="page-content">
			<!-- PAGE CONTENT BEGINS -->
			
			<div class="page-header">
			    <asp:Button ID="btnSaveDB" runat="server" CausesValidation="False" Text="保存" CssClass="btn btn-sm btn-primary" OnClick="btnSaveDB_Click" />
            </div>
			
		    <div class="row">
		    <div class="col-xs-12">
                
            <asp:DataGrid ID="dgSqlServer" runat="server" class="table table-striped table-bordered" AutoGenerateColumns="False" DataKeyField="pkID" Width="100%" OnItemCommand="dgSqlServer_ItemCommand" OnItemDataBound="dgSqlServer_ItemDataBound">
                <Columns>
                    <asp:BoundColumn DataField="pkID" HeaderText="ID" HeaderStyle-CssClass="title"></asp:BoundColumn>
                    <asp:BoundColumn DataField="serviceName" HeaderText="名称" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="ip" HeaderText="IP" HeaderStyle-CssClass="title"></asp:BoundColumn>
                    <asp:BoundColumn DataField="dbUser" HeaderText="数据库管理员" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="dbPwd" HeaderText="管理员密码" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="dbPort" HeaderText="端口" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="是否在用" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:DropDownList ID="ddlSqlOnUsing" runat="server" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.OnUsing") %>'>
                                <asp:ListItem Value="0">禁用</asp:ListItem>
                                <asp:ListItem Value="1">使用</asp:ListItem>
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="执行" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <div class="action-buttons">
                            <asp:LinkButton ID="editSql" runat="server" CausesValidation="false" CommandName="edit"><i class="ace-icon fa fa-pencil bigger-130 green" title="编辑"></i></asp:LinkButton>&nbsp;
                            <asp:LinkButton ID="delSql" runat="server" CommandName="delete" CausesValidation="false"
                                CommandArgument='<%# DataBinder.Eval(Container, "DataItem.serviceName") %>'><i class="ace-icon fa fa-trash-o bigger-130 red" title="删除"></i></asp:LinkButton>&nbsp;
                            <asp:HyperLink ID="hplViewWebSite" runat="server" NavigateUrl='<%# "WebSiteList.aspx?dbId="+Eval("pkId")+"&name=" + Eval("serviceName") %>'><i class="ace-icon fa fa-search-plus bigger-130" title="查看站点列表" ></i></asp:HyperLink>
                                </div>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                </Columns>
            </asp:DataGrid>
            <div class="clearfix">
	            <div class="col-xs-12">
                    <asp:Label ID="lblSqlPage" runat="server"></asp:Label>
                </div>
            </div>
            
            <div class="row form-horizontal">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">服务名称</label>
		            <div class="col-sm-9">
		                <asp:TextBox ID="txtSqlName" runat="server" CssClass="col-xs-10 col-sm-5"></asp:TextBox>
		                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtSqlName"
                        Display="Dynamic" ErrorMessage="请输入数据库服务器名称！" ValidationGroup="webreg"></asp:RequiredFieldValidator>
                    </div>
		        </div>
		        <div class="form-group">
			        <label class="col-sm-3 control-label no-padding-right" for="form-field-1">服务器IP</label>
                    <div class="col-sm-9">
                        <asp:TextBox ID="txtSqlIp" runat="server" CssClass="col-xs-10 col-sm-5"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="txtSqlIp"
                        Display="Dynamic" ErrorMessage="请输入服务器Ip！" ValidationGroup="webreg"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="txtSqlIp"
                        Display="Dynamic" ErrorMessage="IP地址格式不正确！" ValidationExpression="^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" ValidationGroup="webreg"></asp:RegularExpressionValidator>
                    </div>
		        </div>
                <div class="form-group">
			        <label class="col-sm-3 control-label no-padding-right" for="form-field-1">数据库端口</label>
                    <div class="col-sm-9">
                        <asp:TextBox ID="txtDbPort" runat="server" CssClass="col-xs-10 col-sm-5" Enabled="false" ReadOnly="True">1433</asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="txtDbPort"
                        Display="Dynamic" ErrorMessage="请输入数据库端口！" ValidationGroup="webreg"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="txtDbPort"
                        Display="Dynamic" ErrorMessage="端口必须为大于0的整数！" ValidationExpression="^[0-9]*[1-9][0-9]*$" ValidationGroup="webreg"></asp:RegularExpressionValidator>
                    </div>
		        </div>
                <div class="form-group">
			        <label class="col-sm-3 control-label no-padding-right" for="form-field-1">数据库管理员</label>
                    <div class="col-sm-9">
                        <asp:TextBox ID="txtDbAdmin" runat="server" CssClass="col-xs-10 col-sm-5">sa</asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="txtDbAdmin"
                        Display="Dynamic" ErrorMessage="请输入数据库管理员！" ValidationGroup="webreg"></asp:RequiredFieldValidator>
                    </div>
                    
		        </div>
                <div class="form-group">
			        <label class="col-sm-3 control-label no-padding-right" for="form-field-1">管理员密码</label>
                    <div class="col-sm-9">
                        <asp:TextBox ID="txtDbPwd" runat="server" CssClass="col-xs-10 col-sm-5"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="txtDbPwd"
                        Display="Dynamic" ErrorMessage="请输入管理员密码！" ValidationGroup="webreg"></asp:RequiredFieldValidator>
                    </div>
		        </div>
            </div>
            <div class="clearfix">
                <div class="col-md-offset-3 col-md-9">
                    <asp:Button ID="btnAddDB" runat="server" Text="添加" CssClass="btn btn-sm btn-primary" OnClientClick="return checkPort()" OnClick="btnAddDB_Click" ValidationGroup="webreg" />
                    &nbsp;
                    <asp:Button ID="btnCancelDB" runat="server" Text="取消" CssClass="btn btn-sm" CausesValidation="False" OnClick="btnCancelDB_Click" />
                    
                    <input id="sqlId" runat="server" type="hidden" name="sqlId" />
                    <input id="hiddenIp" runat="server" name="hiddenIp" type="hidden" />
                    
                </div>
            </div>
            </div>
	        </div>
            </div>
            <!-- PAGE CONTENT ENDS -->
        </div>
    </div>
    </form>
    
    <script type="text/javascript">
			
		    function checkPort()
		    {
		        if(document.getElementById("txtSqlIp").value=="")
		        {
		            alert("请输入服务器IP！");
		            return false;
		        }
		        if(document.getElementById("txtDbPort").value=="")
		        {
		            alert("请输入端口号！");
		            return false;
		        }
		        if(IP2V(document.getElementById("txtSqlIp").value)==false)
		        {
		            alert("IP地址格式不正确！");
		            return false;
		        }
		        return true;
		    }

            function IP2V(ip)
            {
                re=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/g;  //匹配IP地址的正则表达式
                if(re.test(ip))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
</script>
</body>
</html>


        