Exemple #1
0
        protected void btnDel_Click(object sender, EventArgs e)
        {
            bool   isOk = true;
            string id   = Page.Request.Form[name + Constants.MYQUERY_SELECTID];

            if (!String.IsNullOrEmpty(id))
            {
                try
                {
                    isOk = Template.DelSubjectData(id, CurrentUser.Id);
                }
                catch (Exception ex)
                {
                    isOk = false;
                    Logger.Error("删除查询方案失败", ex);
                    RedirectError("删除查询方案失败,请稍候再试。原因:" + ex.Message);
                }
                if (!isOk)
                {
                    Alert("您不能删除别人的查询方案");
                }
            }
            else
            {
                isOk = false;
                Alert("请先选中一个方案,再点[使用]");
            }
            MyInputs1.DataBind();
            MyGridView1.DataBind(Template.GetSubjectData(name, MyInputs1.Columns, CurrentUser.Id));
        }
Exemple #2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            bool isOk = true;

            try
            {
                //添加
                MySqlParameters mySqlParameters = new MySqlParameters(null);
                mySqlParameters.Add("name", name, null);
                mySqlParameters.Add("title", txtName.Text, null);
                mySqlParameters.Add("userid", ckbPrivate.Checked ? CurrentUser.Id : "public", null);
                mySqlParameters.Add("creater", CurrentUser.Id, null);
                isOk = Template.SaveSubjectData(mySqlParameters, MyInputs1.Columns);
            }
            catch (Exception ex)
            {
                isOk = false;
                Logger.Error("添加查询方案失败", ex);
                RedirectError("添加失败,请稍候再试。原因:" + ex.Message);
                return;
            }
            if (isOk)
            {
                Close(null, false);
            }
            else
            {
                MyInputs1.DataBind();
                MyGridView1.DataBind(Template.GetSubjectData(name, MyInputs1.Columns, CurrentUser.Id));
            }
        }
Exemple #3
0
 protected void btnGet_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = dataFrom.GetDataTable("select top 1 * from " + tablename.Text);
         if (dt != null)
         {
             DataTable ds = new DataTable();
             ds.Columns.Add("name");
             ds.Columns.Add("des");
             ds.Columns.Add("isselect");
             ds.Columns.Add("iswhere");
             foreach (DataColumn dc in dt.Columns)
             {
                 DataRow dr = ds.NewRow();
                 dr["name"] = dc.ColumnName;
                 dr["des"]  = dc.Caption;
                 ds.Rows.Add(dr);
             }
             MyGridView1.DataSource = ds;
         }
     }
     catch (Exception ex)
     {
         Logger.Error("表" + tablename.Text, ex);
         RedirectError("获取表" + tablename.Text + "字段失败。原因:" + ex.Message);
         return;
     }
     WebHelper.SetControlAttributes(btnSave, new TextBoxVal[] { tablename, title });
     MyGridView1.DataBind();
 }
    protected void ENRDropDownList_OnSelectedIndexChanged(Object sender, EventArgs e)
    {
        caption.Text    = "Comparison of Fall Enrollment Numbers  - " + ENRDropDownList.SelectedItem;
        Session["term"] = ENRDropDownList.SelectedValue;
        MyGridView1.DataBind();
        MyGridView2.DataBind();
        MyGridView3.DataBind();
        MyGridView4.DataBind();
        MyGridView5.DataBind();
        MyGridView6.DataBind();
        MyGridView7.DataBind();
        MyGridView8.DataBind();
        MyGridView9.DataBind();
        MyGridView10.DataBind();
        MyGridView11.DataBind();

        string dropValue     = ENRDropDownList.SelectedItem.Text;
        string drop          = ENRDropDownList.SelectedItem.Value.Remove(4, 1);
        int    previousvalue = Convert.ToInt32(drop) - 2;


        //For Last_Term
        MyGridView1.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView2.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView3.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView4.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView5.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView6.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView7.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView8.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView9.Columns[1].HeaderText  = "Fall " + Convert.ToString(previousvalue);
        MyGridView10.Columns[1].HeaderText = "Fall " + Convert.ToString(previousvalue);
        MyGridView11.Columns[1].HeaderText = "Fall " + Convert.ToString(previousvalue);


        //For Current_Term
        MyGridView1.Columns[2].HeaderText  = dropValue;
        MyGridView2.Columns[2].HeaderText  = dropValue;
        MyGridView3.Columns[2].HeaderText  = dropValue;
        MyGridView4.Columns[2].HeaderText  = dropValue;
        MyGridView5.Columns[2].HeaderText  = dropValue;
        MyGridView6.Columns[2].HeaderText  = dropValue;
        MyGridView7.Columns[2].HeaderText  = dropValue;
        MyGridView8.Columns[2].HeaderText  = dropValue;
        MyGridView9.Columns[2].HeaderText  = dropValue;
        MyGridView10.Columns[2].HeaderText = dropValue;
        MyGridView11.Columns[2].HeaderText = dropValue;
    }
