protected void btnGetFields_Click(object sender, EventArgs e)
        {
            try
            {
                int id;
                int.TryParse(Request["Iden"], out id);

                var dt = QueryHelper.GetScheduleQueryHdr(id);
                if (dt != null && dt.Rows.Count > 0)
                {
                    var sql = dt.Rows[0]["sSql"].ToString();
                    var result = QueryHelper.ExecutePageQuery(sql, new QueryParam() { PageIndex = 1, PageSize = 1 });
                    if (result.IsSucess && result.Data != null && result.Data.Columns.Count > 0)
                    {
                        var table = result.Data;
                        List<ScheduleQueryFieldInfo> fields = new List<ScheduleQueryFieldInfo>();
                        foreach (DataColumn item in table.Columns)
                        {
                            if (item.ColumnName != "ROWSTAT")
                            {
                                var field = new ScheduleQueryFieldInfo();
                                field.iIden = QueryHelper.NewIden("smScheduleQueryField");
                                field.iQueryHdrId = id;
                                field.sFieldName = item.ColumnName;
                                field.sCaption = item.ColumnName;
                                field.bShow = true;
                                field.iWidth = 0;
                                field.bAllowWarp = true;
                                field.sHorizontalAlignment = "center";
                                field.sVerticalAlignment = "middle";
                                field.iSortIndex = table.Columns.IndexOf(item);
                                fields.Add(field);
                            }
                        }
                        QueryHelper.AddScheduleQueryField(fields);

                        GridViewBind();
                    }
                    else
                    {
                        throw new Exception(result.Message);
                    }
                }
                else
                {
                    throw new Exception("未配置子查询!");
                }
            }
            catch (Exception ex)
            {
                this.hasError = true;
                this.errorMsg = ex.Message;
            }
        }
Exemple #2
0
        public static void ModifyScheduleQueryField(ScheduleQueryFieldInfo scheduleQueryFieldInfo)
        {
            var sql = @"
update smScheduleQueryField
set 
    sCaption=@sCaption, 
    bShow=@bShow, 
    iWidth=@iWidth, 
    bAllowWarp=@bAllowWarp, 
    sHorizontalAlignment=@sHorizontalAlignment, 
    sVerticalAlignment=@sVerticalAlignment, 
    iSortIndex=@iSortIndex
where iIden=@iIden";
            var connectionString = WebConfig.GetConnectionString();
            var param = new SqlParameter[8];
            param[0] = new SqlParameter("@iIden", scheduleQueryFieldInfo.iIden);
            param[1] = new SqlParameter("@sCaption", scheduleQueryFieldInfo.sCaption);
            param[2] = new SqlParameter("@bShow", scheduleQueryFieldInfo.bShow) { SqlDbType = SqlDbType.Bit };
            param[3] = new SqlParameter("@iWidth", scheduleQueryFieldInfo.iWidth);
            param[4] = new SqlParameter("@bAllowWarp", scheduleQueryFieldInfo.bAllowWarp) { SqlDbType = SqlDbType.Bit };
            param[5] = new SqlParameter("@sHorizontalAlignment", scheduleQueryFieldInfo.sHorizontalAlignment);
            param[6] = new SqlParameter("@sVerticalAlignment", scheduleQueryFieldInfo.sVerticalAlignment);
            param[7] = new SqlParameter("@iSortIndex", scheduleQueryFieldInfo.iSortIndex);
            SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, sql, param);
        }
        protected void GridViewField_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                var obj = new ScheduleQueryFieldInfo();
                GridViewRow row = this.GridViewField.Rows[e.RowIndex];
                obj.iIden = Convert.ToInt32(this.GridViewField.DataKeys[e.RowIndex].Values[0].ToString());
                obj.sCaption = ((TextBox)row.FindControl("txtCaption")).Text.Trim();
                obj.bShow = ((CheckBox)row.FindControl("chkShow")).Checked;
                obj.iWidth = Convert.ToInt32(((TextBox)row.FindControl("txtWidth")).Text);
                obj.bAllowWarp = ((CheckBox)row.FindControl("chkAllowWarp")).Checked;
                obj.sHorizontalAlignment = ((DropDownList)row.FindControl("ddlHorizontalAlignment")).SelectedValue;
                obj.sVerticalAlignment = ((DropDownList)row.FindControl("ddlVerticalAlignment")).SelectedValue;
                obj.iSortIndex = Convert.ToInt32(((TextBox)row.FindControl("txtSortIndex")).Text);
                QueryHelper.ModifyScheduleQueryField(obj);

                GridViewField.EditIndex = -1;
                GridViewBind();
            }
            catch (Exception ex)
            {
                this.hasError = true;
                this.errorMsg = ex.Message;
            }
        }