Exemplo n.º 1
0
        private void DgBind()
        {
            string strAssType = cmbAssType.Text.Trim();

            if (strAssType == "全部")
            {
                strAssType = "";
            }
            else
            {
                strAssType = this.GetColEn(strAssType, "AT");
            }

            string strGoodsType = cmbGoodsType.Text.Trim();

            if (strGoodsType == "全部")
            {
                strGoodsType = "";
            }
            else
            {
                strGoodsType = this.GetColEn(strGoodsType, "GT");
            }
            string strBegin  = dtpBegin.Value.ToShortDateString() + " 00:00:00";
            string strEnd    = dtpEnd.Value.ToShortDateString() + " 23:59:59";
            string strDeptID = this.cmbDept.Text.Trim();

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

            htPara.Add("strAssType", strAssType);
            htPara.Add("strGoodsType", strGoodsType);
            htPara.Add("strBegin", strBegin);
            htPara.Add("strEnd", strEnd);
            htPara.Add("strDeptID", strDeptID);

            Exception err      = null;
            DataTable dt       = new DataTable();
            string    strType1 = "";

            if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked == true)
            {
                //dt=cs.GetConsItemQuery(htPara,out err);
                //strType1="0";
                return;
            }
            if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked == false)
            {
                dt       = cs.GetConsItemQuery1(htPara, out err);
                strType1 = "1";
            }
            if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked == false)
            {
                dt       = cs.GetConsItemQuery2(htPara, out err);
                strType1 = "2";
            }
            if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == true)
            {
                dt       = cs.GetConsItemQuery3(htPara, out err);
                strType1 = "3";
            }
            if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked == true)
            {
                dt       = cs.GetConsItemQuery4(htPara, out err);
                strType1 = "4";
            }
            if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked == false)
            {
                dt       = cs.GetConsItemQuery5(htPara, out err);
                strType1 = "5";
            }
            if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked == true)
            {
                dt       = cs.GetConsItemQuery6(htPara, out err);
                strType1 = "6";
            }
            if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false)
            {
                //dt=cs.GetConsItemQuery(htPara,out err);
                //strType1="0";
                return;
            }

            if (dt != null && dt.Rows.Count >= 0)
            {
                int    iCount = 0;
                double dFee   = 0;
                double dRate  = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    iCount += int.Parse(dt.Rows[i]["tolcount"].ToString());
                    dFee   += double.Parse(dt.Rows[i]["tolfee"].ToString());
                    dRate  += double.Parse(dt.Rows[i]["tolrate"].ToString());
                }
                txtCount.Text              = iCount.ToString();
                txtFee.Text                = Math.Round(dFee, 2).ToString();
                txtTolRate.Text            = Math.Round(dRate, 2).ToString();
                this.dataGrid1.CaptionText = "会员消费分类统计报表";
                this.dataGrid1.SetDataBinding(dt, "");
                if (strType1 == "0")
                {
                    this.DataTableConvert(dt, "vcAssType", "AT", "vcCommCode", "vcCommName");
                    this.DataTableConvert(dt, "vcDeptID", "MD", "vcCommCode", "vcCommName");
                    this.EnToCh("门店,会员类型,商品类型,商品名称,数量合计,金额合计,折扣合计", "100,100,100,100,100,100", dt, this.dataGrid1);
                }
                if (strType1 == "1")
                {
                    this.DataTableConvert(dt, "vcDeptID", "MD", "vcCommCode", "vcCommName");
                    this.EnToCh("门店,商品名称,数量合计,金额合计,折扣合计", "100,100,100,100", dt, this.dataGrid1);
                }
                if (strType1 == "2")
                {
                    this.DataTableConvert(dt, "vcAssType", "AT", "vcCommCode", "vcCommName");
                    this.EnToCh("会员类型,商品类型,数量合计,金额合计,折扣合计", "100,100,100,100", dt, this.dataGrid1);
                }
                if (strType1 == "3")
                {
                    this.EnToCh("商品类型,商品名称,数量合计,金额合计,折扣合计", "100,100,100,100", dt, this.dataGrid1);
                }
                if (strType1 == "4")
                {
                    this.DataTableConvert(dt, "vcAssType", "AT", "vcCommCode", "vcCommName");
                    this.EnToCh("会员类型,商品类型,商品名称,数量合计,金额合计,折扣合计", "100,100,100,100,100", dt, this.dataGrid1);
                }
                if (strType1 == "5")
                {
                    this.DataTableConvert(dt, "vcDeptID", "MD", "vcCommCode", "vcCommName");
                    this.DataTableConvert(dt, "vcAssType", "AT", "vcCommCode", "vcCommName");
                    this.EnToCh("门店,会员类型,商品名称,数量合计,金额合计,折扣合计", "100,100,100,100,100", dt, this.dataGrid1);
                }
                if (strType1 == "6")
                {
                    this.DataTableConvert(dt, "vcDeptID", "MD", "vcCommCode", "vcCommName");
                    this.EnToCh("门店,商品类型,商品名称,数量合计,金额合计,折扣合计", "100,100,100,100,100", dt, this.dataGrid1);
                }
                if (dt.Rows.Count > 0)
                {
                    this.sbtnExcel.Enabled = true;
                }
                else
                {
                    this.sbtnExcel.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show("查询出错,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                if (err != null)
                {
                    clog.WriteLine(err);
                }
            }
        }