Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void AddColumn()
        {
            // remove fields
            storeInsurance.RemoveFields();

            var view = gpInsurance.View[0];

            //init group header
            var headerGroupRow = new HeaderGroupRow();

            //add column group header
            headerGroupRow.Columns.Add(new HeaderGroupColumn
            {
                Header  = "",
                ColSpan = 4,
                Align   = Alignment.Center
            });

            // column index
            var colIndex = new RowNumbererColumn
            {
                ColumnID = "colIndex",
                Header   = "STT",
                Align    = Alignment.Center,

                Width = 40
            };

            gpInsurance.ColumnModel.Columns.Add(colIndex);

            // init column employee name
            var colFullName = new Column
            {
                ColumnID  = "colFullName",
                Header    = "Họ và tên",
                DataIndex = "FullName",
                Align     = Alignment.Left,
                Width     = 150
            };
            var recordFieldFullName = new RecordField()
            {
                Name    = "FullName",
                Mapping = "FullName"
            };

            storeInsurance.AddField(recordFieldFullName);
            gpInsurance.ColumnModel.Columns.Add(colFullName);

            // column employee code
            var colEmployeeCode = new Column
            {
                ColumnID  = "colEmployeeCode",
                Header    = "Mã nhân viên",
                DataIndex = "EmployeeCode",
                Align     = Alignment.Left,
                Width     = 100
            };
            var recordFieldEmployeeCode = new RecordField()
            {
                Name    = "EmployeeCode",
                Mapping = "EmployeeCode"
            };

            storeInsurance.AddField(recordFieldEmployeeCode);
            gpInsurance.ColumnModel.Columns.Add(colEmployeeCode);

            //init column departmentName
            var colDepartmentName = new Column
            {
                ColumnID  = "colDepartmentName",
                Header    = "Đơn vị",
                DataIndex = "DepartmentName",
                Align     = Alignment.Left,
                Width     = 150
            };
            var recordFieldDepartmentName = new RecordField()
            {
                Name    = "DepartmentName",
                Mapping = "DepartmentName"
            };

            storeInsurance.AddField(recordFieldDepartmentName);
            gpInsurance.ColumnModel.Columns.Add(colDepartmentName);

            // init count
            var count    = 0;
            var products = new string[] { "Công ty đóng", "Người LĐ đóng" };

            // add column by month
            for (var i = 0; i < 12; i++)
            {
                //add group header
                headerGroupRow.Columns.Add(new HeaderGroupColumn
                {
                    Header  = @"Tháng {0}".FormatWith(i + 1),
                    ColSpan = products.Length,
                    Align   = Alignment.Center
                });

                // init field
                var recordField = new RecordField()
                {
                    Name    = "Month{0}".FormatWith(i + 1),
                    Mapping = "InsuranceDetailModels[{0}]".FormatWith(count++)
                };
                foreach (var product in products)
                {
                    var value = "EnterpriseSocial";
                    if (product == @"Công ty đóng")
                    {
                        value = "EnterpriseSocial";
                    }
                    else
                    {
                        value = "LaborerSocial";
                    }

                    // init column
                    var col = new Column
                    {
                        ColumnID  = value,
                        Header    = product,
                        DataIndex = recordField.Name,
                        Align     = Alignment.Left,
                        Width     = 150,
                        Renderer  = { Fn = "RenderMonth" }
                    };

                    // add column
                    gpInsurance.ColumnModel.Columns.Add(col);
                }
                // add field
                storeInsurance.AddField(recordField);
            }

            //add header group row
            view.HeaderGroupRows.Add(headerGroupRow);
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                var structure = new Dictionary <string, string>
                {
                    { "总数", "" },
                    { "同步下家数", "" },
                    { "扣量", "" }
                };

                var products          = new string[] { "下行数 ", "成功数", "成功率" };
                var grid              = GridPanel1;
                var view              = grid.View[0];
                var store             = grid.Store[0];
                var cm                = grid.ColumnModel;
                var continentGroupRow = new HeaderGroupRow();
                var data              = new object[5];
                var i      = 0;
                var random = new Random();

                foreach (KeyValuePair <string, string> keyValuePair in structure)
                {
                    var continent = keyValuePair.Key;

                    continentGroupRow.Columns.Add(new HeaderGroupColumn
                    {
                        Header  = continent,
                        Align   = Alignment.Center,
                        ColSpan = products.Length
                    });


                    foreach (string product in products)
                    {
                        store.Reader[0].Fields.Add(continent + product, RecordFieldType.Int);

                        cm.Columns.Add(new Column
                        {
                            DataIndex = continent + product,
                            Header    = product,
                            Renderer  =
                            {
                                Format = RendererFormat.UsMoney
                            }
                        });
                    }

                    var arr = new int[28];

                    for (int j = 0; j < arr.Length; j++)
                    {
                        arr[j] = Convert.ToInt32((Math.Floor(random.NextDouble() * 11) + 1) * 100000);
                    }

                    data[i++] = arr;
                }

                view.HeaderGroupRows.Add(continentGroupRow);

                store.DataSource = data;
                store.DataBind();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Query Button Click
        /// </summary>
        protected void QueryBtn_Click(object sender, DirectEventArgs e)
        {
            try {
                var columns           = new string[] { "序号", "Lsc名称", "地区名称", "县市名称", "局站名称", "设备名称" };
                var len               = columns.Length;
                var grid              = MainGridPanel;
                var store             = grid.GetStore();
                var view              = grid.GetView();
                var model             = grid.ColumnModel.Columns;
                var continentGroupRow = new HeaderGroupRow();

                model.Clear();
                view.HeaderGroupRows.Clear();
                store.RemoveFields();

                continentGroupRow.Columns.Add(new HeaderGroupColumn {
                    Header  = "",
                    ColSpan = len,
                    Align   = Alignment.Center
                });

                for (int i = 0; i < len; i++)
                {
                    var dataIndex = String.Format("Data{0}", i);
                    store.AddField(new RecordField(dataIndex, RecordFieldType.String), false);

                    var column = new Column();
                    column.Header    = columns[i];
                    column.DataIndex = dataIndex;
                    column.CustomConfig.Add(new ConfigItem("DblClickEnabled", "0", ParameterMode.Value));
                    model.Add(column);
                }

                var data = e.ExtraParams["SyncColumns"];
                if (!String.IsNullOrEmpty(data))
                {
                    var jdata = JSON.Deserialize <Newtonsoft.Json.Linq.JArray>(data);
                    foreach (var row in jdata)
                    {
                        var col = row.Value <String>("col");
                        var alm = row.Value <String>("alm");
                        var min = row.Value <Int32>("min");
                        var max = row.Value <Int32>("max");

                        continentGroupRow.Columns.Add(new HeaderGroupColumn {
                            Header  = col,
                            ColSpan = 2,
                            Align   = Alignment.Center
                        });

                        var dataIndex1 = String.Format("Data{0}-1", len);
                        store.AddField(new RecordField(dataIndex1, RecordFieldType.Float), false);

                        var column1 = new Column();
                        column1.Header    = "累计时长";
                        column1.DataIndex = dataIndex1;
                        column1.CustomConfig.Add(new ConfigItem("DblClickEnabled", "0", ParameterMode.Value));
                        model.Add(column1);

                        var dataIndex2 = String.Format("Data{0}-2", len++);
                        store.AddField(new RecordField(dataIndex2, RecordFieldType.Int), false);

                        var column2 = new Column();
                        column2.Header    = "告警次数";
                        column2.DataIndex = dataIndex2;
                        column2.CustomConfig.Add(new ConfigItem("DblClickEnabled", "1", ParameterMode.Value));
                        model.Add(column2);
                    }

                    ViewState["scdata"] = data;
                }

                view.HeaderGroupRows.Add(continentGroupRow);
                store.ClearMeta();
                grid.Render();
            } catch (Exception err) {
                WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name);
                WebUtility.ShowMessage(EnmErrType.Error, err.Message);
            }
        }