<%@ Page Title="Setting Login" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="manageUser.aspx.cs" Inherits="edicenter.manageUser" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
          <br /><br /><br /><br />
 <div class="container-fluid">
        <div class="row row-offcanvas row-offcanvas-right">

        <div class="col-xs-12 col-sm-12">
    <div class="row">

         <div class="panel panel-primary">
      <div class="panel-heading">&nbsp&nbsp Setting Login&nbsp&nbsp&nbsp&nbsp&nbsp[<%= Session["ULogin"].ToString().Trim() %>]</div>
      <div class="panel-body">
           &nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           <asp:Label ID="lblVenderID" runat="server" Text="User:"></asp:Label>
           <asp:TextBox ID="txtUser" runat="server" ReadOnly = "false" Width="150px"></asp:TextBox>&nbsp&nbsp  
           &nbsp&nbsp&nbsp;  
           <asp:Button ID="btnSearch" runat="server" Text="Search" width="100px" OnClick="btnSearch_Click" />&nbsp&nbsp&nbsp 
           <asp:Button ID="btnSearchAll" runat="server" Text="Search All" Width="120px" CssClass="btn-primary" Font-Bold="true" OnClick="btnSearchAll_Click" />
           <br /><br />
           &nbsp&nbsp
           <asp:Label ID="lblAdd" runat="server" Text="Add User:"></asp:Label>
           <asp:TextBox ID="txtAddUser" runat="server" ReadOnly = "false" Width="150px"></asp:TextBox>&nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp;  
           <asp:Label ID="Label4" runat="server" Text="Add Plant:"></asp:Label>
           <asp:TextBox ID="txtAddPlant" runat="server" ReadOnly = "false" Width="150px"></asp:TextBox>&nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp;
           <br /><br />
           &nbsp;<asp:Label ID="lblAddName" runat="server" Text="Add Name:"></asp:Label>
           <asp:TextBox ID="txtAddName" runat="server" ReadOnly = "false" Width="150px"></asp:TextBox>&nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp; 
           <asp:Label ID="Label5" runat="server" Text="Add Email:"></asp:Label>
           <asp:TextBox ID="txtAddEmail" runat="server" ReadOnly = "false" Width="150px"></asp:TextBox>&nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp;    
           <br /><br />
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           <asp:Button ID="btnAdd" runat="server" Text="Add" width="100px" OnClick="btnAdd_Click" />&nbsp&nbsp&nbsp
           <br /><br />
           <asp:Label ID="lblResultSearch" runat="server" Text="" Font-Bold="true"></asp:Label>&nbsp&nbsp&nbsp&nbsp  
           &nbsp&nbsp 
           <br />               
&nbsp;<asp:Repeater id="myRepeater" runat="server">
	<HeaderTemplate>
