2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
2011-06-29 20:27:07 +00:00
|
|
|
|
using Tanshu.Accounts.Entities;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Entities.Auth;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
using Tanshu.Accounts.Helpers;
|
2011-12-05 09:41:02 +00:00
|
|
|
|
using Tanshu.Accounts.Management;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using Tanshu.Accounts.PointOfSale.Sales;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
using Tanshu.Accounts.Repository;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using Tanshu.Common;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
using Tanshu.Common.KeyboardControl;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public enum LoginType
|
|
|
|
|
{
|
|
|
|
|
Keyboard,
|
|
|
|
|
Msr
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
public partial class MainForm : Form
|
|
|
|
|
{
|
|
|
|
|
public MainForm()
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
//using (var frm = new SplashForm())
|
|
|
|
|
// frm.ShowDialog();
|
|
|
|
|
|
|
|
|
|
SessionManager.Initialize();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
private User form_userEvent(object sender, UserEventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-04-11 12:55:45 +00:00
|
|
|
|
var user = e.User;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
|
|
|
|
|
if (user == null)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using (var form = new UserForm(null))
|
2011-01-31 20:33:22 +00:00
|
|
|
|
form.ShowDialog();
|
|
|
|
|
else
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using (var form = new UserForm(user.UserID))
|
2011-01-31 20:33:22 +00:00
|
|
|
|
form.ShowDialog();
|
2011-04-11 12:55:45 +00:00
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
e.Handled = true;
|
|
|
|
|
return new User();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnLogin_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
LoginUser(LoginType.Keyboard);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnSale_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.SALES))
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using (var frmSale = new SalesForm(new BillController(null, true)))
|
2011-02-09 12:03:22 +00:00
|
|
|
|
frmSale.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnProduct_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.PRODUCTS))
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using (var frm = new ProductListForm())
|
2011-02-09 12:03:22 +00:00
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnProductGroup_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.PRODUCTS))
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using (var frm = new ProductGroupListForm())
|
2011-02-09 12:03:22 +00:00
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnCustomer_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-04-11 12:55:45 +00:00
|
|
|
|
using (var frm = new CustomersForm(null, ""))
|
|
|
|
|
frm.ShowDialog();
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnAdvanceReceive_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.SALES))
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using (var frm = new frmRecieveAdvance())
|
2011-02-09 12:03:22 +00:00
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnAdvanceAdjust_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.SALES))
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using (var frm = new frmAdjustAdvance())
|
2011-02-09 12:03:22 +00:00
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
Close();
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCreateUser_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES))
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using (var bi = new UserBI())
|
2011-02-09 12:03:22 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using (var form = new SelectUser(bi.GetFilteredUsers, true))
|
|
|
|
|
{
|
2011-12-05 09:41:02 +00:00
|
|
|
|
form.UserEvent += form_userEvent;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
2011-02-09 12:03:22 +00:00
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-09 12:03:22 +00:00
|
|
|
|
private void btnUserRoles_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES))
|
|
|
|
|
using (var frm = new AssignUserGroups())
|
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnChangePassword_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using (var frm = new ChangePassword(new KeyboardControl()))
|
2011-01-31 20:33:22 +00:00
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnCashierCheckout_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.CASHIER_CHECKOUT))
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using (var frm = new CashierCheckoutForm())
|
2011-02-09 12:03:22 +00:00
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void btnSaleAnalysis_Click(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.SALE_ANALYSIS))
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using (var frm = new frmSaleAnalysisForm())
|
2011-02-09 12:03:22 +00:00
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
2011-01-31 20:33:22 +00:00
|
|
|
|
|
2011-02-09 12:03:22 +00:00
|
|
|
|
private void btnSaleDetail_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.SALE_DETAIL))
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using (var frm = new FrmSaleDetail())
|
2011-02-09 12:03:22 +00:00
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void MainForm_Load(object sender, EventArgs e)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2012-04-08 12:28:15 +00:00
|
|
|
|
#if (DEBUG)
|
|
|
|
|
MessageBox.Show("This software does not print kots!!!","Debug Mode", MessageBoxButtons.OK , MessageBoxIcon.Exclamation);
|
|
|
|
|
#endif
|
2011-01-31 20:33:22 +00:00
|
|
|
|
CheckRoles();
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-01-31 20:33:22 +00:00
|
|
|
|
private void CheckRoles()
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
btnSale.Visible = Session.IsAllowed(RoleConstants.SALES);
|
|
|
|
|
|
|
|
|
|
btnProduct.Visible = Session.IsAllowed(RoleConstants.PRODUCTS);
|
|
|
|
|
btnProductGroup.Visible = Session.IsAllowed(RoleConstants.PRODUCTS);
|
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
btnOpenBill.Visible = Session.IsAllowed(RoleConstants.OPEN_BILL);
|
|
|
|
|
|
2011-02-09 12:03:22 +00:00
|
|
|
|
btnCustomer.Visible = Session.IsAllowed(RoleConstants.CUSTOMERS);
|
|
|
|
|
|
|
|
|
|
btnAdvanceReceive.Visible = Session.IsAllowed(RoleConstants.RECEIVE_ADVANCE);
|
|
|
|
|
|
|
|
|
|
btnAdvanceAdjust.Visible = Session.IsAllowed(RoleConstants.ADJUST_ADVANCE);
|
|
|
|
|
|
|
|
|
|
btnCreateUser.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_USERS);
|
|
|
|
|
btnUserRoles.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_USERS);
|
|
|
|
|
|
|
|
|
|
btnGroupRoles.Visible = Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES);
|
|
|
|
|
|
2011-02-18 16:54:48 +00:00
|
|
|
|
btnCashierCheckout.Visible = Session.IsAllowed(RoleConstants.CASHIER_CHECKOUT);
|
2011-02-09 12:03:22 +00:00
|
|
|
|
btnSaleAnalysis.Visible = Session.IsAllowed(RoleConstants.SALE_ANALYSIS);
|
|
|
|
|
btnSaleDetail.Visible = Session.IsAllowed(RoleConstants.SALE_DETAIL);
|
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
btnBillDetails.Visible = Session.IsAllowed(RoleConstants.BILL_DETAILS);
|
2011-08-28 12:17:15 +00:00
|
|
|
|
btnVoidOrReprints.Visible = Session.IsAllowed(RoleConstants.VOID_OR_REPRINTED_BILL_REPORT);
|
2011-12-05 09:41:02 +00:00
|
|
|
|
btnDiscountReport.Visible = Session.IsAllowed(RoleConstants.VOID_OR_REPRINTED_BILL_REPORT);
|
2011-06-23 12:47:48 +00:00
|
|
|
|
|
2011-02-09 12:03:22 +00:00
|
|
|
|
btnChangePassword.Visible = Session.IsAuthenticated;
|
2011-12-05 09:41:02 +00:00
|
|
|
|
btnManagement.Visible = false;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnGroupRoles_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES))
|
|
|
|
|
using (var frm = new AssignGroupRoles())
|
|
|
|
|
frm.ShowDialog();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-02-09 12:03:22 +00:00
|
|
|
|
|
2011-02-18 16:54:48 +00:00
|
|
|
|
private void btnSwipeLogin_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
LoginUser(LoginType.Msr);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
private void LoginUser(LoginType loginType)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
|
|
|
|
ILogin login;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
switch (loginType)
|
|
|
|
|
{
|
|
|
|
|
case LoginType.Keyboard:
|
|
|
|
|
login = new KeyboardLogin();
|
|
|
|
|
break;
|
|
|
|
|
case LoginType.Msr:
|
|
|
|
|
login = new MsrLogin();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
|
|
|
|
if (!Session.IsAuthenticated)
|
|
|
|
|
{
|
|
|
|
|
if (login.LoginUser())
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
Text = "Main Menu - User: " + Session.User.Name;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
btnLogin.Text = "Logout";
|
|
|
|
|
btnSwipeLogin.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
login.LogoutUser();
|
2011-03-11 18:49:48 +00:00
|
|
|
|
Text = "Main Menu - Login";
|
2011-02-18 16:54:48 +00:00
|
|
|
|
btnLogin.Text = "Login";
|
|
|
|
|
btnSwipeLogin.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
CheckRoles();
|
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
|
|
|
|
|
private void btnOpenBill_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!Session.IsAllowed(RoleConstants.OPEN_BILL))
|
|
|
|
|
return;
|
|
|
|
|
var result = InputBox.Show("Bill Number", "0", InputBox_Validating);
|
|
|
|
|
if (!result.OK)
|
|
|
|
|
return;
|
2011-06-29 20:27:07 +00:00
|
|
|
|
Voucher voucher;
|
|
|
|
|
using (var bi = new VoucherBI(false))
|
2011-12-05 09:41:02 +00:00
|
|
|
|
voucher = bi.Get(x => x.BillID == result.Text);
|
2011-06-23 12:47:48 +00:00
|
|
|
|
if (Session.IsAllowed(RoleConstants.SALES))
|
|
|
|
|
using (var frmSale = new SalesForm(new BillController(voucher.VoucherID, true)))
|
|
|
|
|
frmSale.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void InputBox_Validating(object sender, InputBoxValidatingArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Regex.IsMatch(e.Text, @"^\d+-\d\d\d\d")) return;
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
e.Message = "Bill No should be in format ##-####";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnBillDetails_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Session.IsAllowed(RoleConstants.BILL_DETAILS))
|
|
|
|
|
using (var frm = new BillDetailsForm())
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-28 12:17:15 +00:00
|
|
|
|
private void btnVoidOrReprints_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Session.IsAllowed(RoleConstants.VOID_OR_REPRINTED_BILL_REPORT))
|
2011-12-05 09:41:02 +00:00
|
|
|
|
using (var frm = new VoidReprintedForm())
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnManagement_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (var frm = new QuantityForm())
|
2011-08-28 12:17:15 +00:00
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-05 09:41:02 +00:00
|
|
|
|
private void btnDiscountReport_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (var frm = new DiscountReportForm())
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|