d8ecec8bb6
BillInventory Renamed. Refactored Bill to be more usable. Added Bill Detail Report. Added Open Bill and Bill Details Roles. Zero Rate Products have Yellow background Color. Refactored UserBI, FoodTableBI, ModifierBI, PrintLocationBI, ProductBI, ProductGroupBI, TaxBI, UserBI, Cached the Products List. Product and Product Group Form Working.
121 lines
3.6 KiB
C#
121 lines
3.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()
|
|
{
|
|
cmbUsers.DisplayMember = "Name";
|
|
cmbUsers.ValueMember = "UserID";
|
|
using (var bi = new UserBI())
|
|
cmbUsers.DataSource = bi.List();
|
|
}
|
|
|
|
private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
GetLists();
|
|
}
|
|
|
|
private void GetLists()
|
|
{
|
|
IList<Group> groups;
|
|
IList<Group> userGroups;
|
|
if (cmbUsers.SelectedValue == null)
|
|
{
|
|
groups = MembershipBI.GetGroups();
|
|
userGroups = new List<Group>();
|
|
|
|
}
|
|
else
|
|
{
|
|
int userid = (int)cmbUsers.SelectedValue;
|
|
groups = MembershipBI.GetGroupsNotOfUser(userid);
|
|
userGroups = MembershipBI.GetGroupsOfUser(userid);
|
|
}
|
|
|
|
RefreshRoles(groups, userGroups);
|
|
}
|
|
private void RefreshRoles(IList<Group> groups, IList<Group> userGroups)
|
|
{
|
|
lstGroups.DisplayMember = "Name";
|
|
lstGroups.ValueMember = "GroupID";
|
|
lstGroups.DataSource = groups;
|
|
|
|
lstUserGroups.DisplayMember = "Name";
|
|
lstUserGroups.ValueMember = "GroupID";
|
|
lstUserGroups.DataSource = userGroups;
|
|
|
|
btnAddAll.Enabled = btnAddSelected.Enabled = groups.Count > 0;
|
|
btnRemoveAll.Enabled = btnRemoveSelected.Enabled = userGroups.Count > 0;
|
|
}
|
|
|
|
private void btnAddSelected_Click(object sender, EventArgs e)
|
|
{
|
|
if (lstGroups.SelectedItem != null)
|
|
{
|
|
int userID = (int)cmbUsers.SelectedValue;
|
|
int groupID = (int)lstGroups.SelectedValue;
|
|
MembershipBI.AddUserToGroup(userID, groupID);
|
|
GetLists();
|
|
}
|
|
}
|
|
|
|
private void btnRemoveSelected_Click(object sender, EventArgs e)
|
|
{
|
|
if (lstUserGroups.SelectedItem != null)
|
|
{
|
|
int userID = (int)cmbUsers.SelectedValue;
|
|
int groupID = (int)lstUserGroups.SelectedValue;
|
|
MembershipBI.RemoveUserFromGroup(userID, groupID);
|
|
GetLists();
|
|
}
|
|
}
|
|
|
|
private void btnAddAll_Click(object sender, EventArgs e)
|
|
{
|
|
int userID = (int)cmbUsers.SelectedValue;
|
|
int groupID;
|
|
for (int i = 0; i <= lstGroups.Items.Count - 1; i++)
|
|
{
|
|
groupID = ((Group)lstGroups.Items[i]).GroupID;
|
|
MembershipBI.AddUserToGroup(userID, groupID);
|
|
}
|
|
GetLists();
|
|
}
|
|
|
|
private void btnRemoveAll_Click(object sender, EventArgs e)
|
|
{
|
|
int userID = (int)cmbUsers.SelectedValue;
|
|
int groupID;
|
|
for (int i = 0; i <= lstUserGroups.Items.Count - 1; i++)
|
|
{
|
|
groupID = ((Group)lstUserGroups.Items[i]).GroupID;
|
|
MembershipBI.RemoveUserFromGroup(userID, groupID);
|
|
}
|
|
GetLists();
|
|
}
|
|
}
|
|
}
|