示例#1
0
        private void CheckUpdateFunc(bool show = false)
        {
            CheckUpdate update = new CheckUpdate();

            var text    = update.CheckProgramUpdate();
            var version = update.GetVersion().Replace("\n", string.Empty);


            DialogResult updateResult;

            if (String.Equals(version, Application.ProductVersion))
            {
                if (show)
                {
                    MessageBox.Show(text + "\n\r\n\rОбновление не требуется.", "Обновление", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                updateResult = MessageBox.Show(text + "\n\r\n\rТребуется обновление. Обновить ПО?", "Обновление", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (updateResult == DialogResult.Yes)
                {
                    bool notSaveTables = false;

                    foreach (MarksTable table in tables)
                    {
                        if (table.startEdit)
                        {
                            notSaveTables = true;
                        }
                    }

                    DialogResult saveTables = DialogResult.No;

                    if (notSaveTables)
                    {
                        saveTables = MessageBox.Show("У вас есть не сохранённые таблицы, сохранить?", "Сохранить?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    }

                    if (saveTables == DialogResult.Yes)
                    {
                        Dnevnik_FormClosing(null, null);
                    }

                    Properties.Settings.Default.change_log = false;
                    Properties.Settings.Default.Save();

                    update.UpdateProgram(Status, loadBar, LabelLoad);
                }
            }
        }