protected void btnMove_Click(object sender, EventArgs e) { bool found1 = false, found2 = false; int Position = Convert.ToInt32(ddlPosition.SelectedValue); int ItemToMove = Convert.ToInt32(ddlItemToMove.SelectedValue); BPDisciplineLevels bp = new BPDisciplineLevels(); BECompetencies ds = bp.SelectAll(); BECompetencies.tbl_DisciplineLevelsRow[] disciplinerows = (BECompetencies.tbl_DisciplineLevelsRow[])ds.tbl_DisciplineLevels.Select("", "DisciplineLevelOrder"); BECompetencies.tbl_DisciplineLevelsRow movediscipline = ds.tbl_DisciplineLevels.FindByDisciplineLevelID(ItemToMove); foreach (BECompetencies.tbl_DisciplineLevelsRow discipline in disciplinerows) { if (found1 && found2) break; if (discipline.DisciplineLevelID == movediscipline.DisciplineLevelID) { found1 = true; if (discipline.DisciplineLevelID == Position) found2 = true; } else if (discipline.DisciplineLevelID == Position) { found2 = true; if (rblBeforeAfter.SelectedValue == "0") { movediscipline.DisciplineLevelOrder = discipline.DisciplineLevelOrder; discipline.DisciplineLevelOrder++; } else { if (found1) discipline.DisciplineLevelOrder--; movediscipline.DisciplineLevelOrder = discipline.DisciplineLevelOrder + 1; } } else if (found1 && !found2) discipline.DisciplineLevelOrder--; else if (found2 && !found1) discipline.DisciplineLevelOrder++; } bp.Update(ds); dgDisciplineLevels.DataSource = GetData(); dgDisciplineLevels.DataBind(); }
protected DataView GetData() { BPDisciplineLevels bp = new BPDisciplineLevels(); DSCompetencies = bp.SelectAll(); DSCompetencies.tbl_DisciplineLevels.DefaultView.Sort = "DisciplineLevelOrder"; BindMoveControl(DSCompetencies.tbl_DisciplineLevels.DefaultView); DSCompetencies.tbl_DisciplineLevels.DefaultView.RowFilter = RowFilter("DisciplineLevelTitle", ((LinkButton)rptLetters.Items[0].FindControl("lnkLetter")).CommandName, "DisciplineLevelActive", lstActive.SelectedValue); return DSCompetencies.tbl_DisciplineLevels.DefaultView; }
protected void BindDisciplineLevels() { BPDisciplineLevels bp = new BPDisciplineLevels(); BECompetencies ds = bp.SelectAll(); ds.tbl_DisciplineLevels.DefaultView.Sort = "DisciplineLevelOrder"; ddlDisciplineLevels.DataSource = ds.tbl_DisciplineLevels.DefaultView; ddlDisciplineLevels.DataTextField = "DisciplineLevelTitle"; ddlDisciplineLevels.DataValueField = "DisciplineLevelID"; ddlDisciplineLevels.DataBind(); ddlDisciplineLevels.Items.Insert(0, new ListItem("(All Discipline Levels)", "-1")); if (FilterCatID != "-1") if (ddlDisciplineLevels.Items.FindByValue(FilterCatID) != null) ddlDisciplineLevels.SelectedValue = FilterCatID; }