Beispiel #1
0
        public void update_tree()//Обновление дерева объектов
        {
            TreeNode node     = new TreeNode();
            TreeNode sub_node = new TreeNode();
            TreeNode typeNode = new TreeNode("Tovary");

            treeView1.Nodes.Clear();

            foreach (string type in lists.GetTypes())
            {
                CCategorizedList cat_list = lists.GetCatList(type);
                List <string>    subtypes = cat_list.GetTypes();

                foreach (string subtype in subtypes)
                {
                    TreeNode     subtypeNode = new TreeNode(subtype);
                    List <CItem> items       = cat_list.GetByType(subtype);

                    foreach (CItem item in items)
                    {
                        TreeNode itemNode = new TreeNode(item.ToString());
                        itemNode.Text = item.Get()["name"];

                        subtypeNode.Nodes.Add(itemNode);
                    }
                    typeNode.Nodes.Add(subtypeNode);
                }
            }
            treeView1.Nodes.Add(typeNode);
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)                     //Изменение товара
        {
            Dictionary <string, string> param = new Dictionary <string, string>(); //Спсок полей редактируемого обьекта
            TreeNode s_node = treeView1.SelectedNode;

            if (s_node != null)
            {
                param["name"] = s_node.Text.ToString();

                foreach (string type in lists.GetTypes())
                {
                    CCategorizedList cat_list = lists.GetCatList(type);
                    List <string>    subtypes = cat_list.GetTypes();

                    foreach (string subtype in subtypes)
                    {
                        TreeNode     subtypeNode = new TreeNode(subtype);
                        List <CItem> items       = cat_list.GetByType(subtype);

                        foreach (CItem item in items)
                        {
                            var t = item.Get();
                            if (t.ContainsValue(param["name"]))
                            {
                                lists.Remove(item);
                                new_frm.main_frm = this;
                                new_frm.edit_item(t);
                            }
                        }
                    }
                }
                update_tree();
                update_data();
            }
        }
Beispiel #3
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)//Сохранение списка объектв
        {
            Dictionary <string, string> param = new Dictionary <string, string>();
            SaveFileDialog save = new SaveFileDialog();

            save.InitialDirectory = "c:\\";
            save.ShowDialog();
            string file_name = save.FileName;

            try
            {
                SQLiteConnection m_dbConnection;
                m_dbConnection = new SQLiteConnection("Data Source=" + file_name + ";Version=3;");
                m_dbConnection.Open();

                foreach (string type in lists.GetTypes())
                {
                    CCategorizedList cat_list = lists.GetCatList(type);
                    List <string>    subtypes = cat_list.GetTypes();

                    foreach (string subtype in subtypes)
                    {
                        TreeNode     subtypeNode = new TreeNode(subtype);
                        List <CItem> items       = cat_list.GetByType(subtype);

                        foreach (CItem item in items)
                        {
                            if (item.Get()["parent_type"].CompareTo("Writings") == 0)
                            {
                                string sql = "UPDATE Table1 SET parent_type = " + item.Get()["parent_type"] + "name = " + item.Get()["name"] + "price = " + item.Get()["price"] +
                                             "type = " + item.Get()["type"] + "type = " + item.Get()["color"] + "WHERE strih_kod = " + item.Get()["strih_code"];
                            }
                            else
                            {
                                string sql = "UPDATE Table1 SET paret = " + item.Get()["parent_type"] + "name = " + item.Get()["name"] + "price = "
                                             + item.Get()["price"] + "type = " + item.Get()["type"] + "page_count = " + item.Get()["page_count"]
                                             + "WHERE strih_kod = " + item.Get()["strih_code"];
                            }
                        }
                    }
                }
                m_dbConnection.Close();
            }
            catch
            {
                MessageBox.Show("Uncorrect data", "ERROR!!!", MessageBoxButtons.OK);
            }
        }