Exemple #5
0
        /// <summary>
        /// 使用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUse_Click(object sender, EventArgs e)
        {
            string id = Page.Request.Form[name + Constants.MYQUERY_SELECTID];

            if (!String.IsNullOrEmpty(id))
            {
                try
                {
                    Template.SetSubjectParameters(sqlParameters, MyInputs1.Columns, id);
                }
                catch (Exception ex)
                {
                    Logger.Error("获取方案条件失败", ex);
                }
                Close(null);
            }
            else
            {
                MyInputs1.DataBind();
                MyGridView1.DataBind(Template.GetSubjectData(name, MyInputs1.Columns, CurrentUser.Id));
                Alert("请先选中一个方案,再点[使用]");
            }
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            name = QueryString[Constants.MYQUERY_NAME];
            //仅首次加载初始化
            if (String.IsNullOrEmpty(name))
            {
                Close("模板运行需要传递n参数,即对应的查询定制xml的名字(不含后缀)");
                return;
            }
            if (!Page.IsPostBack)
            {
                btnUse.Attributes.Add("onclick", "if (getSelectId('" + name + Constants.MYQUERY_SELECTID + "')) {return true;} else {alert('请先选中一个方案,再点[使用]');return false;}");
                btnDel.Attributes.Add("onclick", "if (getSelectId('" + name + Constants.MYQUERY_SELECTID + "')) {return true;} else {alert('请先选中一个方案,再点[删除]');return false;}");
            }
            //初始化参数
            MyInputs1.InputsType = MyInputsType.Detail;
            //初始化样式
            Template.SetGridViewStyle(MyGridView1);

            XmlDocument doc = null;

            //xml获取和基本判断
            try
            {
                doc = FromXml.GetXml(name);
            }
            catch (Exception ex)
            {
                Logger.Error("读取xml错误", ex);
                RedirectError("初始化失败,请稍候再试。原因:" + ex.Message);
                return;
            }
            //开始加载xml
            XmlNode myquery = XmlHelper.GetNode(doc.DocumentElement, "myquery");

            if (myquery == null)
            {
                Close("xml文件不是系统提供的定制查询配置文件");
                return;
            }
            //设置分页属性
            FromXml.SetGridViewPage(null, MyGridView1);
            try
            {
                //获得数据来源
                DataFrom dataFrom = new DataFrom(myquery, CurrentUser, QueryString);
                MyGridView1.Columns        = FromXml.GetSubjectColumns(myquery, dataFrom, MyInputs1, sqlParameters);
                MyGridView1.KeyColumnNames = "subject-id";

                if (!Page.IsPostBack)
                {
                    MyGridView1.DataBind(Template.GetSubjectData(name, MyInputs1.Columns, CurrentUser.Id));
                    MyInputs1.DataBind();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("初始化失败", ex);
                RedirectError("初始化失败,请稍候再试。原因:" + ex.Message);
            }
        }
    private void getHTMLGridView()
    {
        string attachment = "attachment; filename=" + Path.GetFileName(Request.PhysicalPath).Substring(0, Path.GetFileName(Request.PhysicalPath).Length - 5) + "_" + ENRDropDownList.SelectedItem + ".doc";

        Response.ClearContent();
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "application/vnd.word";
        StringWriter   stw       = new StringWriter();
        HtmlTextWriter htextw    = new HtmlTextWriter(stw);
        String         cellcount = MyGridView1.Rows[0].Cells.Count.ToString();
        string         header    = "<div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '";

        header += MyGridView1.Width.ToString() + "'><tr><td align='center' style='letter-spacing: 0.2em;' colspan='";
        header += cellcount + "'>TEXAS TECH UNIVERSITY</td></tr>";
        header += "<tr><td align='center' colspan='";
        header += cellcount + "'>" + caption.Text.ToUpper() + "</td></tr>";
        header += "<tr><td align='center' colspan='";
        header += cellcount + "'>DEPARTMENT OF INSTITUTIONAL RESEARCH</td></tr><tr><td align='center' style='font-size:11px;' colspan='";
        header += cellcount + "'>(Uncertified Data)</td></tr><tr><td colspan='";
        header += cellcount + "'><br></td></tr><tr><td align='center' colspan='";
        header += cellcount + "'><br>" + gvCaptionN.Text.ToString() + "</td></tr><tr><td colspan='";
        header += cellcount + "'></td></tr></table></div>";
        Response.Output.Write(header);
        MyGridView1.DataBind();
        MyGridView1.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView2.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionA.Text.ToString() + "</td></tr></table></div>");
        MyGridView2.DataBind();
        MyGridView2.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView3.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionP.Text.ToString() + "</td></tr></table></div>");
        MyGridView3.DataBind();
        MyGridView3.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView4.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionR.Text.ToString() + "</td></tr></table></div>");
        MyGridView4.DataBind();
        MyGridView4.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView5.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionU.Text.ToString() + "</td></tr></table></div>");
        MyGridView5.DataBind();
        MyGridView5.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView6.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionG.Text.ToString() + "</td></tr></table></div>");
        MyGridView6.DataBind();
        MyGridView6.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView7.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionT.Text.ToString() + "</td></tr></table></div>");
        MyGridView7.DataBind();
        MyGridView7.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView8.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionD.Text.ToString() + "</td></tr></table></div>");
        MyGridView8.DataBind();
        MyGridView8.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView9.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionS.Text.ToString() + "</td></tr></table></div>");
        MyGridView9.DataBind();
        MyGridView9.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView10.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionH.Text.ToString() + "</td></tr></table></div>");
        MyGridView10.DataBind();
        MyGridView10.RenderControl(htextw);
        stw.WriteLine("<br><div><table align='center' style='font-weight:bold; font-family:Verdana; font-size:14px; line-height:18px;' width= '" + MyGridView11.Width.ToString() + "'><tr><td align='center' colspan='" + cellcount + "'>" + gvCaptionO.Text.ToString() + "</td></tr></table></div>");


        MyGridView11.DataBind();
        MyGridView11.RenderControl(htextw);
        Response.Output.Write(stw.ToString());
        Response.End();
    }