Ejemplo n.º 1
0
        private void btn_new_session_Click(object sender, EventArgs e)
        {
            if (rich_Original.TextLength > 0 | rich_Translated.TextLength > 0)
            {
                SaveThis();
            }
            List <string> Sessions = TranslationTools.GetSessionNames();
            string        name     = TextBox_SessionName.Text;

            if (name.Length < 3 | name.Length > 15)
            {
                MessageBox.Show("Write a name with:\nmore than 2 letters and less than 16");
                return;
            }
            for (int i = 0; i < Sessions.Count; i++)
            {
                if (Sessions[i].Equals(name, StringComparison.CurrentCultureIgnoreCase))
                {
                    MessageBox.Show(Name + " already exists choose another");
                    return;
                }
            }
            CloneList(myList, tempList);
            int Id;

            for (int i = 0; i < myList.Count; i++)
            {
                TranslationTools.InsertImagePath(myList[i]);
                Id = TranslationTools.GetLastId();            //gets the inserted ID of InsertImagePath
                TranslationTools.InsertSession(name, Id);     //creates a session
                TranslationTools.InsertScript(myList[i], Id); //associates the Id of the images table to the text
            }
            TranslationTools.FillDropDownSessions("SELECT DISTINCT NameSession from Session;", comboSession);
        }       //debuged
Ejemplo n.º 2
0
        }       //debuged

        public void auto_save_new()
        {
            DateTime      thisDay  = DateTime.Now;
            List <string> Sessions = TranslationTools.GetSessionNames();
            string        name     = "Auto Save " + thisDay.ToString();

            for (int i = 0; i < Sessions.Count; i++)
            {
                if (Sessions[i].Equals(name, StringComparison.CurrentCultureIgnoreCase))
                {
                    return;
                }
            }
            int Id;

            for (int i = 0; i < tempList.Count; i++)
            {
                TranslationTools.InsertImagePath(tempList[i]);
                Id = TranslationTools.GetLastId();              //gets the inserted ID of InsertImagePath
                TranslationTools.InsertSessionWAuto(name, Id);  //creates a session
                TranslationTools.InsertScript(tempList[i], Id); //associates the Id of the images table to the text
            }
            string a = GetAutoSaves();

            if (a != "")
            {
                TranslationTools.DeleteSession(a);
            }
            //TranslationTools.FillDropDownSessions("SELECT DISTINCT NameSession from Session;", comboSession);
        }
Ejemplo n.º 3
0
        private void btn_save_session_Click(object sender, EventArgs e)
        {
            if (comboSession.SelectedItem == null)
            {
                MessageBox.Show("Select a session");
                return;
            }
            string name = comboSession.Text;

            if (IsAutoSave(name))
            {
                MessageBox.Show("You can't overwrite Auto Saves!"); return;
            }


            if (rich_Original.TextLength > 0 | rich_Translated.TextLength > 0)
            {
                SaveThis();
            }
            CloneList(myList, tempList);
            //TranslationTools.DeleteDataFromTables();
            //1º apagar todos os dados da sessão que se vai salvar
            TranslationTools.DeleteSession(name);

            //2º invocar a função new session, é provavelmente melhor copiar porque se o
            //primeiro passo foi bem sucessido, o nome não existe
            int Id;

            for (int i = 0; i < myList.Count; i++)
            {
                TranslationTools.InsertImagePath(myList[i]);
                Id = TranslationTools.GetLastId();            //gets the inserted ID of InsertImagePath
                TranslationTools.InsertSession(name, Id);     //creates a session
                TranslationTools.InsertScript(myList[i], Id); //associates the Id of the images table to the text
            }
            //REFRESH THE SESSION LIST (comboSession)
        }