Exemplo n.º 1
0
    protected void SetUserGridData()
    {


         

        //logFiles.ErrorLog("INTO SET USER GRID: curr group " + CurrentGroupName);

        try
        {
            string groupname = CurrentGroupName;
          
            curgrpname.Text = " Current Group: " + groupname;
            if (CurrentGroupName == "None") return;

            
            setLeadeermsg(username, groupname);


            int groupid = groupManagement.find_group_id(groupname);
            if (groupid < 1)
            {
                ShowErrorMessage(" did not find group " + groupname);
                return;
            }

            string selectQuery = " SELECT distinctrow webmpx.group_members.*  FROM webmpx.group_members WHERE (((Group_members.Groupname)='" + groupname + "')) order by webmpx.group_members.Username asc;";

            using (OdbcConnection connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString))
            {
                connection.Open();
                using (OdbcCommand command = new OdbcCommand(selectQuery, connection))
                using (OdbcDataAdapter adapter = new OdbcDataAdapter(command))
                {
                    DataTable dt = new DataTable();
                    try
                    {
                        adapter.Fill(dt);
                        dt.DefaultView.Sort = SortExpression;
                        groupmembers.DataSource = dt.DefaultView;
                        groupmembers.DataBind();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Error in getting data using sql query: " + selectQuery + ". " + ex.Message, ex);
                    }
                }
                connection.Close();
            }

        }
        catch (Exception exp)
        {
            logFiles.ErrorLog(exp);
            ShowErrorMessage("An error has occured when reading user data.");

        }
    }
    protected void gridGroupModels_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        Button btn = e.CommandSource as Button;

        if (btn == null)
        {
            return;
        }


        int groupid = Convert.ToInt32(DropDownList2.SelectedValue);


        GridViewRow row = btn.NamingContainer as GridViewRow;

        if (e.CommandName.Equals("Update"))
        {
            UpdateRow(row);
            gridGroupModels.EditIndex = -1;
        }
        else if (e.CommandName.Equals("Delete"))
        {
            doDeleteFile(row);   //  no confirm !! lucie gwwd
        }
        else if (e.CommandName.Equals("Edit"))
        {
            gridGroupModels.EditIndex = row.RowIndex;
            //  get fileid info
            CurrentFileid = Convert.ToString(get_modelid_row(row));
        }
        else if (e.CommandName.Equals("CancelUpdate"))
        {
            gridGroupModels.EditIndex = -1;
        }
        else if (e.CommandName.Equals("Copy"))
        {
            btnLeft_Click(row);
        }


        SetGroupModelsData(groupManagement.find_group_id(CurrentGroupName));
    }