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);
            }
        }
示例#2
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, "синяя синичка");
     }
 }
示例#3
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("Карточка задания не создана!");
     }
 }
示例#4
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();
        }