Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            bool save = false;

            try
            {
                if (String.Compare(oldPath, textBox1.Text) != 0)
                {
                    oldPath = TrshConfig.SettFile = textBox1.Text;
                    save    = true;
                }

                if (String.Compare(oldDat, textBox2.Text) != 0)
                {
                    if (String.IsNullOrWhiteSpace(textBox2.Text) || textBox2.Text[0] == ',')
                    {
                        MessageBox.Show("Вы не указали дни!");
                        return;
                    }

                    List <int> tempdays = new List <int>();
                    string[]   days     = textBox2.Text.Split(',');
                    int        cnt      = days.Count();

                    for (int i = 0; i < cnt; i++)
                    {
                        tempdays.Add(Convert.ToInt32(days[i]));
                    }

                    oldDat = textBox2.Text;
                    TrshConfig.SettDays = tempdays;
                    save = true;
                }
            }
            catch
            {
                MessageBox.Show("Вы неправильно указали дни!\nДни нужно указвать через запятую без пробелов\nНапример: 15,45", "Ошибка!");
            }

            if (save)
            {
                if (TrshConfig.CreateConfig(true))
                {
                    MessageBox.Show("Настройки сохранены!");
                    if (Main.isLoaded)
                    {
                        form.LoadForm();
                    }
                }
            }
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            notifyIcon1.Visible = false;
            timer1.Interval     = SET_INTERVAL;

            if (!TrshConfig.GetConfig())
            {
                MessageBox.Show("Это первый запуск программы, пожалуйста настройте её.");
            }
            else if (TrshConfig.SettType == 0)
            {
                MessageBox.Show("В настройках программы указан неправильный путь к файлу/директории, пожалуйста перенастройте.");
            }
            else
            {
                LoadForm();
                return;
            }

            button3_Click(sender, e);
            LoadForm();
        }
Example #3
0
        void LoadExcel(bool msg = true)
        {
            sMess = null;
            switch (TrshConfig.GetType(TrshConfig.SettFile))
            {
            case 0:
                MessageBox.Show("В настройках программы указан неправильный путь к файлу/директории, пожалуйста перенастройте.");
                return;

            case 1:
                GetExcelInDataGrid(TrshConfig.SettFile);
                break;

            case 2:
                string[] dirs = Directory.GetFiles(TrshConfig.SettFile, "*.xls*");
                foreach (string file in dirs)
                {
                    var f = new FileInfo(file);
                    if (f.Name[0] != '~')
                    {
                        GetExcelInDataGrid(file);
                    }
                }
                break;
            }

            int i = -1;

            while (++i < sGrids.Count)
            {
                if (sGrids[i].Rows.Count == 0)
                {
                    if (sGrids[i] != dataGridView1)
                    {
                        sGrids[i].Dispose();
                    }
                    else
                    {
                        sGrids[i].Visible = false;
                    }

                    GetDays.RemoveAt(i);
                    sGrids.RemoveAt(i);

                    i--;
                    continue;
                }
                else
                {
                    this.Controls.Add(sGrids[i]);
                    sMess += "Через " + GetDays[i].ToString() + " " + get_wordend(GetDays[i], "день", "дня", "дней") +
                             (sGrids[i].RowCount == 1 ? " истечет " : " истекут ") + sGrids[i].RowCount.ToString() + " " + get_wordend(sGrids[i].RowCount, "договор", "договора", "договоров") + "\n";
                }
            }

            switch (sGrids.Count)
            {
            case 0:
                MessageBox.Show("Никаких данных не найдено!");
                return;

            case 1: break;

            default:
                button1.Visible = true;
                button2.Visible = true;
                break;
            }

            SelectedGrid = 0;
            UpdateLabel();

            if (msg)
            {
                MessageBox.Show(sMess);
            }
        }
Example #4
0
File: Main.cs Project: borland51/nn
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                switch (TrshConfig.GetType(TrshConfig.SettFile))
                {
                case 0:
                    if (WindowState == FormWindowState.Minimized)
                    {
                        notifyIcon1.ShowBalloonTip(10000, "Ошибка!", "В настройках программы указан неправильный путь к файлу/директории, пожалуйста перенастройте.", ToolTipIcon.Info);
                    }
                    MessageBox.Show("В настройках программы указан неправильный путь к файлу/директории, пожалуйста перенастройте.");
                    return;

                case 1:
                    if (HASH[0] == GetFileHash(TrshConfig.SettFile))
                    {
                        return;
                    }
                    break;

                case 2:
                    string[] dirs = Directory.GetFiles(TrshConfig.SettFile, "*.xls*");
                    bool     ret  = true;
                    foreach (string file in dirs)
                    {
                        var f = new FileInfo(file);
                        if (f.Name[0] != '~')
                        {
                            bool   cont  = false;
                            string fHash = GetFileHash(file);
                            foreach (string hash in HASH)
                            {
                                if (String.Compare(hash, fHash) != 0)
                                {
                                    continue;
                                }

                                cont = true;
                                break;
                            }

                            if (!cont)
                            {
                                ret = false;
                                break;
                            }
                        }
                    }

                    if (ret)
                    {
                        return;
                    }

                    break;
                }

                LoadForm(false);

                if (sMess == null)
                {
                    return;
                }

                if (WindowState == FormWindowState.Minimized)
                {
                    notifyIcon1.ShowBalloonTip(10000, "Обновлено!", "Получены новые данные по договорам, зайдите в программу...", ToolTipIcon.Info);
                }

                MessageBox.Show(sMess);
            }
            catch { }
        }