This Business service takes a paramater of type integer called productid and returns ProductInfo. ProductInfo is a constructor class that holds the variables that make ProductInfo. See the bottom of page for ProductInfo class.
public
ProductInfo GetProductInfo(int productid)
{
DDatabaseReader reader=null;
ProductInfo
info = new
ProductInfo("junk","12/07/02","12/07/02",10,"C:/??","Good","cash");
try
{
string sql = string.Format("select
CProductTitle,CStartTime,CEndTime,CStartPrice,CImage,CProductDesc,CPayDesc from
TProductInfo where CProductId ={0}", productid);
reader = mDatabase.SQLQuery(sql);
if(reader.Read()==false)
{reader.Dispose();
mDebug.WriteLine("GetProductInfo():Did not get any
rows");
return info;
}
info
= new
ProductInfo(reader["CProductTitle"].ToString(),reader["CStartTime"].ToString(),reader["CEndTime"].ToString(),int.Parse(reader["CStartPrice"].ToString()),reader["CImage"].ToString(),reader["CProductDesc"].ToString(),reader["CPayDesc"].ToString());
reader.Dispose();
return
info;
catch(Exception
ex)
{if(reader!=null)
{ reader.Dispose(); }
mDebug.WriteLine("GetProductInfo():"+ex.ToString()
);
}
return
info;
}
////////////////////////////////////////////////////////////////////////////////
This is the ProductInfo class. It is basically constructor class to instantiate the variables that ProductInfo returns.
using
System;
namespace
MyProject
{
public class
ProductInfo
{
private int
CProductId;
private string
CBSignInName;
private string
CSSignInName;
private string
CProductTitle;
public string
CStartTime;
public string
CEndTime;
private string
CTimeLeft;
private int
CStartPrice;
private string
CImage;
private string
CProductDesc;
private string
CPayDesc;
public int
ProdId{get{return
CProductId;}}
public string
BSignId{get{return
CBSignInName;}}
public string
SSellerId{get{return
CSSignInName;}}
public string
Title{get{return
CProductTitle;}}
public string
StartTime{get{return
CStartTime;}}
public string
EndTime{get{return
CEndTime;}}
public int
StartPrice{get{return
CStartPrice;}}
public string
Image{get{return
CImage;}}
public string
ProdDesc{get{return
CProductDesc;}}
public string
Pay{get{return
CPayDesc;}
{
CStartTime=st;
CEndTime=et;
CStartPrice=sp;
CImage=img;
CProductDesc=proddes;
CPayDesc=paydes;
}
}
}