private void ItemColumnChoose(string filter) { using (ChooseEditItem dialog = new ChooseEditItem(true, filter)) { if (dialog.Run() != ResponseType.Ok) { EditGridCell(grid.EditedCell.Row, 0); return; } for (int i = selectedDetails.Count - 1; i >= 0; i--) { if (selectedDetails [i].ItemId == -1) { selectedDetails.RemoveAt(i); } } foreach (Item item in dialog.SelectedItems) { OperationDetail saleDetail; if (grid.EditedCell.Row >= selectedDetails.Count) { saleDetail = new SaleDetail(); selectedDetails.Add((SaleDetail)saleDetail); } else { saleDetail = selectedDetails [grid.EditedCell.Row]; } saleDetail.ItemEvaluate(item, PriceGroup.RegularPrice); } } EditGridCell(grid.EditedCell.Row, 1); }
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { if (this.dataGridView2.CurrentCell.OwningColumn.Name == "删除")//q(Msg_Type.fielddelete) { int index = dataGridView2.CurrentRow.Index; BindList.RemoveAt(index); for (int i = 0; i < BindList.Count; i++) { BindList[i].XH = (i + 1); } int a = dataGridView2.Columns.Count; if (BindList.Count == 0) { dataGridView2.DataSource = new List <MES_TM_TMINFO_LIST>(); dataGridView2.Columns["删除"].DisplayIndex = 4;//q(Msg_Type.fielddelete) } else { dataGridView2.DataSource = BindList.ToArray(); dataGridView2.Columns["删除"].DisplayIndex = 4;//q(Msg_Type.fielddelete) } dataGridView2.ClearSelection(); Verify(); } } }
private void chkUseAdvances_Toggled(object o, EventArgs args) { usedAdvances.Clear(); double remainder; if (chkUseAdvances.Active) { remainder = AddAdvancePayments(); } else { remainder = paymentWidget.Received; for (int i = payments.Count - 1; i >= 0; i--) { if (advances.Any(a => a.Id == payments [i].Id)) { remainder += payments [i].Quantity; payments.RemoveAt(i); } } } paymentWidget.RefreshGrid(); paymentWidget.Received = remainder; paymentWidget.FocusReceived(); RecalculateChange(paymentWidget.Received); }
protected override void btnNew_Clicked(object o, EventArgs args) { Partner partner = null; if (BusinessDomain.LoggedUser.LockedPartnerId > 0) { partner = Partner.GetById(BusinessDomain.LoggedUser.LockedPartnerId); } else { using (ChooseEditPartner dialog = new ChooseEditPartner(true, string.Empty)) if (dialog.Run() == ResponseType.Ok && dialog.SelectedItems.Length > 0) { partner = dialog.SelectedItems [0]; } } if (partner == null) { return; } using (EditNewAdvancePayment dialog = new EditNewAdvancePayment(partner)) { if (dialog.Run() != ResponseType.Ok || dialog.Payments.Count <= 0) { return; } BindList <Payment> advances = dialog.Payments; List <Payment> savedPayments = Payment.DistributeAdvances(advances, partner.Id); for (int i = advances.Count - 1; i >= 0; i--) { if (advances [i].Sign < 0) { advances.RemoveAt(i); } else { advances [i].CommitAdvance(); } } savedPayments.AddRange(advances); if (savedPayments.Count > 0) { dialog.PrintPayments(savedPayments); } ReinitializeGrid(true, null); } }
private void DeleteGridRow(int i) { if (!grid.EditedCell.IsValid) { return; } if (itemShortcuts.Count > 1) { int col = grid.EditedCell.Column; int row = grid.EditedCell.Row; int newRow; if (row == itemShortcuts.Count - 1) { // If we are deleting the last row move one row up itemShortcuts.RemoveAt(row); newRow = row - 1; } else { // If we are deleting row from somewhere in between stay on the same line itemShortcuts.RemoveAt(row); newRow = row; } EditGridCell(newRow, col); } else { itemShortcuts.Clear(); itemShortcuts.Add(new ItemShortcut()); EditGridCell(0, 0); } }
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); }