コード例 #1
0
ファイル: PactComboBox.cs プロジェクト: merlin2504/RD12
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            if (GetFeatureID(this) == 0)
            {
                return;
            }

            CommonClient oDMCommon = new CommonClient();
            DataTable    dt        = oDMCommon.GetDataTable("SELECT * FROM AdmnLayoutLists WHERE ID=" + GetFeatureID(this).ToString(), GetCompanyDBIndex(this).ToString());

            oDMCommon.Close();
            strTable      = dt.Rows[0]["TableName"].ToString();
            strPrimaryKey = dt.Rows[0]["PrimaryKey"].ToString();
            _Where        = dt.Rows[0]["WhereClause"].ToString();

            XmlDocument xDoc = new XmlDocument();

            xDoc.LoadXml(dt.Rows[0]["LayoutXML"].ToString());

            XmlNodeList xList = xDoc.SelectNodes("XML/Columns/TreeColumn");
            TreeColumn  oCol;

            oColumns = new List <TreeColumn>();

            _Query = "SELECT " + strPrimaryKey;

            this.IsEditable = true;
            Microsoft.Windows.Controls.DataGridTextColumn dgCol;

            dgCol            = new Microsoft.Windows.Controls.DataGridTextColumn();
            dgCol.Header     = strPrimaryKey;
            dgCol.Binding    = new Binding(strPrimaryKey);
            dgCol.Visibility = System.Windows.Visibility.Hidden;
            this.Columns.Add(dgCol);


            for (int i = 0; i < xList.Count; i++)
            {
                oCol    = (TreeColumn)PACTSerializer.FromXml(xList[i].OuterXml, typeof(TreeColumn));
                _Query += "," + oCol.Name;

                dgCol        = new Microsoft.Windows.Controls.DataGridTextColumn();
                dgCol.Header = oCol.Label;

                if (xList.Count == 1)
                {
                    if (this.Width > 0)
                    {
                        dgCol.Width = this.Width;
                    }
                    else
                    {
                        dgCol.Width = oCol.Width;
                    }
                }
                else
                {
                    dgCol.Width = oCol.Width;
                }

                dgCol.CanUserResize = false;
                dgCol.CanUserSort   = false;
                dgCol.Binding       = new Binding(oCol.Name);
                iWidth += oCol.Width;
                this.Columns.Add(dgCol);
                oColumns.Add(oCol);
            }

            _Query += " FROM " + strTable;

            if (this.SelectedValue != null)
            {
                valueSelected = true;
            }

            //this.SelectedValue = new Binding(strPrimaryKey);
            this.SelectedValuePath = strPrimaryKey;
        }
コード例 #2
0
ファイル: PactComboBox.cs プロジェクト: merlin2504/RD12
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            if (GetFeatureID(this) == 0)
                return;

            CommonClient oDMCommon = new CommonClient();
            DataTable dt = oDMCommon.GetDataTable("SELECT * FROM AdmnLayoutLists WHERE ID=" + GetFeatureID(this).ToString(), GetCompanyDBIndex(this).ToString());
            oDMCommon.Close();
            strTable = dt.Rows[0]["TableName"].ToString();
            strPrimaryKey = dt.Rows[0]["PrimaryKey"].ToString();
            _Where = dt.Rows[0]["WhereClause"].ToString();

            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml(dt.Rows[0]["LayoutXML"].ToString());

            XmlNodeList xList = xDoc.SelectNodes("XML/Columns/TreeColumn");
            TreeColumn oCol;
            oColumns = new List<TreeColumn>();

            _Query = "SELECT " + strPrimaryKey;

            this.IsEditable = true;
            Microsoft.Windows.Controls.DataGridTextColumn dgCol;

            dgCol = new Microsoft.Windows.Controls.DataGridTextColumn();
            dgCol.Header = strPrimaryKey;
            dgCol.Binding = new Binding(strPrimaryKey);
            dgCol.Visibility = System.Windows.Visibility.Hidden;
            this.Columns.Add(dgCol);

            for (int i = 0; i < xList.Count; i++)
            {
                oCol = (TreeColumn)PACTSerializer.FromXml(xList[i].OuterXml, typeof(TreeColumn));
                _Query += "," + oCol.Name;

                dgCol = new Microsoft.Windows.Controls.DataGridTextColumn();
                dgCol.Header = oCol.Label;

                if (xList.Count == 1)
                {
                    if (this.Width > 0)
                        dgCol.Width = this.Width;
                    else
                        dgCol.Width = oCol.Width;
                }
                else
                    dgCol.Width = oCol.Width;

                dgCol.CanUserResize = false;
                dgCol.CanUserSort = false;
                dgCol.Binding = new Binding(oCol.Name);
                iWidth += oCol.Width;
                this.Columns.Add(dgCol);
                oColumns.Add(oCol);
            }

            _Query += " FROM " + strTable;

            if (this.SelectedValue != null)
                valueSelected = true;

            //this.SelectedValue = new Binding(strPrimaryKey);
            this.SelectedValuePath = strPrimaryKey;
        }
