示例#1
0
    public static void BindData(DataTable _rptData, GridPanel _gp, Store _store)
    {
        // remove old data and record set

        _store.Reader.Clear();

        _gp.SelectionModel.Clear();

        _gp.ColumnModel.Columns.Clear();

        if (_rptData == null)
        {
            _gp.Render();
            return;
        }
        //_store.Model.Clear();

        var _jsonReader = new Ext.Net.JsonReader();

        foreach (DataColumn _dataColumn in _rptData.Columns)
        {
            // create field

            _jsonReader.Fields.Add(new RecordField(_dataColumn.ColumnName));

            // create the column

            var _column = new Column
            {
                Header = _dataColumn.ColumnName,

                DataIndex = _dataColumn.ColumnName,
            };

            _gp.ColumnModel.Columns.Add(_column);
        }

        _store.Reader.Add(_jsonReader);

        _store.DataSource = _rptData.DefaultView;

        _store.DataBind();

        // redraw [] must call

        _gp.Render();
    }
示例#2
0
        private void dbsa()
        {
            if (DLStation.Value != null)
            {

                if (DLType.Value.ToString() == "Personal")
                {
                    if (DLStation.SelectedItem.Text.ToString() == "")
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title = "Message",
                            Message = "请先选择站点",
                            Buttons = MessageBox.Button.OK,
                            Width = 320,
                            Icon = MessageBox.Icon.INFO
                        });
                    }
                    else{
                        string namme = DLUser.SelectedItem.Text;
                        string sss = "";
                        if (namme != "")
                        {
                            sss = "and name='" + namme + "'";
                        }
                        string sss1 = "";
                        if (namme != "")
                        {
                            sss1 = "and person='" + namme + "'";
                        }
                        string xxx = "";
                        if (ComboBox1.SelectedItem.Value != null)
                        {
                            string code = ComboBox1.SelectedItem.Value.ToString();
                            if (code != "")
                            {
                                xxx = "and accountcode='" + code + "'";
                            }
                        }
                        //string xxx1 = "";
                        //if (code != "")
                        //{
                        //    xxx1 = "and accountcode='" + code + "'";
                        //}

                        string sql = "SELECT isnull(nn.Station,mm.station) as Station,isnull(nn.department,mm.Deptment) as Deptment,isnull(nn.NAME,mm.NAME) as NAME,isnull(nn.SACCOUNDCODE,mm.SACCOUNDCODE) as SACCOUNDCODE ,SACCOUNDNAME=(select SAccountName from AccoundCode where SAccountCode=isnull(nn.SACCOUNDCODE,mm.SACCOUNDCODE)),isnull(nn.amount,0) as used,isnull(mm.amount,0) as budget,last=isnull(mm.amount,0)-isnull(nn.amount,0) FROM " +

                " (select isnull(aa.person,bb.person) as name,isnull(aa.accountcode,bb.accountcode) as SACCOUNDCODE,isnull(aa.station,bb.station) as station,isnull(aa.department,bb.department) as department,(isnull(aa.amount,0)+isnull(bb.amount,0)) as   amount from    " +
                " (select person,accountcode,station,[Department], (isnull(sum(b.CenterAmountP),0)+isnull(sum(b.CenterAmountC),0)) as amount from ETraveleDetail as b inner join ETravel as a on a.id=b.no where year(tdate)='" + DLYears.Value.ToString() + "' and  month(tdate)<='" + DLMonths.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "' and  a.type='0' and a.status='2' "+sss1+" "+xxx+" group by  person,accountcode,station,[Department]) as aa " +

                " full outer join  " +

                " (select person,accountcode,station,[Department], isnull(sum(b.CostCenterAmount),0) as amount from EeommonDetail as b inner join Ecommon as a on a.id=b.no where year(tdate)='" + DLYears.Value.ToString() + "' and  month(tdate)<='" + DLMonths.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "' and  a.type='0'  and a.status='2'  " + sss1 + " " + xxx + "  group by  person,accountcode,station,[Department] ) as  bb " +

                " on aa.person=bb.person and aa.accountcode=bb.accountcode and aa.station=bb.station and aa.department=bb.department ) AS NN"+
                          " full outer join" +
               " (select aaa.NAME,SUM(AMOUNT) AS AMOUNT,bbb.AccountCode as SACCOUNDCODE,bbb.AccountDes as SACCOUNDNAME,aaa.Station,aaa.Deptment from BudgetDetail AS aaa inner join BudgetMain  as bbb on aaa.fid=bbb.id  WHERE bbb.Years='" + DLYears.Value.ToString() + "' and  aaa.Months<='" + DLMonths.Value.ToString() + "' AND  aaa.STATION='" + DLStation.Value.ToString() + "' " + sss + " " + xxx + "  GROUP BY NAME,AccountCode,AccountDes,aaa.Station,Deptment ) AS MM " +

                      "  ON  MM.NAME=NN.name AND MM.SACCOUNDCODE=NN.SACCOUNDCODE AND MM.Station=NN.Station AND MM.Deptment=NN.department " +

                " ORDER BY NAME,SACCOUNDCODE";
                        DataSet ds = dbs.GetSqlDataSet(sql);

                        JsonReader reader = new JsonReader();
                        reader.Fields.Add("Station");
                        reader.Fields.Add("Deptment");
                        reader.Fields.Add("NAME");
                        reader.Fields.Add("SACCOUNDCODE");
                        reader.Fields.Add("SACCOUNDNAME");
                        reader.Fields.Add("used");
                        reader.Fields.Add("budget");
                        reader.Fields.Add("last");
                        Store1.Reader.Add(reader);
                        Store1.DataSource = ds.Tables[0];
                        Store1.DataBind();
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Unit",
                            DataIndex = "Station"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Department",
                            DataIndex = "Deptment"
                        });

                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "User",
                            DataIndex = "NAME"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Account Code",
                            DataIndex = "SACCOUNDCODE"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Account Name",
                            DataIndex = "SACCOUNDNAME"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Used",
                            DataIndex = "used"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Budget",
                            DataIndex = "budget"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Balance",
                            DataIndex = "last"
                        });
                   }
                }
                else if (DLType.Value.ToString() == "Department")
                {
                    if (DLStation.SelectedItem.Text.ToString() == "")
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title = "Message",
                            Message = "请先选择站点",
                            Buttons = MessageBox.Button.OK,
                            Width = 320,
                            Icon = MessageBox.Icon.INFO
                        });
                    }
                    else
                    {
                        string namme = DLDepartment.SelectedItem.Text;
                        string sss = "";
                      
                        if (namme != "")
                        {
                            sss = "and Deptment='" + namme + "'";
                        }
                        string sss1 = "";

                        if (namme != "")
                        {
                            sss1 = "and department='" + namme + "'";
                        }
                        string sql = "";
                        if (DLDepartment.SelectedItem.Text == "")
                        {
                            string xxxd = "";
                            if (ComboBox1.SelectedItem.Value != null)
                            {
                                string coded = ComboBox1.SelectedItem.Value.ToString();
                                if (coded != "")
                                {
                                    xxxd = "and accountcode='" + coded + "'";
                                }
                            }
                            sql = "SELECT isnull(nn.Station,mm.station) as Station,isnull(nn.department,mm.Deptment) as Deptment,isnull(nn.SACCOUNDCODE,mm.SACCOUNDCODE) as SACCOUNDCODE ,SACCOUNDNAME=(select SAccountName from AccoundCode where SAccountCode=isnull(nn.SACCOUNDCODE,mm.SACCOUNDCODE)),isnull(nn.amount,0) as used,isnull(mm.amount,0) as budget,last=isnull(mm.amount,0)-isnull(nn.amount,0) FROM " +

                    " (select isnull(aa.accountcode,bb.accountcode) as SACCOUNDCODE,isnull(aa.station,bb.station) as station,isnull(aa.department,bb.department) as department,(isnull(aa.amount,0)+isnull(bb.amount,0)) as   amount from    " +
                    " (select accountcode,station,[Department], (isnull(sum(b.CenterAmountP),0)+isnull(sum(b.CenterAmountC),0)) as amount from ETraveleDetail as b inner join ETravel as a on a.id=b.no where year(tdate)='" + DLYears.Value.ToString() + "' and  month(tdate)<='" + DLMonths.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "' and  a.type='0' and a.status='2' " + sss1 + " " + xxxd + " group by  accountcode,station,[Department]) as aa " +

                    " full outer join  " +

                    " (select accountcode,station,[Department], isnull(sum(b.CostCenterAmount),0) as amount from EeommonDetail as b inner join Ecommon as a on a.id=b.no where year(tdate)='" + DLYears.Value.ToString() + "' and  month(tdate)<='" + DLMonths.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "' and  a.type='0'  and a.status='2'  " + sss1 + " " + xxxd + " group by  accountcode,station,[Department] ) as  bb " +

                    " on aa.accountcode=bb.accountcode and aa.station=bb.station and aa.department=bb.department ) AS NN" +
  " full outer join" +
                                " (select SUM(AMOUNT) AS AMOUNT,bbb.AccountCode as SACCOUNDCODE,bbb.AccountDes as SACCOUNDNAME,aaa.Station,aaa.Deptment from BudgetDetail AS aaa inner join BudgetMain  as bbb on aaa.fid=bbb.id  WHERE bbb.Years='" + DLYears.Value.ToString() + "' and  aaa.Months<='" + DLMonths.Value.ToString() + "' AND  aaa.STATION='" + DLStation.Value.ToString() + "' " + sss + " " + xxxd + "  GROUP BY AccountCode,AccountDes,aaa.Station,Deptment ) AS MM " +

                                "  ON  MM.SACCOUNDCODE=NN.SACCOUNDCODE AND MM.Station=NN.Station AND MM.Deptment=NN.department " +

                    " ORDER BY Deptment,SACCOUNDCODE";
                             DataSet ds = dbs.GetSqlDataSet(sql);

                             JsonReader reader = new JsonReader();
                             reader.Fields.Add("Station");
                             reader.Fields.Add("Deptment");
                             reader.Fields.Add("SACCOUNDCODE");
                             reader.Fields.Add("SACCOUNDNAME");
                             reader.Fields.Add("used");
                             reader.Fields.Add("budget");
                             reader.Fields.Add("last");
                             Store1.Reader.Add(reader);
                             Store1.DataSource = ds.Tables[0];
                             Store1.DataBind();
                             GridPanel1.ColumnModel.Columns.Add(new Column()
                             {
                                 Header = "Unit",
                                 DataIndex = "Station"
                             });
                             GridPanel1.ColumnModel.Columns.Add(new Column()
                             {
                                 Header = "Department",
                                 DataIndex = "Deptment"
                             });
                           
                             GridPanel1.ColumnModel.Columns.Add(new Column()
                             {
                                 Header = "Account Code",
                                 DataIndex = "SACCOUNDCODE"
                             });
                             GridPanel1.ColumnModel.Columns.Add(new Column()
                             {
                                 Header = "Account Name",
                                 DataIndex = "SACCOUNDNAME"
                             });
                             GridPanel1.ColumnModel.Columns.Add(new Column()
                             {
                                 Header = "Used",
                                 DataIndex = "used"
                             });
                             GridPanel1.ColumnModel.Columns.Add(new Column()
                             {
                                 Header = "Budget",
                                 DataIndex = "budget"
                             });
                             GridPanel1.ColumnModel.Columns.Add(new Column()
                             {
                                 Header = "Balance",
                                 DataIndex = "last"
                             });
                        }
                        else
                        {
                            string xxxd = "";
                            if (ComboBox1.SelectedItem.Value != null)
                            {
                                string coded = ComboBox1.SelectedItem.Value.ToString();
                                if (coded != "")
                                {
                                    xxxd = "and accountcode='" + coded + "'";
                                }
                            }
                            sql = "SELECT isnull(nn.Station,mm.station) as Station,isnull(nn.department,mm.Deptment) as Deptment,isnull(nn.NAME,mm.NAME) as NAME,isnull(nn.SACCOUNDCODE,mm.SACCOUNDCODE) as SACCOUNDCODE ,SACCOUNDNAME=(select SAccountName from AccoundCode where SAccountCode=isnull(nn.SACCOUNDCODE,mm.SACCOUNDCODE)),isnull(nn.amount,0) as used,isnull(mm.amount,0) as budget,last=isnull(mm.amount,0)-isnull(nn.amount,0) FROM " +

                                " (select isnull(aa.person,bb.person) as name,isnull(aa.accountcode,bb.accountcode) as SACCOUNDCODE,isnull(aa.station,bb.station) as station,isnull(aa.department,bb.department) as department,(isnull(aa.amount,0)+isnull(bb.amount,0)) as   amount from    " +
                                " (select person,accountcode,station,[Department], (isnull(sum(b.CenterAmountP),0)+isnull(sum(b.CenterAmountC),0)) as amount from ETraveleDetail as b inner join ETravel as a on a.id=b.no where year(tdate)='" + DLYears.Value.ToString() + "' and  month(tdate)<='" + DLMonths.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "' and  a.type='0' and a.status='2' " + sss1 + " " + xxxd + " group by  person,accountcode,station,[Department]) as aa " +

                                " full outer join  " +

                                " (select person,accountcode,station,[Department], isnull(sum(b.CostCenterAmount),0) as amount from EeommonDetail as b inner join Ecommon as a on a.id=b.no where year(tdate)='" + DLYears.Value.ToString() + "' and  month(tdate)<='" + DLMonths.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "' and  a.type='0'  and a.status='2'  " + sss1 + " " + xxxd + "  group by  person,accountcode,station,[Department] ) as  bb " +

                                " on aa.person=bb.person and aa.accountcode=bb.accountcode and aa.station=bb.station and aa.department=bb.department ) AS NN" +
                            " full outer join" +
                                " (select aaa.NAME,SUM(AMOUNT) AS AMOUNT,bbb.AccountCode as SACCOUNDCODE,bbb.AccountDes as SACCOUNDNAME,aaa.Station,aaa.Deptment from BudgetDetail AS aaa inner join BudgetMain  as bbb on aaa.fid=bbb.id  WHERE bbb.Years='" + DLYears.Value.ToString() + "' and  aaa.Months<='" + DLMonths.Value.ToString() + "' AND  aaa.STATION='" + DLStation.Value.ToString() + "' " + sss + " " + xxxd + "  GROUP BY NAME,AccountCode,AccountDes,aaa.Station,Deptment ) AS MM " +

                                "  ON  MM.NAME=NN.name AND MM.SACCOUNDCODE=NN.SACCOUNDCODE AND MM.Station=NN.Station AND MM.Deptment=NN.department " +

                                " ORDER BY Deptment,SACCOUNDCODE,NAME";
                        
                      
                        DataSet ds = dbs.GetSqlDataSet(sql);

                        JsonReader reader = new JsonReader();
                        reader.Fields.Add("Station");
                        reader.Fields.Add("Deptment");
                        reader.Fields.Add("NAME");
                        reader.Fields.Add("SACCOUNDCODE");
                        reader.Fields.Add("SACCOUNDNAME");
                        reader.Fields.Add("used");
                        reader.Fields.Add("budget");
                        reader.Fields.Add("last");
                        Store1.Reader.Add(reader);
                        Store1.DataSource = ds.Tables[0];
                        Store1.DataBind();
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Unit",
                            DataIndex = "Station"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Department",
                            DataIndex = "Deptment"
                        });

                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "NAME",
                            DataIndex = "NAME"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Account Code",
                            DataIndex = "SACCOUNDCODE"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Account Name",
                            DataIndex = "SACCOUNDNAME"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Used",
                            DataIndex = "used"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Budget",
                            DataIndex = "budget"
                        });
                        GridPanel1.ColumnModel.Columns.Add(new Column()
                        {
                            Header = "Balance",
                            DataIndex = "last"
                        });
                        }
                    }
                }
                else
                {
                    int m = int.Parse(DLMonths.SelectedItem.Text);
                    string xxff = "";
                    for (int x = 0; x < m; x++)
                    { 
                        int xxgg=x+1;
                        if (x == m - 1)
                        {
                            xxff = xxff + "m" + xxgg;
                        }
                        else
                        { xxff = xxff + "m" + xxgg+"+"; }
                    }
                    string xxxd = "";
                    string xxxdd = "";
                    if (ComboBox1.SelectedItem.Value != null)
                    {
                        string coded = ComboBox1.SelectedItem.Value.ToString();
                        if (coded != "")
                        {
                            xxxd = "and accountcode='" + coded + "'";
                            xxxdd = "and BaacountCode='" + coded + "'";
                        }
                    }
                    string sql = "SELECT isnull(nn.Station,mm.station) as Station,isnull(nn.SACCOUNDCODE,mm.SACCOUNDCODE) as SACCOUNDCODE ,SACCOUNDNAME=(select SAccountName from AccoundCode where SAccountCode=isnull(nn.SACCOUNDCODE,mm.SACCOUNDCODE)),isnull(nn.amount,0) as used,isnull(mm.amount,0) as budget,last=isnull(mm.amount,0)-isnull(nn.amount,0) FROM " +

                  " (select isnull(aa.accountcode,bb.accountcode) as SACCOUNDCODE,isnull(aa.station,bb.station) as station,(isnull(aa.amount,0)+isnull(bb.amount,0)) as   amount from    " +
                  " (select accountcode,station, (isnull(sum(b.CenterAmountP),0)+isnull(sum(b.CenterAmountC),0)) as amount from ETraveleDetail as b inner join ETravel as a on a.id=b.no where year(tdate)='" + DLYears.Value.ToString() + "' and  month(tdate)<='" + DLMonths.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "' and  a.type='0' and a.status='2'" + xxxd + "  group by  accountcode,station) as aa " +

                  " full outer join  " +

                  " (select accountcode,station, isnull(sum(b.CostCenterAmount),0) as amount from EeommonDetail as b inner join Ecommon as a on a.id=b.no where year(tdate)='" + DLYears.Value.ToString() + "' and  month(tdate)<='" + DLMonths.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "' and  a.type='0'  and a.status='2'  " + xxxd + " group by  accountcode,station ) as  bb " +

                  " on  aa.accountcode=bb.accountcode and aa.station=bb.station ) AS NN" +
                              " full outer join  " +
                 " (select SUM("+xxff+") AS AMOUNT,BaacountCode as SACCOUNDCODE,'' as SACCOUNDNAME,Station from BudgetMain   WHERE Years='" + DLYears.Value.ToString() + "' AND  STATION='" + DLStation.Value.ToString() + "'"+xxxdd+"  GROUP BY BaacountCode,Station) AS MM " +

                        "  ON  MM.SACCOUNDCODE=NN.SACCOUNDCODE AND MM.Station=NN.Station " +

                  " ORDER BY SACCOUNDCODE";
                    DataSet ds = dbs.GetSqlDataSet(sql);

                    JsonReader reader = new JsonReader();
                    reader.Fields.Add("Station");
                    reader.Fields.Add("SACCOUNDCODE");
                    reader.Fields.Add("SACCOUNDNAME");
                    reader.Fields.Add("used");
                    reader.Fields.Add("budget");
                    reader.Fields.Add("last");
                    Store1.Reader.Add(reader);
                    Store1.DataSource = ds.Tables[0];
                    Store1.DataBind();
                    GridPanel1.ColumnModel.Columns.Add(new Column()
                    {
                        Header = "Unit",
                        DataIndex = "Station"
                    });


                    GridPanel1.ColumnModel.Columns.Add(new Column()
                    {
                        Header = "Account Code",
                        DataIndex = "SACCOUNDCODE"
                    });
                    GridPanel1.ColumnModel.Columns.Add(new Column()
                    {
                        Header = "Account Name",
                        DataIndex = "SACCOUNDNAME"
                    });
                    GridPanel1.ColumnModel.Columns.Add(new Column()
                    {
                        Header = "Used",
                        DataIndex = "used"
                    });
                    GridPanel1.ColumnModel.Columns.Add(new Column()
                    {
                        Header = "Budget",
                        DataIndex = "budget"
                    });
                    GridPanel1.ColumnModel.Columns.Add(new Column()
                    {
                        Header = "Balance",
                        DataIndex = "last"
                    });
                }
                GridPanel1.DataBind();

                GridPanel1.Reconfigure();
            }
            else
            {
                string sql = "SELECT mm.Station,mm.Deptment,mm.MONTHS,mm.NAME,mm.SACCOUNDCODE,mm.SACCOUNDNAME,isnull(nn.amount,0) as used,isnull(mm.amount,0) as budget,last=isnull(mm.amount,0)-isnull(nn.amount,0) FROM (select aaa.MONTHS,aaa.NAME,SUM(AMOUNT) AS AMOUNT,aaa.SACCOUNDCODE,aaa.SACCOUNDNAME,aaa.Station,aaa.Deptment from BudgetDetail AS aaa inner join BudgetMain  as bbb on aaa.fid=bbb.id  WHERE 1=2 GROUP BY aaa.MONTHS,NAME,SACCOUNDCODE,SACCOUNDNAME,aaa.Station,Deptment ) AS MM " +
   " left JOIN" +
   " (select aa.months,aa.person,aa.accountcode,aa.station,aa.department,(isnull(aa.amount,0)+isnull(bb.amount,0)) as   amount from  " +
   " (select month(tdate) as months,person,accountcode,station,[Department], (sum(b.pamount)+sum(b.camount)) as amount from ETraveleDetail as b inner join ETravel as a on a.id=b.no where 1=2 and  a.type='0' and a.status<>'3' group by  month(tdate),person,accountcode,station,[Department]) as aa " +

   " full outer join  " +

   " (select month(tdate) as months,person,accountcode,station,[Department], sum(b.Amount) as amount from EeommonDetail as b inner join Ecommon as a on a.id=b.no where 1=2 and  a.type='0'  and a.status<>'3' group by  month(tdate),person,accountcode,station,[Department] ) as  bb " +

   " on aa.months=bb.months and aa.person=bb.person and aa.accountcode=bb.accountcode and aa.station=bb.station and aa.department=bb.department ) AS NN ON MM.MONTHS=NN.MONTHS AND MM.NAME=NN.PERSON AND MM.SACCOUNDCODE=NN.accountcode AND MM.Station=NN.Station AND MM.Deptment=NN.department " +

   " ORDER BY NAME,SACCOUNDCODE,MM.MONTHS";
                DataSet ds = dbs.GetSqlDataSet(sql);

                JsonReader reader = new JsonReader();
                reader.Fields.Add("Station");
                reader.Fields.Add("MONTHS");
                reader.Fields.Add("Deptment");
                reader.Fields.Add("NAME");
                reader.Fields.Add("SACCOUNDCODE");
                reader.Fields.Add("SACCOUNDNAME");
                reader.Fields.Add("used");
                reader.Fields.Add("budget");
                reader.Fields.Add("last");
                Store1.Reader.Add(reader);
                Store1.DataSource = ds.Tables[0];
                Store1.DataBind();
                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "Unit",
                    DataIndex = "Station"
                });
                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "Department",
                    DataIndex = "Deptment"
                });

                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "User",
                    DataIndex = "NAME"
                });
                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "Month",
                    DataIndex = "MONTHS"
                });
                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "Account Code",
                    DataIndex = "SACCOUNDCODE"
                });
                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "Account Name",
                    DataIndex = "SACCOUNDNAME"
                });
                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "Used",
                    DataIndex = "used"
                });
                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "Budget",
                    DataIndex = "budget"
                });
                GridPanel1.ColumnModel.Columns.Add(new Column()
                {
                    Header = "Balance",
                    DataIndex = "last"
                });
                GridPanel1.DataBind();

                GridPanel1.Reconfigure();
            }

        }
