Click here to Skip to main content
15,888,579 members
Home / Discussions / C#
   

C#

 
AnswerRe: concatenative approach to TTS Pin
OriginalGriff17-Aug-16 4:51
mveOriginalGriff17-Aug-16 4:51 
AnswerRe: concatenative approach to TTS Pin
Gerry Schmitz17-Aug-16 6:01
mveGerry Schmitz17-Aug-16 6:01 
AnswerRe: concatenative approach to TTS Pin
Bernhard Hiller17-Aug-16 21:51
Bernhard Hiller17-Aug-16 21:51 
QuestionHow to make a border less form draggable inside specified location in .net? Pin
srikrishnathanthri17-Aug-16 1:34
srikrishnathanthri17-Aug-16 1:34 
AnswerRe: How to make a border less form draggable inside specified location in .net? Pin
BillWoodruff17-Aug-16 3:03
professionalBillWoodruff17-Aug-16 3:03 
GeneralRe: How to make a border less form draggable inside specified location in .net? Pin
srikrishnathanthri17-Aug-16 19:09
srikrishnathanthri17-Aug-16 19:09 
GeneralRe: How to make a border less form draggable inside specified location in .net? Pin
BillWoodruff17-Aug-16 21:41
professionalBillWoodruff17-Aug-16 21:41 
Generalhow to create user rights for different forms c# Pin
Member 308047017-Aug-16 1:14
Member 308047017-Aug-16 1:14 
Hi I have windows form.in that

I have table tbluseraction

actionid actionname
-------------------------
1 read
2 write
3 delete

I have another table tbluserform

formid formname
---------------------------------
1 frmbackup
2 frmrestore


Now i want to give premission to each form.I have check box for every permission

after giving rights it is saved in table as

formid actionid
1 1
1 2
2 1


I have given source code and Please help me

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace DERPS
{
public partial class frmERPRights : Form
{

int ModuleCode;
int UserCode;
DataTable dtColumns;
public frmERPRights()
{
InitializeComponent();

}




private void button1_Click(object sender, EventArgs e)
{
dgvERPPermission.Columns.Add("clmFormCode", "Form Code");//0
dgvERPPermission.Columns.Add("clmFormDescription", "Form Description");//1
using (SqlConnection CNN = new SqlConnection(AppManager.GetConnectionString()))
{
CNN.Open();

using (SqlCommand scmd = new SqlCommand()) {

scmd.CommandText = "select ActionCode, ActionName from erpactions where isPermissible=1";

scmd.Connection = CNN;
SqlDataAdapter sda = new SqlDataAdapter(scmd);
dtColumns = new DataTable();
dgvERPPermission.AutoGenerateColumns = false;
sda.Fill(dtColumns);
foreach (DataRow row in dtColumns.Rows)
{
DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
checkColumn.Name = row[0].ToString();
checkColumn.HeaderText = row[1].ToString();
checkColumn.Width = 50;
checkColumn.ReadOnly = false;
checkColumn.FillWeight = 10; //if the datagridview is resized (on form resize) the checkbox won't take up too much; value is relative to the other columns' fill values
dgvERPPermission.Columns.Add(checkColumn);

}
}
}


using (SqlConnection CNN = new SqlConnection(AppManager.GetConnectionString()))
{
CNN.Open();

using (SqlCommand scmd = new SqlCommand())
{

scmd.CommandText = "select FormCode,FormDescription from ERPFORMS";

scmd.Connection = CNN;
SqlDataAdapter sda = new SqlDataAdapter(scmd);
DataTable dt = new DataTable();
dgvERPPermission.AutoGenerateColumns = false;
sda.Fill(dt);
object[] row1;
foreach (DataRow row in dt.Rows)
{

row1 = new object[] { row[0], row[1] };
dgvERPPermission.Rows.Add(row1);

}


}


}
}

private void tsbSave_Click(object sender, EventArgs e) //to be saved
{
try
{

using (SqlConnection CNN = new SqlConnection(AppManager.GetConnectionString()))
{
CNN.Open();



foreach (DataGridViewRow row in dgvERPPermission.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
string value = cell.Value.ToString();
if (cell.Value.ToString() == "true")
{

MessageBox.Show(value);
}

}
}


}

}
catch (Exception ex)
{

}
}
}

}


Thanks

chandran
GeneralRe: how to create user rights for different forms c# Pin
Aless Alessio17-Aug-16 1:35
Aless Alessio17-Aug-16 1:35 
GeneralRe: how to create user rights for different forms c# Pin
Richard MacCutchan17-Aug-16 2:01
mveRichard MacCutchan17-Aug-16 2:01 
QuestionC# and MS SQL DeadLock Pin
Zeyad Jalil16-Aug-16 23:41
professionalZeyad Jalil16-Aug-16 23:41 
AnswerRe: C# and MS SQL DeadLock Pin
Pete O'Hanlon17-Aug-16 0:15
mvePete O'Hanlon17-Aug-16 0:15 
AnswerRe: C# and MS SQL DeadLock Pin
Gerry Schmitz17-Aug-16 6:09
mveGerry Schmitz17-Aug-16 6:09 
AnswerRe: C# and MS SQL DeadLock Pin
Andrea Simonassi16-Sep-16 3:46
Andrea Simonassi16-Sep-16 3:46 
Questionhow to copy controls of one flowlayoutpanel to other? Pin
Le@rner16-Aug-16 20:30
Le@rner16-Aug-16 20:30 
AnswerRe: how to copy controls of one flowlayoutpanel to other? Pin
Richard MacCutchan16-Aug-16 21:22
mveRichard MacCutchan16-Aug-16 21:22 
GeneralRe: how to copy controls of one flowlayoutpanel to other? Pin
Le@rner16-Aug-16 22:30
Le@rner16-Aug-16 22:30 
GeneralRe: how to copy controls of one flowlayoutpanel to other? Pin
OriginalGriff16-Aug-16 22:55
mveOriginalGriff16-Aug-16 22:55 
GeneralRe: how to copy controls of one flowlayoutpanel to other? Pin
Le@rner18-Aug-16 19:02
Le@rner18-Aug-16 19:02 
QuestionC# GDI+ simulation of inclined plane Pin
Member 1268837716-Aug-16 5:59
Member 1268837716-Aug-16 5:59 
AnswerRe: C# GDI+ simulation of inclined plane Pin
OriginalGriff16-Aug-16 6:14
mveOriginalGriff16-Aug-16 6:14 
GeneralRe: C# GDI+ simulation of inclined plane Pin
Member 1268837716-Aug-16 6:29
Member 1268837716-Aug-16 6:29 
GeneralRe: C# GDI+ simulation of inclined plane Pin
OriginalGriff16-Aug-16 6:33
mveOriginalGriff16-Aug-16 6:33 
GeneralRe: C# GDI+ simulation of inclined plane Pin
Member 1268837716-Aug-16 7:05
Member 1268837716-Aug-16 7:05 
GeneralRe: C# GDI+ simulation of inclined plane Pin
OriginalGriff16-Aug-16 8:00
mveOriginalGriff16-Aug-16 8:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.