示例#1
0
    protected void gvw_archi_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Editer")
        {
            pnl_edit.Visible = true;
            DRYA drya = DataMapping.GetListDRYA("section ='" + section + "' and rotary_year='" + rbl_rotaryYear.SelectedValue + "'").Where(x => x.id == int.Parse("" + e.CommandArgument)).FirstOrDefault();
            lbl_nomEdit.Text    = drya.name + " " + drya.surname;
            tbx_desc.Text       = drya.description;
            hfd_id.Value        = "" + drya.id;
            pnl_buttons.Visible = false;
            pnl_add.Visible     = false;
            BindDDLJobs();
        }
        if (e.CommandName == "Deleter")
        {
            List <DRYA> list = DataMapping.GetListDRYA("section='" + section + "' and rotary_year='" + rotary_year + "'");
            DRYA        d    = DataMapping.GetListDRYA("id = " + e.CommandArgument).First();
            foreach (DRYA drya in list)
            {
                if (drya.rank > d.rank)
                {
                    drya.rank--;
                    DataMapping.InsertDRYA(drya);
                }
            }
            DataMapping.DeleteDRYA(int.Parse("" + e.CommandArgument));

            RefreshList_Grid();
        }
        if (e.CommandName == "Up")
        {
            List <DRYA> list = DataMapping.GetListDRYA("section='" + section + "' and rotary_year='" + rotary_year + "'");
            DRYA        d    = DataMapping.GetListDRYA("id = " + e.CommandArgument).First();
            foreach (DRYA drya in list)
            {
                if (drya.rank == d.rank - 1)
                {
                    drya.rank++;
                    d.rank--;
                    DataMapping.InsertDRYA(drya);
                    DataMapping.InsertDRYA(d);
                    break;
                }
            }
            RefreshList_Grid();
        }
        if (e.CommandName == "Down")
        {
            List <DRYA> list = DataMapping.GetListDRYA("section='" + section + "' and rotary_year='" + rotary_year + "'");
            DRYA        d    = DataMapping.GetListDRYA("id = " + e.CommandArgument).First();
            foreach (DRYA drya in list)
            {
                if (drya.rank == d.rank + 1)
                {
                    drya.rank--;
                    d.rank++;
                    DataMapping.InsertDRYA(drya);
                    DataMapping.InsertDRYA(d);
                    break;
                }
            }
            RefreshList_Grid();
        }
    }