Example #1
0
        private int FindColumnIndex(ColumnSynonim text, int rowIndex)  //ищет в заданной строке текст
        {
            string str;

            for (int i = 1; i <= maxCol; i++)
            {
                if (ws.Cells[1, i].Value == null)
                {
                    continue;
                }

                str = ws.Cells[1, i].Value.ToString();
                if ((str == text.name) || (str == text.altName))   //поиск столбца с № полиса
                {
                    return(i);
                }
            }
            return(-1);
        }
Example #2
0
        public void SaveSettings() //Сохранение настроек
        {
            toolStripStatusLabel1.Text = "Выполняется, ждите...";

            SetDefaultColors();

            //В не заполненные поля устанавливаем значения по умолчанию
            if (!textBox1.Text.StartsWith("http://"))
            {
                textBox1.Text = @"http://" + textBox1.Text;
            }
            if (textBox1.Text[textBox1.Text.Length - 1] != '/')
            {
                textBox1.Text += @"/";
            }
            if (textBox5.Text == "")
            {
                textBox5.Text = "0";
            }
            if (textBox4.Text == "")
            {
                textBox4.Text = "10";
            }
            if (comboBox2.Text == "")
            {
                comboBox2.SelectedIndex = 0;
            }
            if ((comboBox2.Text != "Текущая папка") && (comboBox2.Text[comboBox2.Text.Length - 1] != '\\'))
            {
                comboBox2.Text += @"\";
            }
            if (comboBox1.Text == "")
            {
                comboBox1.Text = "Прикрепленные пациенты (Выгрузка из СРЗ).XLSX";
            }
            if ((radioButton1.Checked == false) && (radioButton2.Checked == false))
            {
                radioButton1.Checked = true;
            }
            if (comboBox3.SelectedIndex == -1)
            {
                comboBox3.SelectedIndex = 0;
            }

            for (int i = 0; i < dataGridView1.RowCount - 1; i++)    //проверяем заполненность таблицы с учетными записями
            {
                for (int j = 0; j < 3; j++)
                {
                    if (dataGridView1.Rows[i].Cells[j].Value == null)
                    {
                        dataGridView1.Rows.RemoveAt(i);
                        break;
                    }
                }
            }

            for (int i = 0; i < dataGridView2.RowCount - 1; i++)    //проверяем заполненность таблицы альтернативных названий стобцов
            {
                if (dataGridView2.Rows[i].Cells["OldName"].Value == null)
                {
                    dataGridView2.Rows.RemoveAt(i);
                    continue;
                }
                if ((dataGridView2.Rows[i].Cells["NewName"].Value == null) || (dataGridView2.Rows[i].Cells["NewName"].Value.ToString() == ""))
                {
                    dataGridView2.Rows[i].Cells["NewName"].Value = dataGridView2.Rows[i].Cells["OldName"].Value;
                }
                if (dataGridView2.Rows[i].Cells["HideCol"].Value == null)
                {
                    dataGridView2.Rows[i].Cells["HideCol"].Value = false;
                }
                if (dataGridView2.Rows[i].Cells["Delete"].Value == null)
                {
                    dataGridView2.Rows[i].Cells["Delete"].Value = false;
                }
            }

            //Записываем настройки в класс настроек
            settings.Site              = textBox1.Text;
            settings.ProxyAddress      = textBox2.Text;
            settings.ProxyPort         = int.Parse(textBox5.Text);
            settings.Folder            = comboBox2.Text;
            settings.File              = comboBox1.Text;
            settings.DownloadFile      = radioButton1.Checked;
            settings.Threads           = int.Parse(textBox4.Text);
            settings.EncryptLevel      = comboBox3.SelectedIndex;
            settings.hidePassword      = checkBox2.Checked;
            settings.RenameGender      = checkBox1.Checked;
            settings.RenameColumnNames = checkBox3.Checked;
            settings.ColumnAutoWidth   = checkBox4.Checked;
            settings.AutoFilter        = checkBox5.Checked;
            settings.ColumnOrder       = checkBox6.Checked;

            Credential[] creds = new Credential[dataGridView1.RowCount - 1];
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                creds[i] = new Credential();
                creds[i].SetLogin(dataGridView1.Rows[i].Cells["Login"].Value.ToString(), settings.EncryptLevel);
                creds[i].SetPassword(dataGridView1.Rows[i].Cells["Password"].Value.ToString(), settings.EncryptLevel);
                creds[i].Requests = int.Parse(dataGridView1.Rows[i].Cells["Limit"].Value.ToString());
            }
            settings.Accounts = creds;

            ColumnSynonim[] colSyn = new ColumnSynonim[dataGridView2.RowCount - 1];
            for (int i = 0; i < dataGridView2.RowCount - 1; i++)
            {
                colSyn[i].name    = dataGridView2.Rows[i].Cells["OldName"].Value.ToString();
                colSyn[i].altName = dataGridView2.Rows[i].Cells["NewName"].Value.ToString();
                colSyn[i].hide    = (Boolean)dataGridView2.Rows[i].Cells["HideCol"].Value;
                colSyn[i].delete  = (Boolean)dataGridView2.Rows[i].Cells["Delete"].Value;
            }
            settings.ColumnSynonims = colSyn;

            settings.SaveSettings();
            toolStripStatusLabel1.Text = "Настройки успешно сохранены.";
        }