private void grvDepartment_CommandCellClick(object sender, EventArgs e)
{
var gridCommandCellElement = sender as GridCommandCellElement;
if (gridCommandCellElement != null)
{
#region MyRegion
#region MyRegion
var value = gridCommandCellElement.ColumnInfo.Name;
int departmentId = Convert.ToInt32(gridCommandCellElement.RowInfo.Cells["DepartmentId"].Value);
Department department =
(_outEntities.Department.Local.Where(g => g.DepartmentId ==
departmentId))
.SingleOrDefault();
#endregion
if (value != null && department!=null)
{
if (value == "colDelete")
{
#region Delete Group & UsersGroup
////delete
from Departments Table..
ICollection<UserProfile> usersProfiles =
(from u in
_outEntities.UserProfile.Local where u.DepartmentId == departmentId select u)
.ToList();
if (usersProfiles.Count == 0)
{
DialogResult result
= RadMessageBox.Show("Are you sure
you want to delete this item ?",
"Delete confirm",
MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
#region MyRegion
//Department department =
//
(_outEntities.Department.Local.Where(g => g.DepartmentId ==
departmentId))
//
.SingleOrDefault();
_outEntities.Department.Local.Remove(department);
_outEntities.SaveChanges();
gridCommandCellElement.RowInfo.Delete();
#endregion
(new Thread(() => DepartmentManagement.DeleteDepartmentRef(departmentId.ToString()))).Start();
}
}
else
{
RadMessageBox.Show("You can't delete this item, related data was
found.", "Attention",
MessageBoxButtons.OK, RadMessageIcon.Info);
}
#endregion
}
}
#endregion
}
}
ليست هناك تعليقات:
إرسال تعليق