My appliction working in local host but while i have take this in IP like : 10.1.246.59 its not working.
Images Capture : http://localhost/vstr_gt_ps/Default.aspx?Id=10
Images not Capture : http://10.1.246.59/vstr_gt_ps/Default.aspx?Id=10
lgn.aspx
<%@ Page Language="C#" AutoEventWireup="true" Codefile="lgn.aspx.cs" Inherits="vstr_gt_ps_systm.lgn" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
.auto-style4 {
margin-left: 0px;
}
.auto-style6 {
font-weight: 700;
margin-left: 38px;
}
.auto-style7 {
height: 607px;
width: 819px;
margin-left: 0px;
}
.auto-style11 {
text-align: left;
margin-left: 48px;
}
.auto-style13 {
text-align: center;
font-size: xx-large;
color: #FFFFFF;
background-color: #006666;
height: 29px;
}
.auto-style15 {
text-align: right;
color: #FFFFFF;
width: 108px;
background-color: #003366;
}
.auto-style16 {
background-color: #003366;
width: 817px;
}
.auto-style17 {
width: 108px;
background-color: #003366;
}
.auto-style20 {
height: 94px;
width: 90px;
float: left;
margin-left: 0px;
text-decoration: underline;
}
.auto-style21 {
color: #FFFFFF;
}
.auto-style22 {
text-decoration: underline;
}
.auto-style38 {
font-size: larger;
}
.auto-style39 {
text-decoration: underline;
}
.auto-style40 {
font-size: x-large;
}
.auto-style41 {
height: 521px;
width: 729px;
}
.auto-style42 {
width: 268435280px;
}
.auto-style43 {
width: 444px;
}
</style>
</head>
<body bgcolor="#FFFFFF" class="auto-style11">
<form id="form1" runat="server">
<div>
<table border="1" class="auto-style7">
<tr>
<td class="auto-style13" >
<img src="images/m1.png" class="auto-style20" /></td>
<td class="auto-style13" colspan="2" >
<span class="auto-style22"><span class="auto-style38"><span class="auto-style39"><strong>Meja Thermal Power Plant</strong></span><strong><br class="auto-style39" />
</strong>
</span></span><span class="auto-style40"><strong>VISITOR GATE PASS SYSTEM</strong></span></td>
<tr>
<td class="auto-style15" ><strong>User Name </strong></td>
<td class="auto-style16" >
<asp:TextBox ID="TextBox1" runat="server" CssClass="auto-style4" Height="25px" Width="163px"></asp:TextBox>
<br /><asp:Label ID="Label1" runat="server" Text="Label" CssClass="auto-style21"></asp:Label></td>
<td rowspan="4" class="auto-style42">
<img src="Images/VP.jpg" />
<img src="Images/visitor.jpg" class="auto-style43"/>
</td>
</tr>
<tr>
<td class="auto-style15"><strong> Password </strong></td>
<td class="auto-style16">
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password" CssClass="auto-style4" Height="25px" Width="163px"></asp:TextBox>
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style17"> </td>
<td class="auto-style16">
<asp:Button ID="Button1" runat="server" CssClass="auto-style6" Height="27px" Text="Login" Width="89px" OnClick="Button1_Click" />
</td>
</tr>
<tr>
<td colspan="2" rowspan="2" >
<img src="Images/visitor1.jpg" class="auto-style41"/></td>
</tr>
</table>
</div>
</form>
</body>
</html>
.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace vstr_gt_ps_systm
{
public partial class lgn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "(User Name :Your 6-Digit Employee Id & password:123456)";
}
protected void Button1_Click(object sender, EventArgs e)
{
int PROJECT_ID;
SqlConnection con = new SqlConnection(@"Data Source=10.1.246.4;Initial Catalog=gate_pss;User ID=dba_ntpc_meja_intranet;Password=alpha$890;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
//SqlConnection con = new SqlConnection(@"Data Source=10.1.246.4;Initial Catalog=DB_NTPC_MEJA_INTRANET; User ID=dba_ntpc_meja_intranet; Password=alpha$890; Connection Timeout=15;Connection Lifetime=0;Min Pool Size=0;Max Pool Size=100;Pooling=true");
con.Open();
SqlCommand cmd = new SqlCommand("Select * from emp where emp_id=@emp_id and Password=@Password", con);
cmd.Parameters.AddWithValue("@emp_id", TextBox1.Text.ToString());
cmd.Parameters.AddWithValue("@Password", TextBox2.Text.ToString());
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
if (reader.Read())
{
Session["emp_id"] = reader["emp_id"].ToString();
Session["emp_nm"] = reader["emp_nm"].ToString();
Session["dept"] = reader["dept"].ToString();
reader.Close();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
PROJECT_ID = int.Parse(dt.Rows[0]["PROJECT_ID"].ToString());
switch (PROJECT_ID)
{
case 1003:
string EmpId = TextBox1.Text;
Response.Redirect(string.Format("~/emp.aspx?EmpId={0}", EmpId));
break;
case 1002:
Response.Redirect("emp.aspx");
break;
//case 3:
// Response.Redirect("Elec_Twn_Comp.aspx");
// break;
// case 4:
// Response.Redirect("Elec_Plnt_Comp.aspx");
//break;
// case 5:
// Response.Redirect("Cvl_Twn_Comp.aspx");
// break;
//case 6:
// Response.Redirect("Cvl_Plnt_Comp.aspx");
// break;
//case 7:
//Response.Redirect("Hr_Comp.aspx");
// break;
case 1008:
string empid = TextBox1.Text;
Response.Redirect(string.Format("~/cisf.aspx?empid={0}", empid));
break;
}
}
}
else
{
reader.Close();
cmd.Dispose();
con.Close();
lblMessage.Font.Size = FontUnit.Large;
lblMessage.Text = "Invalid credentials";
lblMessage.ForeColor = System.Drawing.Color.Red;
}
}
}
}
.aspx
<%@ Page Language="C#" AutoEventWireup="true" Codefile="Default.aspx.cs" Inherits="vstr_gt_ps_systm.Default" %>
<script src="js/JavaScript1.js"></script>
<script src="js/WebCam.js"></script>
<title>VGP</title>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">
<style type="text/css">
.style1
{
color: #FF0066;
text-decoration: underline;
font-weight: bold;
}
</style>
<style type="text/css">
@media print
{
.noprint {display:none;}
}
@media screen
{
}
.auto-style73 {
margin-left: 0px;
}
auto-style73 {
margin-left: 0px;
}
</style>
<style type="text/css">
.auto-style1 {
width: 71px;
background-color: #FFFFFF;
height: 118px;
}
.auto-style43 {
width: 1038px;
height: 682px;
margin-left: 19px;
background-color: #FFFFFF;
}
.auto-style42 {
height: 72px;
width: 74px;
text-align: center;
margin-left: 26px;
}
.auto-style44 {
font-size: xx-large;
}
.auto-style45 {
font-size: large;
}
.auto-style46 {
width: 1192px;
background-color: #FFFFFF;
height: 50px;
}
.auto-style54 {
width: 941px;
background-color: #FFFFFF;
text-align: left;
height: 36px;
}
.auto-style63 {
width: 126px;
background-color: #FFFFFF;
}
.auto-style68 {
width: 485px;
background-color: #FFFFFF;
text-align: left;
height: 21px;
}
.auto-style72 {
width: 1192px;
background-color: #FFFFFF;
text-align: left;
height: 36px;
}
.auto-style73 {
background-color: #FFFFFF;
}
#btnCapture {
}
</style>
<style type="text/css">
.style1
{
color: #FF0066;
text-decoration: underline;
font-weight: bold;
}
</style>
<style type="text/css">
@media print
{
.noprint {display:none;}
}
@media screen
{
}
.auto-style73 {
margin-left: 0px;
height: 60px;
}
.auto-style73 {
margin-left: 0px;
height: 60px;
}
#webcam {
width: 218px;
}
.auto-style74 {
margin-left: 0px;
background-color: #FFFFFF;
}
.auto-style75 {
width: 126px;
background-color: #FFFFFF;
height: 50px;
}
.auto-style80 {
color: #FF0066;
text-decoration: underline;
font-weight: bold;
}
#Print {
width: 80px;
}
.auto-style81 {}
.auto-style83 {
width: 485px;
background-color: #FFFFFF;
text-align: left;
height: 6px;
}
.auto-style84 {
width: 1192px;
background-color: #FFFFFF;
text-align: left;
height: 6px;
}
.auto-style88 {
width: 1192px;
background-color: #FFFFFF;
text-align: left;
height: 21px;
}
.auto-style90 {
height: 23px;
margin-left: 0px;
background-color: #FFFFFF;
}
.auto-style91 {
width: 126px;
background-color: #FFFFFF;
text-align: left;
height: 51px;
}
.auto-style93 {
background-color: #FFFFFF;
text-align: left;
height: 51px;
}
.auto-style94 {
width: 126px;
background-color: #FFFFFF;
text-align: left;
height: 36px;
}
.auto-style96 {
background-color: #FFFFFF;
text-align: left;
height: 23px;
width: 281px;
}
.auto-style97 {
background-color: #FFFFFF;
text-align: left;
height: 23px;
}
.auto-style98 {
width: 126px;
background-color: #FFFFFF;
text-align: left;
height: 23px;
}
.auto-style99 {
height: 23px;
margin-left: 0px;
background-color: #FFFFFF;
width: 126px;
}
.auto-style100 {
width: 126px;
background-color: #FFFFFF;
height: 18px;
}
.auto-style101 {
width: 1192px;
background-color: #FFFFFF;
height: 18px;
}
.auto-style103 {
background-color: #FFFFFF;
text-align: left;
height: 51px;
width: 174px;
}
.auto-style106 {
text-align: left;
}
.auto-style108 {
background-color: #FFFFFF;
text-align: left;
height: 51px;
width: 280px;
}
.auto-style109 {
height: 23px;
margin-left: 0px;
background-color: #FFFFFF;
width: 362px;
}
.auto-style112 {
background-color: #FFFFFF;
text-align: left;
height: 23px;
width: 422px;
}
.auto-style113 {
background-color: #FFFFFF;
text-align: left;
height: 51px;
width: 362px;
}
.auto-style114 {
background-color: #FFFFFF;
text-align: left;
height: 23px;
width: 280px;
}
</style>
</head>
<body align="center" text-align: left; height: 498px; width: 1249px;" class="auto-style73">
<form id="form1" runat="server">
<table border="1" class="auto-style43" >
<tr>
<td class="auto-style75"><img src="images/m1.png" class="auto-style42" /></td>
<th class="auto-style46" style="box-sizing: border-box;" colspan="5" ><span class="auto-style44">Meja Thermal Power Plant<br />
<span style="color: rgb(0, 0, 0); font-family: Roboto; font-size: 15px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: center; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">A Joint Venture of NTPC Ltd & UPRVUNL</span></span><br class="auto-style44"/>
</th>
</tr>
<tr>
<td class="auto-style100"></td>
<th class="auto-style101" style="box-sizing: border-box;" colspan="5" >
</span>
<font style="box-sizing: border-box;">
<span class="auto-style45">VISITOR GATE PASS </span></font></th>
</tr>
<tr>
<td class="auto-style63" rowspan="2">
<img id="imgCapture" /></td>
<th class="auto-style68" style="box-sizing: border-box;" colspan="4" >Visitor Id:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></th>
<th class="auto-style88" >
Visitor Aadhar No. :
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label></th>
</tr>
<tr>
<th class="auto-style83" style="box-sizing: border-box;" colspan="4" >
Visitor Name : <asp:Label ID="Label4" runat="server" Text="Label"></asp:Label></th>
<th class="auto-style84" >
Gender :
<asp:Label ID="Label7" runat="server" Text="Label"></asp:Label></th>
</tr>
<tr>
<th class="auto-style98" style="box-sizing: border-box;" >
Father/Husband Name:</th>
<th class="auto-style114" style="box-sizing: border-box;" colspan="2" >
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label></th>
<th class="auto-style96" colspan="2" >
Current Address :
</th>
<th class="auto-style97" >
<asp:Label ID="Label8" runat="server" Text="Label"></asp:Label></th>
</tr>
<tr>
<th class="auto-style94" style="box-sizing: border-box;" >
Purpose of visit :</th>
<th class="auto-style54" style="box-sizing: border-box;" colspan="4" >
<asp:Label ID="Label9" runat="server" Text="Label"></asp:Label></th>
<th class="auto-style72" >
</th>
</tr>
<tr>
<th class="auto-style91" style="box-sizing: border-box;" >
Emp.Name:</th>
<th class="auto-style108" style="box-sizing: border-box;" colspan="2" >
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></th>
<th class="auto-style103" >
Emp. ID :</th>
<th class="auto-style113" >
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label></th>
<th class="auto-style93" >
Department :<asp:Label ID="Label12" runat="server" Text=""></asp:Label></th>
</tr>
<tr>
<th class="auto-style99">Gate pass Cretion Date/Time:</th>
<th class="auto-style112">
<asp:Label ID="Label10" runat="server" Text="Label" CssClass="auto-style106"></asp:Label></th>
<th class="auto-style90" colspan="2">Plant Entry Date/Time:</th>
<th class="auto-style109" >
<asp:Label ID="Label11" runat="server" Text="Label"></asp:Label></th>
<th class="auto-style90" >
</th>
</tr>
<tr>
<th height="120" colspan="3" class="auto-style73" style="height: 60px">CISF Signature</th>
<th height="120" colspan="3" colspan="2" class="auto-style73" style="height: 60px" >
Employee Signature</th>
</tr>
<tr>
<th colspan="6" class="auto-style73">
<div class="noprint">
<input id="btnCapture" type="button" value="Image Capture" />
<button id="Print" onclick="window.print();return false;" /> Print</button>
<asp:Button ID="Button1" runat="server" Text="Back" CssClass="auto-style81" CausesValidation="false" Height="22px" OnClick="Button1_Click" Width="78px" />
<asp:Button ID="Button3" runat="server" Text="Plant In Time" CssClass="auto-style81" CausesValidation="false" Height="22px" OnClick="Button2_Click" Width="103px" /></th>
</div> </tr>
</table>
</form>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="WebCam.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
Webcam.set({
width: 170,
height: 120,
image_format: 'jpeg',
jpeg_quality: 90
});
Webcam.attach('#webcam');
$("#btnCapture").click(function () {
Webcam.snap(function (data_uri) {
$("#imgCapture")[0].src = data_uri;
$("#btnUpload").removeAttr("disabled");
});
});
$("#btnUpload").click(function () {
$.ajax({
type: "POST",
url: "cisf_v.aspx/SaveCapturedImage",
data: "{data: '" + $("#imgCapture")[0].src + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) { }
});
});
});
</script>
<div class="noprint">
<table align="center" border="1" bgcolor="#B7FFC9" cellpadding="4" cellspacing="2" style="border: 1px solid #999999; font-family: Century; width: 311px; margin-left: 44px;" class="auto-style1">
<tr>
<td class="auto-style80" colspan="4" style="text-align: center; background-color: #FEEEDE">Capture Image</td>
<div class="noprint">
<th height="120" colspan="2" class="auto-style74">
<div id="webcam"> </div> </div>
</tr> </table>
</div>
.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.Services;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
namespace vstr_gt_ps_systm
{
public partial class Default : System.Web.UI.Page
{
[WebMethod()]
public static bool SaveCapturedImage(string data)
{
string fileName = DateTime.Now.ToString("dd-MM-yy hh-mm-ss");
//Convert Base64 Encoded string to Byte Array.
byte[] imageBytes = Convert.FromBase64String(data.Split(',')[1]);
//Save the Byte Array as Image File.
string filePath = HttpContext.Current.Server.MapPath(string.Format("~/Captures/{0}.jpg", fileName));
File.WriteAllBytes(filePath, imageBytes);
return true;
}
int empno = 0;
protected void Page_Load(object sender, EventArgs e)
{
empno = Convert.ToInt32(Request.QueryString["Id"].ToString());
Session["EmpId"] = empno;
if (!IsPostBack)
{
BindTextBoxvalues();
}
}
private void BindTextBoxvalues()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("select * from vstr where Id=" + empno, con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
Label1.Text = dt.Rows[0][0].ToString();
Label3.Text = dt.Rows[0][1].ToString();
Label2.Text = dt.Rows[0][2].ToString();
Label4.Text = dt.Rows[0][4].ToString();
Label5.Text = dt.Rows[0][5].ToString();
Label6.Text = dt.Rows[0][6].ToString();
Label7.Text = dt.Rows[0][7].ToString();
Label8.Text = dt.Rows[0][8].ToString();
Label9.Text = dt.Rows[0][9].ToString();
Label10.Text = dt.Rows[0][14].ToString();
Label11.Text = dt.Rows[0][15].ToString();
Label12.Text = dt.Rows[0][3].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
string cisf_in_flag = "YES";
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("UPDATE vstr SET cisf_in_flag = @cisf_in_flag WHERE Id = @Id"))
{
cmd.Parameters.AddWithValue("@Id", Label1.Text);
cmd.Parameters.AddWithValue("@cisf_in_flag", cisf_in_flag);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
Response.Redirect("cisf.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
string mrk_in_cisf = DateTime.Now.ToString();
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("UPDATE vstr SET mrk_in_cisf = @mrk_in_cisf WHERE Id = @Id"))
{
cmd.Parameters.AddWithValue("@Id", Label1.Text);
cmd.Parameters.AddWithValue("@mrk_in_cisf", mrk_in_cisf);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
}
CREATE TABLE [dbo].[vstr] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[emp_id] NCHAR (10) NULL,
[emp_nm] VARCHAR (100) NULL,
[dept] VARCHAR (20) NULL,
[vst_nm] VARCHAR (100) NULL,
[vst_adhr] NCHAR (20) NULL,
[fa_hu_nm] VARCHAR (100) NULL,
[gndr] VARCHAR (50) NULL,
[crnt_add] VARCHAR (5000) NULL,
[pur_pos] VARCHAR (5000) NULL,
[emp_out_flag] VARCHAR (3) DEFAULT ('N') NULL,
[cisf_out_flag] VARCHAR (3) DEFAULT ('N') NULL,
[emp_in_flag] VARCHAR (3) DEFAULT ('N') NULL,
[cisf_in_flag] VARCHAR (3) DEFAULT ('N') NULL,
[mrk_in_emp] DATETIME DEFAULT (getdate()) NULL,
[mrk_in_cisf] DATETIME DEFAULT (getdate()) NULL,
[mrk_out_emp] DATETIME NULL,
[mark_out_cisf] DATETIME NULL,
[img] VARCHAR (50) NULL,
CONSTRAINT [PK_vstr] PRIMARY KEY CLUSTERED ([Id] ASC)
);