#region private
private int iD;
private int projectID;
private string category;
private decimal unitPrice;
#endregion
#region public
public int ID
{
get { return iD; }
set { iD = value; }
}
public int ProjectID
{
get { return projectID; }
set { projectID = value; }
}
public string Category
{
get { return category; }
set { category = value; }
}
public decimal UnitPrice
{
get { return unitPrice; }
set { unitPrice = value; }
}
#endregion
/// <summary>
/// 添加ys
/// </summary>
/// <param name="steelUintPrice">ys</param>
/// <returns>最新编号</returns>
public int Add()
{
string sql = @"INSERT INTO SteelUintPrice(ProjectID,Category,UnitPrice)
values(@ProjectID,@Category,@UnitPrice);
SELECT SCOPE_IDENTITY();";
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@ProjectID",SqlDbType.Int,4),
new SqlParameter("@Category",SqlDbType.NVarChar,50),
new SqlParameter("@UnitPrice",SqlDbType.Decimal,9)
};
int i = 0;
para[i++].Value = ProjectID;
para[i++].Value = Category;
para[i++].Value = UnitPrice;
return Convert.ToInt32(DbHelperSQL.GetSingle(sql, para));
}
非常感谢重点就在new SqlParameter("@Category",SqlDbType.NVarChar,50) 用Nvarchar之后可以存特殊字符。