Created
August 22, 2014 10:31
-
-
Save weiland/e961c148b9b90ae51cf7 to your computer and use it in GitHub Desktop.
Receive one article from the DB via C# and SQL Stored Procedure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Models.ShopArticle GetArticle(int aID) | |
{ | |
SqlCommand cmd = CreateSQLCommand("spGetShopArticle"); | |
cmd.Parameters.Add(CreateParam("@ArticleID", aID)); | |
var dataTable = Fill(cmd); | |
var retval = new Models.ShopArticle(); | |
if (dataTable.TDataRows.Count == 0) | |
{ | |
return retval; | |
} | |
var row = dataTable.TDataRows[0]; | |
retval = new Models.ShopArticle() | |
{ | |
Article = new Models.Article() | |
{ | |
ArticleID = row.GetInt("ArticleID").GetValueOrDefault(-1), | |
Name = row.GetString("Name"), | |
Description = row.GetString("Description"), | |
TechnicalSpecs = row.GetString("TechnicalSpecs"), | |
Company = row.GetString("Company"), | |
CategoryID = row.GetInt("CategoryID").GetValueOrDefault(1) | |
}, | |
StartTime = row.GetDateTime("StartTime").Value, | |
EndTime = DateTime.Parse(row.GetString("EndTime")), | |
StartPrice = decimal.Parse(row.GetString("StartPrice")), | |
EndPrice = decimal.Parse(row.GetString("EndPrice")) | |
}; | |
return retval; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment