Example #1
0
        /// <summary>
        /// 修改用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
            {
                var row = dataGridView1.Rows[e.RowIndex];

                var userName = row.Cells[0].Value.ToString();

                var oUser = _ftpServerUsers.FirstOrDefault(b => b.UserName == userName);

                if (oUser == null)
                {
                    return;
                }

                var cf = new CreateUserForm(oUser);

                if (cf.ShowDialog(this) == DialogResult.OK)
                {
                    var user = cf.FtpServerUser;
                    _ftpServerUsers.Remove(oUser);
                    _ftpServerUsers.Add(user);
                    FTPServerConfigManager.SetUser(user.UserName, user.Password, user.Root);
                    FTPServerConfigManager.Save();
                    Init();
                }
            }
        }
Example #2
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void skinButton3_Click(object sender, EventArgs e)
        {
            var cf = new CreateUserForm();

            if (cf.ShowDialog(this) == DialogResult.OK)
            {
                var user = cf.FtpServerUser;

                if (FTPServerConfigManager.GetUser(user.UserName) != null)
                {
                    MessageBox.Show("当前用户已存在!");
                    return;
                }

                _ftpServerUsers.Add(user);
                FTPServerConfigManager.SetUser(user.UserName, user.Password, user.Root);
                FTPServerConfigManager.Save();
                Init();
            }
        }