using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using StoresAndStockPricing.Model;
using Ubik.Engine.Client;
using StoresAndStockPricing.Controls;
namespace StoresAndStockPricing.Client{
public partial class SchedulePriceChangeForm : Form
{
private Session _session;
private StockItem _targetItem;
private BoundComboBoxSource<RetailStoreGroup> _applyToComboSource;
public SchedulePriceChangeForm()
{
InitializeComponent();
}
public SchedulePriceChangeForm(Session session, StockItem targetItem, RetailStoreGroup defaultGroup)
: this()
{
if (session == null)
throw new ArgumentNullException("session");
if (targetItem == null)
throw new ArgumentNullException("targetItem");
if (defaultGroup == null)
throw new ArgumentNullException("defaultGroup");
_session = session;
_targetItem = targetItem;
_applyToComboSource = new BoundComboBoxSource<RetailStoreGroup>(_session,
delegate(Session s, RetailStoreGroup group)
{
return group.Name;
});
_applyToComboSource.Filter = "";
_applyToCombo.DataSource = _applyToComboSource;
_applyToCombo.SelectItem<RetailStoreGroup>(defaultGroup);
}
private void _okButton_Click(object sender, EventArgs e)
{
StockItemSellingPriceMaintenanceEvent priceChangeEvent = new StockItemSellingPriceMaintenanceEvent(
_session,
EngineDateTime.UtcNow + new TimeSpan(0, 0, (int)_secondsBeforeChange.Value),
_targetItem,
_applyToCombo.GetSelectedItem<RetailStoreGroup>(),
_newPrice.Value);
priceChangeEvent.Insert();
}
private void _secondsBeforeChange_ValueChanged(object sender, EventArgs e)
{
if (_secondsBeforeChange.Value < 0M)
throw new ApplicationException(SchedulePriceChangeFormResources.SecondsMustBePositive);
}
}
}
|