private void button1_Click(object sender, EventArgs e) { try { HA_ConnectionDAL dal = new HA_ConnectionDAL(); if (string.IsNullOrEmpty(txtConnName.Text)) { MessageBox.Show("请输入连接名称"); return; } if (cobj == null) { int ret = dal.AddNew(new HA_Connection { conn_name = txtConnName.Text, conn_IP = txtConnIP.Text, conn_DBType = comboDBType.Text, conn_CType = txtCType.Text, conn_Account = txtConnAccount.Text, conn_note = txtConnNote.Text, conn_Alias = txtDBName.Text, conn_Password = txtPassword.Text, conn_String = "" }); if (ret < 0) { MessageBox.Show("保存失败 : " + ret); } } else { //UpdateProject bool ret = dal.Update(new HA_Connection { conn_name = txtConnName.Text, conn_IP = txtConnIP.Text, conn_DBType = comboDBType.Text, conn_CType = txtCType.Text, conn_Account = txtConnAccount.Text, conn_note = txtConnNote.Text, conn_Alias = txtDBName.Text, conn_Password = txtPassword.Text, conn_String = txtConnStr.Text }); if (ret == false) { MessageBox.Show("保存失败 : " + ret); } } Close(); } catch (Exception ex) { MessageBox.Show("保存失败 : " + ex.Message); } }
private void btnSaveBackToConn_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtConnStrGen.Text)) { try { if (skinLVConns.SelectedItems.Count > 0) { labelConnStatus.Text = ""; var a = skinLVConns.SelectedItems[0]; HA_ConnectionDAL dal = new HA_ConnectionDAL(); HA_Connection ha_conn = new HA_Connection { conn_name = a.SubItems[1].Text, conn_IP = a.SubItems[2].Text, conn_Account = a.SubItems[3].Text, conn_Password = a.SubItems[4].Text, conn_DBType = a.SubItems[5].Text, conn_Alias = a.SubItems[6].Text, conn_CType = a.SubItems[7].Text, conn_String = txtConnStrGen.Text, conn_note = a.SubItems[9].Text }; bool ret = dal.Update(ha_conn); if (ret) { labelConnStatus.Text = "保存成功!"; ReloadConnection(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }