zoukankan      html  css  js  c++  java
  • C# 实现动态添加列,新增合计行,求和

     

       DataTable da = CommonBLL.GetList("*", "sys_dict", "IfState=1 and DictTypeId=14");
    
                string strField = "CACCNUM as 账号账号,Loannumber as 借据号,BILLDATE as 借款时间,CAName as 借款人姓名,CPOSITION as 质押商品房位置,LoanAmount as 借款总额,";
                for (int i = 0; i < da.Rows.Count; i++)
                {
                    strField += " case when xqName ='" + da.Rows[i]["DictName"].ToString() + "' then  LoanAmount else  null end as " + da.Rows[i]["DictName"].ToString() + "_借款总额,";
                }
                strField += "Rateval as 年利率,Endratedata as 到期时间,CTEL 借款人固定电话,CMOBILE as 借款人手机号,CSSNUMBER as 身份证号,CADDRESS as 住址,CWORK as 所在单位,Realtor as 售楼员,Proportion as 首付比例,RepayAmountSum as 己还本金合计,";
                for (int i = 0; i < da.Rows.Count; i++)
                {
                    strField += " case when xqName ='" + da.Rows[i]["DictName"].ToString() + "' then  RepayAmountSum else  null end as " + da.Rows[i]["DictName"].ToString() + "_己还本金合计,";
                }
                strField += "RepayRateSum as 已清利息合计,";
                for (int i = 0; i < da.Rows.Count; i++)
                {
                    strField += " case when xqName ='" + da.Rows[i]["DictName"].ToString() + "' then  RepayRateSum else  null end as " + da.Rows[i]["DictName"].ToString() + "_已清利息合计,";
                }
                strField += "RepaySum as 本息合计,SurplusSum as 剩余本金合计 ,";
                for (int i = 0; i < da.Rows.Count; i++)
                {
                    strField += " case when xqName ='" + da.Rows[i]["DictName"].ToString() + "' then  SurplusSum else  null end as " + da.Rows[i]["DictName"].ToString() + "_剩余本金合计,";
                }
                strField += "Repay as 已还清";
                DataTable dt = JZCard.BLL.CommonBLL.GetList(strField, "v_finance_billloan_list", _strWhere);
                decimal JkHj = Commons.ParseDecimalValue(dt.Compute("sum(借款总额)", ""));
                decimal YHBJHJ = Commons.ParseDecimalValue(dt.Compute("sum(己还本金合计)", ""));
                decimal YQLXHJ = Commons.ParseDecimalValue(dt.Compute("sum(已清利息合计)", ""));
                decimal BXHJ = Commons.ParseDecimalValue(dt.Compute("sum(本息合计)", ""));
                decimal SYBXHJ = Commons.ParseDecimalValue(dt.Compute("sum(剩余本金合计)", ""));
                
                DataRow dr = dt.NewRow();
                dr["账号账号"] = "合计";
                dr["借款总额"] = JkHj;
                dr["己还本金合计"] = YHBJHJ;
                dr["已清利息合计"] = YQLXHJ;
                dr["本息合计"] = BXHJ;
                dr["剩余本金合计"] = SYBXHJ;
    
                dt.Rows.Add(dr);
                // c#如何设置DataGridView的自动创建列
                this.dg_BillLoanList.AutoGenerateColumns = true;
               
                this.dg_BillLoanList.DataSource = dt;
  • 相关阅读:
    二进制,八进制,十进制,十六进制之间的转换
    using关键字的使用
    简单工厂和单例设计模式
    面向对象的七种设计原则
    第六章 初始继承和多态
    第五章项目:体检套餐管理系统
    第二章《深入C#数据类型》项目经理评分
    <<MySchool数据库设计优化>> 内部测试
    Python 日志处理(一) 按Nginx log_format 分割日志记录
    Python 爬虫练习(一) 爬取国内代理ip
  • 原文地址:https://www.cnblogs.com/rwh871212/p/4984040.html
Copyright © 2011-2022 走看看