private void button4_Click(object sender, EventArgs e)//删除行 { int row = 0; row = dataGridView1.CurrentCell.RowIndex; if (dataGridView1.RowCount > 0) { string ls_time = (string)dataGridView1.Rows[row].Cells[1].Value; string ls_type = (string)dataGridView1.Rows[row].Cells[2].Value; if (string.IsNullOrEmpty(ls_time) || string.IsNullOrEmpty(ls_type)) { MessageBox.Show("未选中行或选中了空行!"); return; } string ls_sql = @"delete from mysysset where itemtype='backuptime' and itemname='" + ls_time + "' and itemvalue='" + ls_type + "'"; int li_row = MyConfig.ExecuteScalarNum(ls_sql); BindDataGridView(); MessageBox.Show("删除成功!"); return; } }
public int of_SetMySysSet(string as_type, string as_item, string as_value) { MyConfig.DbName = "config.db"; int li_row = 0; string ls_sql = "select count(*) from mysysset where itemtype='" + as_type + "' and itemname='" + as_item + "'"; li_row = MyConfig.ExecuteScalarNum(ls_sql); n_create_sql lnv_sql = new n_create_sql("mysysset", MyConfig.DbName); lnv_sql.of_AddCol("itemtype", as_type); lnv_sql.of_AddCol("itemname", as_item); lnv_sql.of_AddCol("itemvalue", as_value); int li_rc = 0; if (li_row <= 0) { li_rc = lnv_sql.of_execute(); } if (li_row > 0) { li_rc = lnv_sql.of_execute("itemtype=@itemtype and itemname=@itemname", "@itemtype=" + as_type, "@itemname=" + as_item); } return(li_rc); }