コード例 #1
0
ファイル: AddForm.cs プロジェクト: kahineasin/PFCSharpHelper
        private void LoadField()
        {
            var fieldNode = FieldSetsHelper.FindField(_fieldSetsXml, lbDataSet.Text, _fieldName);

            if (fieldNode != null)
            {
                var config = new PFModelConfig(fieldNode, lbDataSet.Text);
                tbName.Text = config.FieldName;
                tbText.Text = config.FieldText;
                if (config.FieldType != null)
                {
                    cbType.SelectedItem = PFDataHelper.GetStringByType(config.FieldType);
                }
                cbVisible.Checked = config.Visible;
                if (config.FieldSqlLength != null)
                {
                    nudSqlLength.Value    = config.FieldSqlLength.Value;
                    nudSqlLength.ReadOnly = !(cbHaveSqlLength.Checked = true);
                }
                else
                {
                    nudSqlLength.ReadOnly = !(cbHaveSqlLength.Checked = false);
                }
                if (config.FieldWidth != null)
                {
                    nudWidth.Value    = decimal.Parse(config.FieldWidth.Replace("px", ""));
                    nudWidth.ReadOnly = !(cbHaveWidth.Checked = true);
                }
                else
                {
                    nudWidth.ReadOnly = !(cbHaveWidth.Checked = false);
                }
                //_pfModelConfig = config;
            }
        }
コード例 #2
0
ファイル: AddForm.cs プロジェクト: kahineasin/PFCSharpHelper
        private void DoAdd()
        {
            var old = FieldSetsHelper.FindField(_fieldSetsXml, lbDataSet.Text, tbName.Text);

            if (old != null)
            {
                MessageBox.Show(string.Format("{0}中已有存在{1}", lbDataSet.Text, tbName.Text));
                return;
            }
            var fields = _fieldSetsXml.SelectSingleNode(string.Format(@"DataSets/DataSet[@name='{0}']/Fields", lbDataSet.Text));

            if (fields != null)
            {
                XmlNode fieldNode = _fieldSetsXml.CreateNode("element", "Field", "");
                XmlNode nameNode  = _fieldSetsXml.CreateNode("element", "FieldName", "");
                nameNode.InnerText = tbName.Text;
                fieldNode.AppendChild(nameNode);

                UpdateFieldNodeByForm(ref fieldNode);

                #region old
                //XmlNode textNode = _fieldSetsXml.CreateNode("element", "FieldText", "");
                //textNode.InnerText = tbText.Text;
                //XmlNode sqlLengthNode = _fieldSetsXml.CreateNode("element", "FieldSqlLength", "");
                //sqlLengthNode.InnerText = nudSqlLength.Value.ToString();
                //XmlNode widthNode = _fieldSetsXml.CreateNode("element", "FieldWidth", "");
                //widthNode.InnerText = nudWidth.Value.ToString();
                //fieldNode.AppendChild(textNode);
                //if (cbType.SelectedItem != null)
                //{
                //    XmlNode typeNode = _fieldSetsXml.CreateNode("element", "FieldType", "");
                //    typeNode.InnerText = cbType.SelectedItem.ToString();
                //    fieldNode.AppendChild(typeNode);
                //}
                //if (cbHaveSqlLength.Checked) { fieldNode.AppendChild(sqlLengthNode); }
                //if (cbHaveWidth.Checked) { fieldNode.AppendChild(widthNode); }
                //if (!cbVisible.Checked)
                //{
                //    var visibleNode = _fieldSetsXml.CreateNode("element", "Visible", "");
                //    visibleNode.InnerText = "false";
                //    fieldNode.AppendChild(visibleNode);
                //}
                #endregion

                //添加为根元素的第一层子结点
                fields.AppendChild(fieldNode);
                _fieldSetsXml.Save(_xmlPath);

                MessageBox.Show("新增成功");
                AddEvent(tbName.Text);
                this.Close();
            }
        }
コード例 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var selects = dgvFieldSet.SelectedRows;

            if (selects.Count == 1 && (!selects[0].IsNewRow))
            {
                if (selects[0].Cells["FieldName"].Value != null)
                {
                    var fieldNode = FieldSetsHelper.FindField(_fieldSetsXml, selects[0].Cells["hideDataSet"].Value.ToString(), selects[0].Cells["FieldName"].Value.ToString());
                    if (fieldNode != null)
                    {
                        fieldNode.ParentNode.RemoveChild(fieldNode);
                        _fieldSetsXml.Save(_xmlPath);
                        MessageBox.Show("删除成功");
                        RefreshGrid();
                    }
                }
            }
            else
            {
                MessageBox.Show("只能删除一个字段");
            }
        }
コード例 #4
0
ファイル: AddForm.cs プロジェクト: kahineasin/PFCSharpHelper
        private void DoEdit()//现在这样每个属性单独判断(而不是生成一个Field大节点来替换)有个好外,就是如果某程序需要在xml加一个属性,但没更新本功能时,使用本功能不会影响未纳入管理的属性
        {
            var fieldNode = FieldSetsHelper.FindField(_fieldSetsXml, lbDataSet.Text, _fieldName);

            if (fieldNode != null)
            {
                UpdateFieldNodeByForm(ref fieldNode);

                #region old
                //var n = fieldNode.SelectSingleNode("FieldText");
                //if (n != null) { n.InnerText = tbText.Text; }
                //var t = fieldNode.SelectSingleNode("FieldType");
                //if (t != null) { t.InnerText = cbType.SelectedItem.ToString(); }

                //var l = fieldNode.SelectSingleNode("FieldSqlLength");
                //if (l != null)
                //{
                //    if (cbHaveSqlLength.Checked) { l.InnerText = nudSqlLength.Value.ToString(); } else { fieldNode.RemoveChild(l); }
                //}
                //else
                //{
                //    if (cbHaveSqlLength.Checked)
                //    {
                //        XmlNode sqlLengthNode = _fieldSetsXml.CreateNode("element", "FieldSqlLength", "");
                //        sqlLengthNode.InnerText = nudSqlLength.Value.ToString();
                //        fieldNode.AppendChild(sqlLengthNode);
                //    }
                //}

                //var w = fieldNode.SelectSingleNode("FieldWidth");
                //if (w != null) {
                //    if (cbHaveWidth.Checked) { w.InnerText = nudWidth.Value.ToString(); } else { fieldNode.RemoveChild(w); }
                //}else
                //{
                //    if (cbHaveWidth.Checked)
                //    {
                //        XmlNode widthNode = _fieldSetsXml.CreateNode("element", "FieldWidth", "");
                //        widthNode.InnerText = nudWidth.Value.ToString();
                //        fieldNode.AppendChild(widthNode);
                //    }
                //}
                //var v = fieldNode.SelectSingleNode("Visible");
                //if (v != null)
                //{
                //    if (cbVisible.Checked) { fieldNode.RemoveChild(v); }
                //}
                //else
                //{
                //    if (!cbVisible.Checked)
                //    {
                //        XmlNode visibleNode = _fieldSetsXml.CreateNode("element", "Visible", "");
                //        visibleNode.InnerText = "false";
                //        fieldNode.AppendChild(visibleNode);
                //    }
                //}
                #endregion

                _fieldSetsXml.Save(_xmlPath);
                MessageBox.Show("修改成功");
                EditEvent();
                this.Close();
            }
        }