narsil/Tanshu.Accounts.PointOfSale/MainForm.cs
2011-01-06 12:47:00 +05:30

237 lines
7.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using Tanshu.Accounts.BI;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Helpers;
using Tanshu.Accounts.PointOfSale.Updates;
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(Roles.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(Roles.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(Roles.SECURITY_MANAGE_ROLES))
{
if (roleBI.IsAllowed)
using (SelectUser form = new SelectUser(new UserBI().GetFilteredUsers, true))
{
form.userEvent += new UserEventHandler(form_userEvent);
form.ShowDialog();
}
}
}
UserBO form_userEvent(object sender, UserEventArgs e)
{
UserBO 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 UserBO();
}
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(Roles.SECURITY_MANAGE_ROLES))
{
if (roleBI.IsAllowed)
using (AssignRoles frm = new AssignRoles())
frm.ShowDialog();
}
}
private void paymentsToolStripMenuItem1_Click_1(object sender, EventArgs e)
{
using (PaymentForm frm = new PaymentForm())
{
frm.ShowDialog();
}
}
private void salesAnalysisToolStripMenuItem1_Click(object sender, EventArgs e)
{
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI(Roles.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(Roles.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(Roles.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(Roles.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(Roles.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(Roles.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(Roles.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(Roles.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(Roles.SALES_SALES_BILL))
{
if (roleBI.IsAllowed)
{
new ProductBI().UpdateShortName();
using (SalesForm frmSale = new SalesForm())
frmSale.ShowDialog();
}
}
}
}
}