private Dictionary <string, object> prepareWorkParameters(clsAllWork prWork) { Dictionary <string, object> par = new Dictionary <string, object>(10); par.Add("WorkType", prWork.WorkType); par.Add("Name", prWork.Name); par.Add("Date", prWork.Date); par.Add("Value", prWork.Value); par.Add("Width", prWork.Width); par.Add("Height", prWork.Height); par.Add("Type", prWork.Type); par.Add("Weight", prWork.Weight); par.Add("Material", prWork.Material); par.Add("ArtistName", prWork.ArtistName); return(par); }
public string PostArtWork(clsAllWork prWork) { // insert try { int lcRecCount = clsDbConnection.Execute("INSERT INTO Work " + "(WorkType, Name, Date, Value, Width, Height, Type, Weight, Material, ArtistName) " + "VALUES (@WorkType, @Name, @Date, @Value, @Width, @Height, @Type, @Weight, @Material, @ArtistName)", prepareWorkParameters(prWork)); if (lcRecCount == 1) { return("One artwork inserted"); } else { return("Unexpected artwork insert count: " + lcRecCount); } } catch (Exception ex) { return(ex.GetBaseException().Message); } }
public string PutArtWork(clsAllWork prWork) { // update try { int lcRecCount = clsDbConnection.Execute("UPDATE Work SET " + "Date = @Date, Value = @Value, Width = @Width," + "Height = @Height, Type = @Type, Weight = @Weight, Material = @Material WHERE ArtistName=@ArtistName AND Name=@Name", prepareWorkParameters(prWork)); if (lcRecCount == 1) { return("One artwork updated"); } else { return("Unexpected artwork update count: " + lcRecCount); } } catch (Exception ex) { return(ex.GetBaseException().Message); } }