Exemple #1
0
    /// <summary>
    /// 根据查询条件绑定数据
    /// </summary>
    /// <param name="xmmc"></param>
    /// <param name="num1"></param>
    /// <param name="danwei"></param>
    /// <param name="status"></param>
    /// <param name="time0"></param>
    /// <param name="time1"></param>
    public void BindData(String xmmc, String num1, String danwei,
                         String status, String time0, String time1, String status1, String Status2)
    {
        U_FASPBU bu1 = new U_FASPBU();

        this.GridView1.DataSource = bu1.GetShenPiListBySearchCondition(xmmc,
                                                                       num1, danwei, status, time0, time1, status1, Status2);
        this.GridView1.DataBind();
    }
Exemple #2
0
    //执行查询
    private void SearchData(SearchStruct info1)
    {
        this.SearchTable.Visible = false;
        this.SearchInfo.Visible  = true;

        U_FASPBU bu1 = new U_FASPBU();
        DataSet  ds1 = bu1.GetShenPiListBySearchCondition(info1);

        ////////////////////////////////////////////////////////
        DataTable[] ArrData = new DataTable[] { new DataTable(), new DataTable() };

        #region Code1
        ds1.Tables[0].Columns.Add("sort1");                 //增加排序列
        ds1.Tables[0].Columns.Add("Money1", typeof(Double));
        ds1.Tables[0].Columns.Add("money2", typeof(double));

        if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
        {
            //将查询结果的列写入Dt1和Dt2
            ArrayList colName = new ArrayList();
            foreach (DataColumn col1 in ds1.Tables[0].Columns)
            {
                DataColumn newCol1 = new DataColumn(col1.ColumnName, col1.DataType);
                DataColumn newCol2 = new DataColumn(col1.ColumnName, col1.DataType);

                ArrData[0].Columns.Add(newCol1);
                ArrData[1].Columns.Add(newCol2);
                colName.Add(col1.ColumnName);       //得到列的数组
            }

            //得到资产包的ID列表;
            ArrayList baozclist = this.GetZcbaoIDList();

            //将数据写入Dt1和Dt2
            //DataRow dr2=null;
            foreach (DataRow dr1 in ds1.Tables[0].Rows)
            {
                //设置Sort1的值
                String str1 = dr1["xmsbh"].ToString().Trim().Replace('-', '-');
                String str2 = null;
                if (str1.IndexOf('-') > 0)
                {
                    String temp1 = str1.Split('-')[0].PadLeft(5, '0');
                    String temp2 = str1.Split('-')[1].PadLeft(5, '0');
                    str2 = temp1 + "-" + temp2;
                }
                else
                {
                    str2 = str1.PadLeft(5, '0') + "-" + "00000";
                }

                str2         = str2 + "-" + dr1["num2"].ToString();
                dr1["sort1"] = str2;

                //将数据分别移到数据1表和数据2表
                int    i  = 0;
                String id = dr1["zcid"].ToString().Trim();
                if (baozclist.Contains(id))
                {
                    i = 1;
                }

                DataRow newdr = ArrData[i].NewRow();
                foreach (String m in colName)
                {
                    newdr[m] = dr1[m];
                }
                ArrData[i].Rows.Add(newdr);
            }
        }
        #endregion

        #region code2
        for (int i = 0; i < ArrData.Length; i++)
        {
            //分别计算合计的户数和数据
            if (ArrData[i] != null && ArrData[i].Rows.Count > 0)
            {
                ArrayList arr1 = new ArrayList();
                double    d1 = 0, d2 = 0, d3 = 0;
                foreach (DataRow dr1 in ArrData[i].Rows)
                {
                    String num2 = dr1["num2"].ToString().Trim();
                    if (String.IsNullOrEmpty(num2) == false)
                    {
                        if (arr1.Contains(num2) == false)
                        {
                            arr1.Add(num2);
                        }
                    }

                    /////////////////////////////////////////////////////
                    String temp = dr1["benjin"].ToString().Replace(",", "");
                    if (String.IsNullOrEmpty(temp))
                    {
                        temp = "0";
                    }
                    d1 = d1 + double.Parse(temp);

                    temp = dr1["lixi"].ToString().Replace(",", "");
                    if (String.IsNullOrEmpty(temp))
                    {
                        temp = "0";
                    }
                    d2 = d2 + double.Parse(temp);

                    temp = dr1["zqce"].ToString().Replace(",", "");
                    if (String.IsNullOrEmpty(temp))
                    {
                        temp = "0";
                    }
                    d3 = d3 + double.Parse(temp);
                }

                DataRow dr = ArrData[i].NewRow();
                ArrData[i].Rows.Add(dr);
                dr["status1"]  = DBNull.Value;
                dr["spstatus"] = "&nbsp;";
                dr["num2"]     = "&nbsp;";
                dr["xmmc"]     = "<center><b>合  计(" + arr1.Count + "户) </b></center>";
                dr["benjin"]   = d1.ToString();
                dr["lixi"]     = d2.ToString();
                dr["zqce"]     = d3.ToString();
                dr["sort1"]    = "ZZZZZ";
            }
        }
        #endregion code2

        //绑定数据
        DataView view1 = null;
        if (ArrData[0].Rows.Count + ArrData[1].Rows.Count > 0)
        {
            if (ArrData[0] == null || ArrData[0].Rows.Count == 0)
            {
                view1      = ArrData[1].DefaultView;
                view1.Sort = "sort1";
                this.GridView1.DataSource = view1;
                this.GridView1.DataBind();
            }
            else
            {
                view1      = ArrData[0].DefaultView;
                view1.Sort = "sort1";
                this.GridView1.DataSource = view1;
                this.GridView1.DataBind();

                view1      = ArrData[1].DefaultView;
                view1.Sort = "sort1";
                this.GridView2.DataSource = view1;
                this.GridView2.DataBind();
            }
        }

        //展开导航项
        Common_Master_Zcsp master1 = this.Master as Common_Master_Zcsp;
        if (master1 != null)
        {
            master1.SetShowMax();
        }
    }