Example #1
0
        private string GetShopID()
        {
            string    shopID = string.Empty;
            CListItem item   = this.cmbShopName.SelectedItem as CListItem;

            if (item != null)
            {
                shopID = item.Value;
            }
            return(shopID);
        }
 /// <summary>
 /// 设置下拉列表选中指定的值
 /// </summary>
 /// <param name="combo">下拉列表</param>
 /// <param name="value">指定的CListItem中的值</param>
 public static void SetComboBoxItem(this ComboBoxEdit combo, string value)
 {
     for (int i = 0; i < combo.Properties.Items.Count; i++)
     {
         CListItem item = combo.Properties.Items[i] as CListItem;
         if (item != null && item.Value == value)
         {
             combo.SelectedIndex = i;
         }
     }
 }
        /// <summary>
        /// 获取下拉列表的值
        /// </summary>
        /// <param name="combo">下拉列表</param>
        /// <returns></returns>
        public static string GetComboBoxValue(this ComboBoxEdit combo)
        {
            CListItem item = combo.SelectedItem as CListItem;

            if (item != null)
            {
                return(item.Value);
            }
            else
            {
                return("");
            }
        }
        private void txtFieldName_SelectedIndexChanged(object sender, EventArgs e)
        {
            CListItem item = txtFieldName.SelectedItem as CListItem;

            if (item == null || string.IsNullOrEmpty(item.Value))
            {
                return;
            }

            this.txtItem.Text = "";
            this.txtItem.Properties.Items.Clear();
            this.lstItems.Items.Clear();

            List <string> fileList = BLLFactory <ItemDetail> .Instance.GetFieldList(item.Value);

            this.txtItem.Properties.Items.AddRange(fileList.ToArray());

            this.ReportTitle         = string.Format("{0}统计报表", item.Text);
            this.lblReportTitle.Text = string.Format("{0}统计报表", item.Text);
        }
        private void BindData()
        {
            //设置报表标题
            this.Text = ReportTitle;
            this.lblReportTitle.Text = ReportTitle;
            this.xtraTabControl1.SelectedTabPageIndex = 0;

            #region 初始化图表内容
            this.chartPie.Series.Clear();
            this.chartBar.Series.Clear();

            string where = GetConditionSql();

            dt = DataTableHelper.CreateTable("argument,datavalue|int");
            DataRow   row;
            int       countRepeat = 0;
            CListItem fieldItem   = txtFieldName.SelectedItem as CListItem;
            if (fieldItem != null && !string.IsNullOrEmpty(fieldItem.Value) && this.lstItems.Items.Count > 0)
            {
                string fieldName  = fieldItem.Value;
                int    totalCount = BLLFactory <ItemDetail> .Instance.GetRecordCount(where);//计算总人数

                foreach (string searchItem in this.lstItems.Items)
                {
                    string condition = string.Format("{0} like '%{1}%' ", fieldName, searchItem);
                    if (!string.IsNullOrEmpty(where))
                    {
                        condition += string.Format(" AND {0}", where);
                    }

                    int countValue = BLLFactory <ItemDetail> .Instance.GetRecordCount(condition);//计算总人数

                    countRepeat += countValue;

                    row    = dt.NewRow();
                    row[0] = searchItem;
                    row[1] = countValue;
                    dt.Rows.Add(row);
                }

                //增加其他
                row    = dt.NewRow();
                row[0] = "其他";
                row[1] = totalCount - countRepeat;
                dt.Rows.Add(row);
            }
            else
            {
                MessageDxUtil.ShowTips("请选择统计字段和统计项目,然后才进行统计");
                return;
            }
            this.gridControl1.DataSource = dt;

            if (dt != null && dt.Rows.Count > 0)
            {
                this.chartPie.DataSource = dt;

                Series pieSeries = CreateSeries(dt, DevExpress.XtraCharts.ViewType.Pie3D, NumericFormat.Percent);
                chartPie.Series.Add(pieSeries);
                chartPie.Legend.Visible = true;

                PieSeriesLabel label = pieSeries.Label as PieSeriesLabel;
                ((PiePointOptions)label.PointOptions).PercentOptions.PercentageAccuracy = 4;
                ((PiePointOptions)label.PointOptions).PercentOptions.ValueAsPercent     = true;

                label.Position = PieSeriesLabelPosition.TwoColumns;                                         //设置饼图上lable的显示方式,此方式将独立出一个列显示lable
                (pieSeries.View as DevExpress.XtraCharts.Pie3DSeriesView).ExplodeMode = PieExplodeMode.All; //突出显示饼块
                (pieSeries.View as DevExpress.XtraCharts.Pie3DSeriesView).ExplodedDistancePercentage = 5;
                //(pieSeries.View as DevExpress.XtraCharts.PieSeriesView).RuntimeExploding = true; //设置了他,你就可以把你喜欢的饼块拖出来。。。

                this.chartBar.DataSource = dt;
                chartBar.Series.Add(CreateSeries(dt, DevExpress.XtraCharts.ViewType.Bar, NumericFormat.General));
                chartBar.Legend.Visible = false;
                chartBar.SeriesTemplate.LabelsVisibility = DefaultBoolean.True;
            }
            #endregion
        }