Esempio n. 1
0
        protected override void OnProcess(Cell cell, Cell nextCell, RegistrationInfo info)
        {
            var cellText = cell.Range.Text;

            if (nextCell != null && cellText.Contains(PHONE))
            {
                nextCell.Range.Text = info.Phone;
            }

            if (nextCell != null && cellText.Contains(EMAIL))
            {
                nextCell.Range.Text = info.Email;
            }

            if (cellText.Contains(DATE))
            {
                cell.Range.Text = string.Format(CultureInfo.InvariantCulture, "{0} {1}",
                                                cell.Range.Text.TrimEnd('\a').TrimEnd('\r'),
                                                DateTime.Now.ToString(DateFormat));
            }
        }
        protected override void OnProcess(Cell cell, Cell nextCell, RegistrationInfo info)
        {
            var cellText = cell.Range.Text;

            if (cellText.Contains(DATE))
            {
                cell.Range.Text = string.Format(CultureInfo.InvariantCulture, "{0} {1}",
                                                cell.Range.Text.TrimEnd('\a').TrimEnd('\r'),
                                                DateTime.Now.ToString(DateFormat));
            }

            if (cellText.Contains(PHONE))
            {
                cell.Range.Text = string.Format(CultureInfo.InvariantCulture, "{0} {1}",
                                                cell.Range.Text.TrimEnd('\a').TrimEnd('\r'), info.Phone);
            }

            if (cellText.Contains(EMAIL))
            {
                cell.Range.Text = string.Format(CultureInfo.InvariantCulture, "{0} {1}",
                                                cell.Range.Text.TrimEnd('\a').TrimEnd('\r'), info.Email);
            }

            if (cellText.Contains(info.Class) && nextCell != null)
            {
                nextCell.Range.Text = "X";
            }

            if (cellText.Contains("САС ВСЕХ ПОРОД") && nextCell != null)
            {
                nextCell.Range.Text = "X";
            }

            if (cellText.Contains(info.Mono))
            {
                cell.Range.Text = string.Format(CultureInfo.InvariantCulture, "{0}\tX",
                                                cell.Range.Text.TrimEnd('\a').TrimEnd('\r'));
            }
        }
Esempio n. 3
0
        public void Process(RegistrationInfo regInfo)
        {
            foreach (Word.Table table in document.Tables)
            {
                for (int r = 1; r <= table.Rows.Count; r++)
                {
                    for (int c = 1; c <= table.Columns.Count; c++)
                    {
                        try
                        {
                            var       cellText = table.Cell(r, c).Range.Text;
                            Word.Cell nextCell = null;
                            try
                            {
                                nextCell = table.Cell(r, c + 1);
                            }
                            catch (Exception)
                            {
                            }

                            if (nextCell != null)
                            {
                                if (cellText.Contains("Breed") || cellText.Contains("Порода"))
                                {
                                    nextCell.Range.Text = regInfo.Breed;
                                }

                                if (cellText.Contains("Sex") || cellText.Contains("Пол"))
                                {
                                    nextCell.Range.Text = regInfo.Sex;
                                }

                                if (cellText.Contains("Color") || cellText.Contains("Цвет"))
                                {
                                    nextCell.Range.Text = regInfo.Color;
                                }

                                if (cellText.Contains("birth") || cellText.Contains("рожд"))
                                {
                                    nextCell.Range.Text = regInfo.DOB.ToString(DateFormat);
                                }

                                if (cellText.Contains("of the dog") || cellText.Contains("Кличка"))
                                {
                                    nextCell.Range.Text = regInfo.Name;
                                }

                                if (cellText.Contains("Pedigree") || cellText.Contains("родос"))
                                {
                                    nextCell.Range.Text = regInfo.Pedigree;
                                }

                                if (cellText.Contains("Father") || cellText.Contains("Отец"))
                                {
                                    nextCell.Range.Text = regInfo.Father;
                                }

                                if (cellText.Contains("Mother") || cellText.Contains("Мать"))
                                {
                                    nextCell.Range.Text = regInfo.Mother;
                                }

                                if (cellText.Contains("Breeder") || cellText.Contains("Заводчик"))
                                {
                                    nextCell.Range.Text = regInfo.Breeder;
                                }

                                if (cellText.Contains("Owner") || cellText.Contains("Владелец"))
                                {
                                    nextCell.Range.Text = regInfo.Owner;
                                }

                                if (cellText.Contains("Клуб регистрации"))
                                {
                                    nextCell.Range.Text = regInfo.Club;
                                }

                                if (cellText.Contains("Address") || cellText.Contains("Адрес"))
                                {
                                    nextCell.Range.Text = regInfo.Address;
                                }

                                if (cellText.Contains(regInfo.Class))
                                {
                                    nextCell.Range.Text = "X";
                                }
                            }

                            OnProcess(table.Cell(r, c), nextCell, regInfo);
                        }
                        catch (Exception)
                        {
                            //break;
                        }
                    }
                }
            }
            document.Save();
            wordApp.Visible = true;
        }
Esempio n. 4
0
 protected abstract void OnProcess(Word.Cell cell, Word.Cell nextCell, RegistrationInfo info);