private void AddNewTemplatePath_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog  dlg    = new OpenFileDialog();
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                if (SQLiteClass.ExecuteSelectCountTemplatePath(SQLiteClass.dbpath, theTemplate.Id, dlg.FileName) > 0)
                {
                    MessageBox.Show(Properties.Resources.TD_Path_Caution);
                    return;
                }

                ListTemplatePath newTP = new ListTemplatePath();
                newTP.Id          = 0; //dummy
                newTP.Template_Id = theTemplate.Id;
                newTP.Order       = SQLiteClass.ExecuteSelectMaxTemplatePath(SQLiteClass.dbpath, theTemplate.Id) + 1;
                newTP.Path        = dlg.FileName;

                SQLiteClass.ExecuteInsertTableTemplatePath(SQLiteClass.dbpath, newTP);

                TemplatePathListViewModel.tplv.Entries.Clear();
                SQLiteClass.ExecuteSelectTableTemplatePath(SQLiteClass.dbpath, TemplatePathListViewModel.tplv, theTemplate.Id);
            }
        }
Beispiel #2
0
        public static Boolean ExecuteUpdateTableTemplatePath(string dbpath, ListTemplatePath lt)
        {
            Boolean ret = false;

            SQLiteConnection con = new SQLiteConnection("Data Source=" + dbpath + ";");

            con.Open();

            SQLiteCommand com = new SQLiteCommand("UPDATE template_path SET template_id=@template_id, torder=@torder, path=@path where id=@id", con);

            com.Parameters.Add(sqliteParamInt64(com, "@id", lt.Id));
            com.Parameters.Add(sqliteParamInt64(com, "@template_id", lt.Template_Id));
            com.Parameters.Add(sqliteParamInt64(com, "@torder", lt.Order));
            com.Parameters.Add(sqliteParam(com, "@path", lt.Path));

            try
            {
                com.ExecuteNonQuery();
                ret = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("database table template path update error!\n" + ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(ret);
        }
Beispiel #3
0
        public static Boolean ExecuteInsertTableTemplatePath(string dbpath, ListTemplatePath lt)
        {
            Boolean ret = false;

            object obj;

            SQLiteConnection con = new SQLiteConnection("Data Source=" + dbpath + ";");

            con.Open();

            SQLiteCommand com = new SQLiteCommand("INSERT INTO template_path (template_id, torder, path) VALUES (@template_id, @torder, @path)", con);

            com.Parameters.Add(sqliteParamInt64(com, "@template_id", lt.Template_Id));
            com.Parameters.Add(sqliteParamInt64(com, "@torder", lt.Order));
            com.Parameters.Add(sqliteParam(com, "@path", lt.Path));

            try
            {
                obj = com.ExecuteNonQuery();
                ret = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("database table template path insert error!\n" + ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(ret);
        }
Beispiel #4
0
        public static Boolean ExecuteSelectTableTemplatePath(string dbpath, TemplatePathListViewModel tplv, Int64 template_id)
        {
            Boolean ret = false;

            string sql = "SELECT * from template_path WHERE template_id = @template_id ORDER BY torder ASC";

            SQLiteConnection con = new SQLiteConnection("Data Source=" + dbpath + ";");

            con.Open();

            SQLiteCommand com = new SQLiteCommand(sql, con);

            com.Parameters.Add(sqliteParamInt64(com, "@template_id", template_id));

            try
            {
                SQLiteDataReader sdr = com.ExecuteReader();

                while (sdr.Read() == true)
                {
                    ListTemplatePath lt = new ListTemplatePath();
                    lt.Id          = (Int64)sdr["id"];
                    lt.Template_Id = (Int64)sdr["template_id"];
                    lt.Order       = (Int64)sdr["torder"];
                    lt.Path        = (string)sdr["path"];
                    tplv.Entries.Add(lt);
                }
                sdr.Close();
                ret = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("database table template path select error!\n" + ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(ret);
        }