Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtName.EditValue == null || string.IsNullOrEmpty(txtName.Text.Trim()))
            {
                MessageBox.Show("名称不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtBaseName.EditValue == null || string.IsNullOrEmpty(txtBaseName.Text.Trim()))
            {
                MessageBox.Show("基本名称不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            _dataset.Name      = txtName.EditValue.ToString();
            _dataset.BaseName  = txtBaseName.EditValue.ToString();
            _dataset.AliasName = txtAliasName.EditValue.ToString();

            int oid = _database.GetObjectID(_dataset.Name, enumTemplateObjectType.FeatureDataset);

            if (_dataset.ID > 0)
            {
                if (_dataset.ID != oid)
                {
                    MessageBox.Show("该名称已经存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                if (oid > 0)
                {
                    MessageBox.Show("该名称已经存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            _database.SaveDataset(_dataset);
            DialogResult = DialogResult.OK;
        }
Пример #2
0
        private bool SaveDomain()
        {
            IYTDomain domain = new YTDomain();

            domain.Name        = txtName.EditValue == null ? "" : txtName.EditValue.ToString();
            domain.Description = txtDescription.EditValue == null ? "" : txtDescription.EditValue.ToString();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                string code = dataGridView1.Rows[i].Cells[0].Value == null
                    ? ""
                    : dataGridView1.Rows[i].Cells[0].Value.ToString();
                string description = dataGridView1.Rows[i].Cells[1].Value == null
                    ? ""
                    : dataGridView1.Rows[i].Cells[1].Value.ToString();
                if (string.IsNullOrEmpty(code))
                {
                    continue;
                }
                YTDomainValue pair = new YTDomainValue()
                {
                    Value = code, Description = description
                };
                domain.ValuePairs.Add(pair);
            }

            int back = _database.GetObjectID(domain.Name, enumTemplateObjectType.Domain);

            if (back > 0 && back != _domain.ID)
            {
                MessageBox.Show("该数据字典已经存在,请改名后保存!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            domain.ID = _domain.ID;
            return(_database.SaveDomain(domain));

            _domain = domain;
        }
Пример #3
0
        private bool SaveTemplate()
        {
            _tmpTemplate                  = new ObjectTemplate();
            _tmpTemplate.Name             = txtName.EditValue == null?"": txtName.EditValue.ToString().Trim();
            _tmpTemplate.AliasName        = txtAliasName.EditValue == null?"": txtAliasName.EditValue.ToString().Trim();
            _tmpTemplate.BaseName         = txtBaseName.EditValue == null?"": txtBaseName.EditValue.ToString().Trim();
            _tmpTemplate.FeatureTypeName  = cmbFeatureType.SelectedValue.ToString();
            _tmpTemplate.GeometryTypeName = cmbGeometryTypes.SelectedValue.ToString();
            _tmpTemplate.DatasetName      = cmbDatasets.SelectedValue == null ? "":cmbDatasets.SelectedValue.ToString();
            string msg = "";

            for (int i = 0; i < _fieldTable.Rows.Count; i++)
            {
                DataRow row    = _fieldTable.Rows[i];
                YTField pField = new YTField()
                {
                    Name          = row["FieldName"].ToString(),
                    AliasName     = row["AliasName"].ToString(),
                    FieldTypeName = row["FieldType"].ToString(),
                    AllowNull     = (bool)row["AllowNull"],
                    IsKey         = (bool)row["IsKey"],
                    Length        = (int)row["FieldLength"],
                    Precision     = (int)row["Precision"],
                    DomainName    = row["DomainName"].ToString()
                };
                if (pField.IsValid(out msg) == false)
                {
                    MessageBox.Show(msg, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                _tmpTemplate.Fields.Add(pField);
            }


            int oid = _database.GetObjectID(_tmpTemplate.Name, enumTemplateObjectType.FeatureClass);

            if (_template.ID > 0)
            {
                if (_template.ID != oid)
                {
                    MessageBox.Show("已经有同名称的模板存在,请修改名称!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            else
            {
                if (oid > 0)
                {
                    MessageBox.Show("已经有同名称的模板存在,请修改名称!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }

            try
            {
                _tmpTemplate.ID       = _template.ID;
                _tmpTemplate.Database = _template.Database;
                _template.Database.SaveTemplate(_tmpTemplate);
                _template = _tmpTemplate;
            }
            catch (Exception ex)
            {
                MessageBox.Show("程序发生错误" + ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }



            return(true);
        }