public DataTable GetMaterialOfDepositoryList(string depositoryId, string strWhere) { DataTable materialOfDepositoryList = new DataTable(); if (depositoryId != "") { materialOfDepositoryList = AllocationAction.GetMaterialOfDepositoryList(depositoryId, strWhere); } return(materialOfDepositoryList); }
protected void btnBind_ServerClick(object sender, EventArgs e) { this.UpdateDataSource(); DataTable dataTable = this.ViewState["DataTable"] as DataTable; DataTable materialOfDepositoryList = AllocationAction.GetMaterialOfDepositoryList(this.HdnSelectOutDepo.Value, this.HdnViewCodeList.Value); DataColumn dataColumn = new DataColumn("Total", typeof(decimal)); dataColumn.DefaultValue = 0m; materialOfDepositoryList.Columns.Add(dataColumn); if (dataTable != null && materialOfDepositoryList != null) { if (dataTable.Rows.Count == 1 && string.IsNullOrEmpty(dataTable.Rows[0]["scode"].ToString())) { dataTable.Rows.RemoveAt(0); } dataTable.PrimaryKey = new DataColumn[] { dataTable.Columns["scode"], dataTable.Columns["sprice"], dataTable.Columns["corp"] }; materialOfDepositoryList.PrimaryKey = new DataColumn[] { materialOfDepositoryList.Columns["scode"], materialOfDepositoryList.Columns["sprice"], materialOfDepositoryList.Columns["corp"] }; dataTable.Merge(materialOfDepositoryList, true); this.ViewState["DataTable"] = dataTable; } if (dataTable.Rows.Count > 0) { this.GVMaterialList.DataSource = dataTable; this.GVMaterialList.DataBind(); string total = Convert.ToDecimal(dataTable.Compute("SUM(Total)", string.Empty)).ToString("0.000"); GridViewUtility.AddTotalRow(this.GVMaterialList, total, 12); return; } this.GVMaterialList.DataSource = dataTable; this.GVMaterialList.DataBind(); }