Exemple #1
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-7-10"))
                {
                    //接收打印类型
                    sType = HTTPRequest.GetInt("dType", 0);

                    //接收日期参数
                    bDate = (HTTPRequest.GetString("bDate").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("bDate").Trim()) : DateTime.Now; //获得日期
                    eDate = (HTTPRequest.GetString("eDate").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("eDate").Trim()) : DateTime.Now; //获得日期
                    //页面日期格式转换
                    bTime  = bDate.ToString("yyyy.MM");
                    eTime  = eDate.ToString("yyyy.MM");
                    pTime  = pDate.ToString("yyyy.MM.dd");
                    uiName = tbUserInfo.GetUserInfoModel(this.userid);
                    status = HTTPRequest.GetInt("status", 0);

                    //1、时间打印
                    if (sType == 0)
                    {
                        //读出数据
                        kList = CostDetails.getFeeSubjectID(bDate, eDate);
                        if (kList.Rows.Count > 0)
                        {
                            DataSet ds = new DataSet();
                            for (int i = 0; i < kList.Rows.Count; i++)
                            {
                                DataTable dt = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(kList.Rows[i][0]), status);
                                dList           = dt.Copy();
                                dList.TableName = "t_" + i;
                                ds.Tables.Add(dList);
                            }

                            sCost = ds.Tables[0].Clone();                        //创建新表 克隆以有表的架构
                            object[] objArray = new object[sCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                            for (int m = 0; m < ds.Tables.Count; m++)
                            {
                                if (ds.Tables[m].Rows.Count > 0)
                                {
                                    for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                                    {
                                        ds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                        sCost.Rows.Add(objArray);                           //将数组的值添加到新表中
                                    }
                                }
                            }
                            if (sCost.Rows.Count > 0)
                            {
                                detailsCount = sCost.Rows.Count;
                                int p = 0;
                                dt = sCost.Clone();
                                foreach (DataRow dr in sCost.Rows)
                                {
                                    dt.ImportRow(dr);
                                    p++;
                                    if (p % MaxDetailsCount == 0)
                                    {
                                        dsDetails.Tables.Add(dt);
                                        dt.TableName = "t_" + p;
                                        dt           = sCost.Clone();
                                    }
                                }
                                if (dt.Rows.Count > 0)
                                {
                                    //剩下的行数
                                    dsDetails.Tables.Add(dt);
                                    dt           = sCost.Clone();
                                    dt.TableName = "t_" + (p + 1);
                                }
                            }
                            else
                            {
                                AddErrLine("无数据打印,请查询后再次打印数据!");
                            }
                        }
                        else
                        {
                            AddErrLine("未能获得科目编号!");
                        }
                    }

                    //2、科目打印
                    if (sType == 1)
                    {
                        //1.找到科目名称;
                        DataSet   classDataSet = new DataSet();
                        DataSet   ds           = new DataSet();
                        DataTable dt           = new DataTable();
                        getTreeNode = HTTPRequest.GetString("feeID");
                        result      = getTreeNode.Split(',');

                        //把选择的科目整理到dataset中
                        for (int i = 0; i < result.Length - 1; i++)
                        {
                            //--==================获得科目名称================
                            DataTable className = CostDetails.getClassName(result[i]);
                            DataTable ddt       = className.Copy();
                            ddt.TableName = "k" + i + c_count;
                            classDataSet.Tables.Add(ddt);
                            c_count++;
                        }

                        //-==========================合成科目名称表=============================
                        //把dataset中的datatable合并到一张表中
                        newTable = classDataSet.Tables[0].Clone();              //创建新表 克隆以有表的架构
                        object[] objArray = new object[newTable.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                        for (int m = 0; m < classDataSet.Tables.Count; m++)
                        {
                            if (classDataSet.Tables[m].Rows.Count > 0)
                            {
                                for (int n = 0; n < classDataSet.Tables[m].Rows.Count; n++)
                                {
                                    classDataSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                    newTable.Rows.Add(objArray);                                  //将数组的值添加到新表中
                                }
                            }
                        }
                        dsDetails.Tables.Add(newTable);
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-7-10"))
                {
                    bDate  = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("bDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("bDate"))) : DateTime.Now.AddDays(-(DateTime.Now.Day) + 1);
                    eDate  = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("eDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("eDate"))) : DateTime.Now;
                    sType  = HTTPRequest.GetInt("sType", 0);
                    status = HTTPRequest.GetInt("get_status", 0);//0=全部;1=已审核

                    if (ispost)
                    {
                        //按时间统计
                        if (sType == 0)
                        {
                            kList = CostDetails.getFeeSubjectID(bDate, eDate);
                            DataSet ds = new DataSet();
                            for (int i = 0; i < kList.Rows.Count; i++)
                            {
                                DataTable dt = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(kList.Rows[i][0]), status);
                                dList           = dt.Copy();
                                dList.TableName = "t_" + i;
                                ds.Tables.Add(dList);
                            }
                            if (ds.Tables.Count > 0)
                            {
                                sCost = ds.Tables[0].Clone();                        //创建新表 克隆以有表的架构
                                object[] objArray = new object[sCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                for (int m = 0; m < ds.Tables.Count; m++)
                                {
                                    if (ds.Tables[m].Rows.Count > 0)
                                    {
                                        for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                                        {
                                            ds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                            sCost.Rows.Add(objArray);                           //将数组的值添加到新表中
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //按科目统计
                    if (sType == 1)
                    {
                        DataSet classDataSet = new DataSet();
                        getTreeNode = HTTPRequest.GetString("get_treeNode");
                        result      = getTreeNode.Split(',');


                        //把选择的科目整理到dataset中
                        for (int i = 0; i < result.Length - 1; i++)
                        {
                            DataTable tr = CostDetails.getObjectsListName(Convert.ToInt32(result[i]));

                            if (tr != null)
                            {
                                for (int p = 0; p < tr.Rows.Count; p++)
                                {
                                    TreeName += tr.Rows[p][0].ToString() + ",";
                                }
                            }
                            else
                            {
                                TreeName = "";
                            }

                            //获得科目名称
                            DataTable className = CostDetails.getClassName(result[i]);

                            DataTable ddt = className.Copy();
                            ddt.TableName = "k" + i + c_count;
                            classDataSet.Tables.Add(ddt);
                            c_count++;
                        }
                        if (classDataSet.Tables.Count > 0)
                        {
                            //把dataset中的datatable合并到一张表中
                            newTable = classDataSet.Tables[0].Clone();              //创建新表 克隆以有表的架构
                            object[] objArray = new object[newTable.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                            for (int m = 0; m < classDataSet.Tables.Count; m++)
                            {
                                if (classDataSet.Tables[m].Rows.Count > 0)
                                {
                                    for (int n = 0; n < classDataSet.Tables[m].Rows.Count; n++)
                                    {
                                        classDataSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                        newTable.Rows.Add(objArray);                                  //将数组的值添加到新表中
                                    }
                                }
                            }
                            if (TreeName.Length > 2)
                            {
                                TreeName = TreeName.Substring(0, TreeName.Length - 1);
                            }
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }