Example #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)
            {
            }
        }
Example #2
0
        /// <summary>
        /// XML文件加载
        /// </summary>
        /// <param name="xElement"></param>
        /// <param name="draggable"></param>
        public void CreatStimControl(XElement xElement)
        {
            CreateStimControl stimControl = new CreateStimControl(xElement, null);

            //添加属性选择对象
            stimControl.AutoStimControl.Click += new System.EventHandler(stimControl_Click);
            //添加拖住标识
            stimControl.AutoStimControl.MouseDown += new MouseEventHandler(control_MouseDown);
            stimControl.AutoStimControl.MouseUp   += new MouseEventHandler(control_MouseUp);

            //pb.WireControl(stimControl.AutoStimControl);
            tabPageDetail.Controls.Add(stimControl.AutoStimControl);
            //if (stimControl.AutoStimControl.DataFile is RadioButtonGroup)
            //{
            //    ((RadioButtonGroup)stimControl.AutoStimControl.DataFile).InitUI();
            //}
        }
Example #3
0
        /// <summary>
        /// 数据库加载
        /// </summary>
        /// <param name="row"></param>
        /// <param name="draggable"></param>
        public void CreatStimControl(DataRow row)
        {
            CreateStimControl stimControl = new CreateStimControl(row, null);

            stimControl.AutoStimControl.Location = new Point(20 + _layoutColumn * 300, 10 + _layoutRow * 35);
            //只读属性,通过是否主键判断 Y:是,N:否
            if ("Y" == row["ISPK"].ToString())
            {
                //stimControl.AutoStimControl.Enabled = false;
                //StimTxt.dataFile.ReadOnly = true;
                stimControl.AutoStimControl.property.ControlEnable = 0;
            }
            //添加属性选择对象
            stimControl.AutoStimControl.Click += new System.EventHandler(stimControl_Click);
            //添加拖住标识
            stimControl.AutoStimControl.MouseDown += new MouseEventHandler(control_MouseDown);
            stimControl.AutoStimControl.MouseUp   += new MouseEventHandler(control_MouseUp);
            tabPageDetail.Controls.Add(stimControl.AutoStimControl);
        }
Example #4
0
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="controls">控件集合</param>
        /// <param name="result">返回值</param>
        public void ModifyData(Control.ControlCollection controls, ref object result)
        {
            StringBuilder sbUpdateSql = new StringBuilder("update " + TableName + " set ");
            StringBuilder sbKeyValue  = new StringBuilder();
            StringBuilder sbWhere     = new StringBuilder(" where 1=1 ");
            //获取填写的值
            Hashtable         htItem = new Hashtable();
            CreateStimControl csc    = new CreateStimControl();

            foreach (StimControl item in controls)
            {
                DataRow row   = DtStruct.Select("COLUMN_NAME='" + item.Name + "'")[0];
                string  value = csc.GetValueByType(item.DataFile);
                //如果不是主键
                if (!PkList.Contains(item.Name))
                {
                    //值为空(此处''表示为空)
                    if (string.IsNullOrEmpty(value.ToString()))
                    {
                        //if (row["Nullable"].ToString() == "N" || item.property.ControlRequired == 1)XElement xEl = xElement.Single(el => (string)el.Attribute("Column_Name") == item.Name).Elements("DataRule").Single();
                        //字段不能为空
                        if (row["Nullable"].ToString() == "N" || item.property.ControlRequired == 1)
                        {
                            MessageBox.Show(item.lblFile.Text + " 不能为空!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            result = "error";
                            return;
                        }
                    }
                    //值不为空
                    else
                    {
                        ;
                        sbKeyValue.Append("," + item.Name);
                        string type = row["DATA_TYPE"].ToString();
                        if (type.Equals("NUMBER"))
                        {
                            sbKeyValue.Append("=" + value);
                        }
                        else if (type.Equals("DATE") || type.ToUpper().IndexOf("TIMESTAMP") == 0)
                        {
                            sbKeyValue.Append("=to_date('" + value + "','YYYY-MM-DD HH24:MI:SS')");
                        }
                        else if (value.ToString().ToLower().Equals("sysdate"))
                        {
                            sbKeyValue.Append("=" + value);
                        }
                        else
                        {
                            sbKeyValue.Append("='" + value + "'");
                        }
                    }
                }
                else
                {
                    sbWhere.Append(" and " + item.Name);
                    sbWhere.Append("='" + value + "'");
                }
                htItem.Add(item.property, value);
            }
            sbKeyValue.Remove(0, 1);//移除第一个逗号
            sbUpdateSql.Append(sbKeyValue);
            sbUpdateSql.Append(sbWhere);
            //数据验证格式和正确性验证
            foreach (DictionaryEntry objDE in htItem)
            {
                string val = objDE.Value.ToString();
                StimControlProperty property = objDE.Key as StimControlProperty;
                //验证输入值
                if (!checkValudate(property, val, htItem))
                {
                    MessageBox.Show(property.Text + " 输入值错误!", "提示消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    result = "error";
                    return;
                }
            }
            result = _bll.UpdateData(sbUpdateSql.ToString());
        }
Example #5
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();
        }