void uxDelete_Click(object sender, ImageClickEventArgs e) { if (CurrentRowIndex < 0) { uxMessage.Text = "هیچ سطری انتخاب نشده است."; return; } CancelEventArgs e1 = new CancelEventArgs(); OnRowDeleting(this, e1); if (e1.Cancel == true) { return; } Record r = new Record(TableName); r.Keys[KeyFieldName] = CurrentKeyValue; r.Delete(); RowsCount--; if (CurrentRowIndex == RowsCount - 1) { CurrentRowIndex--; } FillControls(); uxMessage.Text = "حذف با موفقيت انجام شد."; // OnCurrentRowChanged(); OnRowDeleted(); ClearForm(); FormState = FormState.New; }
/// <summary> /// Deletes the Account from the backing storage. This object is considered invalid once /// this method has been executed. /// </summary> public void Delete() { Record.Delete(); var bans = Bans; foreach (var b in bans) { b.Delete(); } }
public void DeleteRecord() { Record r = this.table.NewRecord(); r[intColumn] = Any.Int32; r.Save(); r.Delete(); Assert.AreEqual(0, this.table.Count()); }
void uxGrid_DeleteCommand(object sender, GridCommandEventArgs e) { if (!AllowDeleting) { return; } if (TableInfo == null) { return; } Record r = GetRecord(e.Item); r.Delete(); }
public void DeleteNonInsertedRecord() { Record r1 = this.table.NewRecord(); r1[intColumn] = 1; r1.Save(); Record r2 = this.table.NewRecord(); try { r2.Delete(); Assert.Fail("Expected EsentError exception"); } catch (EsentException) { } Assert.AreEqual(1, r1[intColumn]); }
/// <summary> /// When the "Remove Entry" button is clicked, remove the selected employee and customer entries, /// along with the related schedule and attendance entries respectively, from the database and from the /// DataSet. Update the grid to reflect these changes. /// </summary> private void RemoveButton_Click(object sender, EventArgs e) { try { // Get selected row. GridRangeInfo info = databaseGrid.TableModel.Selections.GetSelectedRows(true, true)[0]; // Get an element fromt the row. Element element = databaseGrid.TableModel.GetDisplayElementAt(info.Top); // Get the table the element belongs to. GridNestedTable gnt = element as GridNestedTable; // Get the data of the row. DataRowView drv = gnt.ChildTable.ParentTable.CurrentElement.GetData() as DataRowView; // Get the name of the table the row belongs to. string table = gnt.ChildTable.Name; if (table == "Employees") { // Remove the employee and corresponding employee schedule entry from the database. DatabaseWorker.RemoveEmployee(Convert.ToInt32(drv[0])); // Get the grid employee entry. Record record = gnt.ChildTable.ParentTable.CurrentElement.GetRecord(); // Get the index of the employee entry. // This index is the same as the index of the corresponding employee schedule entry. int index = databaseGrid.GetTable("Employees").UnsortedRecords.IndexOf(record); // Delete the corresponding employee schedule entry from the grid. databaseGrid.GetTable("Employee Schedule").UnsortedRecords[index].Delete(); // Delete the employee entry from the grid. record.Delete(); // Delete the employee and employee schedule entries from the DataSet. database.Tables["Employees"].Rows[index].Delete(); database.Tables["Employee Schedule"].Rows[index].Delete(); // Commit changes to the DataSet. database.AcceptChanges(); } else if (table == "Customers") { // Remove the customer and corresponding customer attendance entry from the database. DatabaseWorker.RemoveCustomer(Convert.ToInt32(drv[0])); // Get the grid customer entry. Record record = gnt.ChildTable.ParentTable.CurrentElement.GetRecord(); // Get the index of the customer entry. // This index is the same as the index of the corresponding customer attendance entry. int index = databaseGrid.GetTable("Customers").UnsortedRecords.IndexOf(record); // Delete the corresponding customer attendance entry from the grid. databaseGrid.GetTable("Customer Attendance").UnsortedRecords[index].Delete(); // Delete the customer entry from the grid. record.Delete(); // Delete the customer and customer attendance entries from the DataSet. database.Tables["Customers"].Rows[index].Delete(); database.Tables["Customer Attendance"].Rows[index].Delete(); // Commit changes to the DataSet. database.AcceptChanges(); } // If the table is neither of the above, display the appropriate error message. else if (table == "Employee Schedule") { MessageBoxAdv.Show(this, "Cannot remove employee schedule entry directly. \n" + "To remove it, delete the corresponding employee entry.", "Error"); } else if (table == "Customer Attendance") { MessageBoxAdv.Show(this, "Cannot remove customer attendance entry directly. \n" + "To remove it, delete the corresponding customer entry.", "Error"); } } catch (Exception) { } }
private void barItem2_Click(object sender, EventArgs e) { Record rec = this.gridGroupingControl1.Table.CurrentRecord; rec.Delete(); }
/// <summary> /// Deletes the IPBan from the backing storage. This object is considered invalid once /// this method has been executed. /// </summary> internal void Delete() { Record.Delete(); }
/// <summary> /// **************** TODO: COMPLETE DOCUMENTATION ***************** /// /// When the "Remove Entry" button is clicked, remove the selected employee and customer entries /// along with the related schedule and attendance entries respectively, from the database and from the /// DataSet. Update the grid to the reflect these changes. /// </summary> private void removeButton_Click(object sender, EventArgs e) { try { GridRangeInfoList range = databaseGrid.TableModel.Selections.GetSelectedRows(true, true); foreach (GridRangeInfo info in range) { Element element = databaseGrid.TableModel.GetDisplayElementAt(info.Top); GridNestedTable gnt = element as GridNestedTable; GridNestedTable gnt1 = gnt; while (gnt1 != null && gnt1.ChildTable != null) { gnt = gnt1; gnt1 = gnt.ChildTable.ParentTable.CurrentElement as GridNestedTable; } DataRowView drv = gnt.ChildTable.ParentTable.CurrentElement.GetData() as DataRowView; string table = gnt.ChildTable.ParentTable.CurrentElement.GetRecord().ParentChildTable.Name; if (table == "Employees") { DatabaseWorker.RemoveEmployee(Convert.ToInt32(drv[0])); Record record = gnt.ChildTable.ParentTable.CurrentElement.GetRecord(); int index = databaseGrid.GetTable("Employees").UnsortedRecords.IndexOf(record); databaseGrid.GetTable("Employee Schedule").UnsortedRecords[index].Delete(); record.Delete(); database.Tables["Employees"].Rows[index].Delete(); database.Tables["Employee Schedule"].Rows[index].Delete(); database.AcceptChanges(); } else if (table == "Customers") { DatabaseWorker.RemoveCustomer(Convert.ToInt32(drv[0])); Record record = gnt.ChildTable.ParentTable.CurrentElement.GetRecord(); int index = databaseGrid.GetTable("Customers").UnsortedRecords.IndexOf(record); databaseGrid.GetTable("Customer Attendance").UnsortedRecords[index].Delete(); record.Delete(); database.Tables["Customers"].Rows[index].Delete(); database.Tables["Customer Attendance"].Rows[index].Delete(); database.AcceptChanges(); } else if (table == "Employee Schedule") { MessageBoxAdv.Show(this, "Cannot remove employee schedule entry directly. \n" + "To remove it, delete the corresponding employee entry.", "Error"); } else if (table == "Customer Attendance") { MessageBoxAdv.Show(this, "Cannot remove customer attendance entry directly. \n" + "To remove it, delete the corresponding customer entry.", "Error"); } } } catch (Exception) { MessageBoxAdv.Show(this, "Not a valid entry", "Error"); } }
/// <summary> /// Deletes the AccountBan from the backing storage. This object is considered invalid once /// this method has been executed. /// </summary> public void Delete() { Record.Delete(); }
public override string ExecuteAndGetResponse(ImputCommand param) { foreach(var item in dictions.GetUsingdictions()) { if(param.Count != 2) return "#ivalid number of args"; Record row = new Record(item.ToString()); row.word = param[0]; if(!row.SelectByWord()) return "#word not found"; if(!row.Delete()) return "#something wrong :("; if(!this.TrySetPriorForRow(row,param[1])) return "#invalid arg priority"; if (!row.Insert()) return "#something wrong :("; } return "#done"; }
private string DeleteRowByWordAndGetResponse(string word) { foreach(var item in dictions.GetUsingdictions()) { Record row = new Record(item.ToString()); row.word = word; if (!row.Delete()) return "#not deleted"; } return "#done" ; }
private static object findmessagid(FileInfo f) { string msgid = null; using(Database db = new Database()) { RecordType rt = new RecordType(db, 3); Record r = new Record(rt); r.Container = new Record(db, 172739); r.Title = f.Name; r.SetDocument(f.FullName); r.Save(); msgid = r.MessageId; r.Delete(); } return msgid; }