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.
75 lines
2.2 KiB
75 lines
2.2 KiB
3 months ago
|
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 Point_Of_Sale_Managment
|
||
|
{
|
||
|
public partial class UserRoles : Form
|
||
|
{
|
||
|
DatabaseConn conn = new DatabaseConn();
|
||
|
SqlConnection cn = new SqlConnection();
|
||
|
SqlCommand cm = new SqlCommand();
|
||
|
SqlDataReader dr;
|
||
|
public UserRoles()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
cn = new SqlConnection(conn.MyConnection());
|
||
|
}
|
||
|
|
||
|
private void UserRoles_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
LoadRoles();
|
||
|
}
|
||
|
public int LoadRoles()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
int i = 0;
|
||
|
cn.Open();
|
||
|
cm = new SqlCommand("Select * from systemUserRoles order by roles asc", cn);
|
||
|
dr = cm.ExecuteReader();
|
||
|
while (dr.Read())
|
||
|
{
|
||
|
|
||
|
dataGridView1.Invoke(new Action(() =>
|
||
|
{
|
||
|
dataGridView1.Rows.Add(dr[0].ToString().ToUpper());
|
||
|
if (bool.Parse(dr[1].ToString()))
|
||
|
{
|
||
|
dataGridView1.Rows[i].Cells[1].Value = CheckState.Checked;
|
||
|
}
|
||
|
if (bool.Parse(dr[2].ToString()))
|
||
|
{
|
||
|
dataGridView1.Rows[i].Cells[2].Value = CheckState.Checked;
|
||
|
}
|
||
|
if (bool.Parse(dr[3].ToString()))
|
||
|
{
|
||
|
dataGridView1.Rows[i].Cells[3].Value = CheckState.Checked;
|
||
|
}
|
||
|
if (bool.Parse(dr[4].ToString()))
|
||
|
{
|
||
|
dataGridView1.Rows[i].Cells[4].Value = CheckState.Checked;
|
||
|
}
|
||
|
}));
|
||
|
i++;
|
||
|
}
|
||
|
dr.Close();
|
||
|
cn.Close();
|
||
|
return 1;
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
cn.Close();
|
||
|
return 2;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|