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.

121 lines
3.6 KiB

using BiskLog_Point_Of_Sale.Company_Setup;
using Point_Of_Sale_Managment;
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;
namespace BiskLog_Point_Of_Sale.Multiple_Login
{
public partial class idleLogout : Form
{
Form active = null;
Form1 mainform = null;
public bool thumbsUp = false;
public bool thumbsDown = true;
SqlConnection cn;
SqlCommand cm;
DatabaseConn conn = new DatabaseConn();
public idleLogout(Form1 mainForm = null, Form fl = null)
{
InitializeComponent();
cn = new SqlConnection(conn.MyConnection());
if (fl != null)
{
active = fl;
}
if (mainForm != null)
{
mainform = mainForm;
}
panel1.Left = (ClientSize.Width - panel1.Width) / 2;
}
private void Cllose_Click(object sender, EventArgs e)
{
if (mainform != null)
{
mainform.Dispose();
}
if (active != null)
{
active.Dispose();
}
this.Dispose();
}
private void Cllose_MouseEnter(object sender, EventArgs e)
{
cllose.BackColor = Color.Crimson;
}
private void Cllose_MouseLeave(object sender, EventArgs e)
{
cllose.BackColor = Color.FromArgb(20, 158, 132);
}
private void IdleLogout_Load(object sender, EventArgs e)
{
}
private async void Button1_Click(object sender, EventArgs e)
{
ResumeSession resume = new ResumeSession();
resume.BringToFront();
resume.ShowDialog();
if (resume.DialogResult == DialogResult.OK)
{
if (resume.DifferentUser)
{
if (mainform != null)
{
mainform.Dispose();
}
if (active != null)
{
active.Dispose();
}
this.Dispose();
}
else if (resume.SuccessfulLogin)
{
thumbsUp = true;
this.DialogResult = DialogResult.OK;
this.Close();
}
else if (resume.ElseWhere)
{
Task<int> task = new Task<int>(() =>
{
try
{
cn.Open();
cm = new SqlCommand("Update tblUser_activity set workstation = @workstation where username = @username", cn);
cm.Parameters.AddWithValue("@username", MainLogin.login_user);
cm.Parameters.AddWithValue("@workstation", Splashscreen.macAddress);
cm.ExecuteNonQuery();
cn.Close();
}
catch
{
cn.Close();
}
return 1;
});
task.Start();
await task;
thumbsDown = true;
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}
}
}