示例#3
0
        protected override void CreateChildControls()
        {
            // Store

            JsonReader jsonReader = new JsonReader();
            jsonReader.IDProperty = "ID";
            jsonReader.Fields.Add("ID");
            jsonReader.Fields.Add("Title");
            jsonReader.Fields.Add("IconUrl");

            _store = new Store { ID = ID + "Store" };
            _store.Reader.Add(jsonReader);

            var items = GetItems();
            if (!ExtNet.IsAjaxRequest)
            {
                _store.DataSource = items;
                _store.DataBind();
            }

            Controls.Add(_store);

            // Grid Panel

            _gridPanel = new ChildrenEditorGridPanel { ID = ID + "GridPanel" };
            _gridPanel.AddItemButtonClicked += OnGridPanelAddItemButtonClicked;
            _gridPanel.ItemsRemoved += OnGridPanelItemsRemoved;
            Controls.Add(_gridPanel);

            _gridPanel.StoreID = _store.ID;

            // Editor Windows

            foreach (ContentItem contentItem in items)
                AddEditorWindow(contentItem);

            base.CreateChildControls();
        }
示例#4
0
        protected void loadgrid2(object sender, DirectEventArgs e)
        {
            var store = new Store { ID = "Store1" };
            var reader = new JsonReader { IDProperty = "ID" };
            reader.Fields.Add("ID", "Type", "Heji", "Biaodanhao", "Tijiao");
            reader.Fields.Add(new RecordField
            {
                Name = "Level",
                Convert = { Handler = "return ".ConcatWith(1, ";") }
            });
            store.Reader.Add(reader);

            DataTable dt = new DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Type");
            dt.Columns.Add("Heji");
            dt.Columns.Add("Biaodanhao");
            dt.Columns.Add("Tijiao");
            DataRow dr = dt.NewRow();
            dr["ID"] = "10";
            dr["Type"] = "差旅费";
            dr["Heji"] = "100";
            dr["Biaodanhao"] = "BJS1101";
            dr["Tijiao"] = "2012-12-11";
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr["ID"] = "11";
            dr["Type"] = "通用费用";
            dr["Heji"] = "1100";
            dr["Biaodanhao"] = "BJS1112";
            dr["Tijiao"] = "2012-12-21";
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr["ID"] = "12";
            dr["Type"] = "差旅费";
            dr["Heji"] = "100";
            dr["Biaodanhao"] = "BJS1123";
            dr["Tijiao"] = "2012-12-31";
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr["ID"] = "13";
            dr["Type"] = "通用费用";
            dr["Heji"] = "100";
            dr["Biaodanhao"] = "BJS1134";
            dr["Tijiao"] = "2012-11-11";
            dt.Rows.Add(dr);
            
            var grid = new GridPanel
            {
                ID = "Grid1",
                Store = { 
                                    store
                                 },
                AutoScroll = true,
                Border = false,
                Title = "可按住Ctrl以多选,然后点击右侧&quot;+&quot;按钮向右侧添加数据.",
                Height = 530
            };
            //build columns
            grid.ColumnModel.Columns.Add(new RowNumbererColumn { Width = 25 });
            grid.ColumnModel.Columns.Add(new Column { DataIndex = "Biaodanhao", Header = "表单号" });
            grid.ColumnModel.Columns.Add(new Column { DataIndex = "Type", Header = "单据类型" });
            grid.ColumnModel.Columns.Add(new Column { DataIndex = "Heji", Header = "合计" });
            grid.ColumnModel.Columns.Add(new Column { DataIndex = "Tijiao", Header = "提交时间" });
            grid.ColumnModel.ID = "Grid1_CM";
            var view = new Ext.Net.GridView
            {
                ID = "Grid1_View",
                ForceFit = true
            };
            grid.View.Add(view);
            var sm = new RowSelectionModel { ID = "Grid1_SM" };
            //sm.Listeners.BeforeRowSelect.Handler = "return false;";//合计类不允许选择
            grid.SelectionModel.Add(sm);

            // add expander for all levels except last (last level is 5)
            view.Listeners.BeforeRefresh.Fn = "clean";
            var re = new RowExpander
            {
                ID = "Grid1_RE",
                EnableCaching = true,
                Template = { ID = "Grid1_TPL", Html = "<div id=\"row_{ID}\" style=\"background-color:white;\"></div>" }
            };
            re.Listeners.BeforeExpand.Fn = "loadLevel";
            grid.Plugins.Add(re);
            Panel5.Items.Add(grid);
            store.DataSource = dt;
            store.DataBind();
            grid.Listeners.ViewReady.Fn = "expangrid";
            grid.Listeners.ViewReady.Single = true;
            grid.Render();
            //X.AddScript("expandallgrid();");
            //re.ExpandAll();
            //BuildLevel(int level, string recId, string gridId,string dtype)
            //
            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    if (dt.Rows[i]["Type"].ToString() == "差旅费")
            //    {
            //        var newgridid = "L2_" + dt.Rows[i]["ID"].ToString() + "_Grid";
            //        var store2 = new Store { ID = "L2_" + dt.Rows[i]["ID"].ToString() + "_Store" };
            //        var reader2 = new JsonReader { IDProperty = "ID" };
            //        reader.Fields.Add("ID", "Type", "Heji", "Biaodanhao", "Tijiao");
            //        reader.Fields.Add(new RecordField
            //        {
            //            Name = "Level",
            //            Convert = { Handler = "return ".ConcatWith(2, ";") }
            //        });
            //        store2.Reader.Add(reader2);

            //        DataTable dt2 = new DataTable();
            //        dt2.Columns.Add("ID");
            //        dt2.Columns.Add("Type");
            //        dt2.Columns.Add("Heji");
            //        dt2.Columns.Add("Biaodanhao");
            //        dt2.Columns.Add("Tijiao");
            //        Random ran = new Random();
            //        DataRow dr2 = dt2.NewRow();
            //        dr2["ID"] = dt.Rows[i]["ID"].ToString() + "0";
            //        dr2["Type"] = "票价合计";
            //        dr2["Heji"] = "120";
            //        dr2["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
            //        dr2["Tijiao"] = "2012-12-11";
            //        dt2.Rows.Add(dr2);
            //        dr2 = dt2.NewRow();
            //        dr2["ID"] = dt.Rows[i]["ID"].ToString() + "1";
            //        dr2["Type"] = "酒店";
            //        dr2["Heji"] = "120";
            //        dr2["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
            //        dr2["Tijiao"] = "2012-12-11";
            //        dt2.Rows.Add(dr2);
            //        dr2 = dt2.NewRow();
            //        dr2["ID"] = dt.Rows[i]["ID"].ToString() + "2";
            //        dr2["Type"] = "交通费";
            //        dr2["Heji"] = "120";
            //        dr2["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
            //        dr2["Tijiao"] = "2012-12-11";
            //        dt2.Rows.Add(dr2);
            //        dr2 = dt2.NewRow();
            //        dr2["ID"] = dt.Rows[i]["ID"].ToString() + "3";
            //        dr2["Type"] = "膳食费";
            //        dr2["Heji"] = "120";
            //        dr2["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
            //        dr2["Tijiao"] = "2012-12-11";
            //        dt2.Rows.Add(dr2);
            //        dr2 = dt2.NewRow();
            //        dr2["ID"] = dt.Rows[i]["ID"].ToString() + "4";
            //        dr2["Type"] = "机场费";
            //        dr2["Heji"] = "120";
            //        dr2["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
            //        dr2["Tijiao"] = "2012-12-11";
            //        dt2.Rows.Add(dr2);
            //        dr2 = dt2.NewRow();
            //        dr2["ID"] = dt.Rows[i]["ID"].ToString() + "5";
            //        dr2["Type"] = "其他";
            //        dr2["Heji"] = "120";
            //        dr2["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
            //        dr2["Tijiao"] = "2012-12-11";
            //        dt2.Rows.Add(dr2);
            //        dr2 = dt2.NewRow();
            //        dr2["ID"] = dt.Rows[i]["ID"].ToString() + "6";
            //        dr2["Type"] = "每日津贴";
            //        dr2["Heji"] = "120";
            //        dr2["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
            //        dr2["Tijiao"] = "2012-12-11";
            //        dt2.Rows.Add(dr2);

            //        var grid2 = new GridPanel
            //        {
            //            ID = newgridid,
            //            Store = { 
            //                        store2
            //                     },
            //            AutoHeight = true,
            //            AutoScroll = true,
            //            EnableColumnMove = false,
            //        };
            //        //build columns
            //        grid2.ColumnModel.Columns.Add(new RowNumbererColumn { Width = 25 });
            //        grid2.ColumnModel.Columns.Add(new Column { DataIndex = "Type", Header = "费用类型", Resizable = false });
            //        grid2.ColumnModel.Columns.Add(new Column { DataIndex = "Heji", Header = "合计", Resizable = false });
            //        grid2.ColumnModel.Columns.Add(new Column { DataIndex = "Biaodanhao", Header = "公司预支", Resizable = false });
            //        grid2.ColumnModel.ID = newgridid + "_CM";
            //        var view2 = new Ext.Net.GridView
            //        {
            //            ID = newgridid+"_View",
            //            ForceFit = true
            //        };
            //        grid2.View.Add(view2);
            //        var sm2 = new RowSelectionModel { ID = newgridid+"_SM" };
            //        sm2.Listeners.BeforeRowSelect.Handler = "return false;";//合计类不允许选择
            //        grid2.SelectionModel.Add(sm2);

            //        // add expander for all levels except last (last level is 5)
            //        view2.Listeners.BeforeRefresh.Fn = "clean";
            //        var re2 = new RowExpander
            //        {
            //            ID = newgridid+"_RE",
            //            EnableCaching = true,
            //            Template = { ID = newgridid+"_TPL", Html = "<div id=\"row_{ID}\" style=\"background-color:white;\"></div>" }
            //        };
            //        //re2.Listeners.BeforeExpand.Fn = "loadLevel";
            //        grid2.Plugins.Add(re2);

            //        var renderEl2 = "row_" + dt.Rows[i]["ID"].ToString();
            //        X.Get(renderEl2).SwallowEvent(new string[] { "click", "mousedown", "mouseup", "dblclick" }, true);
            //        this.RemoveFromCache(newgridid, "Grid1");

            //        store2.DataSource = dt2;
            //        store2.DataBind();

            //        grid.Render(renderEl2, RenderMode.RenderTo);
            //        this.AddToCache(newgridid, "Grid1");
            //    }
            //}
            //if (1 == 1)
            //{
            //    grid.Title = "可按住Ctrl以多选.";
            //    grid.Height = 400;
            //    grid.AutoHeight = false;
            //    grid.Border = false;
            //    //this.Form.Controls.Add(grid);
            //    Panel5.Html = "";
            //    Panel5.Items.Add(grid);
            //    //grid.Plugins.Add(new PanelResizer());
            //}
            //else
            //{
                //var renderEl = "row_" + recId;
                //X.Get(renderEl).SwallowEvent(new string[] { "click", "mousedown", "mouseup", "dblclick" }, true);

                //this.RemoveFromCache(newGridId, gridId);
                //grid.Render(renderEl, RenderMode.RenderTo);
                //this.AddToCache(newGridId, gridId);
            //}
            //
            
            
        }
