private void ShowAssigns() { ItemsGrid.Rows.Clear(); if (UpdatingItem == null) { return; } List <CustomerPaymentAssign> assigns = (new CustomerPaymentBLL(AppSettings.Current.ConnStr)).GetAssigns((UpdatingItem as CustomerPayment).ID).QueryObjects; if (assigns != null && assigns.Count > 0) { CustomerReceivableSearchCondition con = new CustomerReceivableSearchCondition(); con.ReceivableIDS = assigns.Select(it => it.ReceivableID).ToList(); List <CustomerReceivable> crs = (new CustomerReceivableBLL(AppSettings.Current.ConnStr)).GetItems(con).QueryObjects; if (crs != null && crs.Count > 0) { foreach (CustomerPaymentAssign assign in assigns) { CustomerReceivable cr = crs.FirstOrDefault(it => it.ID == assign.ReceivableID); int row = ItemsGrid.Rows.Add(); ItemsGrid.Rows[row].Tag = assign; ItemsGrid.Rows[row].Cells["colSheetID"].Value = cr.SheetID; ItemsGrid.Rows[row].Cells["colClassID"].Value = CustomerReceivableTypeDescription.GetDescription(cr.ClassID); ItemsGrid.Rows[row].Cells["colAssign"].Value = assign.Amount.Trim(); } } int rowTotal = ItemsGrid.Rows.Add(); ItemsGrid.Rows[rowTotal].Cells["colSheetID"].Value = "合计"; ItemsGrid.Rows[rowTotal].Cells["colAssign"].Value = assigns.Sum(item => item.Amount).Trim(); } }
protected override void ShowItemInGridViewRow(DataGridViewRow row, object item) { CustomerReceivable cr = item as CustomerReceivable; row.Tag = cr; row.Cells["colSheetID"].Value = cr.SheetID; row.Cells["colOrderID"].Value = cr.OrderID; row.Cells["colCreateDate"].Value = cr.CreateDate.ToString("yyyy-MM-dd"); row.Cells["colClassID"].Value = CustomerReceivableTypeDescription.GetDescription(cr.ClassID); row.Cells["colAmount"].Value = cr.Amount.Trim(); if (cr.Haspaid != 0) { row.Cells["colHaspaid"].Value = cr.Haspaid.Trim(); } if (cr.Remain != 0) { row.Cells["colNotpaid"].Value = cr.Remain.Trim(); int days = DaysBetween(DateTime.Today, cr.CreateDate); row.Cells["colHowold"].Value = days >= 0 ? string.Format("{0}天", days) : string.Empty; } if (cr.Amount < 0) { row.DefaultCellStyle.ForeColor = Color.Red; } }
private void ShowItemInGridViewRow(DataGridViewRow row, CustomerReceivable cr) { row.Tag = cr; row.Cells["colSheetID"].Value = cr.SheetID; row.Cells["colOrderID"].Value = cr.OrderID; row.Cells["colCreateDate"].Value = cr.CreateDate.ToString("yyyy-MM-dd"); row.Cells["colClassID"].Value = CustomerReceivableTypeDescription.GetDescription(cr.ClassID); row.Cells["colRemain"].Value = cr.Remain; row.Cells["colAssign"].Value = 0; row.Cells["colMemo"].Value = cr.Memo; }