public ClearspanLumber(string clearspanLumberCode, DateTime inquiryDate) { GetDatabaseValues(clearspanLumberCode); Price = GetLumberPrice(this.Lumbercode, inquiryDate); }
private LumberPrice GetLumberPrice(string _lumberCode, DateTime _inquiryDate) { DataSet myDataset = new DataSet(); string sql; sql = "Select * from lumberprices where lumbercode = '" + _lumberCode + "' and pricedate <= '" + _inquiryDate + "' order by pricedate desc"; myDataset = CCDAccess.SelectFromDB(sql); string _priceDate = ""; int _price = 0; Single _factor = 0; int _fobMillPrice = 0; int _freight = 0; LumberPrice tempLumberPrices; if ((myDataset != null)) { foreach (DataTable table in myDataset.Tables) { if (table.Rows.Count > 0) { DataRow d = table.Rows[0]; bool validData = true; if (d["PriceDate"] == DBNull.Value) { validData = false; } else { _priceDate = d["PriceDate"].ToString(); } if (d["Price"] == DBNull.Value) { validData = false; } else { _price = Convert.ToInt16(d["Price"]); } if (d["Factor"] == DBNull.Value) { validData = false; } else { _factor = Convert.ToSingle(d["Factor"]); } if (d["FobMillPrice"] == DBNull.Value) { _fobMillPrice = 0; } else { _fobMillPrice = Convert.ToInt16(d["FobMillPrice"]); } if (d["Freight"] == DBNull.Value) { _freight = 0; } else { _freight = Convert.ToInt16(d["Freight"]); } if (validData) { tempLumberPrices = new LumberPrice(_lumberCode, _priceDate, _price, _factor, _fobMillPrice, _freight); } else { tempLumberPrices = new LumberPrice(); } return(tempLumberPrices); } } } return(new LumberPrice()); }
public ClearspanLumber(string clearspanLumberCode) { GetDatabaseValues(clearspanLumberCode); Price = GetLumberPrice(clearspanLumberCode, DateTime.Now); }