Please help i want to pop up a new page like a size of 350 by 400 pixel inside an update if statement.i was able to do this
<asp:Button ID="btnpopup" runat="server" BackColor="#0099FF" Font-Bold="True" ForeColor="White" Height="39px" onclick="btnpopup_Click"
onclientclick="return openPopup()" Text="Print Now" Width="135px" />
function openPopup() {
window.open("Reciept.aspx", "_blank", "WIDTH=350,HEIGHT=400, scrollbars=no, menubar=no,resizable=no,directories=no,location=no");
}
it worked but the page pops out before the update statement takes place ,so it displays the last record before the update statement took place
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
public partial class Nampak_Home : System.Web.UI.Page
{
string selectSQL, selectSQL1, selectSQL5, selectSQL6;
string updateSQL, updateSQL1, updateSQL5, updateSQL6, updateSQL2;
SqlCommand cmd = new SqlCommand();
SqlConnection dbConn = new SqlConnection();
SqlDataReader dr, ;
protected void Page_Load(object sender, EventArgs e)
{
selectSQL = "select * from List_Staff WHERE Emp_No ='" + Session["Emp"].ToString() + "'";
dbConn.ConnectionString = "Data Source=LAPTOP-VO\\SQLEXPRESS; Initial Catalog=Client;Integrated Security=True;";
cmd.Connection = dbConn;
cmd.CommandText = selectSQL;
cmd.CommandType = CommandType.Text;
try
{
dbConn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
Label1.Text = dr["Name"].ToString();
Session["L"] = dr["Name"].ToString();
Label2.Text = dr["Emp_No"].ToString();
Session["D"] = dr["Emp_No"].ToString();
Label3.Text = dr["Department"].ToString();
Session["J"] = dr["Department"].ToString();
Label4.Text = dr["Company"].ToString();
Session["E"] = dr["Company"].ToString();
Session["Value"] = dr["Value"].ToString();
Session["Cat"] = dr["Meal_Cat"].ToString();
Label5.Text = dr["Meal_Ticket"].ToString();
Session["Cv"] = dr["Meal_Ticket"].ToString();
int C = Convert.ToInt32(Session["Cv"]);
if (C < 1)
{
btnpopup.Enabled = false;
}
else
{
}
}
else
{
}
dr.Close();
}
catch (Exception err)
{
Label6.Text = "Error Logging in ";
Label6.Text += err.ToString();
}
finally
{
dbConn.Close();
}
}
protected void btnpopup_Click(object sender, EventArgs e)
{
string dt = DateTime.Now.ToString("dd.MM.yyyy HH:mm");
String.Format("{0:d/M/yyyy HH:mm}", dt);
Session["T"] = dt;
DateTime bt = System.DateTime.Now;
string format = "dd/MM/yyyy";
string newDate = bt.ToString(format);
Session["T1"] = newDate;
selectSQL = "select Meal_Ticket from List_Staff WHERE Emp_No ='" + Session["Emp"].ToString() + "'";
dbConn.ConnectionString = "Data Source=LAPTOP-VO\\SQLEXPRESS; Initial Catalog=Client;Integrated Security=True;";
cmd.Connection = dbConn;
cmd.CommandText = selectSQL;
cmd.CommandType = CommandType.Text;
try
{
dbConn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["RT"] = dr["Meal_Ticket"].ToString();
int x = Convert.ToInt32(Session["RT"]);
int y = x - 1;
string t = y.ToString();
Session["TR"] = y.ToString();
updateSQL = "update List_Staff set Meal_Ticket='" + y + "' where Emp_No ='" + Session["Emp"].ToString() + "'";
dbConn.ConnectionString = "Data Source=LAPTOP-VO\\SQLEXPRESS; Initial Catalog=Client;Integrated Security=True;";
cmd.Connection = dbConn;
cmd.CommandText = updateSQL;
cmd.CommandType = CommandType.Text;
try
{
dbConn.Open();
int updated1 = cmd.ExecuteNonQuery();
if (updated1 == 1)
{
selectSQL = "select Value1 from Static WHERE id ='1'";
dbConn.ConnectionString = "Data Source=LAPTOP-VO\\SQLEXPRESS; Initial Catalog=Client;Integrated Security=True;";
cmd.Connection = dbConn;
cmd.CommandText = selectSQL;
cmd.CommandType = CommandType.Text;
try
{
dbConn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["Val"] = dr5["Value1"].ToString();
int G = Convert.ToInt32(Session["Val"]);
int H = G + 1;
string j = H.ToString();
Session["V1"] = H.ToString();
updateSQL = "update Static set Value1='" + Session["V1"].ToString() + "' where id ='1'";
dbConn.ConnectionString = "Data Source=LAPTOP-VO\\SQLEXPRESS; Initial Catalog=Client;Integrated Security=True;";
cmd.Connection = dbConn;
cmd.CommandText = updateSQL;
cmd.CommandType = CommandType.Text;
try
{
dbConn.Open();
int updated2 = cmd.ExecuteNonQuery();
if (updated2 == 1)
{
String insertSQL9;
DateTimeFormatInfo dateFormatProvider = new DateTimeFormatInfo();
dateFormatProvider.ShortDatePattern = "0:d/M/yyyy HH:mm";
var tt = DateTime.Parse(Session["T"].ToString(), dateFormatProvider);
DateTimeFormatInfo dateFormatProvider1 = new DateTimeFormatInfo();
dateFormatProvider1.ShortDatePattern = "dd/MM/yyyy";
var tt1 = DateTime.Parse(Session["T1"].ToString(), dateFormatProvider);
insertSQL = "INSERT INTO MealLog (";
insertSQL += "Name,Emp_No,Meal_Cat,Department,Company,Reciept_No,Value,Time,Time1)";
insertSQL += "VALUES('";
insertSQL += Session["L"].ToString() + "','";
insertSQL += Session["D"].ToString() + "','";
insertSQL += Session["Cat"].ToString() + "','";
insertSQL += Session["J"].ToString() + "','";
insertSQL += Session["E"].ToString() + "','";
insertSQL += Session["V1"].ToString() + "','";
insertSQL += Session["Value"].ToString() + "','";
insertSQL += tt + "','";
insertSQL += tt1 + "')";
String connectionString = "Data Source=LAPTOP-VO\\SQLEXPRESS; Initial Catalog=Client;Integrated Security=True;";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(insertSQL, con);
int added9 = 0;
try
{
con.Open();
added9 = cmd.ExecuteNonQuery();
if (added9 == 1)
{
i want the page to pop out after this update is done.
i want to pop up a new page like a size of 350 by 400 pixel after the update
}
else
{
}
}
catch (Exception err)
{
Label6.Text += err.ToString();
}
finally
{
dbConn.Close();
}
}
else
{
}
}
catch (Exception err)
{
Label6.Text = "Error Updating ";
Label6.Text += err.ToString();
}
finally
{
dbConn6.Close();
}
}
else
{
}
dr.Close();
}
catch (Exception err)
{
Label6.Text = "Error Logging in 2 ";
Label6.Text += err.ToString();
}
finally
{
dbConn5.Close();
}
}
}
catch (Exception err)
{
Response.Write(err.ToString());
}
finally
{
dbConn.Close();
}
}
else
{
Label6.Text = "sorry you cant view this page ";
}
dr.Close();
}
catch (Exception err)
{
Label6.Text = "Error Logging in 3";
Label6.Text += err.ToString();
}
finally
{
dbConn.Close();
}
Response.Redirect(HttpContext.Current.Request.Path);
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Session.Remove("Emp");
Session["Emp"] = "";
}
}
Please help i want to pop up a new page like a size of 350 by 400 pixel inside the update if statement
What I have tried:
I have tried the code below
<asp:Button ID="btnpopup" runat="server" BackColor="#0099FF" Font-Bold="True" ForeColor="White" Height="39px" onclick="btnpopup_Click"
onclientclick="return openPopup()" Text="Print Now" Width="135px" />
function openPopup() {
window.open("Reciept.aspx", "_blank", "WIDTH=350,HEIGHT=400, scrollbars=no, menubar=no,resizable=no,directories=no,location=no");
}
it worked but the page pops out before the update statement takes place ,so it displays the last record before the update statement took place.I want to pop out the page after the update has taken place.