Esempio n. 1
0
 private void ReadChekLists() //читает из сохраненной директории все чек листы
 {
     try
     {
         String[] Files = Directory.GetFiles(DataChekList.SaveTrack + @"\CheckList\", "*.test");
         CheckLists.Clear();
         if (Files.Length != 0)
         {
             foreach (string file in Files)
             {
                 string Data = "";
                 try
                 {
                     Data = File.ReadAllText(file);
                     if (DataChekList.Encrypt)
                     {
                         Data = Sini4ka.Landing(Data, "синяя синичка");
                     }
                     CheckLists.Add(JsonConvert.DeserializeObject <CheckList>(Data));
                 }
                 catch (Exception e)
                 {
                     MessageBox.Show("Ошибка чтения теста. " + e.Message);
                 }
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Ошибка загрузки чек листов. " + e.Message);
     }
 }
Esempio n. 2
0
 public static void LoadSaveTrack(bool encrypt) //загружает путь сохранения
 {
     try
     {
         SaveTrack = File.ReadAllText(Application.StartupPath + @"\SaveTrack.tra");
         if (encrypt)
         {
             SaveTrack = Sini4ka.Landing(SaveTrack, "синяя синичка");
         }
     }
     catch (Exception e)
     {
         SaveTrack = "";
         MessageBox.Show(e.Message);
     }
 }
Esempio n. 3
0
        public void SavePlatList(bool encrypt)
        {
            string data = JsonConvert.SerializeObject(this);

            if (encrypt)
            {
                data = Sini4ka.Flying(data, "синяя синичка");
            }
            try
            {
                File.WriteAllText(DataChekList.SaveTrack + /*Application.StartupPath +*/ @"\CheckList\Inform\Platoons.plat", data);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Esempio n. 4
0
        public static Platoons LoadPlatList(bool encrypt) //чтение предметов
        {
            String data = "";

            try
            {
                data = File.ReadAllText(DataChekList.SaveTrack + /*Application.StartupPath +*/ @"\CheckList\Inform\Platoons.plat");
                if (encrypt)
                {
                    data = Sini4ka.Landing(data, "синяя синичка");
                }
                return(JsonConvert.DeserializeObject <Platoons>(data));
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(new Platoons());
            }
        }
Esempio n. 5
0
 public static void SaveSaveTrack(bool encrypt) //сохраняет суть сохранения
 {
     if (encrypt)
     {
         SaveTrack = Sini4ka.Flying(SaveTrack, "синяя синичка");
     }
     try
     {
         File.WriteAllText(Application.StartupPath + @"\SaveTrack.tra", SaveTrack);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
     if (encrypt)
     {
         SaveTrack = Sini4ka.Landing(SaveTrack, "синяя синичка");
     }
 }
Esempio n. 6
0
 private void button3_Click(object sender, EventArgs e) //готово
 {
     if (DataChekList.Check != null)
     {
         ReadToCheckList();
         String Data = JsonConvert.SerializeObject(DataChekList.Check);
         if (DataChekList.Encrypt)
         {
             Data = Sini4ka.Flying(Data, "синяя синичка");
         }
         try
         {
             File.WriteAllText(DataChekList.SaveTrack + @"\CheckList\" + DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test", Data);
             if (!DataChekList.Cource.SubList.ElementAt <Subject>(DataChekList.Check.Index).CheckListIndexes.Contains(DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test"))//*/
             {
                 DataChekList.Cource.SubList.ElementAt <Subject>(DataChekList.Check.Index).CheckListIndexes.Add(DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test");
                 DataChekList.Cource.SaveSubList(DataChekList.Encrypt);
             }
             DirectoryInfo dirinfo = new DirectoryInfo(DataChekList.SaveTrack + @"\CheckList\Exports\");
             if (dirinfo.Exists)
             {
                 dirinfo.CreateSubdirectory(DataChekList.Check.Inform.Course);
             }
             DataChekList.Check.ExportToWord(DataChekList.SaveTrack + @"\CheckList\Exports\" + DataChekList.Check.Inform.Course + "\\");
         }
         catch (Exception a)
         {
             MessageBox.Show("Ошибка сохранения чек листа. " + a.Message);
         }
         DataChekList.Check.Tasks.Clear();
         CloseCheckList();
     }
     else
     {
         MessageBox.Show("Карточка задания не создана!");
     }
 }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            int classNum     = 0;
            int time         = 0;
            int Excellent    = 0;
            int Good         = 0;
            int Satisfactory = 0;

            try
            {
                classNum     = Convert.ToInt32(textBox6.Text);
                time         = Convert.ToInt32(textBox7.Text);
                Excellent    = Convert.ToInt32(textBox3.Text);
                Good         = Convert.ToInt32(textBox4.Text);
                Satisfactory = Convert.ToInt32(textBox5.Text);
                if (classNum < 0)
                {
                    classNum = 0;
                }
                if (time < 0)
                {
                    time = 0;
                }
                if (Excellent < 0)
                {
                    Excellent = 0;
                }
                if (Good < 0)
                {
                    Good = 0;
                }
                if (Satisfactory < 0)
                {
                    Satisfactory = 0;
                }
            }
            catch (Exception) {}
            if (comboBox1.SelectedIndex < 0)
            {
                MessageBox.Show("Не выбран предмет", "Ошибка");
                return;
            }
            try
            {
                Title title = new Title(textBox2.Text, comboBox1.SelectedItem.ToString(), classNum, richTextBox1.Text, richTextBox2.Text, time, textBox8.Text, richTextBox6.Text, richTextBox3.Text, richTextBox5.Text, richTextBox4.Text);
                if (State == "Create")
                {
                    DataChekList.Check = new CheckList(comboBox1.SelectedIndex, title, new List <Task>(), new Marks(Excellent, Good, Satisfactory), checkBox1.Checked);
                    form.OpenCheckList();
                }
                if (State == "Update")
                {
                    DataChekList.Cource.SubList.ElementAt <Subject>(DataChekList.Check.Index).CheckListIndexes.Remove(DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test"); //удаляет в предмете ссылку на старую версию названия
                    if (File.Exists(DataChekList.SaveTrack + @"\CheckList\" + DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test"))
                    {
                        File.Delete(DataChekList.SaveTrack + @"\CheckList\" + DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test");
                    }
                    ///// изменение имен изображений
                    try
                    {
                        String[] Files = Directory.GetFiles(DataChekList.SaveTrack + @"\CheckList\Pictures\", DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + "*.bin");
                        foreach (string file in Files)
                        {
                            string newFile = file.Replace(DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name, comboBox1.SelectedItem.ToString() + " " + textBox2.Text);
                            File.Move(file, newFile);
                        }
                    }
                    catch (Exception b)
                    {
                        MessageBox.Show("Ошибка сохранения" + b.Message);
                    }
                    //////изменение ссылок на изображения в тесте
                    foreach (Task line in DataChekList.Check.Tasks)
                    {
                        if (line.Image != null)
                        {
                            line.Image = line.Image.Replace(DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name, comboBox1.SelectedItem.ToString() + " " + textBox2.Text);
                        }
                    }
                    //////
                    DataChekList.Check.Index    = comboBox1.SelectedIndex;
                    DataChekList.Check.Inform   = title;
                    DataChekList.Check.Notes    = new Marks(textBox3.Text, textBox4.Text, textBox5.Text);
                    DataChekList.Check.HasTimer = checkBox1.Checked;
                    ///// сохранение нового файла
                    String Data = JsonConvert.SerializeObject(DataChekList.Check);
                    if (DataChekList.Encrypt)
                    {
                        Data = Sini4ka.Flying(Data, "синяя синичка");
                    }
                    try
                    {
                        File.WriteAllText(DataChekList.SaveTrack + @"\CheckList\" + DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test", Data);
                        if (!DataChekList.Cource.SubList.ElementAt <Subject>(DataChekList.Check.Index).CheckListIndexes.Contains(DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test"))//*/
                        {
                            DataChekList.Cource.SubList.ElementAt <Subject>(DataChekList.Check.Index).CheckListIndexes.Add(DataChekList.Check.Inform.Course + " " + DataChekList.Check.Inform.Name + ".test");
                            DataChekList.Cource.SaveSubList(DataChekList.Encrypt);
                        }
                    }
                    catch (Exception a)
                    {
                        MessageBox.Show("Ошибка сохранения чек листа. " + a.Message);
                    }
                    DataChekList.Check.Tasks.Clear();
                    form.UpdateListTests();
                    DataChekList.Check = null;
                }
            }
            catch (Exception a)
            {
                if (State == "Create")
                {
                    MessageBox.Show("Ошибка создания чек листа" + a.Message);
                    DataChekList.Check = new CheckList();
                }
                if (State == "Update")
                {
                    MessageBox.Show("Ошибка изменения чек листа" + a.Message);
                    DataChekList.Check = null;
                }
            }
            this.Close();
        }