Esempio n. 1
0
        private void FrmDetailView_Load(object sender, EventArgs e)
        {
            try
            {
                this.Text = this.TableName;
                _model    = _bll.GetModel(TableName);
                //_model.DETAIL_FORM_XML = XDocument.Load(Application.StartupPath + "\\DetailForm.xml").ToString();

                //按照自定义配置布局控件
                if (!string.IsNullOrEmpty(_model.DETAIL_FORM_XML))
                {
                    xDocConfig = XDocument.Parse(_model.DETAIL_FORM_XML, LoadOptions.None);
                    xElement   = xDocConfig.Root.Elements().Select(el => el);
                    foreach (XElement item in xElement)
                    {
                        //字段名
                        var columnName = (string)item.Attribute("Column_Name");
                        //字段值
                        object columnValue = null;
                        if (AddOrModify == "Modify")
                        {
                            columnValue = DgvRow.Cells[columnName].Value;
                        }
                        CreateStimControl stimControl = new CreateStimControl(item, columnValue, AddOrModify);
                        //非空字段
                        //DtStruct.Select("COLUMN_NAME='" + columnName + "'")[0]["NULLABLE"].ToString() == "N"
                        //var test = xElements.Elements("DataRule").Single(el => (int)el.Attribute("Max") == 100);
                        //XElement xEl = xElement.Single(el => (string)el.Attribute("Column_Name") == columnName).Elements("DataRule").Single();

                        pnlData.Controls.Add(stimControl.AutoStimControl);
                        //非空字段
                        if (((string)item.Attribute("Required")).Equals("True"))
                        {
                            stimControl.AutoStimControl.lblFile.ForeColor = Color.Red;
                        }
                        //ComboBox
                        if (stimControl.AutoStimControl.DataFile is ComboBox && columnValue != null)
                        {
                            //ComboBox的赋值操作只能在这里处理
                            ((ComboBox)stimControl.AutoStimControl.DataFile).SelectedValue = columnValue;
                            //stimControl.AutoStimControl.DataFile.Text = "否";
                        }
                    }
                }
                else
                {
                    MessageBox.Show("尚未对表【" + TableName + "】进行自定义配置,请新增该表的自定义配置!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 表切换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tvSingleTableList_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                _layoutRow    = -1;
                _layoutColumn = -1;
                tabPageDetail.Controls.Clear();
                propertyGrid1.SelectedObject = null;
                //取得表名
                this.TableName     = e.Node.Name;
                tabPageDetail.Text = "表 " + this.TableName + " 界面设计";

                DtStruct = _bll.GetTableInformation(this.TableName).Tables[0];

                _model = _bll.GetModel(e.Node.Name);
                //_model.DETAIL_FORM_XML = XDocument.Load(Application.StartupPath + "\\DetailForm.xml").ToString();

                //按照自定义配置布局控件
                if (!string.IsNullOrEmpty(_model.DETAIL_FORM_XML))
                {
                    XDocument xDoc = XDocument.Parse(_model.DETAIL_FORM_XML, LoadOptions.None);
                    ////Linq to XML
                    //IEnumerable<XNode> xNodes = from nd in xDoc.Root.Nodes() select nd;
                    //Lambda
                    IEnumerable <XElement> xElements = xDoc.Root.Elements().Select(el => el);
                    foreach (XElement item in xElements)
                    {
                        CreatStimControl(item);
                    }
                }
                //系统自动有序布局控件
                else
                {
                    foreach (DataRow row in DtStruct.Rows)
                    {
                        _layoutColumn++;
                        //3表示显示3列
                        if (_layoutColumn % 3 == 0)
                        {
                            _layoutColumn = 0;
                            _layoutRow++;
                        }
                        CreatStimControl(row);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 3
0
        private void FrmDataView_Load(object sender, EventArgs e)
        {
            //表结构
            DtStruct = _bll.GetTableInformation(TableName).Tables[0];
            _model   = _bll.GetModel(TableName);
            foreach (DataRow row in DtStruct.Rows)
            {
                if (row["ISPK"].ToString().Equals("Y"))
                {
                    PkList.Add((string)row["Column_Name".ToUpper()]);
                }
            }
            //_model.DATAGRIDVIEW_XML = XDocument.Load(Application.StartupPath + "\\DetailForm.xml").ToString();
            //按照自定义配置布局控件
            if (_model != null && !string.IsNullOrEmpty(_model.DETAIL_FORM_XML))
            {
                XDocument xDoc = XDocument.Parse(_model.DETAIL_FORM_XML, LoadOptions.None);
                //Lambda
                IEnumerable <XElement> xElements = xDoc.Root.Elements().Select(el => el);

                int _layoutRow    = -1; // 表单布局 行
                int _layoutColumn = -1; // 表单布局 列

                foreach (XElement item in xElements)
                {
                    string ListConditionFlag = item.Attribute("ListConditionFlag").Value;
                    string ListShowFlag      = item.Attribute("ListShowFlag").Value;

                    var dgvCol = new DataGridViewTextBoxColumn
                    {
                        Name             = (string)item.Attribute("Column_Name"),
                        HeaderText       = (string)item.Element("Lable").Value.TrimEnd(':').TrimEnd(':'),
                        DataPropertyName = (string)item.Attribute("Column_Name"),
                        Visible          = ListShowFlag.Equals("True"),
                    };
                    dgvData.Columns.Add(dgvCol);

                    if (ListConditionFlag.Equals("True"))
                    {
                        CreateStimControl stimControl = new CreateStimControl(item, null, "add");
                        _layoutColumn++;
                        //3表示显示3列
                        if (_layoutColumn % 3 == 0)
                        {
                            _layoutColumn = 0;
                            _layoutRow++;
                        }
                        stimControl.AutoStimControl.Location = new Point(20 + _layoutColumn * 300, 20 + _layoutRow * 35);
                        GrpflPanelSearch.Controls.Add(stimControl.AutoStimControl);
                        stimControl.AutoStimControl.Visible          = true;
                        stimControl.AutoStimControl.DataFile.Enabled = true;
                    }
                }
                //grpSearch.Height = (_layoutRow +1)* 35 + 20;
            }
            //系统自动有序布局控件
            else
            {
                foreach (DataRow row in DtStruct.Rows)
                {
                    var dgvCol = new DataGridViewTextBoxColumn
                    {
                        Name             = (string)row["Column_Name".ToUpper()],
                        HeaderText       = (string)row["Column_Name".ToUpper()],
                        DataPropertyName = (string)row["Column_Name".ToUpper()],
                        ReadOnly         = true,
                        //主键
                        //Tag = row["ISPK"].ToString().Equals("Y") ? "ISPK" : ""
                    };
                    dgvData.Columns.Add(dgvCol);

                    //if (row["ISPK"].ToString().Equals("Y"))
                    //{
                    //    PkList.Add(dgvCol.Name);
                    //}
                }
            }
            //LoadData();
        }