protected void btn_save_Click(object sender, ImageClickEventArgs e)
 {
     ReportTableModel report = new ReportTableModel();
     string tablestr = string.Empty;
     for (int i = 0; i < this.tablelist.Items.Count; i++)
     {
         if (tablelist.Items[i].Selected)
         {
             tablestr += "," + tablelist.Items[i].Value;
         }
     }
     report.Tablelist = tablestr.TrimStart(',');
     string id = "0";
     if (Request.QueryString["getid"] != null)
     {
         id = Request.QueryString["getid"].ToString();
     }
     else
     {
         id = HidControl.Value;
     }
     
     report.Menuname = this.txt_menu.Text;
     report.SqlStr = this.txt_sql.Text;
     report.timeFlag = Convert.ToInt32(this.ddl_timeflag.SelectedValue);
     report.Excelhead = "";
     HidControl.Value = TableReportBus.InsertReport(report, UserInfo, id, hiduserid.Value).ToString();
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="report"></param>
        /// <param name="flag">判断是添加还是修改</param>
        /// <returns></returns>
        public static int InsertReport(ReportTableModel report,XBase.Common.UserInfoUtil userinfo,string ID,string useridlist)
        {
            int num = 0;
            StringBuilder strSql = new StringBuilder();
            if (ID == "0")  //添加
            {
                strSql.Append("insert into defdba.ReportTable(Menuname,CompanyCD,sqlstr,timeFlag,tablelist,excelhead) values(@Menuname,@CompanyCD,@SqlStr,@timeFlag,@tablelist,@excelhead)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters = {
					new SqlParameter("@Menuname", SqlDbType.VarChar,200),
                    new SqlParameter("@CompanyCD", SqlDbType.VarChar,200),
					new SqlParameter("@SqlStr", SqlDbType.Text),
					new SqlParameter("@timeFlag", SqlDbType.Int,4),
                    new SqlParameter("@tablelist", SqlDbType.VarChar,100),
                    new SqlParameter("@excelhead", SqlDbType.VarChar,100)
					};
                parameters[0].Value = report.Menuname;
                parameters[1].Value = userinfo.CompanyCD;
                parameters[2].Value = report.SqlStr;
                parameters[3].Value = report.timeFlag;
                parameters[4].Value = report.Tablelist;
                parameters[5].Value = report.Excelhead;
                num = Convert.ToInt32(SqlHelper.ExecuteScalar(strSql.ToString(), parameters));
            }
            else  //修改
            {
                strSql.Append("update defdba.ReportTable set Menuname=@menuname,timeFlag=@timeFlag,sqlstr=@SqlStr,tablelist=@tablelist,excelhead=@excelhead where ID=@id");
                SqlParameter[] parameters = {
					new SqlParameter("@Menuname", SqlDbType.VarChar,200),
                    new SqlParameter("@CompanyCD", SqlDbType.VarChar,200),
					new SqlParameter("@SqlStr", SqlDbType.Text),
					new SqlParameter("@timeFlag", SqlDbType.Int,4),
                    new SqlParameter("@tablelist", SqlDbType.VarChar,100),
                    new SqlParameter("@ID", SqlDbType.VarChar,100),
                    new SqlParameter("@excelhead", SqlDbType.VarChar,500)
					};
                parameters[0].Value = report.Menuname;
                parameters[1].Value = userinfo.CompanyCD;
                parameters[2].Value = report.SqlStr;
                parameters[3].Value = report.timeFlag;
                parameters[4].Value = report.Tablelist;
                parameters[5].Value = ID;
                parameters[6].Value = report.Excelhead;
                try
                {
                    SqlHelper.ExecuteTransSql(strSql.ToString(),parameters);
                    num = Convert.ToInt32(ID);
                }
                catch { return 0; }
            }
            //添加菜单
            CreateMenu(report.Menuname, num.ToString(), userinfo, useridlist);
            return num;

        }
 public static int InsertReport(ReportTableModel report, XBase.Common.UserInfoUtil userinfo, string ID,string useridlist)
 {
     return TableReportDBHelper.InsertReport(report, userinfo,ID,useridlist);
 }