dotnet webform下用grid做财务报表、仓库报表的实现小结

今天实在无聊,上午应朋友之约请半天假去喝茶聊天下午没事就回公司像老牛一样干活,偶然翻很久起以做的项目,翻过之后一阵感概:唉,又是一堆垃圾....(实在无耐,常常在项目结束后有这种感觉---太失败了)本人比较菜做的东东也不怎么样所以请高人莫笑...

财务报表中常见明细表都是很通俗易懂的,如在明细表中可以表现出相应的日汇总、月汇总、任一时间段的汇总
tt.jpg

仓库图:
t2.jpg

这个报表都是全部采用grid做的,原因是我比较讨厌asp中的tr/td/table/tr/td<%xxxx%>这种方式,同样也很讨厌asp.net里的<% =xx %>,这所以讨厌是后期维护特烦还有就是想把UI和业务分开...grid.datasource=ds;grid.databind();只要两句话就搞定了这种多省事啊

如何把上面的UI层的数据封装一个DataSet呢,这就是重点,其实也很简单无非是数据的分解和再组合的过程.熟悉DataSet对象的朋友应该慌然大悟了吧emsmiled.gif
下面贴出仓库报表的部分代码


 

ExpandedBlockStart.gif ContractedBlock.gif          /**/ /// <summary>
InBlock.gif        
/// 材料流水
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="vc_materialid">材料ID</param>
InBlock.gif        
/// <param name="isStandard">是否按国标数量</param>
InBlock.gif        
/// <param name="dt"></param>
ExpandedBlockEnd.gif        
/// <returns></returns>

ExpandedBlockStart.gif ContractedBlock.gif          public   int  stockpileList( string  vc_materialid, bool  isStandard, out  DataTable dt) dot.gif {
InBlock.gif            
if(isStandard)
InBlock.gif                strQuery
="SELECT c_plantype,vc_billtype,dec_standnumber,dec_standprice,dec_total,dt_billdate,vc_billcode  FROM sto_billmaterial WHERE vc_materialid='"+vc_materialid+"' ORDER BY dt_billdate ASC,c_plantype DESC,vc_billcode ASC";
InBlock.gif            
else
InBlock.gif                strQuery
="SELECT c_plantype,vc_billtype,dec_standnumber,dec_specprice,dec_total,dt_billdate,vc_billcode FROM sto_billmaterial WHERE vc_materialid='"+vc_materialid+"' ORDER BY dt_billdate ASC,c_plantype DESC,vc_billcode ASC";
InBlock.gif            
if(cadb==null)cadb=new DataBaseAccess.CADB();
InBlock.gif            
int j=cadb.getDataTable(strCon,strQuery,out dt,ref strErr);
ExpandedSubBlockStart.gifContractedSubBlock.gif            
if(j>0)dot.gif{
InBlock.gif                
//按报表格式添加出库&&结库部分的字段
InBlock.gif
                dt.Columns.Add("_standnumber",typeof(Decimal));
InBlock.gif                dt.Columns.Add(
"_standprice",typeof(Decimal));
InBlock.gif                dt.Columns.Add(
"_total",typeof(Decimal));
InBlock.gif                dt.Columns.Add(
"finallyNumber",typeof(Decimal));
InBlock.gif                dt.Columns.Add(
"finallyPrice",typeof(Decimal));
InBlock.gif                dt.Columns.Add(
"finallyTotal",typeof(Decimal));
InBlock.gif                
//定义交换变量
InBlock.gif
                decimal num,price,total,_num=0,_total=0;
InBlock.gif                
string direction;//单据方向
ExpandedSubBlockStart.gifContractedSubBlock.gif
                for(int i=0;i<j;i++)dot.gif{
InBlock.gif                    direction
=dt.Rows[i][0].ToString().Trim();
InBlock.gif                    num
=Convert.ToDecimal(dt.Rows[i]["dec_standnumber"].ToString());
InBlock.gif                    price
=Convert.ToDecimal(dt.Rows[i]["dec_standprice"].ToString());
InBlock.gif                    total
=Convert.ToDecimal(dt.Rows[i]["dec_total"].ToString());
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
if(direction=="出库")dot.gif{
InBlock.gif                        dt.Rows[i][
"_standnumber"]=num;
InBlock.gif                        dt.Rows[i][
"_standprice"]=price;
InBlock.gif                        dt.Rows[i][
"_total"]=total;
InBlock.gif                        dt.Rows[i][
"dec_standnumber"]=DBNull.Value;
InBlock.gif                        dt.Rows[i][
"dec_standprice"]=DBNull.Value;
InBlock.gif                        dt.Rows[i][
"dec_total"]=DBNull.Value;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockStart.gifContractedSubBlock.gif                    
if(i==0)dot.gif{
InBlock.gif                        dt.Rows[
0]["finallyNumber"]=num;
InBlock.gif                        dt.Rows[
0]["finallyPrice"]=price;
InBlock.gif                        dt.Rows[
0]["finallyTotal"]=total;
InBlock.gif                        
//计算结存数量
InBlock.gif
                        _num=num;
InBlock.gif                        _total
=total;
ExpandedSubBlockStart.gifContractedSubBlock.gif                    }
elsedot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
if(direction=="出库")dot.gif{
InBlock.gif                            dt.Rows[i][
"finallyNumber"]=_num-num;
InBlock.gif                            dt.Rows[i][
"finallyPrice"]=(_total-total)==0?0:(_total-total)/(_num-num);
InBlock.gif                            dt.Rows[i][
"finallyTotal"]=(_total-total);
InBlock.gif                            
//计算结存数量    
InBlock.gif
                            _num=_num-num;
InBlock.gif                            _total
=_total-total;
ExpandedSubBlockStart.gifContractedSubBlock.gif                        }
elsedot.gif{
InBlock.gif                            dt.Rows[i][
"finallyNumber"]=num;
InBlock.gif                            dt.Rows[i][
"finallyPrice"]=price;
InBlock.gif                            dt.Rows[i][
"finallyTotal"]=total;
InBlock.gif                            
//计算结存数量    
InBlock.gif
                            _num=_num+num;
InBlock.gif                            _total
=_total+total;
ExpandedSubBlockEnd.gif                        }

ExpandedSubBlockEnd.gif                    }

InBlock.gif
ExpandedSubBlockEnd.gif                }

InBlock.gif                dt.Columns.Remove(
"c_plantype");
InBlock.gif                dt.AcceptChanges();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
return j;
ExpandedBlockEnd.gif        }

None.gif

呵呵,其实就这么简单

 

 

 

 

 

转载于:https://www.cnblogs.com/floerggyy/archive/2004/12/16/78059.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值