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.
92 lines
3.5 KiB
92 lines
3.5 KiB
using BiskLog_Point_Of_Sale.Properties;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Security;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Point_Of_Sale_Managment
|
|
{
|
|
public partial class users : Form
|
|
{
|
|
DatabaseConn conn = new DatabaseConn();
|
|
SqlConnection cn = new SqlConnection();
|
|
SqlCommand cm = new SqlCommand();
|
|
SqlDataReader dr;
|
|
public users()
|
|
{
|
|
InitializeComponent();
|
|
cn = new SqlConnection(conn.MyConnection());
|
|
loading.Left = (ClientSize.Width - loading.Width) / 2;
|
|
}
|
|
private async void users_Load(object sender, EventArgs e)
|
|
{
|
|
Task<int> task = new Task<int>(LoadUsers);
|
|
loading.Visible = true;
|
|
task.Start();
|
|
await task;
|
|
loading.Visible = false;
|
|
}
|
|
|
|
private void Button1_Click(object sender, EventArgs e)
|
|
{
|
|
AddUser newUser = new AddUser(this);
|
|
newUser.BringToFront();
|
|
newUser.ShowDialog();
|
|
}
|
|
public int LoadUsers()
|
|
{
|
|
try
|
|
{
|
|
dataGridView1.Invoke(new Action(() => dataGridView1.Rows.Clear()));
|
|
int i = 1;
|
|
cn.Open();
|
|
cm = new SqlCommand("Select username,firstname,surname,access_level,last_login from tblUsers where branchID = @branchID", cn);
|
|
cm.Parameters.AddWithValue("@branchID", Settings.Default.BranchID);
|
|
dr = cm.ExecuteReader();
|
|
while (dr.Read())
|
|
{
|
|
string lastLogin;
|
|
if (String.IsNullOrEmpty(dr[4].ToString()))
|
|
{
|
|
lastLogin = "Not Logged in yet";
|
|
}
|
|
else
|
|
{
|
|
lastLogin = Convert.ToDateTime(dr[4].ToString()).ToString("dddd, dd MMMM yyyy HH:mm:ss");
|
|
}
|
|
switch (dr[3].ToString())
|
|
{
|
|
case "owner":
|
|
dataGridView1.Invoke(new Action(() => dataGridView1.Rows.Add(i, dr[0].ToString(), dr[1].ToString() + " " + dr[2].ToString(), "Owner",lastLogin)));
|
|
i++;
|
|
break;
|
|
case "manager":
|
|
dataGridView1.Invoke(new Action(() => dataGridView1.Rows.Add(i, dr[0].ToString(), dr[1].ToString() + " " + dr[2].ToString(), "Manager",lastLogin)));
|
|
i++;
|
|
break;
|
|
case "assist":
|
|
dataGridView1.Invoke(new Action(() => dataGridView1.Rows.Add(i, dr[0].ToString(), dr[1].ToString() + " " + dr[2].ToString(), "Assistant Manager", lastLogin)));
|
|
i++;
|
|
break;
|
|
case "cashier":
|
|
dataGridView1.Invoke(new Action(() => dataGridView1.Rows.Add(i, dr[0].ToString(), dr[1].ToString() + " " + dr[2].ToString(), "Cashier", lastLogin)));
|
|
i++;
|
|
break;
|
|
}
|
|
}
|
|
dr.Close();
|
|
cn.Close();
|
|
dataGridView1.Invoke(new Action(() => dataGridView1.ClearSelection()));
|
|
return 1;
|
|
}
|
|
catch
|
|
{
|
|
cn.Close();
|
|
return 2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|