Beispiel #1
0
    void AggiungiRighe()
    {
        int       nrows             = ToAdd.Rows.Count;
        ArrayList Selected          = new ArrayList();
        ArrayList ToRemoveFromToAdd = new ArrayList();

        for (int index = 0; index < nrows; index++)
        {
            hwCheckBox HwC = GridToAdd.FindControl("Chk_Selector_" + GridToAdd.ID + "_" + index) as hwCheckBox;
            if (HwC == null)
            {
                continue;
            }
            if (HwC.Checked == true)
            {
                Selected.Add(index);
            }
        }

        /*
         * foreach (hwCheckBox hwC in GridToAdd.Controls)
         * {
         *  if (hwC.Checked == true)
         *  {
         *      int i = Int32.Parse(hwC.Tag);
         *      Selected.Add(i);
         *  }
         * }
         */

        foreach (int index in Selected)
        {
            DataRow Curr = ToAdd.Rows[index];
            ToRemoveFromToAdd.Add(Curr);

            //La  aggiunge ad Added
            AddRowToTable(Added, Curr);
        }

        //Rimuove tutte le righe da ToAdd
        foreach (DataRow ToRemove in ToRemoveFromToAdd)
        {
            ToRemove.Delete();
            if (ToRemove.RowState != DataRowState.Detached)
            {
                ToRemove.AcceptChanges();
            }
        }
        UpdateSourceTable();
    }
Beispiel #2
0
    void RimuoviRighe()
    {
        int       nrows             = Added.Rows.Count;
        ArrayList Selected          = new ArrayList();
        ArrayList ToRemoveFromAdded = new ArrayList();

        for (int index = 0; index < nrows; index++)
        {
            hwCheckBox HwC = GridAdded.FindControl("Chk_Selector_" + GridAdded.ID + "_" + index) as hwCheckBox;
            if (HwC == null)
            {
                continue;
            }
            if (HwC.Checked == true)
            {
                Selected.Add(index);
            }
        }

        foreach (int index in Selected)
        {
            //Prende una riga selezionata
            //gridAdded.CurrentRowIndex = index;
            //DataRowView CurrDV = (DataRowView)gridToAdd.BindingContext[myDS, Added.TableName].Current;
            DataRow Curr = Added.Rows[index];
            ToRemoveFromAdded.Add(Curr);

            //La  aggiunge a ToAdd
            AddRowToTable(ToAdd, Curr);
        }

        //Rimuove tutte le righe da Added
        foreach (DataRow ToRemove in ToRemoveFromAdded)
        {
            ToRemove.Delete();
            if (ToRemove.RowState != DataRowState.Detached)
            {
                ToRemove.AcceptChanges();
            }
        }
        UpdateSourceTable();
    }