如何获取在线系统中最后一位注册员工的信息? [英] How to get information for the last registered employee in online system?

查看:57
本文介绍了如何获取在线系统中最后一位注册员工的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已经注册了一名员工
InsertEmployee();
现在,下一条语句我想获取该最后一位注册雇员的信息,因为我的要求是根据该雇员的入职日期计算的,因此我需要计算一些值. //此代码在asp.cs文件中的autoid

私人void Autoid()
{
字符串模式="M";
pr.Mode =模式;
dt = new DataTable();
dt = logic.Maxid(pr);
if(dt.Rows [0] [0] .ToString()!=")
{
txtEMPId.T​​ext =(int.Parse(dt.Rows [0] [0] .ToString())+1).ToString();
}
其他
txtRMPId.T​​ext ="1";
}
//inclass cs文件

公共DataTable InsertEmployeeFormat(ParametersBusinessObjects Schbo)
{
DataTable dt = new DataTable();

DataAcessHelper dashp =新的DataAcessHelper();

如果(Schbo.Mode!="M")
{
SqlCommand cmd = dashp.CreateCommand("sp_Employeedetails");
dashp.AddParameter(cmd,"@EmpIdid",SqlDbType.Int,ParameterDirection.Input,4,Schbo.School);
dashp.AddParameter(cmd,"@EmpName",SqlDbType.VarChar,ParameterDirection.Input,30,Schbo.SchoolName);

dashp.AddParameter(cmd,"@LandlineNo",SqlDbType.VarChar,ParameterDirection.Input,20,Schbo.LandlineNo);
dashp.AddParameter(cmd,"@MobileNo",SqlDbType.VarChar,ParameterDirection.Input,20,Schbo.MobileNo);
dashp.AddParameter(cmd,"@Address",SqlDbType.VarChar,ParameterDirection.Input,30,Schbo.Address);
dashp.AddParameter(cmd,"@ DateofBirth",SqlDbType.Date,ParameterDirection.Input,30,Schbo.strDate);
dashp.AddParameter(cmd,"@EndDate",SqlDbType.Date,ParameterDirection.Input,30,Schbo.EndDate);
dashp.AddParameter(cmd,"@Flag",SqlDbType.VarChar,ParameterDirection.Input,2,Schbo.Mode);
if(Schbo.Mode!="A" && Schbo.Mode!="S" && Schbo.Mode!="G" && Schbo.Mode!="N")
{
dashp.ExecuteStoredProcedure(cmd);
}
其他
{
dt = dashp.GetDataTable(cmd);

}
}
其他
{
SqlCommand cmd = dashp.CreateCommand("sp_maxid");
dt = dashp.GetDataTable(cmd);

}

return dt;

}

//存储过程

ALTER PROCEDURE sp_maxid
/*
(
@ parameter1 int = 5,
@ parameter2数据类型OUTPUT
)
*/
AS
从EmployeeDetailsInfo中选择max(intEmployeeId)
返回

你试试这个.............


hai,
试试这个想法.,
使用select查询查找该表上的最大id并从前端获取它.

像这样的代码:
----------------
con.open();
字符串se =从表名中选择max(uid)";
sqlcommand cmd =新的sqlcommand(se,con);
int lastid = convert.ToInt32(cmd.executescalar());
con.close();

现在您可以获得lastid值...

我希望这对您有用...
再见


您可以在InsertEmployee操作期间生成一个名为"CreatedOn"的字段.下一条语句可以基于CreatedOn字段获取最近的数据.


Suppose I have registered an employee
InsertEmployee();
Now next statement I want to get information for that last registered employee because my requirement is according to the date of joining of that employee I need to calculate some value.

解决方案

//this code in asp.cs file for autoid

private void Autoid()
{
string Mode = "M";
pr.Mode = Mode;
dt = new DataTable();
dt = logic.Maxid(pr);
if (dt.Rows[0][0].ToString() != "")
{
txtEMPId.Text = (int.Parse(dt.Rows[0][0].ToString()) + 1).ToString();
}
else
txtRMPId.Text = "1";
}
//inclass cs file

public DataTable InsertEmployeeFormat(ParametersBusinessObjects Schbo)
{
DataTable dt = new DataTable();

DataAcessHelper dashp = new DataAcessHelper();

if (Schbo.Mode != "M")
{
SqlCommand cmd = dashp.CreateCommand("sp_Employeedetails");
dashp.AddParameter(cmd, "@EmpIdid", SqlDbType.Int, ParameterDirection.Input, 4, Schbo.School);
dashp.AddParameter(cmd, "@EmpName", SqlDbType.VarChar, ParameterDirection.Input, 30, Schbo.SchoolName);

dashp.AddParameter(cmd, "@LandlineNo", SqlDbType.VarChar, ParameterDirection.Input, 20, Schbo.LandlineNo);
dashp.AddParameter(cmd, "@MobileNo", SqlDbType.VarChar, ParameterDirection.Input, 20, Schbo.MobileNo);
dashp.AddParameter(cmd, "@Address", SqlDbType.VarChar, ParameterDirection.Input, 30, Schbo.Address);
dashp.AddParameter(cmd,"@DateofBirth",SqlDbType.Date,ParameterDirection.Input ,30, Schbo.strDate);
dashp.AddParameter(cmd, "@EndDate", SqlDbType.Date, ParameterDirection.Input, 30, Schbo.EndDate);
dashp.AddParameter(cmd, "@Flag", SqlDbType.VarChar, ParameterDirection.Input, 2, Schbo.Mode);
if (Schbo.Mode != "A" && Schbo.Mode != "S" && Schbo.Mode != "G" && Schbo.Mode !="N")
{
dashp.ExecuteStoredProcedure(cmd);
}
else
{
dt = dashp.GetDataTable(cmd);

}
}
else
{
SqlCommand cmd = dashp.CreateCommand("sp_maxid");
dt = dashp.GetDataTable(cmd);

}

return dt;

}

//stored procedure

ALTER PROCEDURE sp_maxid
/*
(
@parameter1 int = 5,
@parameter2 datatype OUTPUT
)
*/
AS
select max(intEmployeeId) from EmployeeDetailsInfo
RETURN

u try this.............


hai,
try this idea.,
use select query on find maximum id on that table and get it from front end.

code like this:
----------------
con.open();
string se="select max(uid) from tablename";
sqlcommand cmd=new sqlcommand(se,con);
int lastid=convert.ToInt32(cmd.executescalar());
con.close();

now you can get lastid value...

i hope this is useful to you...
take care bye bye


You can generate a field named ''CreatedOn'' during InsertEmployee operation. Next statement can fetch the l(e)ast data based on CreatedOn field.


这篇关于如何获取在线系统中最后一位注册员工的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