Example #1
0
 public static int[][] VerifyRepeatCellInRow(DataGridViewRow row, int[] exclueds)
 {
     string[] strs = new string[row.Cells.Count];
     for (int iCell = 0; iCell < strs.Length; iCell++)
     {
         strs[iCell] = (string)row.Cells[iCell].Value;
     }
     return(StringUtility.CheckRepeat(strs, exclueds));
 }
Example #2
0
    /// <summary>
    /// 本地化不能包含重复Key
    /// </summary>
    public static DataGridViewConsoleForm.Message Verify_Localization_RepeatKey(DataGridViewConsoleForm.Level level, string[] keys)
    {
        List <int> excludes = new List <int>();

        // 排除"String ID"
        excludes.Add(0);
        for (int iKey = 1; iKey < keys.Length; iKey++)
        {
            string iterKey = keys[iKey];
            if (string.IsNullOrWhiteSpace(iterKey))
            {
                // 排除空Key
                excludes.Add(iKey);
            }
        }

        int[][] repeats = StringUtility.CheckRepeat(keys, excludes.ToArray());
        if (repeats == null)
        {
            return(null);
        }
        else
        {
            DataGridViewConsoleForm.Message message = CreateMessage(level, -1, 0, VerifyType.Localization_RepeatKey);
            StringBuilder textSb = new StringBuilder(256);
            for (int iRepeats = 0; iRepeats < repeats.Length; iRepeats++)
            {
                int[] repeat = repeats[iRepeats];
                // 重复的行号
                for (int iRepeat = 0; iRepeat < repeat.Length; iRepeat++)
                {
                    textSb.Append(repeat[iRepeat] + 1);
                    if (iRepeat < repeat.Length - 1)
                    {
                        textSb.Append(", ");
                    }
                }
                textSb.Append(string.Format("    Key:({0})", keys[repeat[0]]));
                textSb.AppendLine();
            }
            message.Text = string.Format(message.Text, textSb.ToString());
            return(message);
        }
    }
Example #3
0
    /// <summary>
    /// 一行内,单元格值重复
    /// </summary>
    /// <param name="exclueds">排除的单元格</param>
    /// <returns>见StringUtility.CheckRepeat</returns>
    public static DataGridViewConsoleForm.Message Verify_RepeatCellInRow(DataGridViewConsoleForm.Level level, int rowIdx, DataGridViewRow dataRow, int[] exclueds)
    {
        string[] strs = new string[dataRow.Cells.Count];
        for (int iCell = 0; iCell < strs.Length; iCell++)
        {
            strs[iCell] = (string)dataRow.Cells[iCell].Value;
        }

        int[][] repeats = StringUtility.CheckRepeat(strs, exclueds);
        if (repeats == null)
        {
            return(null);
        }
        else
        {
            DataGridViewConsoleForm.Message message = CreateMessage(level, rowIdx, -1, VerifyType.RepeatCellInRow);

            StringBuilder textSb = new StringBuilder(256);
            for (int iRepeats = 0; iRepeats < repeats.Length; iRepeats++)
            {
                int[] repeat = repeats[iRepeats];
                // 重复的列号(A,B,C……)
                for (int iRepeat = 0; iRepeat < repeat.Length; iRepeat++)
                {
                    textSb.Append(ConvertUtility.NumberToLetter(repeat[iRepeat] + 1));
                    if (iRepeat < repeat.Length - 1)
                    {
                        textSb.Append(", ");
                    }
                }
                textSb.Append(string.Format("    重复的值:({0})", dataRow.Cells[repeat[0]].Value));
                textSb.AppendLine();
            }
            message.Text = string.Format(message.Text, textSb.ToString());
            return(message);
        }
    }