Biskilog POS desktop appilcation
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.

277 lines
10 KiB

using BiskLog_Point_Of_Sale.Properties;
using Point_Of_Sale_Managment;
using Point_Of_Sale_Managment.CashierModule;
using BiskLog_Point_Of_Sale.Multiple_Login;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BiskLog_Point_Of_Sale.Classes;
using BiskLog_Point_Of_Sale.Updates;
using BiskLog_Point_Of_Sale.Company_Setup;
using BiskLog_Point_Of_Sale.Mains;
using Point_Of_Sale_Managment.Cashier_Module.Invoice;
namespace BiskLog_Point_Of_Sale.Cashier_Module
{
public partial class CashierMain : Form
{
SqlConnection cn = new SqlConnection();
SqlCommand cm = new SqlCommand();
SqlDataReader dr;
DatabaseConn databasecon = new DatabaseConn();
Form Active;
public static Form printerDialog;
public static string branch, currency, role;
public static string branchName, bCompanyName, branchLocation, tin, vatno, branchTel;
bool working = false;
public static string user;
public CashierMain(string userl, string accessl)
{
InitializeComponent();
this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;
this.WindowState = FormWindowState.Maximized;
menuStrip1.ForeColor = Color.FromArgb(0, 52, 69);
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;
user = userl;
}
private void Update_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 Duration_Tick(object sender, EventArgs e)
{
if (!working)
{
update.RunWorkerAsync();
}
}
public void POS(List<InvoicePOS> invoice = null, string id = null, CustomerClass customer = null)
{
try
{
if (!String.IsNullOrEmpty(Settings.Default.ReceiptPrinter))
{
NewSalesPOS pos = new NewSalesPOS(this, invoicecode: invoice, invoiceid: id, customer: customer);
pos.TopLevel = false;
if (Active != null)
{
main.Controls.Remove(Active);
}
Active = pos;
main.Controls.Add(pos);
pos.BringToFront();
pos.Show();
}
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();
Active = hardwareSetup;
hardwareSetup.BringToFront();
hardwareSetup.ShowDialog();
Active = null;
}
}
}
catch (Exception ex)
{
ErrorLogging.WriteToFile(ex.ToString());
}
}
private void ProductsToolStripMenuItem_Click(object sender, EventArgs e)
{
Point_Of_Sale_Managment.CashierModule.ProductListForm products = new Point_Of_Sale_Managment.CashierModule.ProductListForm();
products.TopLevel = false;
if (Active != null)
{
main.Controls.Remove(Active);
}
Active = products;
main.Controls.Add(products);
products.BringToFront();
products.LoadRecords();
products.Show();
}
private void SETTINGSToolStripMenuItem_Click(object sender, EventArgs e)
{
Point_Of_Sale_Managment.CashierModule.SystemSettings settings = new Point_Of_Sale_Managment.CashierModule.SystemSettings();
settings.BringToFront();
settings.ShowDialog();
}
private void INVOICEMANGEMENTToolStripMenuItem_Click(object sender, EventArgs e)
{
CashierInvoiceMain products = new CashierInvoiceMain(this);
products.TopLevel = false;
if (Active != null)
{
main.Controls.Remove(Active);
}
Active = products;
main.Controls.Add(products);
products.BringToFront();
products.Show();
}
private void CToolStripMenuItem_Click(object sender, EventArgs e)
{
Customers pos = new Customers(cashier: this);
pos.TopLevel = false;
if (Active != null)
{
main.Controls.Remove(Active);
}
Active = pos;
main.Controls.Add(pos);
pos.BringToFront();
pos.Show();
}
private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void ToolStripMenuItem2_Click(object sender, EventArgs e)
{
AdminUser adminUser = new AdminUser();
adminUser.BringToFront();
adminUser.ShowDialog();
}
private void CategoriesToolStripMenuItem_Click(object sender, EventArgs e)
{
Point_Of_Sale_Managment.CashierModule.formCategoryList products = new Point_Of_Sale_Managment.CashierModule.formCategoryList();
products.TopLevel = false;
if (Active != null)
{
main.Controls.Remove(Active);
}
Active = products;
main.Controls.Add(products);
products.BringToFront();
products.LoadRecords();
products.Show();
}
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
{
CheckUpdates check = new CheckUpdates();
check.BringToFront();
check.ShowDialog();
}
private void BrandsOfProductsToolStripMenuItem_Click(object sender, EventArgs e)
{
Point_Of_Sale_Managment.CashierModule.formBrandList products = new Point_Of_Sale_Managment.CashierModule.formBrandList();
products.TopLevel = false;
if (Active != null)
{
main.Controls.Remove(Active);
}
Active = products;
main.Controls.Add(products);
products.BringToFront();
products.LoadRecords();
products.Show();
}
private void AboutBISKILOGPOSToolStripMenuItem_Click(object sender, EventArgs e)
{
AboutBISKI about = new AboutBISKI();
about.BringToFront();
about.ShowDialog();
}
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(10, 10, 56);
}
private void Label3_MouseLeave(object sender, EventArgs e)
{
label3.BackColor = Color.FromArgb(2, 0, 46);
}
private void Label2_Click(object sender, EventArgs e)
{
this.Close();
}
private void POINTOFSALEToolStripMenuItem_Click(object sender, EventArgs e)
{
POS();
}
}
}