|
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Furniture_Items;
using HistoryParam;
namespace ObjectHistoryWinSample
{
public partial class TableEditor : Form
{
private Table m_Table;
public TableEditor()
{
InitializeComponent();
}
public void Init(Table table)
{
// Keep the object for later use
m_Table = table;
// Model
this.textBoxModel.Text = m_Table.Model;
// Catalog ID
this.textBoxCatalogID.Text = m_Table.CatalogID.ToString();
// Width
this.textBoxWidth.Text = m_Table.Width.ToString();
// Heigt
this.textBoxHeight.Text = m_Table.Height.ToString();
// Length
this.textBoxLength.Text = m_Table.Length.ToString();
// Number of drawers / seats
if (m_Table.GetType().Name.ToLower().IndexOf("writing") >= 0)
{
this.labelNumberOf.Text = "Drawers";
this.textBoxNumberOf.Text = ((WritingTable)m_Table).NumberOfDrawers.ToString();
}
else // Dining table
{
this.labelNumberOf.Text = "Seats";
this.textBoxNumberOf.Text = ((DiningRoomTable)m_Table).NumberOfSeats.ToString();
}
// Price
HandlePrices();
}
private void HandlePrices()
{
listViewPrices.Items.Clear();
ArrayList prices = m_Table.Price.History;
for (int index = 0; index < prices.Count; ++index)
{
TimePeriodValuePair timePeriodValuePair = (TimePeriodValuePair)prices[index];
ListViewItem lvi = new ListViewItem(timePeriodValuePair.From.ToShortDateString());
lvi.SubItems.Add(timePeriodValuePair.Value.ToString());
lvi.Tag = timePeriodValuePair;
this.listViewPrices.Items.Add(lvi);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
EditPrice editPrice = new EditPrice();
if (editPrice.ShowDialog() == DialogResult.OK)
{
m_Table.Price.AddValueByPeriod(editPrice.GetPrice(), editPrice.GetDate());
HandlePrices();
}
}
private void buttonEdit_Click(object sender, EventArgs e)
{
MessageBox.Show("To be developed", "TBD", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
private void buttonDelete_Click(object sender, EventArgs e)
{
MessageBox.Show("To be developed", "TBD", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.