Beispiel #1
0
   public void btnAddUser_Click(object sender, EventArgs e)
    {
        string userNameNew = MyUtilities.clean(txtNewUser.Text);  //   clean user name in case try to crash DB !!!
        userNameNew.Trim();
        string message;
        if (userNameNew == "")
        {
            ShowErrorMessage("No user name entered.  Please try again.");
            return;
        }

       string groupname = CurrentGroupName;


        int groupID = groupManagement.find_group_id(groupname);

        
        //logFiles.ErrorLog(" trying to add user to group " + groupname + " user " + userNameNew);

        int successAdd = groupManagement.unique_user_name(groupname, userNameNew);

        if (successAdd == 0)
        {
            message = "User in group already?";
            logFiles.ErrorMessageLog(message);
            ShowErrorMessage(message);

            return;
        }

        bool leader1 = chkIsLeader.Checked;
        string ld1 = Convert.ToString(leader1);

       
      
        successAdd = groupManagement. add_user_to_group(groupname, userNameNew, leader1, username);
        if (successAdd == 0)
        {
            message = "New user not added.  User '" + userNameNew + "' not found? ";
            logFiles.ErrorMessageLog(message);
            ShowErrorMessage(message);
        }

        message = "User added to group " + groupname + " username " +userNameNew ;

        MailInfo.SendMail(message, MailInfo.GROUP_USER_ADDED);

        SetUserGridData();
        txtNewUser.Text= "";
        chkIsLeader.Checked = false;
    }