Пример #1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtRemoteAddress.Text))
                {
                    DialogResult = DialogResult.Cancel;
                    return;
                }

                RemoteConfigObj = Activator.GetObject(typeof(Z.C.RemoteConfig), GetRemoteAddress()) as RemoteConfig;

                //检查是否能够正常使用
                RemoteConfigObj.GetConfig(txtRemoteName.Text, txtRemotePass.Text);

                if (txtRemoteAddress.SelectedItem is ConfigFileEntity)
                {
                }
                else
                {
                    //检查是否有重复的, 如果是重复的, 则重新赋值
                    ConfigFileEntity cfe = ManagerConfig.Instance.Find(txtRemoteAddress.Text);

                    if (cfe != null)
                    {
                        cfe.RemotePass = txtRemotePass.Text;
                        cfe.RemoteFile = txtRemoteFile.Text;
                    }
                    else
                    {
                        cfe = new ConfigFileEntity();

                        cfe.RemoteAddress = GetRemoteAddress();
                        cfe.RemotePass    = txtRemotePass.Text;
                        cfe.RemoteFile    = txtRemoteFile.Text;
                        cfe.RemoteName    = txtRemoteName.Text;

                        ManagerConfig.Instance.List.Add(cfe);
                        ManagerConfig.Instance.List.Sort();
                    }
                    ManagerConfig.Save();
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }