private void btnDelete_Clicked(object sender, EventArgs e) { Button btn = (Button)sender; Payment payment = btn.Data ["Payment"] as Payment; if (payment == null) { return; } using (MessageOkCancel dialog = new MessageOkCancel( Translator.GetString("Delete Payment"), "Icons.TradePoint32.png", Translator.GetString("Do you want to delete the selected payment?"), "Icons.Delete32.png")) { if (dialog.Run() != ResponseType.Ok) { return; } } payments.Remove(payment); RefreshGrid(); parentWindow.Resize(10, 10); txtReceived.GrabFocus(); OnPaymentDeleted(EventArgs.Empty); }
private void btnLess_Clicked(object sender, EventArgs e) { Button btn = (Button)sender; MoneyContainer container = btn.Data ["Container"] as MoneyContainer; if (container == null) { return; } container.Quantity--; if (container.Quantity <= 0) { list.Remove(container); } RefreshGrid(); }
/// <summary> /// 移出数据项 /// </summary> /// <typeparam name="T">泛型</typeparam> /// <param name="gridView">gridView</param> /// <param name="match">条件委托</param> /// <returns>移出行数</returns> public static int RemoveObject <T>(this DataGridView gridView, Predicate <T> match) { int _result = 0; try { BindList <T> _bindList = gridView.ToBindList <T>(); if (_bindList != null) { _result = _bindList.Remove(match); } } catch (Exception) { _result = 0; } return(_result); }
/// <summary> /// 移出数据项 /// </summary> /// <typeparam name="T">泛型</typeparam> /// <param name="gridView">gridView</param> /// <param name="t">实体类</param> /// <returns>移出是否成功</returns> public static bool RemoveObject <T>(this DataGridView gridView, T t) { bool _result = false; try { BindList <T> _bindList = gridView.ToBindList <T>(); if (_bindList != null) { _result = _bindList.Remove(t); } } catch (Exception) { _result = false; } return(_result); }
protected void btnOK_Clicked(object o, EventArgs args) { if (paymentToEdit != null) { paymentToEdit.PartnerId = partner.Id; paymentToEdit.PartnerName = partner.Name; paymentToEdit.TypeId = paymentWidget.GetPaymentTypeId(); paymentToEdit.Quantity = paymentWidget.Received; payments.Add(paymentToEdit); } else { double amountReceived = paymentWidget.Received; if (amountReceived > 0) { Payment payment = AddPayment(amountReceived); if (!BusinessDomain.OnPaymentProcessed(payment)) { payments.Remove(payment); paymentWidget.RefreshGrid(); return; } } // Add the new payments for (int i = payments.Count - 1; i >= 0; i--) { if (payments [i].Quantity.IsZero()) { payments.RemoveAt(i); } } } BusinessDomain.AppConfiguration.LastPaymentMethod = (BasePaymentType)paymentWidget.GetPaymentTypeId(); dlgEditNewAdvancePayment.Respond(ResponseType.Ok); }