protected void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckInput())
                {
                    var scheduleQueryHdrInfo = new ScheduleQueryHdrInfo();
                    scheduleQueryHdrInfo.sName = this.txtName.Text.Trim();
                    scheduleQueryHdrInfo.iQueryId = Convert.ToInt32(this.txtQueryId.Text);
                    scheduleQueryHdrInfo.iPageSize = Convert.ToInt32(this.txtPageSize.Text);
                    scheduleQueryHdrInfo.iFontSize = Convert.ToInt32(this.txtFontSize.Text);
                    scheduleQueryHdrInfo.sSql = this.txtSQL.Value.Trim();

                    if (this.IsModifyAction)
                    {
                        int id;
                        int.TryParse(Request["Iden"], out id);
                        scheduleQueryHdrInfo.iIden = id;

                        QueryHelper.ModifyScheduleQueryHdr(scheduleQueryHdrInfo);
                        Response.Clear();
                        ClientScript.RegisterStartupScript(this.GetType(), string.Empty,
                          string.Format("<script type=\"text/javascript\">alert('{0}');location.href='{1}';</script>", "修改成功!", Request.Url.PathAndQuery));
                    }
                    else
                    {
                        scheduleQueryHdrInfo.iIden = QueryHelper.NewIden("smScheduleQueryHdr");

                        QueryHelper.AddScheduleQueryHdr(scheduleQueryHdrInfo);
                        Response.Clear();
                        ClientScript.RegisterStartupScript(this.GetType(), string.Empty,
                          string.Format("<script type=\"text/javascript\">alert('{0}');location.href='{1}';</script>", "添加成功!", "AddScheduleQueryHdr.aspx?Action=m&Iden=" + scheduleQueryHdrInfo.iIden.ToString()));
                    }
                }
                else
                {
                    hasError = true;
                }
            }
            catch (System.Exception ex)
            {
                hasError = true;
                errorMsg = ex.Message;
            }
        }
Example #2
0
 public static void AddScheduleQueryHdr(ScheduleQueryHdrInfo scheduleQueryHdrInfo)
 {
     var sql = "INSERT dbo.smScheduleQueryHdr(iIden, sName, iQueryId, sSql, iPageSize, iFontSize) values(@iIden, @sName, @iQueryId, @sSql, @iPageSize, @iFontSize)";
     var connectionString = WebConfig.GetConnectionString();
     var param = new SqlParameter[6];
     param[0] = new SqlParameter("@iIden", scheduleQueryHdrInfo.iIden);
     param[1] = new SqlParameter("@sName", scheduleQueryHdrInfo.sName);
     param[2] = new SqlParameter("@iQueryId", scheduleQueryHdrInfo.iQueryId);
     param[3] = new SqlParameter("@sSql", scheduleQueryHdrInfo.sSql);
     param[4] = new SqlParameter("@iPageSize", scheduleQueryHdrInfo.iPageSize);
     param[5] = new SqlParameter("@iFontSize", scheduleQueryHdrInfo.iFontSize);
     SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, sql, param);
 }
Example #3
0
        public static void ModifyScheduleQueryHdr(ScheduleQueryHdrInfo scheduleQueryHdrInfo)
        {
            var sql = @"
update smScheduleQueryHdr
set sName=@sName, iQueryId=@iQueryId, sSql=@sSql, iPageSize=@iPageSize, iFontSize=@iFontSize
where iIden=@iIden";
            var connectionString = WebConfig.GetConnectionString();
            var param = new SqlParameter[6];
            param[0] = new SqlParameter("@iIden", scheduleQueryHdrInfo.iIden);
            param[1] = new SqlParameter("@sName", scheduleQueryHdrInfo.sName);
            param[2] = new SqlParameter("@iQueryId", scheduleQueryHdrInfo.iQueryId);
            param[3] = new SqlParameter("@sSql", scheduleQueryHdrInfo.sSql);
            param[4] = new SqlParameter("@iPageSize", scheduleQueryHdrInfo.iPageSize);
            param[5] = new SqlParameter("@iFontSize", scheduleQueryHdrInfo.iFontSize);
            SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, sql, param);
        }