private void tBtnDelIntf_Click(object sender, EventArgs e) { if (skinLVParas.SelectedItems.Count > 0) { if (MessageBox.Show("是否要删除该参数?", "参数删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { //listVAGs.SelectedItems.Count > 0 //var proj = listVAGs.SelectedItems[0]; var a = skinLVParas.SelectedItems[0]; DbService db = null; db = DB.GetMainDb(); Hashtable htPara = new Hashtable(); htPara.Add("para_code", a.SubItems[0].Text); int count = (int)db.ExecuteScalarID("CountParaNumbers", htPara); if (count > 0) { MessageBox.Show("还有" + count.ToString() + "个参数组在使用该参数,避免出错,请先检查参数组"); return; } HA_ParameterDAL dal = new HA_ParameterDAL(); if (dal.Delete(a.SubItems[0].Text)) { ShowAllParameters();// ReloadParameter(proj.SubItems[0].Text); } } } }
private void button1_Click(object sender, EventArgs e) { try { HA_ParameterDAL dal = new HA_ParameterDAL(); if (string.IsNullOrEmpty(txtParaCode.Text)) { MessageBox.Show("请输入参数代码"); return; } else if (txtParaCode.Text.Contains(",")) { MessageBox.Show("请不要输入 , (逗号)"); return; } if (paraobj == null) { int ret = dal.AddNew(new HA_Parameter { para_name = txtParaName.Text, para_code = txtParaCode.Text, para_length = txtLength.Text, para_note = txtConnNote.Text, para_required = false, para_datatype = comboDataType.Text, para_default = txtDefaultValue.Text }); if (ret < 0) { MessageBox.Show("保存失败 : " + ret); } } else { //UpdateProject bool ret = dal.Update(new HA_Parameter { para_name = txtParaName.Text, para_code = txtParaCode.Text, para_length = txtLength.Text, para_note = txtConnNote.Text, para_required = false, para_datatype = comboDataType.Text, para_default = txtDefaultValue.Text }); if (ret == false) { MessageBox.Show("保存失败 : " + ret); } } Close(); } catch (Exception ex) { MessageBox.Show("保存失败 : " + ex.Message); } }