Checked actamount before calculating
This commit is contained in:
@ -3,13 +3,7 @@ using Helpers;
|
|||||||
using StockDAL.Interface;
|
using StockDAL.Interface;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace StockInfo
|
namespace StockInfo
|
||||||
@ -17,10 +11,10 @@ namespace StockInfo
|
|||||||
public partial class frmSelling : Form
|
public partial class frmSelling : Form
|
||||||
{
|
{
|
||||||
private readonly IStockRepository _stockRepository;
|
private readonly IStockRepository _stockRepository;
|
||||||
private List<StockMember> remainingStocks = new ();
|
private List<StockMember> remainingStocks = new();
|
||||||
public StockMember stkMemSelected { get; set; } = null;
|
public StockMember stkMemSelected { get; set; } = null;
|
||||||
|
|
||||||
public frmSelling(IStockRepository stockRepository )
|
public frmSelling(IStockRepository stockRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_stockRepository = stockRepository;
|
_stockRepository = stockRepository;
|
||||||
@ -29,7 +23,7 @@ namespace StockInfo
|
|||||||
private void frmSelling_Load(object sender, EventArgs e)
|
private void frmSelling_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
remainingStocks = _stockRepository.GetAllRemainingStocks().ToList();
|
remainingStocks = _stockRepository.GetAllRemainingStocks().ToList();
|
||||||
foreach(var stock in remainingStocks)
|
foreach (var stock in remainingStocks)
|
||||||
{
|
{
|
||||||
var lvRow = lvSellCandidates.Items.Add(stock.StockId);
|
var lvRow = lvSellCandidates.Items.Add(stock.StockId);
|
||||||
lvRow.Tag = stock.Id;
|
lvRow.Tag = stock.Id;
|
||||||
@ -44,9 +38,9 @@ namespace StockInfo
|
|||||||
private void SelectStock(object tag)
|
private void SelectStock(object tag)
|
||||||
{
|
{
|
||||||
//Debug.WriteLine($"selected item {(int)tag}");
|
//Debug.WriteLine($"selected item {(int)tag}");
|
||||||
foreach(var remStk in remainingStocks)
|
foreach (var remStk in remainingStocks)
|
||||||
{
|
{
|
||||||
if(remStk.Id == (int)tag)
|
if (remStk.Id == (int)tag)
|
||||||
{
|
{
|
||||||
stkMemSelected = remStk;
|
stkMemSelected = remStk;
|
||||||
break;
|
break;
|
||||||
@ -87,7 +81,7 @@ namespace StockInfo
|
|||||||
if (txtSoldPrice.Text.IsNumeric() && txtSoldAmount.Text.IsNumeric())
|
if (txtSoldPrice.Text.IsNumeric() && txtSoldAmount.Text.IsNumeric())
|
||||||
{
|
{
|
||||||
txtSellValue.Text = (decimal.Parse(txtSoldPrice.Text) * long.Parse(txtSoldAmount.Text)).ToString();
|
txtSellValue.Text = (decimal.Parse(txtSoldPrice.Text) * long.Parse(txtSoldAmount.Text)).ToString();
|
||||||
txtRemainingNo.Text = (stkMemSelected.PostAmount - long.Parse(txtSoldAmount.Text)).ToString();
|
txtRemainingNo.Text = stkMemSelected.ActAmount > 0 ? (stkMemSelected.PostAmount - long.Parse(txtSoldAmount.Text)).ToString() : 0.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user