Edit stocklist. add stocks,
This commit is contained in:
@ -1,12 +1,6 @@
|
||||
using DataDomain;
|
||||
using Helpers;
|
||||
using OpenQA.Selenium;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BrowserHelper.Extensions
|
||||
{
|
||||
@ -86,14 +80,14 @@ namespace BrowserHelper.Extensions
|
||||
IWebElement tblBody = table.FindElement(By.XPath(".//tbody"));
|
||||
var rows = tblBody.FindElements(By.TagName("tr"));
|
||||
Dictionary<string, int> columnPos = new Dictionary<string, int>();
|
||||
GlobalStopwatch.PrintSecs("After allocations");
|
||||
//GlobalStopwatch.PrintSecs("After allocations");
|
||||
for (int i = 0; i < columns.Count; i++)
|
||||
{
|
||||
if (shareHeaders.Contains(columns[i].Text)) columnPos.Add(columns[i].Text, i);
|
||||
}
|
||||
var antal = shares.Length;
|
||||
int rowIndex = 0;
|
||||
GlobalStopwatch.PrintSecs("Before scraplooping");
|
||||
//GlobalStopwatch.PrintSecs("Before scraplooping");
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var element = row.FindElement(By.XPath(".//td"));
|
||||
@ -116,7 +110,7 @@ namespace BrowserHelper.Extensions
|
||||
}
|
||||
if (antal < 1) break;
|
||||
}
|
||||
GlobalStopwatch.PrintSecs("After scraplooping");
|
||||
//GlobalStopwatch.PrintSecs("After scraplooping");
|
||||
return shareCollection;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using BrowserHelper.Driver;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@ -18,6 +18,6 @@ namespace DatamodelLibrary
|
||||
public DbSet<ShareModel> StockGroups { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
=> options.UseSqlite("Data Source=Stocks.db");
|
||||
=> options.UseSqlite(@"Data Source=.\Stocks.db");
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,10 +246,9 @@ namespace StockDal
|
||||
{
|
||||
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
DumpObjects = new List<DiTraderStockRow>();
|
||||
GlobalStopwatch.PrintSecs("After dictionaries setup ");
|
||||
//var connStocks = _stockPersonConnect.GetAllConnectionsByPersId(persId);
|
||||
//GlobalStopwatch.PrintSecs("After dictionaries setup ");
|
||||
var groupedStocks = _stockRepository.GetStocksGroupedPerPerson(persId);
|
||||
GlobalStopwatch.PrintSecs("After groupedStocks fetched ");
|
||||
//GlobalStopwatch.PrintSecs("After groupedStocks fetched ");
|
||||
|
||||
var lastGroup = string.Empty;
|
||||
var stockList = new List<string>();
|
||||
@ -261,9 +260,9 @@ namespace StockDal
|
||||
{
|
||||
_testSettings.StockWishes = stockList.ToArray();
|
||||
stockList.Clear();
|
||||
GlobalStopwatch.PrintSecs("Before GetStockStatus");
|
||||
//GlobalStopwatch.PrintSecs("Before GetStockStatus");
|
||||
saveStockData( _scrapePage.GetMyStockStatus(lastGroup));
|
||||
GlobalStopwatch.PrintSecs("After GetStockStatus");
|
||||
//GlobalStopwatch.PrintSecs("After GetStockStatus");
|
||||
lastGroup = groupedStock.StockGroup;
|
||||
}
|
||||
else
|
||||
@ -286,14 +285,6 @@ namespace StockDal
|
||||
saveStockData(_scrapePage.GetMyStockStatus(lastGroup));
|
||||
}
|
||||
|
||||
//OpenBrowser(null);
|
||||
//Find_Data();
|
||||
//OpenBrowser();
|
||||
//Find_Data();
|
||||
//OpenBrowser(true);
|
||||
//Find_Data();
|
||||
|
||||
|
||||
if (DumpObjects.Any())
|
||||
{
|
||||
SaveLogging();
|
||||
|
||||
@ -14,8 +14,36 @@ namespace StockDAL
|
||||
public void SaveStockMember(StockMember stockMember)
|
||||
{
|
||||
using (var context = new StockContext())
|
||||
{
|
||||
if (stockMember.Id > 0)
|
||||
{
|
||||
var entity = (from stk in context.Stocks
|
||||
where stk.Id == stockMember.Id
|
||||
select stk).FirstOrDefault();
|
||||
if (entity != null)
|
||||
{
|
||||
entity.StockId = stockMember.StockId;
|
||||
entity.StockExtId = stockMember.StockExtId;
|
||||
entity.ActValue = stockMember.ActValue;
|
||||
entity.ActAmount= stockMember.ActAmount;
|
||||
entity.SoldDate = stockMember.SoldDate;
|
||||
entity.ActDate = stockMember.ActDate;
|
||||
entity.SoldStockPrice = stockMember.SoldStockPrice;
|
||||
entity.SoldValue = stockMember.SoldValue;
|
||||
entity.PostAmount = stockMember.PostAmount;
|
||||
entity.Comment = stockMember.Comment;
|
||||
entity.BuyDate = stockMember.BuyDate;
|
||||
entity.BuyValue = stockMember.BuyValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
var sm = context.Stocks.Add(stockMember);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var sm = context.Stocks.Add(stockMember);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
BIN
StockInfoCore/Stocks.db-shm
Normal file
BIN
StockInfoCore/Stocks.db-shm
Normal file
Binary file not shown.
0
StockInfoCore/Stocks.db-wal
Normal file
0
StockInfoCore/Stocks.db-wal
Normal file
14
StockInfoCore/frmEditStock.Designer.cs
generated
14
StockInfoCore/frmEditStock.Designer.cs
generated
@ -58,6 +58,7 @@ namespace StockInfoCore
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.txtStockName = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.btnSaveNew = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -306,11 +307,23 @@ namespace StockInfoCore
|
||||
this.label3.TabIndex = 28;
|
||||
this.label3.Text = "StockId";
|
||||
//
|
||||
// btnSaveNew
|
||||
//
|
||||
this.btnSaveNew.Location = new System.Drawing.Point(251, 414);
|
||||
this.btnSaveNew.Name = "btnSaveNew";
|
||||
this.btnSaveNew.Size = new System.Drawing.Size(80, 23);
|
||||
this.btnSaveNew.TabIndex = 29;
|
||||
this.btnSaveNew.Text = "SaveAsNew";
|
||||
this.btnSaveNew.UseVisualStyleBackColor = true;
|
||||
this.btnSaveNew.UseWaitCursor = true;
|
||||
this.btnSaveNew.Click += new System.EventHandler(this.btnSaveNew_Click);
|
||||
//
|
||||
// frmEditStock
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(570, 452);
|
||||
this.Controls.Add(this.btnSaveNew);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.txtStockName);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
@ -377,5 +390,6 @@ namespace StockInfoCore
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox txtStockName;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private Button btnSaveNew;
|
||||
}
|
||||
}
|
||||
@ -54,6 +54,7 @@ namespace StockInfoCore
|
||||
private void LoadStockData()
|
||||
{
|
||||
var stockChosen = _stockRepository.GetStockMember(CurrentStockMember);
|
||||
txtStockName.Text = stockChosen.StockId;
|
||||
txtStockExtId.Text = stockChosen.StockExtId;
|
||||
txtActValue.Text = stockChosen.ActValue.ToString();
|
||||
//txtActDate.Text = (DateTime.Today + stockChosen.ActDate.Value.TimeOfDay).ToString();
|
||||
@ -83,14 +84,14 @@ namespace StockInfoCore
|
||||
txtBuyDate.Text = stockChosen.BuyDate.ToString(); // = string.IsNullOrWhiteSpace(txtBuyDate.Text) ? DateTime.Today : DateTime.Parse(txtBuyDate.Text);
|
||||
txtActValue.Text = stockChosen.ActValue.ToString(); // = decimal.Parse(string.IsNullOrEmpty(txtActValue.Text) ? "0" : txtActValue.Text);
|
||||
txtActAmount.Text = stockChosen.ActAmount.ToString(); // = long.Parse(string.IsNullOrEmpty(txtActAmount.Text) ? "0" : txtActAmount.Text);
|
||||
txtSoldDate.Text = stockChosen.SoldDate.ToString(); // = null; //DateTime.MaxValue;
|
||||
txtSoldDate.Text = stockChosen.SoldDate == DateTime.MinValue ? String.Empty : stockChosen.SoldDate.ToString(); // = null; //DateTime.MaxValue;
|
||||
txtSoldPrice.Text = stockChosen.SoldValue.ToString(); // = decimal.Parse("0");
|
||||
txtComment.Text = stockChosen.Comment;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void AddValidateData()
|
||||
private void AddValidateData(bool New)
|
||||
{
|
||||
var currentStock = new StockMember();
|
||||
currentStock.StockId = txtStockName.Text.Trim();
|
||||
@ -101,10 +102,15 @@ namespace StockInfoCore
|
||||
currentStock.BuyDate = string.IsNullOrWhiteSpace(txtBuyDate.Text) ? DateTime.Today : DateTime.Parse(txtBuyDate.Text);
|
||||
currentStock.ActValue = decimal.Parse(string.IsNullOrEmpty(txtActValue.Text) ? "0" : txtActValue.Text);
|
||||
currentStock.ActAmount = long.Parse(string.IsNullOrEmpty(txtActAmount.Text) ? "0" : txtActAmount.Text);
|
||||
currentStock.SoldDate = DateTime.Parse(txtSoldDate.Text);
|
||||
currentStock.SoldDate = txtSoldDate.Text.Trim() == "" ? DateTime.MinValue : DateTime.Parse(txtSoldDate.Text);
|
||||
currentStock.SoldValue = decimal.Parse(txtSoldPrice.Text);
|
||||
currentStock.Comment = txtComment.Text;
|
||||
currentStock.Comment = txtComment.Text.Length<1?String.Empty: txtComment.Text;
|
||||
//RegisteredStocks.Add(currentStock);
|
||||
if (!New)
|
||||
{
|
||||
currentStock.Id = CurrentStockMember;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_stockRepository.SaveStockMember(currentStock);
|
||||
@ -119,6 +125,7 @@ namespace StockInfoCore
|
||||
|
||||
private void initiateRegWin()
|
||||
{
|
||||
txtStockName.Text = "";
|
||||
txtStockExtId.Text = "";
|
||||
txtBuyPrice.Text = "";
|
||||
txtBuyDate.Text = "";
|
||||
@ -133,7 +140,7 @@ namespace StockInfoCore
|
||||
|
||||
private void btnSaveToDB_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddValidateData();
|
||||
AddValidateData(false);
|
||||
}
|
||||
|
||||
private void txtBoughtAmount_TextChanged(object sender, EventArgs e)
|
||||
@ -149,5 +156,10 @@ namespace StockInfoCore
|
||||
e.DrawText();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSaveNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddValidateData(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ namespace StockInfoCore
|
||||
private readonly frmPerson _personWindow;
|
||||
private readonly frmPersonShareConnect _personShareConnect;
|
||||
private readonly frmBackup _backupWindow;
|
||||
|
||||
private readonly frmEditStock _editStock;
|
||||
bool loading = false;
|
||||
//private frmRegisterStock regWindow;
|
||||
//private frmMyStocks stockWindow;
|
||||
@ -58,7 +58,8 @@ namespace StockInfoCore
|
||||
frmSelling sellWindow,
|
||||
frmPerson personWindow,
|
||||
frmPersonShareConnect personShareConnect,
|
||||
frmBackup backupWindow
|
||||
frmBackup backupWindow,
|
||||
frmEditStock editStock
|
||||
)
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -76,6 +77,7 @@ namespace StockInfoCore
|
||||
_personWindow = personWindow;
|
||||
_personShareConnect = personShareConnect;
|
||||
_backupWindow = backupWindow;
|
||||
_editStock = editStock;
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
@ -141,9 +143,9 @@ namespace StockInfoCore
|
||||
|
||||
private void btnValueView_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(!GlobalStopwatch.IsRunning && GlobalStopwatch.EllapsedMillis>0)
|
||||
GlobalStopwatch.Restart();
|
||||
else GlobalStopwatch.Start();
|
||||
//if(!GlobalStopwatch.IsRunning && GlobalStopwatch.EllapsedMillis>0)
|
||||
// GlobalStopwatch.Restart();
|
||||
//else GlobalStopwatch.Start();
|
||||
|
||||
if (SelectedPersonId == 0)
|
||||
{
|
||||
@ -159,8 +161,8 @@ namespace StockInfoCore
|
||||
_stockWindow.Stocks = _stockMarketRepository.StockMarketList;
|
||||
|
||||
Cursor.Current = DefaultCursor;
|
||||
GlobalStopwatch.Stop();
|
||||
GlobalStopwatch.PrintSecs("Before Show Stockwindow");
|
||||
//GlobalStopwatch.Stop();
|
||||
//GlobalStopwatch.PrintSecs("Before Show Stockwindow");
|
||||
_stockWindow.ShowDialog();
|
||||
}
|
||||
}
|
||||
@ -282,7 +284,11 @@ namespace StockInfoCore
|
||||
{
|
||||
//MessageBox.Show($"{((DataGridView)sender).SelectedRows.ToString()} eventargs = {e.ToString()}" );
|
||||
int id = Convert.ToInt32(dataGridView.Rows[dataGridView.CurrentRow.Index].Cells[0].Value);
|
||||
MessageBox.Show($"Vald rads id = {id}");
|
||||
if (DialogResult.OK == MessageBox.Show($"Vald rads id = {id}{Environment.NewLine}Ändra ?", "Fråga", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
|
||||
{
|
||||
_editStock.CurrentStockMember = id;
|
||||
_editStock.ShowDialog();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ namespace StockInfoCore
|
||||
}
|
||||
|
||||
lblOwnerName.Text = $"* {ConnectedPerson.FirstName} {ConnectedPerson.LastName} *";
|
||||
GlobalStopwatch.PrintSecs("In reload (New window)");
|
||||
//GlobalStopwatch.PrintSecs("In reload (New window)");
|
||||
|
||||
txtBuyTotal.Text = BoughtSum.ToString();
|
||||
txtBuyTotal.Refresh();
|
||||
|
||||
@ -62,6 +62,7 @@ namespace StockInfoCore
|
||||
PersonStock ps = new PersonStock();
|
||||
ps.PersonId = ConnectPerson.Id;
|
||||
ps.StockId = int.Parse(lstShares.SelectedValue.ToString());
|
||||
ps.Comment = String.Empty;
|
||||
_stockPersonConnect.SavePersonStockConnection(ps);
|
||||
RefreshShareList();
|
||||
RefreshConnectedList();
|
||||
|
||||
Reference in New Issue
Block a user