private void tBtnDelConn_Click(object sender, EventArgs e) { if (skinLVConns.SelectedItems.Count > 0) { if (MessageBox.Show("是否要删除该连接?", "连接删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { var a = skinLVConns.SelectedItems[0]; DbService db = null; db = DB.GetMainDb(); Hashtable htPara = new Hashtable(); htPara.Add("conn_name", a.SubItems[1].Text); int count = (int)db.ExecuteScalarID("GetInterfaceUsedConnectionsNumber", htPara); if (count > 0) { MessageBox.Show("还有" + count.ToString() + "个接口在使用该连接,避免出错,请先检查接口"); return; } HA_ConnectionDAL dal = new HA_ConnectionDAL(); if (dal.Delete(Convert.ToInt32(a.SubItems[0].Text))) { ReloadConnection(); } } } }
private void tBtnAddConn_Click(object sender, EventArgs e) { HA_ConnectionDAL dal = new HA_ConnectionDAL(); FrmManageConn methodForm = new FrmManageConn(null, ""); methodForm.ShowDialog(); ReloadConnection(); }
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); } } }