da929ad036
Breaking Change: Renamed Discontinued to IsActive and added NA field to products. Cleanup: Removed not used attributes Change: RoleConstants changed to simple string Feature: Table Create/Edit/Reorder and Modifier Create/Edit Form Feature: Bills now show the Tax name from the database and not a hack
93 lines
2.6 KiB
C#
93 lines
2.6 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.Helpers;
|
|
using System.Threading;
|
|
using Tanshu.Accounts.Repository;
|
|
using Tanshu.Accounts.Entities.Auth;
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
{
|
|
public partial class AssignUserGroups : Form
|
|
{
|
|
public AssignUserGroups()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void AssignRoles_Load(object sender, EventArgs e)
|
|
{
|
|
FillUsers();
|
|
}
|
|
|
|
private void FillUsers()
|
|
{
|
|
cmbUser.DisplayMember = "Name";
|
|
cmbUser.ValueMember = "UserID";
|
|
using (var bi = new UserBI())
|
|
cmbUser.DataSource = bi.List();
|
|
}
|
|
|
|
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (cmbUser.SelectedValue == null)
|
|
GetGroups(null);
|
|
else
|
|
GetGroups((Guid)cmbUser.SelectedValue);
|
|
}
|
|
|
|
private void GetGroups(Guid? userID)
|
|
{
|
|
using (var bi = new UserBI())
|
|
{
|
|
var groups = bi.GroupList();
|
|
clbGroups.DataSource = groups;
|
|
|
|
if (userID.HasValue)
|
|
{
|
|
var user = bi.Get(x => x.UserID == userID.Value);
|
|
for (int i = 0; i < clbGroups.Items.Count; i++)
|
|
{
|
|
var item = (Group)clbGroups.Items[i];
|
|
if (item.UserGroups.Any(x => x.User == user))
|
|
{
|
|
clbGroups.SetItemChecked(i, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
if (cmbUser.SelectedValue != null)
|
|
Save((Guid)cmbUser.SelectedValue);
|
|
}
|
|
|
|
private void Save(Guid userID)
|
|
{
|
|
using (var bi = new UserBI())
|
|
{
|
|
var user = bi.Get(x => x.UserID == userID);
|
|
bi.Update(user, clbGroups.CheckedItems.OfType<Group>());
|
|
bi.SaveChanges();
|
|
}
|
|
MessageBox.Show("Update / Save Successful");
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void clbGroups_Format(object sender, ListControlConvertEventArgs e)
|
|
{
|
|
e.Value = ((Group)e.ListItem).Name;
|
|
}
|
|
}
|
|
}
|