Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Thank u so much i tried another thing and it worked.. thanks a lot for your help. but now i am stuck at another place if u could please help
namespace employee_info
{
public partial class _Default : System.Web.UI.Page
{
protected string SHQAPRDConn = System.Configuration.ConfigurationManager.AppSettings["SHQAPRDConn"];
 
protected void Page_Load(object sender, EventArgs e)
{
string login_user;
login_user = User.Identity.Name;
int int_substring = login_user.IndexOf("\\");
login_user = login_user.Substring(int_substring + 1);
login_user = "";
lblMsg.Text = login_user;
 
{
string strSql;
SqlConnection con = new SqlConnection(Conn);

SqlCommand objCmd;
SqlDataAdapter daEmployee;
SqlDataAdapter daVisa;
DataTable dtEmployee = new DataTable();
DataTable dtVisa = new DataTable();
strSql = "SELECT A.EMPLID, A.FIRST_NAME, A.LAST_NAME";
strSql = strSql + " FROM PS_EMPLOYEES A where EMPLID = '" + login_user + "'";

con.Open();
objCmd = new SqlCommand(strSql, con);
objCmd.CommandType = CommandType.Text;
daEmployee = new SqlDataAdapter(objCmd);
daEmployee.Fill(dtEmployee);
 
foreach (DataRow myRow in dtEmployee.Rows)
{
txtFirstName.Text = myRow[1].ToString().Trim();
txtLastName.Text = myRow[2].ToString().Trim();

}
 
 
 
strSql = "SELECT max(EFFDT) , max(EXPIRATN_DT)";
strSql = strSql + " FROM PS_VISA_PMT_DATA where EMPLID = '" + login_user + "'";
con.Close();
objCmd.Dispose();
con = new SqlConnection(SHQAPRDConn);
con.Open();
objCmd = new SqlCommand(strSql, con);
objCmd.CommandType = CommandType.Text;
daVisa = new SqlDataAdapter(objCmd);
daVisa.Fill(dtVisa);

foreach (DataRow myRow in dtVisa.Rows)
{
txtEffdt.Text = DateTime.Parse(myRow[0].ToString()).ToString("dd/MMM/yyyy");
txtExp.Text = DateTime.Parse(myRow[1].ToString()).ToString("dd/MMM/yyyy");
}
 
 
 
objCmd.Dispose();
daEmployee.Dispose();
daVisa.Dispose();
dtEmployee.Dispose();
dtVisa.Dispose();
con.Close();




now i jus wanted to give a condition lik to be alerted if the user s visa expires one month from the sysdate.
Posted
Updated 15-Aug-10 0:30am
v2
Comments
Per Söderlund 15-Aug-10 15:31pm    
Would be nice if you voted on answers and opened a new question when you have a new question,this looks more like a forum thread.

You can also put

"SELECT EMPLID, NAME from PS_EMPLOYEES where EMPLID = @login_user "

and use
SqlParameter param = new SqlParameter("@login_user", ....

It will eliminate the use of SQL Injection.
 
Share this answer
 
Comments
Per Söderlund 11-Aug-10 7:38am    
I agree.
It would be easier to change in the future instead of changing the command text every time.
is "EMPLID" the identity column?
If so it is probably an int and not string .

if i got this right you should change.

"SELECT EMPLID, NAME from PS_EMPLOYEES where EMPLID = login_user ";

to
"SELECT EMPLID, NAME from PS_EMPLOYEES where EMPLID =" + login_user;


then you use the variable login_user = "60050163";
instead of the string "login_user".
If that is what you are trying to get.
 
Share this answer
 
Comments
shweta_online 12-Aug-10 3:11am    
i tried the above change, i am still not getting it
if you got a table with expiration date column which is of DateTime datatype, you can do this in your query.

"SELECT EXPIRATN_DT,DATEDIFF(MM,Getdate(),EXPIRATN_DT) from Whatever_table_i_am_using"


This, will return 2 columns col0 = EXPIRATND_DT and col1 = Integer value on how many months there is between EXPIRATN_DT and todays date.

then you can write your if statement pretty easy.
//Second column of MyRow<br />
if((int)MyRow[1] == 1)<br />
{<br />
//My alert message code goes here<br />
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900