Пример #1
0
        protected void trlDepartment_NodeDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            e.Cancel = true;
            DepartmentBO checkID      = new DepartmentBO();
            Guid         departmentId = (Guid)e.Keys["DepartmentId"];
            //Guid departmentId = Guid.Parse(trlDepartment.FocusedNode["DepartmentId"].ToString());
            //TreeListNode node = trlDepartment.FindNodeByFieldValue("DepartmentId", departmentId);
            //node.Focus();

            //CriteriaOperator criteriaParent = new BinaryOperator("ParentDepartmentId", departmentId);
            //XPCollection<NAS.DAL.Nomenclature.Organization.Department> parentCL = new XPCollection<NAS.DAL.Nomenclature.Organization.Department>(session, criteriaParent);
            //if (parentCL.Count() > 0)
            //{
            //    throw new Exception("Không được xóa phòng ban này vì có phòng ban con.");
            //}
            //else
            //{
            bool checkdepartPerson = checkID.checkExistDepartmentPersonInDepartment(session, departmentId);
            bool checkPrivilege    = checkID.checkExistPrivilegeDepartmentInDepartment(session, departmentId);
            bool checkVouchesActor = checkID.checkExistVouchesActorInDepartment(session, departmentId);

            //trlDepartment.JSProperties.Add("cpQuestion", false);
            if (checkdepartPerson)
            {
                throw new Exception("Không được xóa phòng ban này.");
            }
            else if (checkPrivilege || checkVouchesActor)
            {
                throw new Exception("Không được xóa phòng ban này.");
            }
            else
            {
                //e.Values["RowStatus"] = Constant.ROWSTATUS_DELETED;
                trlDepartment.JSProperties.Add("cpQuestion", departmentId.ToString());
                //trlDepartment.JSProperties["cpQuestion"] = true;
            }

            //}
        }