Example #1
0
        private void RecList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataStruct eventdata = RecList.SelectedItem as DataStruct;

            if (eventdata != null && eventdata is DataStruct)
            {
                NameBox.Text = eventdata.name;
                AuthBox.Text = eventdata.author;
                PageBox.Text = eventdata.page.ToString();
                PathBox.Text = eventdata.path;
                string[] tags = TagsClass.GetTagListFromString(eventdata.tagstring);
                TagList.Items.Clear();
                foreach (string val in tags)
                {
                    addTagFunc(val);
                }
            }
        }
Example #2
0
        private void RecDel_Click(object sender, RoutedEventArgs e)
        {
            DataStruct eventdata = RecList.SelectedItem as DataStruct;

            if (eventdata != null && eventdata is DataStruct)
            {
                Int64   rowid   = eventdata.id;
                DBClass dbclass = new DBClass();
                for (int i = bufdata.Count - 1; i >= 0; i--)
                {
                    if (bufdata[i].id == rowid)
                    {
                        bufdata.Remove(bufdata[i]);
                    }
                }
                UpdateViewSource();
                if (dbclass.DeleteRecord(rowid))
                {
                    MessageBox.Show("Operation Successfully Completed", "Info");
                }
            }
        }
Example #3
0
        public List <DataStruct> QueryRecord(bool LoadAll = false)
        {
            SQLiteCommand     cmd;
            SQLiteDataReader  reader;
            List <DataStruct> list = new List <DataStruct>();

            cmd = DBconn.CreateCommand();
            if (!LoadAll)
            {
                cmd.CommandText = "SELECT rowid,name,author,tag,page,path FROM Record LIMIT 500;";
            }
            else
            {
                cmd.CommandText = "SELECT rowid,name,author,tag,page,path FROM Record;";
            }

            try
            {
                reader = cmd.ExecuteReader();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Error:" + ex.ToString(), "Error Info");
                return(null);
            }
            while (reader.Read())
            {
                DataStruct data = new DataStruct();
                data.name      = (string)reader["name"];
                data.id        = (Int64)reader["rowid"];
                data.author    = (string)reader["author"];
                data.tagstring = (string)reader["tag"];
                data.path      = (string)reader["path"];
                data.page      = (Int64)reader["page"];
                list.Add(data);
            }
            return(list);
        }
Example #4
0
        private void RecUpd_Click(object sender, RoutedEventArgs e)
        {
            DataStruct eventdata = RecList.SelectedItem as DataStruct;

            if (eventdata != null && eventdata is DataStruct)
            {
                Int64         rowid = eventdata.id;
                List <string> Tags  = new List <string>();
                if (TagList.Items.Count > 0)
                {
                    foreach (var item in TagList.Items)
                    {
                        Tags.Add(item.ToString());
                    }
                }
                string[] TagsArray = new string[Tags.Count];
                Tags.CopyTo(TagsArray);
                string  TagString = TagsClass.GetTagStringFromList(TagsArray);
                DBClass dbclass   = new DBClass();
                if (dbclass.UpdateRecord(rowid, NameBox.Text, AuthBox.Text, TagString, PageBox.Text, PathBox.Text))
                {
                    MessageBox.Show("Operation Successfully Completed", "Info");
                }
                for (int i = 0; i < bufdata.Count; i++)
                {
                    if (bufdata[i].id == rowid)
                    {
                        bufdata[i].author    = AuthBox.Text;
                        bufdata[i].name      = NameBox.Text;
                        bufdata[i].page      = int.Parse(PageBox.Text);
                        bufdata[i].path      = PathBox.Text;
                        bufdata[i].tagstring = TagString;
                    }
                }
                UpdateViewSource();
            }
        }