Класс формы
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private readonly BindingList<Entity> _entities = new BindingList<Entity>();
public Form1()
{
InitializeComponent();
dataGridView1.DataSource = _entities;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
_entities.Add(new Entity()
{
Year = Convert.ToUInt16(textBoxYear.Text),
Month = Convert.ToUInt16(textBoxMonth.Text),
Price = Convert.ToDecimal(textBoxPrice.Text),
Volume = Convert.ToDecimal(textBoxVolume.Text),
Revenue = Convert.ToDecimal(textBoxPrice.Text) * Convert.ToDecimal(textBoxVolume.Text)
});
}
}
}
Класс выручки
namespace WindowsFormsApplication1
{
public class Entity
{
public uint Year { get; set; }
public uint Month { get; set; }
public decimal Volume { get; set; }
public decimal Price { get; set; }
public decimal Revenue { get; set; }
}
}
Если значения введены в столбик.
if (textBoxYear.Lines.Count()>1)
{
_entities.Add(new Entity()
{
Year = Convert.ToUInt16(textBoxYear.Lines[0]),
Month = Convert.ToUInt16(textBoxYear.Lines[1]),
Price = Convert.ToDecimal(textBoxYear.Lines[2]),
Volume = Convert.ToDecimal(textBoxYear.Lines[3]),
Revenue = Convert.ToDecimal(textBoxYear.Lines[3]) * Convert.ToDecimal(textBoxYear.Lines[2])
});
}
else
{
_entities.Add(new Entity()
{
Year = Convert.ToUInt16(textBoxYear.Text),
Month = Convert.ToUInt16(textBoxMonth.Text),
Price = Convert.ToDecimal(textBoxPrice.Text),
Volume = Convert.ToDecimal(textBoxVolume.Text),
Revenue = Convert.ToDecimal(textBoxPrice.Text) * Convert.ToDecimal(textBoxVolume.Text)
});
}
Все это примитивно, нужно везде делать проверки, разнести по методам, в общем дерзайте.