101 lines
3.3 KiB
C#
101 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Tanshu.Accounts.Entities;
|
|
using Tanshu.Accounts.Repository;
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
{
|
|
public partial class ModifierListForm : Form
|
|
{
|
|
private IList<Modifier> _list;
|
|
public ModifierListForm()
|
|
{
|
|
InitializeComponent();
|
|
dgvProductGroups.CellClick += new DataGridViewCellEventHandler(dgvProductGroups_CellClick);
|
|
}
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
using (var frm = new ModifierEditForm())
|
|
frm.ShowDialog();
|
|
using (var bi = new ModifierBI())
|
|
_list = bi.List();
|
|
bsList.DataSource = _list;
|
|
}
|
|
|
|
private void ModifierListForm_Load(object sender, EventArgs e)
|
|
{
|
|
using (var bi = new ModifierBI())
|
|
_list = bi.List();
|
|
bsList.DataSource = _list;
|
|
}
|
|
|
|
private void btnEdit_Click(object sender, EventArgs e)
|
|
{
|
|
var id = ((Modifier)bsList.Current).ModifierID;
|
|
using (var frm = new ModifierEditForm(id))
|
|
frm.ShowDialog();
|
|
using (var bi = new ModifierBI())
|
|
_list = bi.List();
|
|
bsList.DataSource = _list;
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void dgvProductGroups_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
// Ignore clicks that are not on button cells.
|
|
if (e.RowIndex < 0)
|
|
return;
|
|
|
|
// Ignore clicks that are not on button cells.
|
|
if (e.ColumnIndex == dgvProductGroups.Columns["moveUp"].Index)
|
|
{
|
|
var modifier = dgvProductGroups.Rows[e.RowIndex].DataBoundItem as Modifier;
|
|
var index = _list.IndexOf(modifier);
|
|
if (index == 0)
|
|
return;
|
|
var previousProduct = _list[index - 1];
|
|
_list.RemoveAt(index);
|
|
_list.Insert(index - 1, modifier);
|
|
bsList.DataSource = _list;
|
|
bsList.ResetBindings(false);
|
|
bsList.CurrencyManager.Position -= 1;
|
|
}
|
|
if (e.ColumnIndex == dgvProductGroups.Columns["moveDown"].Index)
|
|
{
|
|
var modifier = dgvProductGroups.Rows[e.RowIndex].DataBoundItem as Modifier;
|
|
var index = _list.IndexOf(modifier);
|
|
if (index == _list.Count + 1)
|
|
return;
|
|
var nextProduct = _list[index + 1];
|
|
_list.RemoveAt(index);
|
|
_list.Insert(index + 1, modifier);
|
|
bsList.DataSource = _list;
|
|
bsList.ResetBindings(false);
|
|
bsList.CurrencyManager.Position += 1;
|
|
}
|
|
}
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
//using (var bi = new ModifierBI())
|
|
//{
|
|
// bi.UpdateSortOrder(_list);
|
|
// bi.SaveChanges();
|
|
// _list = bi.List();
|
|
// bsList.DataSource = _list;
|
|
//}
|
|
}
|
|
}
|
|
}
|