示例#5
0
        public void BuildLevel(int level, string recId, string gridId,string dtype)
        {
            var storeId = "L".ConcatWith(level, "_", recId, "_Store");
            var newGridId = "L".ConcatWith(level, "_", recId, "_Grid");

            // build store
            var store = new Store { ID = storeId };
            var reader = new JsonReader { IDProperty = "ID" };
            reader.Fields.Add("ID", "Type", "Heji", "Biaodanhao", "Tijiao");
            reader.Fields.Add(new RecordField
            {
                Name = "Level",
                Convert = { Handler = "return ".ConcatWith(level, ";") }
            });
            store.Reader.Add(reader);
            //store.CustomConfig.Add(new ConfigItem("level", level.ToString(), ParameterMode.Raw));

            // bind store
            DataTable dt = new DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Type");
            dt.Columns.Add("Heji");
            dt.Columns.Add("Biaodanhao");
            dt.Columns.Add("Tijiao");
            if (level == 1)
            {
                DataRow dr = dt.NewRow();
                dr["ID"] = "0";
                dr["Type"] = "差旅费";
                dr["Heji"] = "100";
                dr["Biaodanhao"] = "BJS110" + level.ToString();
                dr["Tijiao"] = "2012-12-11";
                dt.Rows.Add(dr);
                dr = dt.NewRow();
                dr["ID"] = "1";
                dr["Type"] = "通用费用";
                dr["Heji"] = "1100";
                dr["Biaodanhao"] = "BJS111" + level.ToString();
                dr["Tijiao"] = "2012-12-21";
                dt.Rows.Add(dr);
                dr = dt.NewRow();
                dr["ID"] = "2";
                dr["Type"] = "差旅费";
                dr["Heji"] = "100";
                dr["Biaodanhao"] = "BJS112" + level.ToString();
                dr["Tijiao"] = "2012-12-31";
                dt.Rows.Add(dr);
                dr = dt.NewRow();
                dr["ID"] = "3";
                dr["Type"] = "通用费用";
                dr["Heji"] = "100";
                dr["Biaodanhao"] = "BJS113" + level.ToString();
                dr["Tijiao"] = "2012-11-11";
                dt.Rows.Add(dr);
            }
            else if(level == 2)
            {
                
                if (dtype == "差旅费")
                {


                    Random ran = new Random();
                    DataRow dr = dt.NewRow();
                    dr["ID"] = recId + "20";
                    dr["Type"] = "票价合计";
                    dr["Heji"] = "120";
                    dr["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
                    dr["Tijiao"] = "2012-12-11";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "21";
                    dr["Type"] = "酒店";
                    dr["Heji"] = "120";
                    dr["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
                    dr["Tijiao"] = "2012-12-11";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "22";
                    dr["Type"] = "交通费";
                    dr["Heji"] = "120";
                    dr["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
                    dr["Tijiao"] = "2012-12-11";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "23";
                    dr["Type"] = "膳食费";
                    dr["Heji"] = "120";
                    dr["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
                    dr["Tijiao"] = "2012-12-11";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "24";
                    dr["Type"] = "机场费";
                    dr["Heji"] = "120";
                    dr["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
                    dr["Tijiao"] = "2012-12-11";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "25";
                    dr["Type"] = "其他";
                    dr["Heji"] = "120";
                    dr["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
                    dr["Tijiao"] = "2012-12-11";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "26";
                    dr["Type"] = "每日津贴";
                    dr["Heji"] = "120";
                    dr["Biaodanhao"] = (120 * Math.Round((decimal)ran.Next(1, 10), 1)).ToString();
                    dr["Tijiao"] = "2012-12-11";
                    dt.Rows.Add(dr);
                }
                else
                {
                    DataRow dr = dt.NewRow();
                    dr = dt.NewRow();
                    dr["ID"] = recId + "20";
                    dr["Type"] = "交际费";
                    dr["Heji"] = "100";
                    dr["Biaodanhao"] = "BJS110" + level.ToString();
                    dr["Tijiao"] = "2012-12-11";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "21";
                    dr["Type"] = "交通费";
                    dr["Heji"] = "1100";
                    dr["Biaodanhao"] = "BJS111" + level.ToString();
                    dr["Tijiao"] = "2012-12-21";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "22";
                    dr["Type"] = "通讯费";
                    dr["Heji"] = "100";
                    dr["Biaodanhao"] = "BJS112" + level.ToString();
                    dr["Tijiao"] = "2012-12-31";
                    dt.Rows.Add(dr);
                    dr = dt.NewRow();
                    dr["ID"] = recId + "23";
                    dr["Type"] = "其他费用";
                    dr["Heji"] = "100";
                    dr["Biaodanhao"] = "BJS113" + level.ToString();
                    dr["Tijiao"] = "2012-11-11";
                    dt.Rows.Add(dr);
                }
            }
            else if (level == 3 && dtype != "差旅费")
            {
                for (int i = 0; i < 4; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"] = recId + "3" + i.ToString();
                    dr["Type"] = "其他费用";
                    dr["Heji"] = (100 + i).ToString();
                    dr["Biaodanhao"] = "费用描述";
                    dr["Tijiao"] = "2012-11-11";
                    dt.Rows.Add(dr);
                }
            }

            //var data = new List<object>();

            //for (int i = 1; i <= 9; i++)
            //{
            //    data.Add(new { ID = recId.ConcatWith("_R", i), Biaodanhao = "Level".ConcatWith(level, ": Row " + i), Type = "Level".ConcatWith(level, ": Row " + i), Heji = "Level".ConcatWith(level, ": Row " + i), Tijiao = "Level".ConcatWith(level, ": Row " + i) });
            //}

            //build grid
            var grid = new GridPanel
            {
                ID = newGridId,
                Store = { 
                                    store
                                 },
                AutoHeight = true,
                AutoScroll = true,
                EnableColumnMove = level == 1,
            };

            //build columns
            grid.ColumnModel.Columns.Add(new RowNumbererColumn { Width = 25 });
            if (level==1)
            {
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Biaodanhao", Header = "表单号" });
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Type", Header = "单据类型" });
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Heji", Header = "合计" });
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Tijiao", Header = "提交时间" });
            }
            else if(level == 2)
            {
                if (dtype == "差旅费")
                {
                    grid.ColumnModel.Columns.Add(new Column { DataIndex = "Type", Header = "费用类型", Resizable = false });
                    grid.ColumnModel.Columns.Add(new Column { DataIndex = "Heji", Header = "合计", Resizable = false });
                    grid.ColumnModel.Columns.Add(new Column { DataIndex = "Biaodanhao", Header = "公司预支", Resizable = false });
                }
                else
                {
                    grid.ColumnModel.Columns.Add(new Column { DataIndex = "Type", Header = "单据类型", Resizable = false });
                    grid.ColumnModel.Columns.Add(new Column { DataIndex = "Heji", Header = "合计", Resizable = false });
                }
            }
            else if (level == 3)
            {
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Heji", Header = "金额", Resizable = false });
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Heji", Header = "费用描述", Resizable = false });
            }
            
            grid.ColumnModel.ID = newGridId + "_CM";

            // build view
            var view = new Ext.Net.GridView
            {
                ID = newGridId + "_View",
                ForceFit = true
            };
            grid.View.Add(view);

            // build selection model
            var sm = new RowSelectionModel { ID = newGridId + "_SM" };
            //if (level != 3 && dtype != "差旅费")
            //{
            //    sm.Listeners.BeforeRowSelect.Handler = "return false;";//合计类不允许选择
            //}
            grid.SelectionModel.Add(sm);
            RowExpander rem = new RowExpander();
            // add expander for all levels except last (last level is 5)
            if (level < 3 && dtype != "差旅费")
            {
                view.Listeners.BeforeRefresh.Fn = "clean";
                var re = new RowExpander
                {
                    ID = newGridId + "_RE",
                    EnableCaching = true,
                    Template = { ID = newGridId + "_TPL", Html = "<div id=\"row_{ID}\" style=\"background-color:white;\"></div>" }
                };
                re.Listeners.BeforeExpand.Fn = "loadLevel";
                rem = re;
                grid.Plugins.Add(re);
            }

            store.DataSource = dt;
            store.DataBind();

            if (level == 1)
            {
                grid.Title = "可按住Ctrl以多选.";
                grid.Height = 400;
                grid.AutoHeight = false;
                grid.Border = false;
                //this.Form.Controls.Add(grid);
                Panel5.Html = "";
                Panel5.Items.Add(grid);
                //grid.Plugins.Add(new PanelResizer());
            }
            else
            {
                var renderEl = "row_" + recId;
                X.Get(renderEl).SwallowEvent(new string[] { "click", "mousedown", "mouseup", "dblclick" }, true);

                this.RemoveFromCache(newGridId, gridId);
                if (level < 3)
                {
                    grid.Listeners.ViewReady.Fn = "expangrid";
                    grid.Listeners.ViewReady.Single = true;
                }
                grid.Render(renderEl, RenderMode.RenderTo);
                this.AddToCache(newGridId, gridId);
            }
            //string gl = newGridId;
            ////记录选择行的空间名
            //if (level == 3 || (level == 2 && dtype == "差旅费"))
            //{
            //    X.AddScript("var st=Hidden1.getValue();Hidden1.setValue(st+='" + gl + ",');");
            //    //X.AddScript("var st=TextField1.getValue();TextField1.setValue(st+='" + gl + ",');");
            //}
        }
示例#6
0
        public void BuildLevel(int level, string recId, string gridId)
        {
            var storeId = "L".ConcatWith(level, "_", recId, "_Store");
            var newGridId = "L".ConcatWith(level, "_", recId, "_Grid");

            // build store
            var store = new Store { ID = storeId };
            var reader = new JsonReader { IDProperty = "ID" };
            reader.Fields.Add("ID", "Name");
            reader.Fields.Add(new RecordField
            {
                Name = "Level",
                Convert = { Handler = "return ".ConcatWith(level, ";") }
            });
            store.Reader.Add(reader);
            store.CustomConfig.Add(new ConfigItem("level", level.ToString(), ParameterMode.Raw));

            // bind store
            var data = new List<object>();

            for (int i = 1; i <= 9; i++)
            {
                data.Add(new { ID = recId.ConcatWith("_R", i), Name = "Level".ConcatWith(level, ": Row " + i) });
            }

            //build grid
            var grid = new GridPanel
            {
                ID = newGridId,
                Store = { 
                                    store
                                 },
                AutoHeight = true,
                EnableColumnMove = level == 1
            };

            //build columns
            grid.ColumnModel.Columns.Add(new RowNumbererColumn { Width = 25 });
            if (level==1)
            {
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Name", Header = "Name" });
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Name", Header = "Class" });
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Name", Header = "Class1" });
            }
            else
            {
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Name", Header = "Name", Resizable = false });
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Name", Header = "Class", Resizable = false });
                grid.ColumnModel.Columns.Add(new Column { DataIndex = "Name", Header = "Class1", Resizable = false });
            }
            
            grid.ColumnModel.ID = newGridId + "_CM";

            // build view
            var view = new Ext.Net.GridView
            {
                ID = newGridId + "_View",
                ForceFit = true
            };
            grid.View.Add(view);

            // build selection model
            var sm = new RowSelectionModel { ID = newGridId + "_SM" };
            if (level != 3)
            {
                sm.Listeners.BeforeRowSelect.Handler = "return false;";//合计类不允许选择
            }
            grid.SelectionModel.Add(sm);

            // add expander for all levels except last (last level is 5)
            if (level < 3)
            {
                view.Listeners.BeforeRefresh.Fn = "clean";
                var re = new RowExpander
                {
                    ID = newGridId + "_RE",
                    EnableCaching = true,
                    Template = { ID = newGridId + "_TPL", Html = "<div id=\"row_{ID}\" style=\"background-color:white;\"></div>" }
                };

                re.Listeners.BeforeExpand.Fn = "loadLevel";

                grid.Plugins.Add(re);
            }

            store.DataSource = data;
            store.DataBind();

            if (level == 1)
            {
                grid.Title = "MultiLevel grid";
                grid.Width = 600;
                grid.Height = 600;
                grid.AutoHeight = false;
                //this.Form.Controls.Add(grid);
                Container1.Items.Add(grid);
                grid.Plugins.Add(new PanelResizer());
            }
            else
            {
                var renderEl = "row_" + recId;
                X.Get(renderEl).SwallowEvent(new string[] { "click", "mousedown", "mouseup", "dblclick" }, true);

                this.RemoveFromCache(newGridId, gridId);
                grid.Render(renderEl, RenderMode.RenderTo);
                this.AddToCache(newGridId, gridId);
            }
        }