private void EditUser_Load(object sender, EventArgs e)
        {
            HttpWebRequest  request;
            HttpWebResponse response;
            string          content;

            teamLeaders = UserRequsts.GetAllTeamLeaders();
            //fill comboBox with team leaders
            comboBoxTeamLeaderEdit.DataSource    = teamLeaders;
            comboBoxTeamLeaderEdit.ValueMember   = "UserId";
            comboBoxTeamLeaderEdit.DisplayMember = "UserName";


            //fill comboBox with userKinds
            usersKind = UsersKindRequst.GetAllUsersKind();
            comboBoxUserKindEdit.DataSource    = usersKind;
            comboBoxUserKindEdit.ValueMember   = "KindUserId";
            comboBoxUserKindEdit.DisplayMember = "KindUserName";

            //get all the workers and fill the combobox
            allUsers = UserRequsts.GetAllUsers();
            comboBoxAllUsers.SelectedIndexChanged -= new EventHandler(ComboBoxAllUsers_SelectedIndexChanged);
            comboBoxAllUsers.DataSource            = allUsers;
            comboBoxAllUsers.ValueMember           = "UserId";
            comboBoxAllUsers.DisplayMember         = "UserName";

            comboBoxAllUsers.SelectedIndexChanged += ComboBoxAllUsers_SelectedIndexChanged;
        }
        private void AddProject_Load(object sender, EventArgs e)
        {
            HttpWebRequest  request;
            HttpWebResponse response;
            string          content;

            //fill comboBox With teamLeaders
            teamLeaders = UserRequsts.GetAllTeamLeaders();
            comboBoxTeamLeader.DataSource    = teamLeaders;
            comboBoxTeamLeader.ValueMember   = "UserId";
            comboBoxTeamLeader.DisplayMember = "UserName";

            //get all the another workers
            allUsers = UserRequsts.GetAllUsers();
        }
示例#3
0
        private void RemoveUser_Load(object sender, EventArgs e)
        {
            HttpWebRequest  request;
            HttpWebResponse response;
            string          content;

            teamLeaders = UserRequsts.GetAllTeamLeaders();


            //fill comboBox with userKinds
            usersKind = UsersKindRequst.GetAllUsersKind();


            //get all the workers and fill the combobox
            allUsers = UserRequsts.GetAllUsers();

            comboBox1.DataSource    = allUsers;
            comboBox1.ValueMember   = "UserId";
            comboBox1.DisplayMember = "UserName";
        }
示例#4
0
        override protected ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            List <User>  users         = UserRequsts.GetAllUsers();
            object       instance      = validationContext.ObjectInstance;
            Type         type          = instance.GetType();
            PropertyInfo property      = type.GetProperty("UserId");
            object       propertyValue = property.GetValue(instance);

            int.TryParse(propertyValue.ToString(), out int UserId);
            bool isUniqe = users.Any(user => user.UserName.Equals(value.ToString()) && user.UserId != UserId) == false;

            if (isUniqe == false)
            {
                return(new ValidationResult("the Name is already exist"));
            }
            else
            {
                return(null);
            }
        }