narsil/Tanshu.Accounts.PointOfSale/MainForm.cs
unknown 0172fc4e01 Added Service Tax and CIN Information to the bill printout
Added Nc Option in settlement
Merged Vouchers and SaleVoucher table. Need to update the Sql Schema
2014-08-08 17:35:38 +05:30

323 lines
11 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 btnPrint_Click(object sender, EventArgs e)
{
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();
// }
//}
}
private void saleToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Sales/SalesBill"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.ProductDAO(connection))
{
dao.UpdateShortName();
}
}
using (var 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)
{
using (var frm = new RecieveAdvanceForm())
{
frm.ShowDialog();
}
}
private void paymentsToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var frm = new AdjustAdvanceForm(false))
{
frm.ShowDialog();
}
}
private void paymentsToolStripMenuItem1_Click(object sender, EventArgs e)
{
using (var frm = new LogViewerForm())
{
frm.ShowDialog();
}
}
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 (var form = new SelectUser(new UserBI().GetFilteredUsers, true))
{
form.userEvent += new UserEventHandler(form_userEvent);
form.ShowDialog();
}
}
}
UserBO form_userEvent(object sender, UserEventArgs e)
{
var user = e.User;
using (var form = new UserForm(user == null ? (Guid?)null : user.UserID))
{
form.ShowDialog();
}
e.Handled = true;
return new UserBO();
}
private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var frm = new ChangePassword())
{
frm.ShowDialog();
}
}
private void assignRolesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Security/ManageRoles"))
MessageBox.Show("You are not authorized to access");
else
{
using (var frm = new AssignRoles())
{
frm.ShowDialog();
}
}
}
private void paymentsToolStripMenuItem1_Click_1(object sender, EventArgs e)
{
using (var 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
{
using (SelectProduct selectProduct = new SelectProduct(new FiltersBI().GetFilteredProducts, false))
{
selectProduct.productEvent += new ProductEventHandler(selectProduct_productEvent);
selectProduct.ShowDialog();
}
}
}
ProductBO selectProduct_productEvent(object sender, ProductEventArgs e)
{
using (var form = new ProductsForm(e.ProductID))
{
form.ShowDialog();
return form.Product;
}
}
private void prToolStripMenuItem_Click(object sender, EventArgs e)
{
ProductGroups ProductGroup = new ProductGroups();
ProductGroup.ShowDialog();
ProductGroup.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 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();
}
}
}