public FileNumberStatisticsStruct[] FileNumberStatistics(string AreaStr) { List <FileNumberStatisticsStruct> vResult = new List <FileNumberStatisticsStruct>(); string[] vAreaArray = AreaStr.Split('|'); foreach (string vTempArea in vAreaArray) { string[] vAreaSplit = vTempArea.Split(','); string vAreaCode = "", vAreaName = ""; if (vAreaSplit.Length == 2) { vAreaCode = vAreaSplit[0]; vAreaName = vAreaSplit[1]; string vSql = string.Format("Select count(*)From UploadFiles where AreaCode like '{0}%'", vAreaCode); DataTable vResultTable = m_BasicDBClass.SelectCustom(vSql); int vFileNumber = DBConvert.ToInt32(vResultTable.Rows[0][0]).Value; FileNumberStatisticsStruct vNewAreaResult = new FileNumberStatisticsStruct() { AreaCode = vAreaCode, UnitName = vAreaName, FileNumber = vFileNumber }; vResult.Add(vNewAreaResult); } } return(vResult.ToArray()); }
private void button_Statistics_Click(object sender, EventArgs e) { string vTitle = ""; string vAreaCodeStr = ""; string vTownshipValue = ((ComboBoxListItem)comboBox_Township.SelectedItem).Value; string vVillageCommitteeValue = ((ComboBoxListItem)comboBox_VillageCommittee.SelectedItem).Value; ComboBoxListItem vFatherItem = null; if (vTownshipValue == "0") { vTitle = "丰城市资料上传统计"; foreach (ComboBoxListItem vTempItem in comboBox_Township.Items) { if (vTempItem.Value != "0") { vAreaCodeStr += string.Format("{0},{1}|", vTempItem.Value, vTempItem.Name); } } } else if (vVillageCommitteeValue == "0") { vFatherItem = (ComboBoxListItem)comboBox_Township.SelectedItem; vTitle = string.Format("{0}资料上传统计", vFatherItem.Name); vAreaCodeStr = string.Format("{0},{1}|", vFatherItem.Value, vFatherItem.Name); foreach (ComboBoxListItem vTempItem in comboBox_VillageCommittee.Items) { if (vTempItem.Value != "0") { vAreaCodeStr += string.Format("{0},{1}|", vTempItem.Value, vTempItem.Name); } } } else { vFatherItem = (ComboBoxListItem)comboBox_VillageCommittee.SelectedItem; vTitle = string.Format("{0}资料上传统计", vFatherItem.Name); vAreaCodeStr = string.Format("{0},{1}|", vFatherItem.Value, vFatherItem.Name); ComboBoxListItem[] vVillageDict = getVillageDict(vVillageCommitteeValue); foreach (ComboBoxListItem vTempItem in vVillageDict) { vAreaCodeStr += string.Format("{0},{1}|", vTempItem.Value, vTempItem.Name); } } if (vAreaCodeStr != "") { vAreaCodeStr = vAreaCodeStr.Remove(vAreaCodeStr.Length - 1); RemoteInterface vRemoteInterface = new RemoteInterface(Program.LoginUserInfo.ID.Value, Program.LoginUserInfo.UserName, Program.LoginUserInfo.Token); var vStatisticsResut = vRemoteInterface.FileNumberStatistics(vAreaCodeStr).Where(m => m.FileNumber > 0); if (vTownshipValue != "0") { FileNumberStatisticsStruct vFatherData = vStatisticsResut.Where(m => m.AreaCode == vFatherItem.Value).FirstOrDefault(); if (vFatherData != null && vFatherData.FileNumber != 0) { int vSum = vStatisticsResut.Where(m => m.AreaCode != vFatherItem.Value).Sum(m => m.FileNumber); vFatherData.FileNumber -= vSum; } } //DataTable vTable = convertToDataTable(vStatisticsResut); if (vStatisticsResut.Count() > 0) { chart_Statistics.DataSource = vStatisticsResut; chart_Statistics.Series[0].XValueMember = "UnitName"; chart_Statistics.Series[0].YValueMembers = "FileNumber"; chart_Statistics.Titles[0].Text = vTitle; chart_Statistics.DataBind(); } else { chart_Statistics.DataSource = new DataTable(); chart_Statistics.Titles[0].Text = vTitle; chart_Statistics.DataBind(); MessageBox.Show("选择的行政区域没有上传资料", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { chart_Statistics.DataSource = new DataTable(); chart_Statistics.Titles[0].Text = vTitle; chart_Statistics.DataBind(); MessageBox.Show("选择的行政区域没有数据", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } }