private void dgCostCash_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.Item: case ListItemType.AlternatingItem: UserControls.ExchangeRateControl ud_ucExchangeRate = (UserControls.ExchangeRateControl)e.Item.FindControl("ucExchangeRate"); DataRowView ud_drvItem = (DataRowView)e.Item.DataItem; if (ud_drvItem["MoneyType"].ToString() != "") { ud_ucExchangeRate.Amount = ud_drvItem["Amount"].ToString(); ud_ucExchangeRate.UnitPrise = ud_drvItem["UnitPrise"].ToString(); ud_ucExchangeRate.MoneyType = ud_drvItem["MoneyType"].ToString(); ud_ucExchangeRate.ExchangeRate = ud_drvItem["ExchangeRate"] == DBNull.Value ? Decimal.Zero:Decimal.Parse(ud_drvItem["ExchangeRate"].ToString()); } //try //{ // ud_ucExchangeRate.Amount = ud_drvItem["Amount"].ToString(); // ud_ucExchangeRate.UnitPrise = ud_drvItem["UnitPrise"].ToString(); //} //catch { } ud_ucExchangeRate.Cash = ud_drvItem["Cash"] == DBNull.Value ? Decimal.Zero : Decimal.Parse(ud_drvItem["Cash"].ToString()); ud_ucExchangeRate.IsShowTitle = false; ud_ucExchangeRate.EditMode = true; ud_ucExchangeRate.BindControl(); break; case ListItemType.Footer: ((Label)e.Item.FindControl("lblSumCashMoney")).Text = ((decimal)ViewState["_" + this.ContractCostCode + "SumCashMoney"]).ToString("N"); break; } }
private void dgCostList_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.Header: break; case ListItemType.Item: case ListItemType.AlternatingItem: string ud_sProjectCode = Request["ProjectCode"] + ""; UserControls.ExchangeRateControl ud_ucExchangeRate = (UserControls.ExchangeRateControl)e.Item.FindControl("ucExchangeRate"); UserControls.InputCostBudgetDtl ud_ucCostBudgetDtl = (UserControls.InputCostBudgetDtl)e.Item.FindControl("ucCostBudgetDtl"); WebNumericEdit ud_txtCostTotalChangeCash = (WebNumericEdit)e.Item.FindControl("txtCostTotalChangeCash"); DataRowView ud_drvItem = (DataRowView)e.Item.DataItem; ud_ucCostBudgetDtl.ProjectCode = ud_sProjectCode; ud_txtCostTotalChangeCash.Enabled = false; ud_ucExchangeRate.IsShowTitle = false; ud_ucExchangeRate.IsAllowCashChange = false; ud_ucExchangeRate.Cash = BLL.ConvertRule.ToDecimal(ud_drvItem["Cash"]); if (ud_drvItem["MoneyType"].ToString() != "") { ud_ucExchangeRate.ExchangeRate = BLL.ConvertRule.ToDecimal(ud_drvItem["ExchangeRate"]); ud_ucExchangeRate.MoneyType = ud_drvItem["MoneyType"].ToString(); } if (HttpUtility.HtmlDecode(e.Item.Cells[1].Text).Trim() != "") { ((UserControls.InputCostBudgetDtl)e.Item.FindControl("ucCostBudgetDtl")).Enable = false; ud_ucExchangeRate.EditMode = false; } else { ((UserControls.InputCostBudgetDtl)e.Item.FindControl("ucCostBudgetDtl")).Enable = true; ud_ucExchangeRate.EditMode = true; } ud_ucExchangeRate.BindControl(); break; case ListItemType.Footer: //显示合计金额 ((Label)e.Item.FindControl("lblSumCostOriginalMoney")).Text = BLL.MathRule.GetDecimalShowString(ViewState["SumCostOriginalMoney"]); ((Label)e.Item.FindControl("lblSumCostTotalChangeMoney")).Text = BLL.MathRule.GetDecimalShowString(ViewState["SumCostTotalChangeMoney"]); ((Label)e.Item.FindControl("lblSumCostChangeMoney")).Text = BLL.MathRule.GetDecimalShowString(ViewState["SumCostChangeMoney"]); ((Label)e.Item.FindControl("lblSumCostNewMoney")).Text = BLL.MathRule.GetDecimalShowString(ViewState["SumCostNewMoney"]); break; default: break; } }
private void gvPaymentDetail_DataBound(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.DataRow: UserControls.ExchangeRateControl ud_ucExchangeRate = (UserControls.ExchangeRateControl)e.Row.FindControl("ucExchangeRate"); DataRowView ud_drvItem = (DataRowView)e.Row.DataItem; ud_ucExchangeRate.Cash = BLL.ConvertRule.ToDecimal(ud_drvItem["ItemCash0"]); ud_ucExchangeRate.ExchangeRate = BLL.ConvertRule.ToDecimal(ud_drvItem["ExchangeRate"]); ud_ucExchangeRate.MoneyType = ud_drvItem["MoneyType"].ToString(); ud_ucExchangeRate.IsShowTitle = false; ud_ucExchangeRate.EditMode = false; ud_ucExchangeRate.BindControl(); break; } }
/// <summary> /// 把数据保存到内存表中 /// </summary> private void SaveToMemory() { if (!IsEditMode) { return; } int counts = DataGrid1.Items.Count; Decimal sum = 0; for (int i = 0; i < counts; i++) { UserControls.ExchangeRateControl dt_ExchangeRateControl = (UserControls.ExchangeRateControl)DataGrid1.Items[i].FindControl("ExchangeRateControl1"); CashTable.Rows[i]["MoneyType"] = dt_ExchangeRateControl.MoneyType; CashTable.Rows[i]["ExchangeRate"] = dt_ExchangeRateControl.ExchangeRate; CashTable.Rows[i]["MoneyTypeID"] = dt_ExchangeRateControl.MoneyTypeValue; CashTable.Rows[i]["Cash"] = dt_ExchangeRateControl.Cash; CashTable.Rows[i]["RMB"] = dt_ExchangeRateControl.RMB; sum += Convert.ToDecimal(CashTable.Rows[i]["RMB"]); } this.divTotalMoney.InnerHtml = BLL.MathRule.GetDecimalShowString(sum.ToString()); }
private string SaveToSession() { string alertMsg = ""; try { string contractCode = this.txtContractCode.Value; string projectCode = Request["ProjectCode"] + ""; EntityData entity = ReadEntitySession(); string contractLabel = txtContractChangeCode.Value; //合同变更基本信息 entity.SetCurrentTable("ContractChange"); foreach (DataRow dr in entity.CurrentTable.Select(String.Format("ContractChangeCode='{0}'", contractLabel), "", DataViewRowState.CurrentRows)) { dr["Voucher"] = txtVoucher.Value; dr["ContractChangeId"] = txtChangeId.Value; dr["ChangeReason"] = txtChangeReason.Value; dr["SupplierChangeMoney"] = txtSupplierChangeMoney.ValueDecimal; dr["ConsultantAuditMoney"] = txtConsultantAuditMoney.ValueDecimal; dr["ProjectAuditMoney"] = txtProjectAuditMoney.ValueDecimal; dr["ChangeType"] = this.ddlChangeType.SelectedItem.Value; } //款项明细 entity.SetCurrentTable("ContractCostChange"); foreach (DataGridItem li in this.dgCostList.Items) { string contractCostChangeCode = li.Cells[0].Text; string contractCostCode = HttpUtility.HtmlDecode(li.Cells[1].Text).Trim(); UserControls.InputCostBudgetDtl ucCostBudgetDtl = (UserControls.InputCostBudgetDtl)li.FindControl("ucCostBudgetDtl"); UserControls.ExchangeRateControl ud_ucExchangeRate = (UserControls.ExchangeRateControl)li.FindControl("ucExchangeRate"); WebNumericEdit txtCostChangeCash = (WebNumericEdit)li.FindControl("txtCostChangeCash"); HtmlInputText txtDescription = (HtmlInputText)li.FindControl("txtDescription"); foreach (DataRow dr in entity.CurrentTable.Select(String.Format("ContractCostChangeCode='{0}'", contractCostChangeCode), "", DataViewRowState.CurrentRows)) { decimal ud_deCostCash, ud_deCostOriginalCash, ud_deCostTotalChangeCash, ud_deCostChangeCash, ud_deCostNewCash, ud_deExchangeRate; decimal ud_deCostMoney, ud_deCostOriginalMoney, ud_deCostTotalChangeMoney, ud_deCostChangeMoney, ud_deCostNewMoney; ud_deCostCash = (decimal)dr["Cash"]; ud_deCostOriginalCash = (decimal)dr["OriginalCash"]; ud_deCostTotalChangeCash = (decimal)dr["TotalChangeCash"]; ud_deCostMoney = (decimal)dr["Money"]; ud_deCostOriginalMoney = (decimal)dr["OriginalMoney"]; ud_deCostTotalChangeMoney = (decimal)dr["TotalChangeMoney"]; ud_deCostChangeCash = txtCostChangeCash.ValueDecimal; ud_deExchangeRate = ud_ucExchangeRate.ExchangeRate; ud_deCostNewCash = ud_deCostOriginalCash + ud_deCostTotalChangeCash + ud_deCostChangeCash; ud_deCostNewMoney = ud_deCostNewCash * ud_deExchangeRate; ud_deCostChangeMoney = ud_deCostChangeCash * ud_deExchangeRate; dr["ChangeCash"] = ud_deCostChangeCash; dr["NewCash"] = ud_deCostNewCash; dr["ChangeMoney"] = ud_deCostChangeMoney; dr["NewMoney"] = ud_deCostNewMoney; dr["Description"] = txtDescription.Value; if (contractCostCode == "") { dr["CostCode"] = ucCostBudgetDtl.CostCode; dr["CostBudgetSetCode"] = ucCostBudgetDtl.CostBudgetSetCode; dr["PBSType"] = ucCostBudgetDtl.PBSType; dr["PBSCode"] = ucCostBudgetDtl.PBSCode; dr["MoneyType"] = ud_ucExchangeRate.MoneyType; dr["ExchangeRate"] = ud_ucExchangeRate.ExchangeRate; } } } WriteEntitySession(entity); entity.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "保存Session出错:" + ex.Message)); } return(alertMsg); }
public string SaveToSession() { string alertMsg = ""; try { string projectCode = Request["ProjectCode"] + ""; EntityData entity = ReadEntitySession(); decimal ud_deCostMoney = Decimal.Zero; //保存币种金额 foreach (DataGridItem ud_dgItem in dgCostCash.Items) { string contractCostCashCode = ud_dgItem.Cells[1].Text; foreach (DataRow dr in entity.Tables["ContractCostCash"].Select(String.Format("ContractCostCashCode='{0}'", contractCostCashCode))) { UserControls.ExchangeRateControl ud_ucExchangeRate = (UserControls.ExchangeRateControl)ud_dgItem.FindControl("ucExchangeRate"); decimal ud_deCash = ud_ucExchangeRate.Cash; decimal ud_deMoney = ud_deCash * ud_ucExchangeRate.ExchangeRate; try { dr["amount"] = ud_ucExchangeRate.Amount; } catch { } try { dr["UnitPrise"] = ud_ucExchangeRate.UnitPrise; } catch { } dr["Cash"] = ud_deCash; dr["MoneyType"] = ud_ucExchangeRate.MoneyType; dr["ExchangeRate"] = ud_ucExchangeRate.ExchangeRate; dr["Money"] = ud_deMoney; ud_deCostMoney += ud_deMoney; } } //保存款项明细 foreach (DataRow dr in entity.Tables["ContractCost"].Select(String.Format("ContractCostCode='{0}'", this.ContractCostCode))) { //try //{ // dr["amount"] = ucCostBudgetDtl.Amount; //} //catch { } //try //{ // dr["UnitPrise"] = ucCostBudgetDtl.UnitPrise; //} //catch { } dr["CostCode"] = ucCostBudgetDtl.CostCode; dr["CostBudgetSetCode"] = ucCostBudgetDtl.CostBudgetSetCode; dr["PBSType"] = ucCostBudgetDtl.PBSType; dr["PBSCode"] = ucCostBudgetDtl.PBSCode; dr["Description"] = txtDescription.Text.Trim(); dr["Money"] = ud_deCostMoney; } //保存付款计划 foreach (DataGridItem ud_dgItem in dgCostPlan.Items) { string contractCostPlanCode = ud_dgItem.Cells[1].Text; string planningPayDate = ((AspWebControl.Calendar)ud_dgItem.FindControl("dtPlanningPayDate")).Value; string payConditionText = ((HtmlInputText)ud_dgItem.FindControl("txtPayConditionText")).Value.Trim(); WebNumericEdit txtMoney = (WebNumericEdit)ud_dgItem.FindControl("txtMoney"); foreach (DataRow dr in entity.Tables["ContractCostPlan"].Select(String.Format("ContractCostPlanCode='{0}'", contractCostPlanCode))) { dr["Money"] = txtMoney.ValueDecimal; dr["PayConditionText"] = payConditionText; if (planningPayDate != "") { dr["PlanningPayDate"] = planningPayDate; } else { dr["PlanningPayDate"] = System.DBNull.Value; } } } WriteEntitySession(entity); entity.Dispose(); return(alertMsg); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "明细保存出错:" + ex.Message)); throw ex; } }