public void calculation() { int i; int checkExistance = 0; DataGridViewRow tempRow = new DataGridViewRow(); for (i = 0; i < balanceDgv.Rows.Count; i++) { tempRow = balanceDgv.Rows[i]; if ((string)tempRow.Cells[0].Value == buy_data.stockName) { checkExistance = 1; break; } } if (checkExistance == 0) { long totalCost = buy_data.buyCost * buy_data.buyQuantity; balanceDgv.Rows.Add(buy_data.stockName, buy_data.buyQuantity, buy_data.buyCost, buy_data.buyCost, 0, 0, totalCost, totalCost); } else if (checkExistance == 1) { long totalCost = (long)tempRow.Cells[7].Value + buy_data.buyCost * buy_data.buyQuantity; long valuationCost = (long)tempRow.Cells[6].Value + buy_data.buyCost * buy_data.buyQuantity; tempRow.Cells[1].Value = (long)tempRow.Cells[1].Value + buy_data.buyQuantity; tempRow.Cells[3].Value = totalCost / (long)tempRow.Cells[1].Value; tempRow.Cells[6].Value = valuationCost; tempRow.Cells[7].Value = totalCost; } long cash = userBalance.getCash(); cash -= buy_data.buyCost * buy_data.buyQuantity; userBalance.setCash(cash); long totalBuyCost = userBalance.getPurchaseAmount(); totalBuyCost += buy_data.buyCost * buy_data.buyQuantity; userBalance.setPurchaseAmount(totalBuyCost); }
private void btnReset_Click(object sender, EventArgs e) { // 잔고 초기화 userBalance = new balance(); long totalAsset = userBalance.getTotalAsset(); long cash = userBalance.getCash(); long profit = userBalance.getProfit(); long purchase = userBalance.getPurchaseAmount(); long currentTotalPrice = userBalance.getCurrentTotalPrice(); lblBalance.Text = totalAsset.ToString(); lbl_percent.Text = "0%"; profit_txt.Text = profit.ToString(); lblPurchaseNumber.Text = purchase.ToString(); evaluated_txt.Text = currentTotalPrice.ToString(); cash_txt.Text = cash.ToString(); }
private void btnReset_Click(object sender, EventArgs e) { // 잔고 초기화 userBalance = new balance(); double totalAsset = userBalance.getTotalAsset(); double cash = userBalance.getCash(); double profitPercent = userBalance.calcProfitPercentage(); double profit = userBalance.getProfit(); double purchase = userBalance.getPurchaseAmount(); double currentTotalPrice = userBalance.getCurrentTotalPrice(); lblBalance.Text = totalAsset.ToString(); lbl_percent.Text = "0%"; profit_txt.Text = profit.ToString(); purchase_txt.Text = purchase.ToString(); evaluated_txt.Text = currentTotalPrice.ToString(); cash_txt.Text = cash.ToString(); }
public mainForm() { InitializeComponent(); userBalance = new balance(); double totalAsset = userBalance.getTotalAsset(); double cash = userBalance.getCash(); double profitPercent = userBalance.calcProfitPercentage(); double profit = userBalance.getProfit(); double purchase = userBalance.getPurchaseAmount(); double currentTotalPrice = userBalance.getCurrentTotalPrice(); lblBalance.Text = totalAsset.ToString(); lbl_percent.Text = "0%"; profit_txt.Text = profit.ToString(); purchase_txt.Text = purchase.ToString(); evaluated_txt.Text = currentTotalPrice.ToString(); cash_txt.Text = cash.ToString(); }
public mainForm() { InitializeComponent(); userBalance = new balance(); buy_data = new buyData(); sell_data = new sellData(); long totalAsset = userBalance.getTotalAsset(); long cash = userBalance.getCash(); double profitPercent = userBalance.getProfitPercentage(); long profit = userBalance.getProfit(); long purchase = userBalance.getPurchaseAmount(); long currentTotalPrice = userBalance.getCurrentTotalPrice(); lblBalance.Text = totalAsset.ToString(); lbl_percent.Text = "0%"; profit_txt.Text = profit.ToString(); lblPurchaseNumber.Text = purchase.ToString(); evaluated_txt.Text = currentTotalPrice.ToString(); cash_txt.Text = cash.ToString(); }