private void EditButton(object sender, EventArgs e) { string command = "update [" + dbi.TableName + "] set "; foreach (var el in sil) { string t; if (el.hc.cellType == HeaderCellType.Foreign) { t = sil[((int)el.control.Tag)].code; } else { if (el.hc.dataType == typeof(DateTime)) { t = ((DateTimePicker)el.control).Value.ToString("dd.MM.yyyy HH:mm:ss"); } else if (el.hc.dataType == typeof(bool)) { t = ((CheckBox)el.control).Checked ? "1" : "0"; } else { t = el.control.Text; } } command += "[" + el.hc.value + "] = \'" + t + "\', "; } command = command.Substring(0, command.Length - 2); command += " where [" + dbi.PrimaryKeys[0] + "] = \'" + PrimaryKeyValue + "\'"; DBWorker.DoScalarSQL(command); Close(); }
private void DeleteButton_Click(object sender, EventArgs e) { if (gridOutput.SelectedRows.Count == 0) { return; } var msg = MessageBox.Show("Вы уверены что хотите удалить запись?", "Удаление", MessageBoxButtons.YesNo); if (msg == DialogResult.No) { return; } string temp = dbi.PrimaryKeys[0]; string command = "Delete from [" + dbi.TableName + "] where [" + temp + "] = \'" + gridOutput.SelectedRows[0].Cells[temp].Value.ToString() + "\'"; DBWorker.DoScalarSQL(command); CombineQuerySortSearch(); }