You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
554 lines
20 KiB
554 lines
20 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Data.SqlClient;
|
|
using BiskLog_Point_Of_Sale.Properties;
|
|
using BiskLog_Point_Of_Sale;
|
|
using BiskLog_Point_Of_Sale.Multiple_Login;
|
|
using BiskLog_Point_Of_Sale.Classes;
|
|
using BiskLog_Point_Of_Sale.Company_Setup;
|
|
using BiskLog_Point_Of_Sale.Products_Module;
|
|
using BiskLog_Point_Of_Sale.Delivery;
|
|
using BiskLog_Point_Of_Sale.OPS_Report;
|
|
using BiskLog_Point_Of_Sale.Mains;
|
|
|
|
namespace Point_Of_Sale_Managment
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
|
|
SqlConnection cn = new SqlConnection();
|
|
SqlCommand cm = new SqlCommand();
|
|
SqlDataReader dr;
|
|
DatabaseConn databasecon = new DatabaseConn();
|
|
Form Active, Active2;
|
|
public static Form printerDialog;
|
|
public static string branch, currency, role;
|
|
public static string branchName, bCompanyName, branchLocation, tin, vatno, branchTel;
|
|
bool working = false;
|
|
SalesPOS sales;
|
|
int DetailedY;
|
|
int summaryY;
|
|
bool fighterjet = false;
|
|
public Form1(string user, string accessl)
|
|
{
|
|
InitializeComponent();
|
|
DoubleBuffered = true;
|
|
cn = new SqlConnection(databasecon.MyConnection());
|
|
currency = Settings.Default.currrencyCode;
|
|
role = accessl;
|
|
branch = Settings.Default.BranchID;
|
|
branchName = Settings.Default.BranchName;
|
|
bCompanyName = Settings.Default.CompanyName;
|
|
branchLocation = Settings.Default.BranchCity;
|
|
tin = Settings.Default.tinNumber;
|
|
vatno = Settings.Default.vatNumber;
|
|
branchTel = Settings.Default.BranchTelephone;
|
|
biski.Left = (main.Width - biski.Width) / 2;
|
|
biski.Top = (main.Height - biski.Height) / 2;
|
|
this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;
|
|
this.WindowState = FormWindowState.Maximized;
|
|
DetailedY = subDetailed.Location.Y;
|
|
summaryY = subSummary.Location.Y;
|
|
mainScroller.Visible = true;
|
|
summaryScroller.Visible = true;
|
|
//if (subDetailed.Height < Screen.FromHandle(this.Handle).WorkingArea.Height)
|
|
//{
|
|
// mainScroller.Visible = false;
|
|
//}
|
|
//else
|
|
//{
|
|
// mainScroller.Visible = true;
|
|
//}
|
|
//if (subSummary.Height < ClientSize.Height)
|
|
//{
|
|
// summaryScroller.Visible = false;
|
|
//}
|
|
//else
|
|
//{
|
|
// summaryScroller.Visible = true;
|
|
//}
|
|
|
|
}
|
|
private void Button6_Click(object sender, EventArgs e)
|
|
{
|
|
InvoiceMain invoiceMain = new InvoiceMain(this);
|
|
invoiceMain.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
main.Controls.Add(invoiceMain);
|
|
Active = invoiceMain;
|
|
invoiceMain.BringToFront();
|
|
invoiceMain.Show();
|
|
}
|
|
private void Button7_Click(object sender, EventArgs e)
|
|
{
|
|
SystemSettings system = new SystemSettings();
|
|
Active2 = system;
|
|
system.BringToFront();
|
|
system.ShowDialog(main);
|
|
Active2 = null;
|
|
}
|
|
private void Button8_Click(object sender, EventArgs e)
|
|
{
|
|
UserSettingsAdminView system = new UserSettingsAdminView();
|
|
system.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
main.Controls.Add(system);
|
|
Active = system;
|
|
system.BringToFront();
|
|
system.Show();
|
|
}
|
|
private void Button18_Click(object sender, EventArgs e)
|
|
{
|
|
if (Active != null)
|
|
{
|
|
Detailed.Visible = false;
|
|
Summary.Visible = true;
|
|
Active.WindowState = FormWindowState.Normal;
|
|
Active.WindowState = FormWindowState.Maximized;
|
|
}
|
|
else
|
|
{
|
|
Detailed.Visible = false;
|
|
Summary.Visible = true;
|
|
}
|
|
Settings.Default.Opensesemi = false;
|
|
Settings.Default.Save();
|
|
}
|
|
private void Button17_Click(object sender, EventArgs e)
|
|
{
|
|
if (Active != null)
|
|
{
|
|
Summary.Visible = false;
|
|
Detailed.Visible = true;
|
|
Active.WindowState = FormWindowState.Normal;
|
|
Active.WindowState = FormWindowState.Maximized;
|
|
}
|
|
else
|
|
{
|
|
Summary.Visible = false;
|
|
Detailed.Visible = true;
|
|
}
|
|
Settings.Default.Opensesemi = true;
|
|
Settings.Default.Save();
|
|
}
|
|
private void Button9_Click(object sender, EventArgs e)
|
|
{
|
|
Confirmation confirmDialog = new Confirmation("Exit", "Are you sure you want to leave ?");
|
|
confirmDialog.BringToFront();
|
|
confirmDialog.ShowDialog();
|
|
if (confirmDialog.DialogResult == DialogResult.Yes)
|
|
{
|
|
updaterDuration.Stop();
|
|
this.Close();
|
|
}
|
|
}
|
|
private void Label2_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
label2.BackColor = Color.Crimson;
|
|
}
|
|
private void Label2_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
label2.BackColor = Color.FromArgb(2, 0, 46);
|
|
}
|
|
private void Label3_Click(object sender, EventArgs e)
|
|
{
|
|
this.WindowState = FormWindowState.Minimized;
|
|
}
|
|
private void Label3_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
label3.BackColor = Color.FromArgb(46, 124, 206);
|
|
}
|
|
private void MainScroller_Scroll(object sender, ScrollEventArgs e)
|
|
{
|
|
int v = mainScroller.Value;
|
|
int hiddenPanelHeight = this.subDetailed.Size.Height - this.ClientSize.Height;
|
|
float moveY = (float)hiddenPanelHeight * ((float)v / 100);
|
|
int newY = DetailedY + (int)moveY;
|
|
subDetailed.Location = new Point(subDetailed.Location.X, newY);
|
|
}
|
|
private void MetroScrollBar2_Scroll(object sender, ScrollEventArgs e)
|
|
{
|
|
int v = summaryScroller.Value;
|
|
int hiddenPanelHeight = this.subSummary.Size.Height - this.ClientSize.Height;
|
|
float moveY = (float)hiddenPanelHeight * ((float)v / 100);
|
|
int newY = summaryY + (int)moveY;
|
|
this.subSummary.Location = new Point(this.subSummary.Location.X, newY);
|
|
}
|
|
private void Button19_Click(object sender, EventArgs e)
|
|
{
|
|
Customers system = new Customers(this);
|
|
system.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
main.Controls.Add(system);
|
|
Active = system;
|
|
system.BringToFront();
|
|
system.Show();
|
|
}
|
|
private void Button12_Click(object sender, EventArgs e)
|
|
{
|
|
DeliveryMain system = new DeliveryMain();
|
|
system.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
main.Controls.Add(system);
|
|
Active = system;
|
|
system.BringToFront();
|
|
system.Show();
|
|
}
|
|
private void Reports_Click(object sender, EventArgs e)
|
|
{
|
|
ReportsMain system = new ReportsMain();
|
|
system.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
main.Controls.Add(system);
|
|
Active = system;
|
|
system.BringToFront();
|
|
system.Show();
|
|
}
|
|
private void UpdaterService_DoWork(object sender, DoWorkEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
working = true;
|
|
cn.Open();
|
|
cm = new SqlCommand("Declare @retu varchar(50) " +
|
|
"set @retu = case when(Select username from tblUser_activity where username = @username and workstation = @workstation) IS NOT NULL then " +
|
|
"(Select username from tblUser_activity where username = @username and workstation = @workstation) else 'NULL' end " +
|
|
"Update tblUser_activity set last_active = current_timestamp where username = @username and workstation = @workstation and username = @retu " +
|
|
"Select @@ROWCOUNT as updated", cn);
|
|
cm.Parameters.AddWithValue("@username", MainLogin.login_user);
|
|
cm.Parameters.AddWithValue("@workstation", Splashscreen.macAddress);
|
|
cm.ExecuteNonQuery();
|
|
dr = cm.ExecuteReader();
|
|
dr.Read();
|
|
if (dr.HasRows)
|
|
{
|
|
if (dr[0].ToString() == "0")
|
|
{
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
this.Hide();
|
|
loggingout loggingout = new loggingout();
|
|
loggingout.BringToFront();
|
|
loggingout.ShowDialog();
|
|
this.Dispose();
|
|
}));
|
|
}
|
|
dr.Close();
|
|
cn.Close();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
cn.Close();
|
|
}
|
|
working = false;
|
|
}
|
|
private void UpdaterDuration_Tick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!working)
|
|
{
|
|
updaterService.RunWorkerAsync();
|
|
|
|
}
|
|
|
|
if ((lastIdle.GetLastInputTime() >= (Settings.Default.idleDuration * 60)) && Settings.Default.logoutOnIdle)
|
|
{
|
|
|
|
updaterDuration.Stop();
|
|
if (Active2 != null)
|
|
{
|
|
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
if (printerDialog != null)
|
|
{
|
|
printerDialog.Close();
|
|
}
|
|
idleLogout idleLogout = new idleLogout(this, Active2);
|
|
idleLogout.BringToFront();
|
|
idleLogout.ShowDialog();
|
|
if (idleLogout.DialogResult == DialogResult.OK)
|
|
{
|
|
if (idleLogout.thumbsUp)
|
|
{
|
|
updaterDuration.Start();
|
|
}
|
|
else if (idleLogout.thumbsDown)
|
|
{
|
|
updaterDuration.Start();
|
|
if (Active2.Name == "SalesPOS")
|
|
{
|
|
sales.newTransaction();
|
|
}
|
|
else
|
|
{
|
|
Active2.Dispose();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Active2.Dispose();
|
|
this.Dispose();
|
|
}
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
if (printerDialog != null)
|
|
{
|
|
printerDialog.Close();
|
|
}
|
|
idleLogout idleLogout = new idleLogout(this);
|
|
idleLogout.BringToFront();
|
|
idleLogout.ShowDialog();
|
|
if (idleLogout.DialogResult == DialogResult.OK)
|
|
{
|
|
if (idleLogout.thumbsUp)
|
|
{
|
|
updaterDuration.Start();
|
|
}
|
|
else if (idleLogout.thumbsDown)
|
|
{
|
|
updaterDuration.Start();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.Dispose();
|
|
}
|
|
}));
|
|
}
|
|
printerDialog = null;
|
|
}
|
|
}
|
|
catch (Exception ex) { ErrorLogging.WriteToFile(ex.ToString()); }
|
|
}
|
|
private void Biski_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
fighterjet = true;
|
|
enlarger.Start();
|
|
}
|
|
private void Biski_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
fighterjet = false;
|
|
}
|
|
private void Enlarger_Tick(object sender, EventArgs e)
|
|
{
|
|
if (fighterjet)
|
|
{
|
|
if (biski.Width <= 559 && biski.Height <= 482)
|
|
{
|
|
biski.Size = new Size(biski.Width + 10, biski.Height + 10);
|
|
biski.Left = (main.Width - biski.Width) / 2;
|
|
biski.Top = (main.Height - biski.Height) / 2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
biski.Size = new Size(311, 288);
|
|
biski.Left = (main.Width - biski.Width) / 2;
|
|
biski.Top = (main.Height - biski.Height) / 2;
|
|
enlarger.Stop();
|
|
}
|
|
}
|
|
private void Help_Click(object sender, EventArgs e)
|
|
{
|
|
AboutBISKI about = new AboutBISKI();
|
|
about.BringToFront();
|
|
about.ShowDialog();
|
|
}
|
|
private void Help_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
help.BackColor = Color.FromArgb(20, 157, 137);
|
|
}
|
|
private void Help_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
help.BackColor = Color.FromArgb(2, 0, 46);
|
|
}
|
|
|
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void Form1_FormClosing(object sender, FormClosedEventArgs e)
|
|
{
|
|
updaterService.Dispose();
|
|
}
|
|
|
|
private void Label3_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
label3.BackColor = Color.FromArgb(2, 0, 46);
|
|
}
|
|
private void Form1_Load(object sender = null, EventArgs e = null)
|
|
{
|
|
systemConfigured.checkedConfigure();
|
|
MainLogin.logged = false;
|
|
//lblName.Text = MainLogin.login_user;
|
|
//lblAdmin.Text = role.ToUpper();
|
|
if (Settings.Default.Opensesemi)
|
|
{
|
|
if (Active != null)
|
|
{
|
|
Summary.Visible = false;
|
|
Detailed.Visible = true;
|
|
Active.WindowState = FormWindowState.Normal;
|
|
Active.WindowState = FormWindowState.Maximized;
|
|
}
|
|
else
|
|
{
|
|
Summary.Visible = false;
|
|
Detailed.Visible = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Active != null)
|
|
{
|
|
Detailed.Visible = false;
|
|
Summary.Visible = true;
|
|
Active.WindowState = FormWindowState.Normal;
|
|
Active.WindowState = FormWindowState.Maximized;
|
|
}
|
|
else
|
|
{
|
|
Detailed.Visible = false;
|
|
Summary.Visible = true;
|
|
}
|
|
}
|
|
updaterService.RunWorkerAsync();
|
|
updaterDuration.Start();
|
|
|
|
if (!Settings.Default.systemSettingsConfigured)
|
|
{
|
|
SystemSettings system = new SystemSettings();
|
|
Active2 = system;
|
|
system.BringToFront();
|
|
system.ShowDialog(main);
|
|
|
|
}
|
|
}
|
|
private void btnMBrand_Click(object sender, EventArgs e)
|
|
{
|
|
formBrandList fm = new formBrandList();
|
|
fm.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
Active = fm;
|
|
main.Controls.Add(fm);
|
|
fm.BringToFront();
|
|
fm.Show();
|
|
}
|
|
private void btnMCat_Click(object sender, EventArgs e)
|
|
{
|
|
formCategoryList formCat = new formCategoryList();
|
|
formCat.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
Active = formCat;
|
|
main.Controls.Add(formCat);
|
|
formCat.BringToFront();
|
|
formCat.Show();
|
|
}
|
|
private void btnProduct_Click(object sender, EventArgs e)
|
|
{
|
|
ProductsMainHolder products = new ProductsMainHolder();
|
|
products.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
Active = products;
|
|
main.Controls.Add(products);
|
|
products.BringToFront();
|
|
//products.LoadRecords();
|
|
products.Show();
|
|
|
|
}
|
|
public void MoveTOPOS(CustomerClass customer = null)
|
|
{
|
|
try
|
|
{
|
|
if (!String.IsNullOrEmpty(Settings.Default.ReceiptPrinter))
|
|
{
|
|
SalesPOS pos = new SalesPOS(this, customer: customer);
|
|
Active2 = pos;
|
|
sales = pos;
|
|
this.Hide();
|
|
pos.BringToFront();
|
|
pos.ShowDialog();
|
|
this.Show();
|
|
Active2 = null;
|
|
}
|
|
else
|
|
{
|
|
string title = "Receipt Printer not set";
|
|
string message = "No default receipt printer has been set, click yes to set default receipt printer";
|
|
Confirmation confirmation = new Confirmation(title, message);
|
|
confirmation.BringToFront();
|
|
confirmation.ShowDialog();
|
|
if (confirmation.DialogResult == DialogResult.Yes)
|
|
{
|
|
HardwareSetupWizardDirect hardwareSetup = new HardwareSetupWizardDirect();
|
|
Active2 = hardwareSetup;
|
|
hardwareSetup.BringToFront();
|
|
hardwareSetup.ShowDialog();
|
|
Active2 = null;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorLogging.WriteToFile(ex.ToString());
|
|
}
|
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
MoveTOPOS();
|
|
}
|
|
private void Button1_Click(object sender, EventArgs e)
|
|
{
|
|
Dashboard dashboard = new Dashboard();
|
|
dashboard.TopLevel = false;
|
|
if (Active != null)
|
|
{
|
|
main.Controls.Remove(Active);
|
|
}
|
|
main.Controls.Add(dashboard);
|
|
Active = dashboard;
|
|
dashboard.BringToFront();
|
|
dashboard.Show();
|
|
}
|
|
}
|
|
}
|
|
|