Smärre korrigeringar
This commit is contained in:
@ -41,7 +41,7 @@ namespace RepositoryPattern
|
|||||||
}
|
}
|
||||||
else if (rdbStock.Checked)
|
else if (rdbStock.Checked)
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = _stockMemberRepository.GetStocks();
|
dataGridView.DataSource = _stockMemberRepository.GetAllStocks();
|
||||||
}
|
}
|
||||||
lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
|
lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
|
||||||
}
|
}
|
||||||
|
|||||||
54
RepositoryPattern/frmMyStocks.Designer.cs
generated
54
RepositoryPattern/frmMyStocks.Designer.cs
generated
@ -54,6 +54,10 @@ namespace RepositoryPattern
|
|||||||
this.label4 = new System.Windows.Forms.Label();
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
||||||
this.label5 = new System.Windows.Forms.Label();
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
this.txtTotalMinus = new System.Windows.Forms.TextBox();
|
||||||
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
|
this.txtTotalPlus = new System.Windows.Forms.TextBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -272,11 +276,57 @@ namespace RepositoryPattern
|
|||||||
this.label5.TabIndex = 11;
|
this.label5.TabIndex = 11;
|
||||||
this.label5.Text = "Uppdatering (min)";
|
this.label5.Text = "Uppdatering (min)";
|
||||||
//
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label6.AutoSize = true;
|
||||||
|
this.label6.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.label6.Location = new System.Drawing.Point(200, 476);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(89, 21);
|
||||||
|
this.label6.TabIndex = 13;
|
||||||
|
this.label6.Text = "Total Minus";
|
||||||
|
//
|
||||||
|
// txtTotalMinus
|
||||||
|
//
|
||||||
|
this.txtTotalMinus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.txtTotalMinus.Location = new System.Drawing.Point(295, 474);
|
||||||
|
this.txtTotalMinus.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.txtTotalMinus.Name = "txtTotalMinus";
|
||||||
|
this.txtTotalMinus.ReadOnly = true;
|
||||||
|
this.txtTotalMinus.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.txtTotalMinus.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label7.AutoSize = true;
|
||||||
|
this.label7.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.label7.Location = new System.Drawing.Point(438, 476);
|
||||||
|
this.label7.Name = "label7";
|
||||||
|
this.label7.Size = new System.Drawing.Size(75, 21);
|
||||||
|
this.label7.TabIndex = 15;
|
||||||
|
this.label7.Text = "Total Plus";
|
||||||
|
//
|
||||||
|
// txtTotalPlus
|
||||||
|
//
|
||||||
|
this.txtTotalPlus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.txtTotalPlus.Location = new System.Drawing.Point(533, 474);
|
||||||
|
this.txtTotalPlus.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.txtTotalPlus.Name = "txtTotalPlus";
|
||||||
|
this.txtTotalPlus.ReadOnly = true;
|
||||||
|
this.txtTotalPlus.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.txtTotalPlus.TabIndex = 14;
|
||||||
|
//
|
||||||
// frmMyStocks
|
// frmMyStocks
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1217, 651);
|
this.ClientSize = new System.Drawing.Size(1217, 651);
|
||||||
|
this.Controls.Add(this.label7);
|
||||||
|
this.Controls.Add(this.txtTotalPlus);
|
||||||
|
this.Controls.Add(this.label6);
|
||||||
|
this.Controls.Add(this.txtTotalMinus);
|
||||||
this.Controls.Add(this.label5);
|
this.Controls.Add(this.label5);
|
||||||
this.Controls.Add(this.numericUpDown1);
|
this.Controls.Add(this.numericUpDown1);
|
||||||
this.Controls.Add(this.label4);
|
this.Controls.Add(this.label4);
|
||||||
@ -326,5 +376,9 @@ namespace RepositoryPattern
|
|||||||
private System.Windows.Forms.ColumnHeader columnHeader11;
|
private System.Windows.Forms.ColumnHeader columnHeader11;
|
||||||
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
||||||
private System.Windows.Forms.Label label5;
|
private System.Windows.Forms.Label label5;
|
||||||
|
private System.Windows.Forms.Label label6;
|
||||||
|
private System.Windows.Forms.TextBox txtTotalMinus;
|
||||||
|
private System.Windows.Forms.Label label7;
|
||||||
|
private System.Windows.Forms.TextBox txtTotalPlus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,6 +21,8 @@ namespace RepositoryPattern
|
|||||||
public decimal BoughtSum { get; set; }
|
public decimal BoughtSum { get; set; }
|
||||||
public decimal TotalDiff { get; set; }
|
public decimal TotalDiff { get; set; }
|
||||||
public decimal CurrentSum { get; set; }
|
public decimal CurrentSum { get; set; }
|
||||||
|
public decimal TotalPlus { get; set; }
|
||||||
|
public decimal TotalMinus { get; set; }
|
||||||
|
|
||||||
public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
|
public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
|
||||||
public IEnumerable<StockMember> CurrentStocks { get; set; }
|
public IEnumerable<StockMember> CurrentStocks { get; set; }
|
||||||
@ -44,6 +46,8 @@ namespace RepositoryPattern
|
|||||||
BoughtSum = 0m;
|
BoughtSum = 0m;
|
||||||
TotalDiff = 0m;
|
TotalDiff = 0m;
|
||||||
CurrentSum = 0m;
|
CurrentSum = 0m;
|
||||||
|
TotalMinus = 0m;
|
||||||
|
TotalPlus = 0m;
|
||||||
foreach (var stock in CurrentStocks)
|
foreach (var stock in CurrentStocks)
|
||||||
{
|
{
|
||||||
stock.ActValue = Stocks[stock.StockId.Trim()].LatestPrice;
|
stock.ActValue = Stocks[stock.StockId.Trim()].LatestPrice;
|
||||||
@ -58,6 +62,12 @@ namespace RepositoryPattern
|
|||||||
txtCurrValue.Refresh();
|
txtCurrValue.Refresh();
|
||||||
txtTotDiff.Text = TotalDiff.ToString();
|
txtTotDiff.Text = TotalDiff.ToString();
|
||||||
txtTotDiff.Refresh();
|
txtTotDiff.Refresh();
|
||||||
|
txtTotalMinus.Text = TotalMinus.ToString();
|
||||||
|
txtTotalMinus.Refresh();
|
||||||
|
txtTotalPlus.Text = TotalPlus.ToString();
|
||||||
|
txtTotalPlus.Refresh();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TotalReload()
|
private void TotalReload()
|
||||||
@ -81,7 +91,10 @@ namespace RepositoryPattern
|
|||||||
{
|
{
|
||||||
var lv = lvMyStocks.Items.Add(currStock.StockId);
|
var lv = lvMyStocks.Items.Add(currStock.StockId);
|
||||||
lv.SubItems.Add(currStock.BuyValue.ToString());
|
lv.SubItems.Add(currStock.BuyValue.ToString());
|
||||||
lv.SubItems.Add(currStock.ActValue.ToString());
|
var currValue = lv.SubItems.Add(currStock.ActValue.ToString());
|
||||||
|
//var saveBcolor = currValue.BackColor;
|
||||||
|
//var valueLevel = currStock.ActValue - currStock.BuyValue;
|
||||||
|
//currValue.ForeColor = valueLevel > 5 ? Color.Red : saveBcolor;
|
||||||
var priceDiff = currStock.ActValue - currStock.BuyValue;
|
var priceDiff = currStock.ActValue - currStock.BuyValue;
|
||||||
lv.SubItems.Add(priceDiff.ToString());
|
lv.SubItems.Add(priceDiff.ToString());
|
||||||
lv.SubItems.Add(currStock.PostAmount.ToString());
|
lv.SubItems.Add(currStock.PostAmount.ToString());
|
||||||
@ -93,6 +106,14 @@ namespace RepositoryPattern
|
|||||||
BoughtSum += buyValue;
|
BoughtSum += buyValue;
|
||||||
TotalDiff += diffValue;
|
TotalDiff += diffValue;
|
||||||
CurrentSum += actValue;
|
CurrentSum += actValue;
|
||||||
|
if (diffValue < 0)
|
||||||
|
{
|
||||||
|
TotalMinus += diffValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TotalPlus += diffValue;
|
||||||
|
}
|
||||||
var lvs = lv.SubItems.Add(diffValue.ToString());
|
var lvs = lv.SubItems.Add(diffValue.ToString());
|
||||||
lv.SubItems.Add(Math.Round(diffproc, 2).ToString());
|
lv.SubItems.Add(Math.Round(diffproc, 2).ToString());
|
||||||
lv.SubItems.Add(currStock.ActDate.ToString());
|
lv.SubItems.Add(currStock.ActDate.ToString());
|
||||||
|
|||||||
@ -11,5 +11,6 @@ namespace StockDal.Interface
|
|||||||
void UpdateActPrice(int Id, decimal price);
|
void UpdateActPrice(int Id, decimal price);
|
||||||
bool Delete(string stockMemberId);
|
bool Delete(string stockMemberId);
|
||||||
void InsertMany(List<StockMember> stockMembers);
|
void InsertMany(List<StockMember> stockMembers);
|
||||||
|
IEnumerable<StockMember> GetAllStocks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ namespace StockDal
|
|||||||
", new { val = price, date = DateTime.Today, id = Id });
|
", new { val = price, date = DateTime.Today, id = Id });
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<StockMember> IStockMemberRepository.GetStocks()
|
public IEnumerable<StockMember> GetStocks()
|
||||||
{
|
{
|
||||||
using IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString);
|
using IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString);
|
||||||
if (db.State == ConnectionState.Closed)
|
if (db.State == ConnectionState.Closed)
|
||||||
@ -77,7 +77,28 @@ namespace StockDal
|
|||||||
,SoldDate
|
,SoldDate
|
||||||
,Comment
|
,Comment
|
||||||
,PostAmount
|
,PostAmount
|
||||||
FROM dbo.StockMember", commandType: CommandType.Text);
|
FROM dbo.StockMember
|
||||||
|
Where SoldDate is null
|
||||||
|
ORDER BY PostAmount * (actvalue - BuyValue) desc", commandType: CommandType.Text);
|
||||||
|
}
|
||||||
|
public IEnumerable<StockMember> GetAllStocks()
|
||||||
|
{
|
||||||
|
using IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString);
|
||||||
|
if (db.State == ConnectionState.Closed)
|
||||||
|
db.Open();
|
||||||
|
return db.Query<StockMember>(@"SELECT Id
|
||||||
|
,StockId
|
||||||
|
,StockExtId
|
||||||
|
,BuyValue
|
||||||
|
,BuyDate
|
||||||
|
,ActValue
|
||||||
|
,ActDate
|
||||||
|
,SoldValue
|
||||||
|
,SoldDate
|
||||||
|
,Comment
|
||||||
|
,PostAmount
|
||||||
|
FROM dbo.StockMember
|
||||||
|
ORDER BY PostAmount * (actvalue - BuyValue) desc", commandType: CommandType.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user