narsil/Tanshu.Accounts.PointOfSale/MainForm.cs

317 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)
{
2011-12-05 09:23:02 +00:00
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));
Print.Thermal.PrintCash(amounts);
//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();
// }
//}
2010-03-02 17:56:21 +00:00
}
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();
2011-12-05 09:23:02 +00:00
using (var frmSale = new SalesForm())
2010-03-02 17:56:21 +00:00
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)
{
2011-12-05 09:23:02 +00:00
using (var frm = new RecieveAdvanceForm())
{
frm.ShowDialog();
}
2010-03-02 17:56:21 +00:00
}
private void paymentsToolStripMenuItem_Click(object sender, EventArgs e)
{
2011-12-05 09:23:02 +00:00
using (var frm = new AdjustAdvanceForm(false))
{
frm.ShowDialog();
}
2010-03-02 17:56:21 +00:00
}
private void paymentsToolStripMenuItem1_Click(object sender, EventArgs e)
{
2011-12-05 09:23:02 +00:00
using (var frm = new LogViewerForm())
{
frm.ShowDialog();
}
2010-03-02 17:56:21 +00:00
}
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
{
2011-12-05 09:23:02 +00:00
using (var form = new SelectUser(new UserBI().GetFilteredUsers, true))
2010-03-02 17:56:21 +00:00
{
form.userEvent += new UserEventHandler(form_userEvent);
form.ShowDialog();
}
}
}
UserBO form_userEvent(object sender, UserEventArgs e)
{
2011-12-05 09:23:02 +00:00
var user = e.User;
2010-03-02 17:56:21 +00:00
2011-12-05 09:23:02 +00:00
using (var form = new UserForm(user == null ? (Guid?)null : user.UserID))
2010-03-02 17:56:21 +00:00
{
2011-12-05 09:23:02 +00:00
form.ShowDialog();
2010-03-02 17:56:21 +00:00
}
2011-12-05 09:23:02 +00:00
2010-03-02 17:56:21 +00:00
e.Handled = true;
return new UserBO();
}
private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
{
2011-12-05 09:23:02 +00:00
using (var frm = new ChangePassword())
{
frm.ShowDialog();
}
2010-03-02 17:56:21 +00:00
}
private void assignRolesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Security/ManageRoles"))
MessageBox.Show("You are not authorized to access");
else
{
2011-12-05 09:23:02 +00:00
using (var frm = new AssignRoles())
{
frm.ShowDialog();
}
2010-03-02 17:56:21 +00:00
}
}
private void paymentsToolStripMenuItem1_Click_1(object sender, EventArgs e)
{
2011-12-05 09:23:02 +00:00
using (var frm = new PaymentForm())
2010-03-02 17:56:21 +00:00
{
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
{
using (SelectProduct selectProduct = new SelectProduct(new ProductBI().GetFilteredProducts, false))
{
selectProduct.productEvent += new ProductEventHandler(selectProduct_productEvent);
selectProduct.ShowDialog();
}
}
}
ProductBO selectProduct_productEvent(object sender, ProductEventArgs e)
{
using (var form = new ProductsForm(e.ProductID))
{
2010-03-02 17:56:21 +00:00
form.ShowDialog();
return form.Product;
2010-03-02 17:56:21 +00:00
}
}
private void prToolStripMenuItem_Click(object sender, EventArgs e)
{
ProductGroups ProductGroup = new ProductGroups();
ProductGroup.ShowDialog();
ProductGroup.Dispose();
2010-03-02 17:56:21 +00:00
}
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 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();
}
}
}