Пример #1
0
        private void DgBind()
        {
            string strBegin = dtpBegin.Value.Year.ToString();

            if (dtpBegin.Value.Month < 10)
            {
                strBegin += "0" + dtpBegin.Value.Month.ToString();
            }
            else
            {
                strBegin += dtpBegin.Value.Month.ToString();
            }
            if (dtpBegin.Value.Day < 10)
            {
                strBegin += "0" + dtpBegin.Value.Day.ToString();
            }
            else
            {
                strBegin += dtpBegin.Value.Day.ToString();
            }

            string strEnd = dtpEnd.Value.Year.ToString();

            if (dtpEnd.Value.Month < 10)
            {
                strEnd += "0" + dtpEnd.Value.Month.ToString();
            }
            else
            {
                strEnd += dtpEnd.Value.Month.ToString();
            }
            if (dtpEnd.Value.Day < 10)
            {
                strEnd += "0" + dtpEnd.Value.Day.ToString();
            }
            else
            {
                strEnd += dtpEnd.Value.Day.ToString();
            }

            this.label1.Text = strBegin + strEnd;

            string strDeptID = this.cmbDept.Text.Trim();

            this.label2.Text = strDeptID;

            if (strDeptID == "全部")
            {
                strDeptID = "%%";
            }
            else
            {
                strDeptID = this.GetColEn(strDeptID, "MD");
            }

            Exception err = null;
            DataTable dt  = new DataTable();

            dt = ca.BusiIncomeReport(strDeptID, strBegin, strEnd, out err);
            if (dt != null && dt.Rows.Count >= 0)
            {
                this.dgStyle();
                if (strDeptID == "%%")
                {
                    this.dataGrid1.CaptionText = SysInitial.CP + "业务量报表--所有门店";
                }
                else
                {
                    this.dataGrid1.CaptionText = SysInitial.CP + "业务量报表--" + this.cmbDept.Text.Trim();
                }
                DataTable dtnew = this.ReportConvert(dt);
                this.dataGrid1.ColumnHeadersVisible = false;
                this.dataGrid1.RowHeadersVisible    = false;
                this.dataGrid1.SetDataBinding(dtnew, "");

                if (dt.Rows.Count > 0)
                {
                    this.sbtnExcel.Enabled = true;
                    this.sbtnPrint.Enabled = true;
                }
                else
                {
                    this.sbtnExcel.Enabled = false;
                    this.sbtnPrint.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show("业务量报表统计出错,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                if (err != null)
                {
                    clog.WriteLine(err);
                }
            }
        }