bahrammzm
پنج شنبه 26 تیر 1393, 11:45 صبح
سلام دوستانمیخوام اطلاعات آخرین رکورد ثبت شده رو بریزم داخل تکست باکس .اما نمیدونم مشکل از کجاست .کدها رو بصورت کامل میذارم
//DBBASE :
public class DBBase
{
private static SqlCommand _command;
private static SqlDataReader _dataReader;
protected static SqlCommand Command
{
get { return _command; }
set { _command = value; }
}
protected static SqlDataReader DataReader
{
get { return _dataReader; }
set { _dataReader = value; }
}
}
//DBCUSTOMER :
public CustomerSet Select_Last_Customer(Customer CurrentCustomer)
{
Command = new SqlCommand("sp_LastCustomer_Select", Connection);
Command.CommandType = System.Data.CommandType.StoredProcedure;
Customer LastCustomer = new Customer();
Connection.Open();
DataReader = Command.ExecuteReader();
if (DataReader.Read())
{
LastCustomer.id = int.Parse(DataReader["id"].ToString());
LastCustomer.fname = DataReader["fname"].ToString();
}
DataReader.Close();
Connection.Close();
return LastCustomer;
}
//BUSINESS CUSTOMER :
public CustomerSet Select_Last_Customer(Customer TempCustomer)
{
return ((new DBCustomer()).Select_Last_Customer(TempCustomer));
}
//UI:
public void LoadDataTotxtCustomerFullName(Customer LastCustomer)
{
CustomerSet ShowLastCustomer = new CustomerSet();
ShowLastCustomer = (new BusinessCustomer().Select_Last_Customer(LastCustom er));
txtLastCustomerName.Text = ShowLastCustomer.ToString();
}
private void frmPhotoReg_Load(object sender, EventArgs e)
{
Customer ShowLastCustomer = new Customer();
txtLastCustomerName.Text = LoadDataTotxtCustomerFullName(ShowLastCustomer);
}
//STOREPROCEDURE:
ALTER procedure [dbo].[sp_LastCustomer_Select]
(
@Error bit out
)
as
begin
select fname,id from tblCustomers
where id = (select MAX(id) from tblCustomers)
set @Error=@@ERROR;
//DBBASE :
public class DBBase
{
private static SqlCommand _command;
private static SqlDataReader _dataReader;
protected static SqlCommand Command
{
get { return _command; }
set { _command = value; }
}
protected static SqlDataReader DataReader
{
get { return _dataReader; }
set { _dataReader = value; }
}
}
//DBCUSTOMER :
public CustomerSet Select_Last_Customer(Customer CurrentCustomer)
{
Command = new SqlCommand("sp_LastCustomer_Select", Connection);
Command.CommandType = System.Data.CommandType.StoredProcedure;
Customer LastCustomer = new Customer();
Connection.Open();
DataReader = Command.ExecuteReader();
if (DataReader.Read())
{
LastCustomer.id = int.Parse(DataReader["id"].ToString());
LastCustomer.fname = DataReader["fname"].ToString();
}
DataReader.Close();
Connection.Close();
return LastCustomer;
}
//BUSINESS CUSTOMER :
public CustomerSet Select_Last_Customer(Customer TempCustomer)
{
return ((new DBCustomer()).Select_Last_Customer(TempCustomer));
}
//UI:
public void LoadDataTotxtCustomerFullName(Customer LastCustomer)
{
CustomerSet ShowLastCustomer = new CustomerSet();
ShowLastCustomer = (new BusinessCustomer().Select_Last_Customer(LastCustom er));
txtLastCustomerName.Text = ShowLastCustomer.ToString();
}
private void frmPhotoReg_Load(object sender, EventArgs e)
{
Customer ShowLastCustomer = new Customer();
txtLastCustomerName.Text = LoadDataTotxtCustomerFullName(ShowLastCustomer);
}
//STOREPROCEDURE:
ALTER procedure [dbo].[sp_LastCustomer_Select]
(
@Error bit out
)
as
begin
select fname,id from tblCustomers
where id = (select MAX(id) from tblCustomers)
set @Error=@@ERROR;