예제 #1
0
        private void load()
        {
            SortedDictionary <int, SupplierOrgStructTable> supplierGroupList = new SortedDictionary <int, SupplierOrgStructTable>();
            string supplierQuery = "SELECT PKEY, VALUE, PARENT_PKEY FROM  BASE_SUPPLIER_ORG_STRUCT ORDER BY PKEY";

            if (m_SupplierOrgList.Count > 0)
            {
                m_SupplierOrgList.Clear();
            }

            using (DataTable dataTable = DatabaseAccessFactoryInstance.Instance.QueryDataTable(FormMain.DB_NAME, supplierQuery))
            {
                foreach (DataRow row in dataTable.Rows)
                {
                    SupplierOrgStructTable record = new SupplierOrgStructTable();
                    record.pkey       = DbDataConvert.ToInt32(row[0]);
                    record.value      = DbDataConvert.ToInt32(row[1]);
                    record.parentPkey = DbDataConvert.ToInt32(row[2]);

                    supplierGroupList.Add(record.pkey, record);
                }
            }

            m_SupplierOrgList = supplierGroupList;
        }
예제 #2
0
        private void getASupplierOrgValue(int parentID, int value)
        {
            ArrayList nodeList = getNodesFormParentID(parentID);

            if (nodeList.Count == 0)
            {
                if (!m_childNodes.ContainsKey(value))
                {
                    m_childNodes.Add(value, value);
                }
            }
            else
            {
                for (int i = 0; i < nodeList.Count; i++)
                {
                    SupplierOrgStructTable record = (SupplierOrgStructTable)nodeList[i];

                    if (!m_childNodes.ContainsKey(record.value))
                    {
                        m_childNodes.Add(record.value, record.value);
                    }

                    getASupplierOrgValue(record.pkey, record.value);
                }
            }
        }
예제 #3
0
        public int getNoteValueFromPkey(int pkey)
        {
            int noteValue = 0;

            if (m_SupplierOrgList.ContainsKey(pkey))
            {
                SupplierOrgStructTable record = (SupplierOrgStructTable)m_SupplierOrgList[pkey];
                noteValue = record.value;
            }

            return(noteValue);
        }
예제 #4
0
        public ArrayList getNodesFormParentID(int parentID)
        {
            ArrayList nodes = new ArrayList();

            SupplierOrgStructTable record = new SupplierOrgStructTable();

            foreach (KeyValuePair <int, SupplierOrgStructTable> index in m_SupplierOrgList)
            {
                record = index.Value;
                if (record.parentPkey == parentID)
                {
                    nodes.Add(record);
                }
            }

            return(nodes);
        }
예제 #5
0
        public int getRootNodePkey()
        {
            int rootNodeID = 0;

            SupplierOrgStructTable record = new SupplierOrgStructTable();

            foreach (KeyValuePair <int, SupplierOrgStructTable> index in m_SupplierOrgList)
            {
                record = index.Value;
                if (record.parentPkey == 0)
                {
                    rootNodeID = record.pkey;
                }
            }

            return(rootNodeID);
        }
예제 #6
0
        public int getPkeyFromValue(int value)
        {
            int       peky  = 0;
            ArrayList nodes = new ArrayList();

            SupplierOrgStructTable record = new SupplierOrgStructTable();

            foreach (KeyValuePair <int, SupplierOrgStructTable> index in m_SupplierOrgList)
            {
                record = index.Value;
                if (record.value == value)
                {
                    peky = record.pkey;
                }
            }

            return(peky);
        }
예제 #7
0
        public void insert(SupplierOrgStructTable supplierOrgStruct)
        {
            string insert = "INSERT INTO [dbo].[BASE_SUPPLIER_ORG_STRUCT] ([VALUE],[PARENT_PKEY]) VALUES (";

            insert += "'" + supplierOrgStruct.value + "',";
            insert += Convert.ToString(supplierOrgStruct.parentPkey);
            insert += ")";

            try
            {
                DatabaseAccessFactoryInstance.Instance.ExecuteCommand(FormMain.DB_NAME, insert);
                MessageBoxExtend.messageOK("数据保存成功");
                load();
            }
            catch (Exception error)
            {
                MessageBoxExtend.messageWarning(error.Message);
                return;
            }
        }
예제 #8
0
        public void update(int pkey, SupplierOrgStructTable supplierOrgStruct)
        {
            string update = "UPDATE [dbo].[BASE_SUPPLIER_ORG_STRUCT] SET ";

            update += "[VALUE] = '" + supplierOrgStruct.value + "',";
            update += "[PARENT_PKEY] = " + Convert.ToString(supplierOrgStruct.parentPkey) + " ";
            update += "WHERE PKEY = " + Convert.ToString(pkey);

            try
            {
                DatabaseAccessFactoryInstance.Instance.ExecuteCommand(FormMain.DB_NAME, update);

                MessageBoxExtend.messageOK("数据修改成功");

                load();
            }
            catch (Exception error)
            {
                MessageBoxExtend.messageWarning(error.Message);
                return;
            }
        }