public void SellStock(Stock.Type stock, int sell) { float actualSell = Math.Min(Stocks[stock].Amount, sell); Cash += actualSell; Stocks[stock].Amount -= actualSell; }
public void BuyStock(Stock.Type stock, int buy) { float actualBuy = Math.Min(buy, Cash); Cash -= actualBuy; Stocks[stock].Amount += actualBuy; }
public void Set1m(Label label, Stock.Type type) { float value = History[type].History[Month - 1]; label.Content = (value * 100).ToString("F1") + "%"; if (value >= 0) { label.Foreground = Brushes.Black; } else { label.Foreground = Brushes.Red; } }
public float GetValue(Stock.Type type, int month) { if (month > Month) { month = Month; } float value = 1.0f; for (int i = 0; i < month; ++i) { value *= 1.0f + History[type].History[i]; } return(value); }
//public Decimal GetAVGUnitPrice_Material(String StoreID,String MaterialCode) //{ // tblStockTableAdapter da = new tblStockTableAdapter(); // da.Connection = Connection; // try // { // return Convert.ToDecimal(da.SPGET_Stock_AVGUnitPrice_Material(MaterialCode, StoreID)); // } // catch (Exception ex) // { // throw new Exception(ex.Message, ex); // } // finally // { // da.Dispose(); // } //} //public Decimal GetAVGUnitPrice_FinishProduct(String StoreID, String FinishProductCode) //{ // tblStockTableAdapter da = new tblStockTableAdapter(); // da.Connection = Connection; // try // { // return Convert.ToDecimal(da.SPGET_Stock_AVGUnitPrice_FinishProduct(FinishProductCode,StoreID)); // } // catch (Exception ex) // { // throw new Exception(ex.Message, ex); // } // finally // { // da.Dispose(); // } //} // public Decimal GetAVGUnitPrice_BasicProduct(String StoreID, String BasicProductCode) //{ // tblStockTableAdapter da = new tblStockTableAdapter(); // da.Connection = Connection; // try // { // return Convert.ToDecimal(da.SPGET_Stock_AVGUnitPrice_BasicProduct(BasicProductCode,StoreID)); // } // catch (Exception ex) // { // throw new Exception(ex.Message, ex); // } // finally // { // da.Dispose(); // } //} public Decimal GetAvailableQty(String StoreID, String Code, Stock.Type Type) { try { SqlParameter[] paramList = new SqlParameter[] { new SqlParameter("@ItemCode", Code), new SqlParameter("@StoreID", StoreID), new SqlParameter("@Type", Type) }; return(Execute.RunSP_Decimal(Connection, "SPGET_Stock_AvailableQty", paramList)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public void Plot(LineGraph graph, Stock.Type type, int min, int max) { graph.Data.Clear(); for (int i = min; i <= max; ++i) { float value = GetValue(type, i); graph.Data.Add(value); } graph.SetColor(0, 0, 0); graph.SetBaseline(1); graph.SetBaselineColor(128, 0, 0); graph.SetBackgroundColor(232, 255, 240); graph.ShowBaseline(false); graph.HideLegendMinMax(); graph.SetLabel("24m"); graph.Refresh(); }
public void Set6m(Label label, Stock.Type type) { float final = 1.0f; for (int i = Month - 6; i < Month; ++i) { final *= History[type].History[i] + 1; } final -= 1.0f; label.Content = (final * 100).ToString("F1") + "%"; if (final >= 0) { label.Foreground = Brushes.Black; } else { label.Foreground = Brushes.Red; } }
public Stock(Stock.Type stock) { Sector = stock; }