المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem wth datagrid [modified]



C# Programming
10-28-2009, 09:40 AM
DataTable dt;

private void Permissions_Load(object sender, EventArgs e){
dt = new DataTable();
dt.Columns.Add("Feature", typeof(string));
dt.Columns.Add("None", typeof(bool));
dt.Columns.Add("ReadOnly", typeof(bool));
dt.Columns.Add("ReadWrite", typeof(bool));

datagridview1.Datasource=dt;
}

private void btnSave_Click(object sender, EventArgs e){

/*On the grid when i'll click on the any checkbox I want to pass parameter to this function SetPermission( , , );
parameter will be from the two enumeratons below


Here is link of Picture >http://img9.imageshack.us/i/35025568.jpg/
I'll explain it in detail as I can
When I click on any checkbox here,I want to pass parameter in set function, for example like this: if I'll click on row Stores, Column read only's expedient checkbox item i want to pass SetPermission(1,1, ...) because in enumeration stores id is 1 and read only's id is 1 too.

SetPermission(?,?,?);*/
}

public void SetPermission(Permission feature, PermissionType permission, int userID) {
SqlCommand cmd = new SqlCommand("Insert into Permissions (UserID,Feature,Permission)Values(@UserID,@Feature,@Permission)", con);

cmd.Parameters.Add(new SqlParameter("UserID", userID));

}



public enum Permission : int
{
Country = 0,
Store = 1,
City = 2
}

public enum PermissionType : byte
{
None = 0,
ReadOnly = 1,
ReadWrite = 2
}

C# Developer

modified on Tuesday, October 27, 2009 8:21 AM