protected virtual void Page_Load(object sender, EventArgs e) { if (this.userid > 0) { if (CheckUserPopedoms("X") || CheckUserPopedoms("6-7-9")) { subjectID = HTTPRequest.GetString("subjectID"); sType = HTTPRequest.GetInt("tid", 0); string dd = HTTPRequest.GetString("bDate"); string td = HTTPRequest.GetString("eDate"); 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; //获得日期 getYear = bDate.ToString("yyyy"); bTime = bDate.ToString("yyyy.MM"); eTime = eDate.ToString("yyyy.MM"); uiName = tbUserInfo.GetUserInfoModel(this.userid); oneMonth = Convert.ToInt32(bDate.ToString("MM")); status = HTTPRequest.GetInt("status", 0); result = subjectID.Split(','); for (int i = 0; i < result.Length - 1; i++) { //获得科目所选节点科目名称 fsubjectName = CostDetails.getObjectsListName(Convert.ToInt32(result[i])); //找到节点的所有父节点 fatherNode = DataClass.GetFeesSubjectClassParentStr(Convert.ToInt32(result[i]), "/"); //截取第一个节点 string[] getFirstNode = fatherNode.Split('/'); for (int pp = 0; pp < getFirstNode.Length; pp++) { className = getFirstNode[0].ToString(); } if (fsubjectName != null) { for (int p = 0; p < fsubjectName.Rows.Count; p++) { zNode = fsubjectName.Rows[p]["cClassName"].ToString(); classCode = fsubjectName.Rows[p]["cCode"].ToString(); classDirection = Convert.ToInt32(fsubjectName.Rows[p]["cDirection"].ToString()); } } //判断是否有子节点 tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i])); if (tl) { dataclass = CostDetails.getTreeChildrenCount(result[i]);//找到子节点 string[] dclass = dataclass.Split(','); for (int j = 0; j < dclass.Length - 1; j++) { //获得月份 mList = CostDetails.getMonthBySubjectAndDateTime(Convert.ToInt32(dclass[j]), bDate, eDate); mdt = mList.Copy(); mdt.TableName = "m_" + j + c_count; mds.Tables.Add(mdt); //获得最大月 maxList += CostDetails.getMonthBySubjectAndDateTime_Max(Convert.ToInt32(dclass[j]), bDate, eDate) + ","; //获得科目名称及编码 objectName = CostDetails.getSubjectNameAndID(Convert.ToInt32(dclass[j])); //上年结转余额 dList = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(dclass[j]), status); ydt = dList.Copy(); ydt.TableName = "y_" + j + c_count; yds.Tables.Add(ydt); c_count++; } //--====================================月份合成表============================================= msCost = mds.Tables[0].Clone(); //创建新表 克隆以有表的架构 object[] objmArray = new object[msCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值 for (int m = 0; m < mds.Tables.Count; m++) { if (mds.Tables[m].Rows.Count > 0) { for (int n = 0; n < mds.Tables[m].Rows.Count; n++) { mds.Tables[m].Rows[n].ItemArray.CopyTo(objmArray, 0); //将表的一行的值存放数组中 msCost.Rows.Add(objmArray); //将数组的值添加到新表中 } } } DataView dv = new DataView(msCost); dv.Sort = "oMonth"; nTable = dv.ToTable(true, "oMonth"); //==============上年结存余额合成一张表============================== ysCost = yds.Tables[0].Clone(); //创建新表 克隆以有表的架构 object[] objArray = new object[ysCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值 for (int m = 0; m < yds.Tables.Count; m++) { if (yds.Tables[m].Rows.Count > 0) { for (int n = 0; n < yds.Tables[m].Rows.Count; n++) { yds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中 ysCost.Rows.Add(objArray); //将数组的值添加到新表中 } } } if (ysCost.Rows.Count > 0) { ycAccountMoney = Convert.ToDecimal(ysCost.Compute("sum(cAccountMoney)", "").ToString()); } //找到科目中最大月 string[] maxListArrary = maxList.Split(','); for (int q = 0; q < maxListArrary.Length - 1; q++) { if (maxListArrary[q].ToString() != "") { int mValue = Convert.ToInt32(maxListArrary[q].ToString()); if (mValue > maxValue) { maxValue = mValue; } } } maxList = maxValue.ToString(); //明细账分页统计打印 for (int j = 0; j < dclass.Length - 1; j++) { //获得明细账打印明细 for (int mm = 0; mm < nTable.Rows.Count; mm++) { if (nTable.Rows.Count == 1) { dtCost = CostDetails.getMonthCost(Convert.ToInt32(dclass[j]), bDate, eDate, Convert.ToInt32(nTable.Rows[mm][0].ToString()), sType, status); } else { DataTable Cost = CostDetails.getMonthCost(Convert.ToInt32(dclass[j]), bDate, eDate, Convert.ToInt32(nTable.Rows[mm][0].ToString()), sType, status); DataTable dtm = Cost.Copy(); dtm.TableName = "rmdn_" + mm + j; dtms.Tables.Add(dtm); } } if (dtms.Tables.Count > 1) { qList = dtms.Tables[0].Clone(); //创建新表 克隆以有表的架构 object[] mArray = new object[qList.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值 for (int m = 0; m < dtms.Tables.Count; m++) { if (dtms.Tables[m].Rows.Count > 0) { for (int n = 0; n < dtms.Tables[m].Rows.Count; n++) { dtms.Tables[m].Rows[n].ItemArray.CopyTo(mArray, 0); //将表的一行的值存放数组中 qList.Rows.Add(mArray); //将数组的值添加到新表中 } } } } else { qList = dtCost.Copy(); } cdt = qList.Copy(); cdt.TableName = "cttr_" + j + tCount; cds.Tables.Add(cdt); tCount++; } csCost = cds.Tables[0].Clone(); //创建新表 克隆以有表的架构 object[] oArray = new object[csCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值 for (int m = 0; m < cds.Tables.Count; m++) { if (cds.Tables[m].Rows.Count > 0) { for (int n = 0; n < cds.Tables[m].Rows.Count; n++) { cds.Tables[m].Rows[n].ItemArray.CopyTo(oArray, 0); //将表的一行的值存放数组中 csCost.Rows.Add(oArray); //将数组的值添加到新表中 } } } if (csCost.Rows.Count > 0 && sType == 0) { DataView dvw = new DataView(csCost); dvw.Sort = "Cmonth"; csCost = dvw.ToTable(true, "Cmonth", "Cday", "CertificateID", "pzCode", "cdName", "cdMoney", "cdMoneyA", "cdMoneyB", "cdMoneyBB", "cDirection", "FeesSubjectID", "cClassName", "cCode"); } if (csCost != null) { detailsCount = csCost.Rows.Count; int p = 0; dt = csCost.Clone(); foreach (DataRow dr in csCost.Rows) { dt.ImportRow(dr); p++; if (p % MaxDetailsCount == 0) { dsDetails.Tables.Add(dt); dt = csCost.Clone(); dt.TableName = "q_" + p; } } if (dt.Rows.Count > 0) { //剩下的行数 dsDetails.Tables.Add(dt); dt = csCost.Clone(); dt.TableName = "t_" + (p + 1); } } dTable = dsDetails.Tables.Count; } else { //上年结转余额 ysCost = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(result[i]), status); //获得月份 nTable = CostDetails.getMonthBySubjectAndDateTime(Convert.ToInt32(result[i]), bDate, eDate); //获得最大月 maxList = CostDetails.getMonthBySubjectAndDateTime_Max(Convert.ToInt32(result[i]), bDate, eDate); //获得科目名称及编码 objectName = CostDetails.getSubjectNameAndID(Convert.ToInt32(result[i])); //获得明细账打印明细 for (int mm = 0; mm < nTable.Rows.Count; mm++) { if (nTable.Rows.Count == 1) { csCost = CostDetails.getMonthCost(Convert.ToInt32(result[i]), bDate, eDate, Convert.ToInt32(nTable.Rows[mm][0].ToString()), sType, status); } else { DataTable Cost = CostDetails.getMonthCost(Convert.ToInt32(result[i]), bDate, eDate, Convert.ToInt32(nTable.Rows[mm][0].ToString()), sType, status); DataTable dtm = Cost.Copy(); dtm.TableName = "rmd_" + mm; dtms.Tables.Add(dtm); } } if (dtms.Tables.Count > 1) { csCost = dtms.Tables[0].Clone(); //创建新表 克隆以有表的架构 object[] objmArray = new object[csCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值 for (int m = 0; m < dtms.Tables.Count; m++) { if (dtms.Tables[m].Rows.Count > 0) { for (int n = 0; n < dtms.Tables[m].Rows.Count; n++) { dtms.Tables[m].Rows[n].ItemArray.CopyTo(objmArray, 0); //将表的一行的值存放数组中 csCost.Rows.Add(objmArray); //将数组的值添加到新表中 } } } } if (csCost != null) { detailsCount = csCost.Rows.Count; int p = 0; dt = csCost.Clone(); foreach (DataRow dr in csCost.Rows) { dt.ImportRow(dr); p++; if (p % MaxDetailsCount == 0) { dsDetails.Tables.Add(dt); dt.TableName = "t_" + p; dt = csCost.Clone(); } } if (dt.Rows.Count > 0) { //剩下的行数 dsDetails.Tables.Add(dt); dt = csCost.Clone(); dt.TableName = "t_" + (p + 1); } } dTable = dsDetails.Tables.Count; } } } 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-9")) { //科目树 FeesSubjectJson = Caches.GetFeesSubjectClassInfoToJson(-1, false, true); bDate = (HTTPRequest.GetString("bDate").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("bDate").Trim()) : DateTime.Now.AddDays(-(DateTime.Now.Day) + 1); //获得日期 eDate = (HTTPRequest.GetString("eDate").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("eDate").Trim()) : DateTime.Now; //获得日期 sType = HTTPRequest.GetInt("seType", -1); //统计类型:0=明细统计,1=总账统计 getYear = bDate.ToString("yyyy"); oneMonth = Convert.ToInt32(bDate.ToString("MM")); status = HTTPRequest.GetInt("get_status", 0); //获得科目选择,遍历科目 fsubject = HTTPRequest.GetString("subject_hd"); result = fsubject.Split(','); if (ispost) { for (int i = 0; i < result.Length - 1; i++) { //获得科目所选节点科目名称 fsubjectName = CostDetails.getObjectsListName(Convert.ToInt32(result[i])); //判断是否有子节点 tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i])); if (tl) { dataclass = CostDetails.getTreeChildrenCount(result[i]); //找到子节点 string[] dclass = dataclass.Split(','); for (int j = 0; j < dclass.Length - 1; j++) { //获得月份 mList = CostDetails.getMonthBySubjectAndDateTime(Convert.ToInt32(dclass[j]), bDate, eDate); mdt = mList.Copy(); mdt.TableName = "m_" + j + c_count; mds.Tables.Add(mdt); //获得最大月 maxList += CostDetails.getMonthBySubjectAndDateTime_Max(Convert.ToInt32(dclass[j]), bDate, eDate) + ","; //获得科目名称及编码 objectName = CostDetails.getSubjectNameAndID(Convert.ToInt32(dclass[j])); //上年结转余额 dList = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(dclass[j]), status); ydt = dList.Copy(); ydt.TableName = "y_" + j + c_count; yds.Tables.Add(ydt); c_count++; } //--====================================月份合成表============================================= msCost = mds.Tables[0].Clone(); //创建新表 克隆以有表的架构 object[] objmArray = new object[msCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值 for (int m = 0; m < mds.Tables.Count; m++) { if (mds.Tables[m].Rows.Count > 0) { for (int n = 0; n < mds.Tables[m].Rows.Count; n++) { mds.Tables[m].Rows[n].ItemArray.CopyTo(objmArray, 0); //将表的一行的值存放数组中 msCost.Rows.Add(objmArray); //将数组的值添加到新表中 } } } DataView dv = new DataView(msCost); dv.Sort = "oMonth"; nTable = dv.ToTable(true, "oMonth"); //=====================上年结存余额合成一张表============================== ysCost = yds.Tables[0].Clone(); //创建新表 克隆以有表的架构 object[] objArray = new object[ysCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值 for (int m = 0; m < yds.Tables.Count; m++) { if (yds.Tables[m].Rows.Count > 0) { for (int n = 0; n < yds.Tables[m].Rows.Count; n++) { yds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中 ysCost.Rows.Add(objArray); //将数组的值添加到新表中 } } } if (ysCost.Rows.Count > 0) { ycAccountMoney = Convert.ToDecimal(ysCost.Compute("sum(cAccountMoney)", "").ToString()); } //====================找到科目中最大月======================================== string[] maxListArrary = maxList.Split(','); for (int q = 0; q < maxListArrary.Length - 1; q++) { if (maxListArrary[q].ToString() != "") { int mValue = Convert.ToInt32(maxListArrary[q].ToString()); if (mValue > maxValue) { maxValue = mValue; } } } maxList = maxValue.ToString(); } else { //上年结转余额 ysCost = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(result[i]), status); //获得月份 nTable = CostDetails.getMonthBySubjectAndDateTime(Convert.ToInt32(result[i]), bDate, eDate); //获得最大月 maxList = CostDetails.getMonthBySubjectAndDateTime_Max(Convert.ToInt32(result[i]), bDate, eDate); //获得科目名称及编码 objectName = CostDetails.getSubjectNameAndID(Convert.ToInt32(result[i])); } } } } else { AddErrLine("权限不足!"); } } else { AddErrLine("请先登录!"); SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); } }