Example #1
0
        /*
                public bool SetT(DbManagerDynamic db, List<ChainRec> buffer, int index, int wh)
                {
                    if (0 > index || index > Nodes.Count) return false;
                    if (Nodes[index].SourceWhNew.State == ValueState.Valid)
                    {
                        if (Nodes[index].SourceWhNew.Value.Equals(wh)) return true;
                    }

                    if (RecExists(Nodes, Nodes[0].Item, wh)) return false;

                    Nodes[index].SourceWhNew = new ChainValue(wh);

                    for (int i = index + 1; i < Nodes.Count; i++)
                    {
                        Nodes.RemoveAt(i);
                        i--;
                    }

                    int loc = wh;
                    while (loc != 0 && loc != -2)
                    {
                        var chainRec = FindRec(buffer, Nodes[0].Item, loc);
                        if (chainRec == null)
                        {
                            var chainRecNew = db.LogisticChainGetRec(Nodes[0].Item, loc);
                            if (chainRecNew == null) break;
                            buffer.Add(chainRecNew);
                            chainRec = chainRecNew;
                        }
                        chainRec.Id = Nodes[0].Id;
                        Nodes.Add(chainRec);
                        loc = Convert.ToInt32(chainRec.SourceWhNew.Value);
                        if (RecExists(Nodes, Nodes[0].Item, loc))
                        {
                            break;
                        }
                    }
                    UpdateSequence();
                    return true;
                }
        */
        public bool SetW(DBManager db, List<ChainRec> buffer, int index, int wh)
        {
            if (0 > index || index > Nodes.Count) return false;
            if (Nodes[index].SourceWhNew != null)
                if (Nodes[index].SourceWhNew.State == ValueStates.Valid)
                {
                    if (Nodes[index].SourceWhNew.Value.Equals(wh)) return true;
                }

            if (RecExists(Nodes, Nodes[0].Item, wh)) return false;

            Nodes[index].SourceWhNew = new ChainValue(wh);

            for (int i = index + 1; i < Nodes.Count; i++)
            {
                Nodes.RemoveAt(i);
                i--;
            }

            int loc = wh;
            while (loc != 0 && loc != -2)
            {
                var chainRec = FindRec(buffer, Nodes[0].Item, loc);
                if (chainRec == null)
                {
                    var chainRecNew = db.LogisticChainGetRec(Nodes[0].Item, loc);
                    if (chainRecNew == null) break;
                    buffer.Add(chainRecNew);
                    chainRec = chainRecNew;
                }
                chainRec.Id = Nodes[0].Id;
                Nodes.Add(chainRec);
                loc = Convert.ToInt32(chainRec.SourceWhNew.Value);
                if (RecExists(Nodes, Nodes[0].Item, loc))
                {
                    break;
                }
            }
            var cnt = Nodes.Count;
            var supplier = Nodes[cnt - 1].SupplierNew;
            if (supplier.State == ValueStates.Valid)
                SetSupplier(/*Nodes[cnt - 1].Seq*/cnt, Convert.ToInt32(supplier.Value),
                            Nodes[cnt - 1].SupplierDescNew.Value.ToString());
            UpdateSequence();
            return true;
        }