<table class="table table-bordered">
<tr style="background-color:#33CC99; color:black; font-weight:bold;height:35px;" align="Left">
                <td>No.</td>
                <td>User</td>
                <td>Password</td>
                <td>Plant</td>
                <td>Name</td>
                <td>Email</td>
                <td>Update</td>
                <td>Delete</td>
                </tr>           	
   </HeaderTemplate>             
	<ItemTemplate>    
			 <tr style="background-color:#FFFFFF; color:black; height:35px;" align="left">
             <td><asp:Label id="Label2" runat="server" Text='<%# myRepeater.Items.Count + 1 %>'></asp:Label></td>             
             <td><asp:Label id="Label1" runat="server" Text='<%# Value_Column(1,Container.DataItem) %>'></asp:Label></td>
             <td><input id="txtPass_<%# Text_CheckColumn(0,Container.DataItem) %>" type="text" value='<%# Value_Column(2,Container.DataItem) %>'/></td> 
             <td><input id="txtPlant_<%# Text_CheckColumn(0,Container.DataItem) %>" type="text" value='<%# Value_Column(3,Container.DataItem) %>'/></td> 
             <td><input id="txtName_<%# Text_CheckColumn(0,Container.DataItem) %>" type="text" value='<%# Value_Column(4,Container.DataItem) %>'/></td> 
             <td><input id="txtMail_<%# Text_CheckColumn(0,Container.DataItem) %>" type="text" value='<%# Value_Column(5,Container.DataItem) %>'/></td> 
             <td><input id="btnMo_<%# Text_CheckColumn(0,Container.DataItem) %>" type="button" value="Update" onclick="modify_click(<%# ID_indexes(Container.DataItem) %>)" class="btn-block" /></td>          
             <td><input id="btnCF_<%# Text_CheckColumn(0,Container.DataItem) %>" type="button" value="Delete" onclick="delete_click(<%# ID_indexes(Container.DataItem) %>)" class="btn-block" /></td>                                                                                                
	         </tr>
   </ItemTemplate>
    
        <AlternatingItemTemplate>          
			 <tr style="background-color:#FAEBD7; color:black; height:35px;" align="left">
             <td><asp:Label id="Label2" runat="server" Text='<%# myRepeater.Items.Count + 1 %>'></asp:Label></td>    
             <td><asp:Label id="Label1" runat="server" Text='<%# Value_Column(1,Container.DataItem) %>'></asp:Label></td>
             <td><input id="txtPass_<%# Text_CheckColumn(0,Container.DataItem) %>" type="text" value='<%# Value_Column(2,Container.DataItem) %>'/></td> 
             <td><input id="txtPlant_<%# Text_CheckColumn(0,Container.DataItem) %>" type="text" value='<%# Value_Column(3,Container.DataItem) %>'/></td> 
             <td><input id="txtName_<%# Text_CheckColumn(0,Container.DataItem) %>" type="text" value='<%# Value_Column(4,Container.DataItem) %>'/></td> 
             <td><input id="txtMail_<%# Text_CheckColumn(0,Container.DataItem) %>" type="text" value='<%# Value_Column(5,Container.DataItem) %>'/></td> 
             <td><input id="btnMo_<%# Text_CheckColumn(0,Container.DataItem) %>" type="button" value="Update" onclick="modify_click(<%# ID_indexes(Container.DataItem) %>)" class="btn-block" style="color:black"/></td>                          
             <td><input id="btnCF_<%# Text_CheckColumn(0,Container.DataItem) %>" type="button" value="Delete" onclick="delete_click(<%# ID_indexes(Container.DataItem) %>)" class="btn-block" style="color:black"/></td>       
			 </tr>		           
	</AlternatingItemTemplate> 

	</asp:Repeater> </table>
               <br />
        
      </div>
    </div>
                
      </div>
            </div>

         </div>

       <script src="css/js/jquery.min.js"></script>
       <script src="css/js/bootstrap.min.js"></script>
       <script type="text/javascript">
           function modify_click(id)
           {
               var txtPass = document.getElementById("txtPass_"+id).value;
               var txtPlant = document.getElementById("txtPlant_"+id).value;
               var txtName = document.getElementById("txtName_"+id).value;
               var txtMail = document.getElementById("txtMail_"+id).value;
               if(txtPass=="")
                   alert("โปรดใส่รหัส Password");
               else if(txtPlant=="")
                   alert("โปรดใส่รหัส Plant");
               else if(txtName=="")
                   alert("โปรดใส่ Name");
               else
               {
                   var confirm_value = document.createElement("INPUT");
                   confirm_value.type = "hidden";
                   confirm_value.name = "confirm_value";
                   if (confirm("Press Button Yes to Update?")) 
                   {
                       confirm_value.value = "Yes";
                       //$.post("email_update.aspx",{id:id});
                       //window.location.reload();   
                       window.open("manageUser_update.aspx?DC="+id+"?"+txtPass+"?"+txtPlant+"?"+txtName+"?"+txtMail,"_self");
                   } 
                   else 
                       confirm_value.value = "No";
                   //window.open("email_update.aspx?DC="+id+"")
               }
           }
           function delete_click(id)
           {
               var txtPass = document.getElementById("txtPass_"+id).value;
               var txtPlant = document.getElementById("txtPlant_"+id).value;
               var txtName = document.getElementById("txtName_"+id).value;
               var txtMail = document.getElementById("txtMail_"+id).value;
               if(txtPass=="")
                   alert("โปรดใส่รหัส Password");
               else if(txtPlant=="")
                   alert("โปรดใส่รหัส Plant");
               else if(txtName=="")
                   alert("โปรดใส่ Name");
               else
               {
                   var confirm_value = document.createElement("INPUT");
                   confirm_value.type = "hidden";
                   confirm_value.name = "confirm_value";
                   if (confirm("Press Button Yes to Update?")) 
                   {
                       confirm_value.value = "Yes";
                       //$.post("email_update.aspx",{id:id});
                       //window.location.reload();   
                       window.open("manageUser_delete.aspx?DC="+id+"?"+txtPass+"?"+txtPlant+"?"+txtName+"?"+txtMail,"_self");
                   } 
                   else 
                       confirm_value.value = "No";
                   //window.open("email_update.aspx?DC="+id+"")
               }
           }
       </script>
    </div>
</asp:Content>
