narsil/Tanshu.Accounts.PointOfSale/MainForm.cs

235 lines
7.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Helpers;
//using Tanshu.Accounts.PointOfSale.Updates;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.SqlDAO;
namespace Tanshu.Accounts.PointOfSale
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void advancesToolStripMenuItem_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
using (RecieveAdvanceForm frm = new RecieveAdvanceForm())
frm.ShowDialog();
}
}
}
private void paymentsToolStripMenuItem_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
using (AdjustAdvanceForm frm = new AdjustAdvanceForm())
frm.ShowDialog();
}
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void createNewUserToolStripMenuItem_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SECURITY_MANAGE_ROLES))
{
if (roleBI.IsAllowed)
using (SelectUser form = new SelectUser(UserBI.GetFilteredUsers, true))
{
form.userEvent += new UserEventHandler(form_userEvent);
form.ShowDialog();
}
}
}
User form_userEvent(object sender, UserEventArgs e)
{
User user = e.User;
if (user == null)
{
using (UserForm form = new UserForm(null))
{
form.ShowDialog();
}
}
else
{
using (UserForm form = new UserForm(user.UserID))
{
form.ShowDialog();
}
}
e.Handled = true;
return new User();
}
private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
{
using (ChangePassword frm = new ChangePassword())
frm.ShowDialog();
}
private void assignRolesToolStripMenuItem_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SECURITY_MANAGE_ROLES))
{
if (roleBI.IsAllowed)
using (AssignRoles frm = new AssignRoles())
frm.ShowDialog();
}
}
private void salesAnalysisToolStripMenuItem1_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALE_DETAIL))
{
if (roleBI.IsAllowed)
using (frmSaleAnalysisForm frm = new frmSaleAnalysisForm())
frm.ShowDialog();
}
}
private void cashierCheckoutToolStripMenuItem1_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_CHECKOUT))
{
if (roleBI.IsAllowed)
using (Cashier_Checkout_Form frm = new Cashier_Checkout_Form())
frm.ShowDialog();
}
}
private void customersToolStripMenuItem_Click(object sender, EventArgs e)
{
//Guid c=new Guid("28BFB512-6B92-4AA1-A931-7993593B8E07");
using (CustomersForm Customer = new CustomersForm(null, ""))
{
Customer.ShowDialog();
}
}
private void productsToolStripMenuItem_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_PRODUCTS))
{
if (roleBI.IsAllowed)
using (ProductsForm frm = new ProductsForm())
frm.ShowDialog();
}
}
private void prToolStripMenuItem_Click(object sender, EventArgs e)
{
ProductTypes ProductType = new ProductTypes();
ProductType.ShowDialog();
ProductType.Dispose();
}
private void viewLogToolStripMenuItem_Click(object sender, EventArgs e)
{
//using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.LOG_VIEW))
//{
// if (roleBI.IsAllowed)
// using (LogViewerForm frm = new LogViewerForm())
// frm.ShowDialog();
//}
}
//private void updateToolStripMenuItem_Click(object sender, EventArgs e)
//{
// using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_OWNER))
// {
// if (roleBI.IsAllowed)
// using (UpdateForm frm = new UpdateForm())
// frm.ShowDialog();
// }
//}
//private void reportToolStripMenuItem_Click(object sender, EventArgs e)
//{
// using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_OWNER))
// {
// if (roleBI.IsAllowed)
// using (SaleTaxReportForm frm = new SaleTaxReportForm())
// frm.ShowDialog();
// }
//}
//private void updateBillsToolStripMenuItem_Click(object sender, EventArgs e)
//{
// using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_OWNER))
// {
// if (roleBI.IsAllowed)
// using (UpdateSales frm = new UpdateSales())
// frm.ShowDialog();
// }
//}
//private void autoToolStripMenuItem_Click(object sender, EventArgs e)
//{
// using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.MASTER_OWNER))
// {
// if (roleBI.IsAllowed)
// using (ReplaceForm frm = new ReplaceForm())
// frm.ShowDialog();
// }
//}
private void btnLogin_Click(object sender, EventArgs e)
{
ILogin login = new KeyboardLogin();
if (!Session.IsAuthenticated)
{
if (login.LoginUser())
{
this.Text = "Main Menu - User: " + Session.User.Name;
btnLogin.Text = "Logout";
}
}
else
{
login.LogoutUser();
this.Text = "Main Menu - Login";
btnLogin.Text = "Login";
}
}
private void btnSale_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(RolesConstants.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
using (SalesForm frmSale = new SalesForm(new BillController()))
frmSale.ShowDialog();
}
}
}
private void button1_Click(object sender, EventArgs e)
{
Fixtures.CreateSchema();
}
}
}