Exemplo n.º 1
0
 private void OnChangeDataBase(ChangeDataBaseEventArgs args)
 {
     if (this.ChangeDataBase != null)
     {
         this.ChangeDataBase.Invoke(this, args);
     }
 }
Exemplo n.º 2
0
        private ChangeDataBaseEventArgs getArgs()
        {
            ChangeDataBaseEventArgs args = new ChangeDataBaseEventArgs();

            args.ServerName     = this.txtServerName.Text.Trim();
            args.Authentication = this.cbAuthentication.SelectedItem.ToString().Trim();
            args.UserName       = this.txtUserName.Text.Trim();
            args.Password       = this.txtPassword.Text.Trim();
            args.Database       = this.txtDatabase.Text.Trim();
            args.Alias          = this.txtAlias.Text.Trim();

            return(args);
        }
Exemplo n.º 3
0
        public void Save(List <ChangeDataBaseEventArgs> toSave, string path)
        {
            List <ChangeDataBaseEventArgs> final = new List <ChangeDataBaseEventArgs>();

            foreach (ChangeDataBaseEventArgs item in toSave)
            {
                ChangeDataBaseEventArgs tmp = new ChangeDataBaseEventArgs();
                tmp.Authentication = item.Authentication;
                tmp.ServerName     = item.ServerName;
                tmp.UserName       = item.UserName;
                tmp.Password       = Howe.Util.SecurityUtil.Encode(item.Password);
                tmp.Database       = item.Database;
                tmp.Alias          = item.Alias;
                final.Add(tmp);
            }
            Howe.Helper.SerializationHelper.Save(final, path);
        }
Exemplo n.º 4
0
 void btnDel_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag is ChangeDataBaseEventArgs)
     {
         var q = MessageBox.Show(this, "确认删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
         if (q == System.Windows.Forms.DialogResult.No)
         {
             return;
         }
         ChangeDataBaseEventArgs toDel = treeView1.SelectedNode.Tag as ChangeDataBaseEventArgs;
         result.Remove(toDel);
         dal.Save(result, Program.FullName);
         this.bindUI_treeView();
     }
     else
     {
         MessageBox.Show("选择需要删除的Conn", "错误");
     }
 }
Exemplo n.º 5
0
        void btnTest_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            ChangeDataBaseEventArgs args = this.getArgs();
            string errorMsg = this.testConn(args.ServerName, args.Authentication, args.UserName, args.Password, args.Database);

            if (string.IsNullOrEmpty(errorMsg))
            {
                this.Cursor = Cursors.Arrow;
                MessageBox.Show("测试成功。", "提示");
                this.btnSave.Enabled = true;
            }
            else
            {
                this.Cursor = Cursors.Arrow;
                MessageBox.Show(errorMsg, "错误");
                this.btnSave.Enabled = false;
            }
        }
Exemplo n.º 6
0
        public FrmAddOrEditConn(ChangeDataBaseEventArgs args)
        {
            InitializeComponent();
            this.c_Model = args;
            this.initEvent();
            this.initUI();

            this.txtServerName.Text = args.ServerName;
            if (args.Authentication == "Windows Authentication")
            {
                this.cbAuthentication.SelectedIndex = 0;
            }
            else
            {
                this.cbAuthentication.SelectedIndex = 1;
            }
            this.txtUserName.Text = args.UserName;
            this.txtPassword.Text = args.Password;
            this.txtDatabase.Text = args.Database;
            this.txtAlias.Text    = args.Alias;
        }
Exemplo n.º 7
0
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag is ChangeDataBaseEventArgs)
            {
                ChangeDataBaseEventArgs toEdit = treeView1.SelectedNode.Tag as ChangeDataBaseEventArgs;
                FrmAddOrEditConn        frm    = new FrmAddOrEditConn(toEdit);
                frm.Owner = this;
                frm.Text  = "Edit Conn";
                frm.ShowDialog();

                if (frm.c_Model != null)
                {
                    result.Remove(toEdit);
                    result.Add(frm.c_Model);
                    dal.Save(result, Program.FullName);
                }
                dal.Save(result, Program.FullName);
                this.bindUI_treeView();
            }
            else
            {
                MessageBox.Show("选择需要编辑的Conn", "错误");
            }
        }