コード例 #3
0
        private void AddDataGrid(StackPanel stackPanel, Microsoft.Windows.Controls.DataGrid dgGrid)
        {
            stackPanel.Children.Clear();

            dgGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            dgGrid.Margin              = new System.Windows.Thickness(1, 1, 0, 1);
            dgGrid.BorderBrush         = new SolidColorBrush(Colors.Transparent);
            dgGrid.HeadersVisibility   = Microsoft.Windows.Controls.DataGridHeadersVisibility.Column;
            dgGrid.GridLinesVisibility = Microsoft.Windows.Controls.DataGridGridLinesVisibility.Horizontal;
            dgGrid.RowHeaderWidth      = 0;
            dgGrid.RowHeight           = 18;

            dgGrid.Style     = (Style)FindResource("DataGridStyle");
            dgGrid.CellStyle = (Style)FindResource("dgCellStyle");
            dgGrid.RowStyle  = (Style)FindResource("dgRowStyle");

            dgGrid.VerticalGridLinesBrush   = (Brush)FindResource("TransparentGridLine");
            dgGrid.HorizontalGridLinesBrush = (Brush)FindResource("TransparentGridLine");
            dgGrid.Background    = new SolidColorBrush(Color.FromRgb(251, 236, 166));
            dgGrid.Foreground    = new SolidColorBrush(Color.FromRgb(29, 56, 117));
            dgGrid.FontSize      = 11;
            dgGrid.IsReadOnly    = true;
            dgGrid.SelectionMode = Microsoft.Windows.Controls.DataGridSelectionMode.Extended;
            dgGrid.SelectionUnit = Microsoft.Windows.Controls.DataGridSelectionUnit.FullRow;

            if (stackPanel.Name == "panUserList")
            {
                dgGrid.ColumnHeaderHeight = 0;
                dgGrid.HeadersVisibility  = Microsoft.Windows.Controls.DataGridHeadersVisibility.None;
            }
            else
            {
                dgGrid.ColumnHeaderStyle = (Style)FindResource("dgColumnHeaderStyle");
            }

            Microsoft.Windows.Controls.DataGridTemplateColumn col1 = new Microsoft.Windows.Controls.DataGridTemplateColumn();
            col1.Header = "     ";

            FrameworkElementFactory factory1 = new FrameworkElementFactory(typeof(Image));

            System.Windows.Data.Binding b1 = new System.Windows.Data.Binding("face");
            b1.Mode = BindingMode.TwoWay;
            factory1.SetValue(Image.SourceProperty, b1);

            DataTemplate cellTemplate1 = new DataTemplate();

            cellTemplate1.VisualTree = factory1;

            col1.CellTemplate = cellTemplate1;
            col1.Width        = 28;
            col1.MinWidth     = 28;
            dgGrid.Columns.Add(col1);

            Microsoft.Windows.Controls.DataGridTextColumn col2 = new Microsoft.Windows.Controls.DataGridTextColumn();
            col2.Header   = "用户名";
            col2.Width    = 90;
            col2.MinWidth = 90;

            col2.Binding = new System.Windows.Data.Binding("id");
            dgGrid.Columns.Add(col2);

            Microsoft.Windows.Controls.DataGridTextColumn col3 = new Microsoft.Windows.Controls.DataGridTextColumn();
            col3.Header = "押注金额";

            col3.Width        = 45;// Microsoft.Windows.Controls.DataGridLength.Auto;
            col3.MinWidth     = 45;
            col3.Binding      = new System.Windows.Data.Binding("betscore");
            col3.ElementStyle = (Style)FindResource("dgElementRightStyle");
            dgGrid.Columns.Add(col3);

            Microsoft.Windows.Controls.DataGridTextColumn col4 = new Microsoft.Windows.Controls.DataGridTextColumn();
            col4.Header = "  金额";

            col4.Width        = 50;// Microsoft.Windows.Controls.DataGridLength.Auto;
            col4.MinWidth     = 50;
            col4.Binding      = new System.Windows.Data.Binding("score");
            col4.ElementStyle = (Style)FindResource("dgElementRightStyle");
            dgGrid.Columns.Add(col4);

            Microsoft.Windows.Controls.DataGridTextColumn col5 = new Microsoft.Windows.Controls.DataGridTextColumn();
            col5.Header = "";

            col5.Width = 25;
            dgGrid.Columns.Add(col5);

            dgGrid.Items.Clear();
            stackPanel.Children.Add(dgGrid);
        }