public bool AliasPluralValidate(LookupValue lookupValue, out string failReason)
        {
            failReason = "";
            /*Don't check items that are not enabled*/

            if (!lookupValue.Enabled)
            {
                return(true);
            }
            if (string.IsNullOrEmpty(lookupValue.AliasPlural))
            {
                failReason = "AliasPlural cannot be zero-length.";
                return(false);
            }
            if (lookupValue.AliasPlural.IndexOf(" ") >= 0)
            {
                failReason = "AliasPlural cannot have spaces.";
                return(false);
            }

            foreach (LookupValue sibling in lookupValue.Parent.LookupValues)
            {
                if (sibling != lookupValue && sibling.Enabled && ArchAngel.Providers.Database.Helper.Script.StringsAreEqual(sibling.AliasPlural, lookupValue.AliasPlural, false))
                {
                    failReason = "Duplicate AliasPlural: " + lookupValue.AliasPlural;
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
        public bool NameValidate(LookupValue lookupValue, out string failReason)
        {
            failReason = "";
            /*Don't check items that are not enabled*/

            if (!lookupValue.Enabled)
            {
                return true;
            }
            if (string.IsNullOrEmpty(lookupValue.Name))
            {
                failReason = "Name cannot be zero-length.";
                return false;
            }
            if (lookupValue.Name.IndexOf(" ") >= 0)
            {
                failReason = "Name cannot have spaces.";
                return false;
            }

            foreach (LookupValue sibling in lookupValue.Parent.LookupValues)
            {
                if (sibling != this && sibling.Enabled && ArchAngel.Providers.Database.Helper.Script.StringsAreEqual(sibling.Name, Name, false))
                {
                    failReason = "Duplicate name: " + Name;
                    return false;
                }
            }
            return true;
        }
Beispiel #3
0
 public virtual string AliasPluralDefault(LookupValue lookupValue)
 {
     return ArchAngel.Providers.Database.Helper.Script.GetPlural(lookupValue.Alias);
 }
Beispiel #4
0
 public bool AliasDisplayValidate(LookupValue lookupValue, out string failReason)
 {
     failReason = "";
     return true;
 }
Beispiel #5
0
        private void btnFetchValuesFromOtherTable_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                if (ddlLookupIdColumns.SelectedItem == null)
                {
                    MessageBox.Show("Please select an ID column.", "Missing Data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                Model.Column idColumn = (Model.Column)ddlLookupIdColumns.SelectedItem;

                string sql = string.Format("SELECT DISTINCT [{0}]", idColumn.Name);

                if (ddlLookupNameColumns.SelectedItem != null &&
                    ddlLookupNameColumns.SelectedItem is Model.Column)
                {
                    sql += string.Format(", [{0}]", ((Model.Column)ddlLookupNameColumns.SelectedItem).Name);
                }
                Model.ScriptObject table = (Model.ScriptObject)ddlLookupTables.SelectedItem;
                sql += string.Format(" FROM [{0}].[{1}] ORDER BY [{2}]", table.Schema, table.Name, idColumn.Name);
                System.Data.DataTable results = null;

                try
                {
                    Providers.Database.Helper.Utility.ResetAllConnections();
                    results = table.Database.RunQuerySQL(sql);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                System.Data.DataRow[] rows = results.Select();

                if (results.Rows.Count > 100)
                {
                    if (MessageBox.Show(string.Format("{0} rows were returned. Are you sure you want to import this many?", results.Rows.Count), "Many Results", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                }
                foreach (System.Data.DataRow row in rows)
                {
                    string id = row[0].ToString();
                    string name = row.ItemArray.Length == 1 ? "" : row[1].ToString();

                    // Check if already exists
                    bool exists = false;

                    foreach (System.Windows.Forms.DataGridViewRow dataGridRow in dataGridViewX1.Rows)
                    {
                        if (dataGridRow.IsNewRow)
                        {
                            continue;
                        }
                        if (dataGridRow.Cells[(int)ColumnNames.Id].Value != null && Slyce.Common.Utility.StringsAreEqual(dataGridRow.Cells[(int)ColumnNames.Id].Value.ToString(), id, false))
                        {
                            if (!Slyce.Common.Utility.StringsAreEqual(dataGridRow.Cells[(int)ColumnNames.Name].Value.ToString(), name, false) &&
                                string.IsNullOrEmpty(dataGridRow.Cells[(int)ColumnNames.Name].Value.ToString()))
                            {
                                dataGridRow.Cells[(int)ColumnNames.Name].Value = name;
                                ((LookupValue)dataGridRow.Tag).Name = name;
                            }
                            exists = true;
                            break;
                        }
                    }
                    if (exists)
                    {
                        continue;
                    }
                    LookupValue lookupValue = new LookupValue(name, false, Lookup);
                    lookupValue.Id = id;
                    lookupValue.Name = name;
                    Lookup.LookupValues.Add(lookupValue);
                    AddLookupValueToGrid(lookupValue);
                }
                HighlightDuplicates();
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Beispiel #6
0
 private void AddLookupValueToGrid(LookupValue lookupValue)
 {
     int newIndex = dataGridViewX1.Rows.Add(new object[] { lookupValue.Enabled, lookupValue.Id.ToString(), lookupValue.Name, lookupValue.Alias, lookupValue.AliasPlural, lookupValue.Description });
     dataGridViewX1.Rows[newIndex].Tag = lookupValue;
 }
Beispiel #7
0
        private void dataGridViewX1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            System.Windows.Forms.DataGridViewRow row = ((DevComponents.DotNetBar.Controls.DataGridViewX)sender).Rows[e.RowIndex];

            if (row.IsNewRow)
            {
                return;
            }
            LookupValue lookupValue = (LookupValue)row.Tag;

            if (row.Tag == null)
            {
                lookupValue = new LookupValue("", true, "", "", Lookup);
                lookupValue.Enabled = true;
                row.Cells[(int)ColumnNames.Enabled].Value = true;
                Lookup.LookupValues.Add(lookupValue);
                row.Tag = lookupValue;
            }
            else
            {
                lookupValue = (LookupValue)row.Tag;
            }
            // Has the Name field been edited?
            if (row.Cells[e.ColumnIndex] == row.Cells[(int)ColumnNames.Name])
            {
                if (row.Cells[(int)ColumnNames.Name] == null || row.Cells[(int)ColumnNames.Name].Value == null)
                {
                    lookupValue.Name = "";
                }
                else
                {
                    lookupValue.Name = row.Cells[(int)ColumnNames.Name].Value.ToString();
                }
                if (string.IsNullOrEmpty(lookupValue.Alias))
                {
                    lookupValue.Alias = lookupValue.AliasDefault(lookupValue);
                    row.Cells[(int)ColumnNames.Alias].Value = lookupValue.Alias;
                }
                if (string.IsNullOrEmpty(lookupValue.AliasPlural))
                {
                    lookupValue.AliasPlural = lookupValue.AliasPluralDefault(lookupValue);
                    row.Cells[(int)ColumnNames.AliasPlural].Value = lookupValue.AliasPlural;
                }
            }
            // Has the Alias field been edited?
            if (row.Cells[e.ColumnIndex] == row.Cells[(int)ColumnNames.Alias])
            {
                lookupValue.Alias = row.Cells[(int)ColumnNames.Alias] == null ? "" : row.Cells[(int)ColumnNames.Alias].Value.ToString();
                lookupValue.AliasPlural = lookupValue.AliasPluralDefault(lookupValue);
                row.Cells[(int)ColumnNames.AliasPlural].Value = lookupValue.AliasPlural;
            }
            if (row.Cells[(int)ColumnNames.Enabled].Value == null)
            {
                row.Cells[(int)ColumnNames.Enabled].Value = false;
            }
            lookupValue.Alias = row.Cells[(int)ColumnNames.Alias].Value == null ? "" : row.Cells[(int)ColumnNames.Alias].Value.ToString();
            lookupValue.AliasPlural = row.Cells[(int)ColumnNames.AliasPlural].Value == null ? "" : row.Cells[(int)ColumnNames.AliasPlural].Value.ToString();
            lookupValue.Description = row.Cells[(int)ColumnNames.Description].Value == null ? "" : row.Cells[(int)ColumnNames.Description].Value == null ? "" : row.Cells[(int)ColumnNames.Description].Value.ToString();
            lookupValue.Enabled = (bool)row.Cells[(int)ColumnNames.Enabled].Value;
            lookupValue.Id = row.Cells[(int)ColumnNames.Id].Value == null ? "" : row.Cells[(int)ColumnNames.Id].Value.ToString();
            lookupValue.Name = row.Cells[(int)ColumnNames.Name].Value == null ? "" : row.Cells[(int)ColumnNames.Name].Value.ToString();
            HighlightDuplicates();
        }
 public virtual string AliasPluralDefault(LookupValue lookupValue)
 {
     return(ArchAngel.Providers.Database.Helper.Script.GetPlural(lookupValue.Alias));
 }
 public bool AliasDisplayValidate(LookupValue lookupValue, out string failReason)
 {
     failReason = "";
     return(true);
 }