narsil/Tanshu.Accounts.PointOfSale/MainForm.cs

326 lines
11 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
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 btnPrint_Click(object sender, EventArgs e)
{
MessageBox.Show(CurrentUser.user.Name);
using (RoleBI roleBI = RoleFactoryBI.GetRoleBI("Sales/Checkout"))
{
if (roleBI.IsAllowed)
using (Cashier_Checkout_Form frmChashierCheckOut = new Cashier_Checkout_Form())
{
frmChashierCheckOut.ShowDialog();
}
}
//Dictionary<int, int> amounts = new Dictionary<int, int>();
//if (txt1000.Text != "") amounts.Add(1000, Convert.ToInt32(txt1000.Text));
//if (txt500.Text != "") amounts.Add(500, Convert.ToInt32(txt500.Text));
//if (txt100.Text != "") amounts.Add(100, Convert.ToInt32(txt100.Text));
//if (txt50.Text != "") amounts.Add(50, Convert.ToInt32(txt50.Text));
//if (txt20.Text != "") amounts.Add(20, Convert.ToInt32(txt20.Text));
//if (txt10.Text != "") amounts.Add(10, Convert.ToInt32(txt10.Text));
//if (txt5.Text != "") amounts.Add(5, Convert.ToInt32(txt5.Text));
//if (txt2.Text != "") amounts.Add(2, Convert.ToInt32(txt2.Text));
//if (txt1.Text != "") amounts.Add(1, Convert.ToInt32(txt1.Text));
//Accounts.Print.Thermal.PrintCash(amounts);
}
private void saleToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/SalesBill"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
new ProductBI().UpdateShortName();
using (SalesForm frmSale = new SalesForm())
frmSale.ShowDialog();
}
}
private void txt1000_TextChanged(object sender, EventArgs e)
{
try
{
int Amount = 0;
Amount += 1000 * Convert.ToInt16(txt1000.Text);
Amount += 500 * (txt500.Text == "" ? 0 : Convert.ToInt16(txt500.Text));
Amount += 100 * (txt100.Text == "" ? 0 : Convert.ToInt16(txt100.Text));
Amount += 50 * (txt50.Text == "" ? 0 : Convert.ToInt16(txt50.Text));
Amount += 20 * (txt20.Text == "" ? 0 : Convert.ToInt16(txt20.Text));
Amount += 10 * (txt10.Text == "" ? 0 : Convert.ToInt16(txt10.Text));
Amount += 5 * (txt5.Text == "" ? 0 : Convert.ToInt16(txt5.Text));
Amount += 2 * (txt2.Text == "" ? 0 : Convert.ToInt16(txt2.Text));
Amount += 1 * (txt1.Text == "" ? 0 : Convert.ToInt16(txt1.Text));
txtTotal.Text = Amount.ToString();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("Error Number " + ex.Source + "\n\r" + ex.Message);
}
}
private void advancesToolStripMenuItem_Click(object sender, EventArgs e)
{
RecieveAdvanceForm frmReceivedAdvance = new RecieveAdvanceForm();
frmReceivedAdvance.ShowDialog();
frmReceivedAdvance.Dispose();
}
private void paymentsToolStripMenuItem_Click(object sender, EventArgs e)
{
AdjustAdvanceForm frmAdjustAdvancesForm = new AdjustAdvanceForm();
frmAdjustAdvancesForm.ShowDialog();
frmAdjustAdvancesForm.Dispose();
}
private void paymentsToolStripMenuItem1_Click(object sender, EventArgs e)
{
LogViewerForm frmPayments = new LogViewerForm();
frmPayments.ShowDialog();
frmPayments.Dispose();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void createNewUserToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Security/ManageRoles"))
MessageBox.Show("You are not authorized to access");
else
{
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)
{
ChangePassword frm = new ChangePassword();
frm.ShowDialog();
frm.Dispose();
}
private void assignRolesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Security/ManageRoles"))
MessageBox.Show("You are not authorized to access");
else
{
AssignRoles frm = new AssignRoles();
frm.ShowDialog();
frm.Dispose();
}
}
private void paymentsToolStripMenuItem1_Click_1(object sender, EventArgs e)
{
using (PaymentForm frm = new PaymentForm())
{
frm.ShowDialog();
}
}
private void MainForm_Load(object sender, EventArgs e)
{
this.Text = "Main Menu - User: " + CurrentUser.user.Name;
}
private void salesAnalysisToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/SaleDetail"))
MessageBox.Show("You are not authorized to access");
else
{
frmSaleAnalysisForm frmSalesAnalysis = new frmSaleAnalysisForm();
frmSalesAnalysis.ShowDialog();
frmSalesAnalysis.Dispose();
}
}
private void cashierCheckoutToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/Checkout"))
MessageBox.Show("You are not authorized to access");
else
{
Cashier_Checkout_Form frmChashierCheckOut = new Cashier_Checkout_Form();
frmChashierCheckOut.ShowDialog();
frmChashierCheckOut.Dispose();
}
}
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)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
ProductsForm form = new ProductsForm();
form.ShowDialog();
form.Dispose();
}
}
private void prToolStripMenuItem_Click(object sender, EventArgs e)
{
ProductTypes ProductType = new ProductTypes();
ProductType.ShowDialog();
ProductType.Dispose();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
//ProductNewRates ProductRates = new ProductNewRates();
//ProductRates.ShowDialog();
//ProductRates.Dispose();
}
private void applyNewRatesToolStripMenuItem_Click(object sender, EventArgs e)
{
//ApplyRates ApplyRate = new ApplyRates();
//ApplyRate.ShowDialog();
//ApplyRate.Dispose();
}
private void masterToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void complexProductsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
//ComplexProductForm form = new ComplexProductForm();
//form.ShowDialog();
//form.Dispose();
}
}
private void viewLogToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Log/View"))
MessageBox.Show("You are not authorized to access");
else
using (LogViewerForm form = new LogViewerForm())
form.ShowDialog();
}
private void updateToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
using (UpdateForm form = new UpdateForm())
{
form.ShowDialog();
}
}
}
private void reportToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
using (SaleTaxReportForm form = new SaleTaxReportForm())
{
form.ShowDialog();
}
}
}
private void updateBillsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
using (UpdateSales form = new UpdateSales())
{
form.ShowDialog();
}
}
}
private void autoToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
MessageBox.Show("You are not authorized to access");
else
using (ReplaceForm form = new ReplaceForm())
form.ShowDialog();
}
}
}