protected void gvApplyDetails_RowDataBound(object sender, GridViewRowEventArgs e) { // 对数据列进行赋值 if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit) { DataRowView drvDetail = (DataRowView)e.Row.DataItem; FormDS.FormApplyDetailViewRow row = (FormDS.FormApplyDetailViewRow)drvDetail.Row; ApplyFeeTotal = decimal.Round((ApplyFeeTotal + row.Amount), 2); if (!row.IsAccruedAmountNull()) { AccruedFeeTotal = decimal.Round((AccruedFeeTotal + row.AccruedAmount), 2); } TextBox txtAccruedAmount = (TextBox)e.Row.FindControl("txtAccruedAmount"); txtAccruedAmount.Attributes.Add("onBlur", "PlusTotal(this);"); txtAccruedAmount.Attributes.Add("onFocus", "MinusTotal(this)"); //txtAccruedAmount.ReadOnly = (bool)this.ViewState["ExecuteReadOnly"]; txtAccruedAmount.Enabled = !(bool)this.ViewState["ExecuteReadOnly"]; CommonUtility.GenerateRepeatControl(e.Row.Cells[3].Controls, row.IsRepeatFormInfoNull() ? "" : row.RepeatFormInfo); } } if (e.Row.RowType == DataControlRowType.Footer) { Label applbl = (Label)e.Row.FindControl("applbl"); applbl.Text = ApplyFeeTotal.ToString("N"); Label totallbl = (Label)e.Row.FindControl("totallbl"); totallbl.Text = AccruedFeeTotal.ToString("N"); } }
protected void gvApplyDetails_RowDataBound(object sender, GridViewRowEventArgs e) { // 对数据列进行赋值 if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit) { DataRowView drvDetail = (DataRowView)e.Row.DataItem; FormDS.FormApplyDetailViewRow row = (FormDS.FormApplyDetailViewRow)drvDetail.Row; manualApplyFeeTotal = decimal.Round((manualApplyFeeTotal + row.Amount), 2); } } this.ViewState["ManualApplyFeeTotal"] = manualApplyFeeTotal; if (e.Row.RowType == DataControlRowType.Footer) { Label sumlbl = new Label(); sumlbl.Text = "合计"; e.Row.Cells[2].Controls.Add(sumlbl); e.Row.Cells[2].CssClass = "RedTextAlignCenter"; e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells[2].Width = new Unit("145px"); Label totallbl = new Label(); totallbl.Text = manualApplyFeeTotal.ToString("N"); e.Row.Cells[3].Controls.Add(totallbl); e.Row.Cells[3].CssClass = "RedTextAlignCenter"; e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Right; e.Row.Cells[3].Width = new Unit("120px"); } }
private bool FillDetail() { bool isValid = true; this.ViewState["AccruedFeeTotal"] = 0; foreach (GridViewRow row in this.gvApplyDetails.Rows) { if (row.RowType == DataControlRowType.DataRow) { FormDS.FormApplyDetailViewRow detailRow = this.InnerDS.FormApplyDetailView[row.RowIndex]; TextBox txtAccruedAmount = (TextBox)row.FindControl("txtAccruedAmount"); if (string.IsNullOrEmpty(txtAccruedAmount.Text.Trim())) { txtAccruedAmount.Text = "0"; } decimal accruedAmount = decimal.Parse(txtAccruedAmount.Text.Trim()); if (accruedAmount < 0) { PageUtility.ShowModelDlg(this.Page, "不能录入负数"); isValid = false; break; } if (accruedAmount > detailRow.Amount) { PageUtility.ShowModelDlg(this.Page, "实际费用不能大于申请费用"); isValid = false; break; } detailRow.AccruedAmount = accruedAmount; this.ViewState["AccruedFeeTotal"] = decimal.Parse(this.ViewState["AccruedFeeTotal"].ToString()) + accruedAmount; } } return(isValid); }
protected void gvApplyDetails_RowDataBound(object sender, GridViewRowEventArgs e) { // 对数据列进行赋值 if (e.Row.RowType == DataControlRowType.DataRow) { ERS.ExpenseItemRow itemRow = null; if ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit) { DataRowView drvDetail = (DataRowView)e.Row.DataItem; FormDS.FormApplyDetailViewRow row = (FormDS.FormApplyDetailViewRow)drvDetail.Row; manualApplyFeeTotal = decimal.Round((manualApplyFeeTotal + row.Amount), 2); itemRow = new MasterDataBLL().GetExpenseItemByID(row.ExpenseItemID); if (itemRow.IsInContract) { inContractAmount = decimal.Round((inContractAmount + row.Amount), 2); } } } this.ViewState["ManualApplyFeeTotal"] = manualApplyFeeTotal; this.ViewState["InContractAmount"] = inContractAmount; if (e.Row.RowType == DataControlRowType.Footer) { Label sumlbl = new Label(); sumlbl.Text = "合计:"; e.Row.Cells[1].Controls.Add(sumlbl); e.Row.Cells[1].CssClass = "RedTextAlignCenter"; e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells[1].Width = new Unit("250px"); Label totallbl = new Label(); totallbl.Text = manualApplyFeeTotal.ToString("N"); e.Row.Cells[2].Controls.Add(totallbl); e.Row.Cells[2].CssClass = "RedTextAlignCenter"; e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right; e.Row.Cells[2].Width = new Unit("100px"); } }