Пример #1
0
    protected void lnkDelete_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "select")
        {
            var node = treeOL.FindNodeByValue(e.CommandArgument.ToString()) ?? new RadTreeNode();

            cboTreeOL.SelectedValue = String.Empty;

            if (node.ParentNode != null)
            {
                cboTreeOL.SelectedValue = node.ParentNode.Value;
            }

            txtOL.Text = node.Text;
        }

        if (e.CommandName == "delete")
        {
            humanResourcesManager = new HumanResourcesManager(this);
            organizationLevel     = humanResourcesManager.GetOrganizationLevel(Company.CompanyId,
                                                                               Convert.ToInt32(e.CommandArgument));

            if (organizationLevel != null)
            {
                IQueryable <OrganizationLevel> childOrganizationLevelList;
                childOrganizationLevelList = humanResourcesManager.GetChildOrganizationLevel(Company.CompanyId, organizationLevel.OrganizationlevelId);

                if (childOrganizationLevelList.Count() != 0)
                {
                    ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                    return;
                }
                else
                {
                    try
                    {
                        humanResourcesManager.DeleteOrganizationLevel(organizationLevel);
                        BindTree();
                    }
                    catch (Exception)
                    {
                        ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                    }
                }
            }
        }
    }
    protected void lnkDelete_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "select")
        {
            var node = treeOL.FindNodeByValue(e.CommandArgument.ToString()) ?? new RadTreeNode();

            cboTreeOL.SelectedValue = String.Empty;

            if (node.ParentNode != null)
                cboTreeOL.SelectedValue = node.ParentNode.Value;
          
            txtOL.Text = node.Text;
        }

        if (e.CommandName == "delete")
        {
            humanResourcesManager = new HumanResourcesManager(this);
            organizationLevel = humanResourcesManager.GetOrganizationLevel(Company.CompanyId,
                Convert.ToInt32(e.CommandArgument));

            if (organizationLevel != null)
            {
                IQueryable<OrganizationLevel> childOrganizationLevelList;
                childOrganizationLevelList = humanResourcesManager.GetChildOrganizationLevel(Company.CompanyId, organizationLevel.OrganizationlevelId);

                if (childOrganizationLevelList.Count() != 0)
                {
                    ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                    return;
                }
                else
                {
                    try
                    {
                        humanResourcesManager.DeleteOrganizationLevel(organizationLevel);
                        BindTree();
                    }
                    catch (Exception)
                    {
                        ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                    }
                }
            }
        }
    }