예제 #1
0
        public static void NodeGerekenKidsMik(ulong node, double Mik)
        {
            // node dan Mik kadar isteniyor, stoktakiler kullanildiginda ne kadar Kids alinmali.
            Dictionary <ulong, double> S = new Dictionary <ulong, double>();  // Stok
            Dictionary <ulong, double> G = new Dictionary <ulong, double>();  // Gereken

            // Burasi Siparis listesindeki her kalem icin donerek, gereken toplam miktarlar alinabilir.
            //foreach(var r in Db.SQL<TTT>("select r from TSD r where r.Prn.ObjectNo = ?", TSBoNo))
            //{
            //    NodeKidsMikDty(node, 1, S, G);
            //}
            NodeGerekenKidsMikDty(node, Mik, S, G);
            NNT s = Db.FromId <NNT>(node);

            Console.WriteLine($"Nodes @{s.Ad} ---------->");
            foreach (var r in G)
            {
                s = Db.FromId <NNT>(r.Key);
                Console.WriteLine($"{s.Ad} -> Stok: {S[r.Key]}, Gereken: {r.Value}");
            }

            /*
             * var aaa = Db.FromId(46);    // Musteri
             * var bbb = Db.FromId(29);    // Depo
             * var tsb = Db.FromId(47) as TSB;    // TSB
             *
             * var ccc = ((KMT)tsb.DST).Adres; // DST is KKK
             */
        }
예제 #2
0
        private static void DownTo(NNT node, List <NNT> lst)    // Start from Usr=node, Downto Ony
        {
            //if (UsrYtk.GetObjectNo() == OnyYtk.GetObjectNo())
            //    return true;

            foreach (var r in Db.SQL <NNR>("select r from NNR r where r.NP = ?", node))
            {
                var aaa = r.NP.Ad;
                var bbb = r.NC.Ad;

                /*
                 * if (r.NP.GetObjectNo() == UsrYtk.GetObjectNo())
                 * {
                 *  //rv = true;
                 *  break;
                 * }
                 * else*/
                lst.Add(r.NC);
                if (r.NC.HasKid)
                {
                    DownTo(r.NC, lst);
                }
            }
            //return rv;
        }
예제 #3
0
        // FindInChildren kullan Eger BR den gidecekse.
        // Yetki deneme, OnyYtk UsrYtk'nin uyesi mi? OnyYtk'nin ustunde UsrYtk var mi? OK
        private static bool IsOnyYtkMemberOfUsrYtk(NNT UsrYtk, NNT OnyYtk, bool varmi)    // UsrYtk, OnyYtk/Constant
        {
            if (UsrYtk.GetObjectNo() == OnyYtk.GetObjectNo())
            {
                return(true);
            }

            if (!varmi)
            {
                foreach (var r in Db.SQL <NNR>("select r from NNR r where r.NP = ?", UsrYtk))
                {
                    var aaa = r.NP.Ad;
                    var bbb = r.NC.Ad;
                    if (r.NC.GetObjectNo() == OnyYtk.GetObjectNo())
                    {
                        varmi = true;
                        break;
                    }
                    else if (r.NC.HasKid && !varmi)
                    {
                        varmi = IsOnyYtkMemberOfUsrYtk(r.NC, OnyYtk, varmi);
                    }
                }
            }
            return(varmi);
        }
예제 #4
0
        public static void Deneme2()
        {
            Dictionary <string, List <string> > d = new Dictionary <string, List <string> >();
            List <List <string> > lls             = new List <List <string> >();

            foreach (var n in Db.SQL <NNT>("SELECT r FROM NNT r"))
            {
                NNT    cn  = n;
                bool   fnd = true;
                string bbb = cn.Ad;
                string aaa = "";
                while (fnd)
                {
                    NNR nr = Db.SQL <NNR>("SELECT r FROM NNR r WHERE r.NC = ?", cn).FirstOrDefault();
                    if (nr == null)
                    {
                        fnd = false;
                    }
                    else
                    {
                        cn  = nr.NP;
                        aaa = aaa + " " + cn.Ad;
                    }
                }
            }
        }
예제 #5
0
        public static void DenemeYetki()  // UsrYtk'nin altinda OnyYtk var mi?
        {
            // Senay296 da Mehmet294 yok
            // Mehmet294 de Sener299 yok
            // Suzan295 de Ali301 var
            // Senay296 da Ali301 var
            NNT  UsrYtk = Db.FromId <NNT>(304);
            NNT  OnyYtk = Db.FromId <NNT>(301);
            bool rv     = IsOnyYtkMemberOfUsrYtk(UsrYtk, OnyYtk, false); // IsOnyYtkMemberOfUsrYtk

            UpToUsr(OnyYtk, UsrYtk);
            DownToOny(UsrYtk, OnyYtk);

            Dictionary <NNT, List <NNT> > mD = new Dictionary <NNT, List <NNT> >();

            foreach (var r in Db.SQL <NNT>("SELECT r FROM NNT r"))
            {
                var list = new List <NNT>();
                DownTo(r, list);
                mD[r] = list;
            }

            // find ony in node
            bool fnd = false;

            foreach (var f in mD[UsrYtk])
            {
                if (f.GetObjectNo() == OnyYtk.GetObjectNo())
                {
                    fnd = true;
                    break;
                }
            }
        }
예제 #6
0
        public static double NeMaliyet(ulong sNo)
        {
            double Fyt = 0;
            NNT    s   = Db.FromId(sNo) as NNT;

            if (s != null)
            {
                if (s.HasKid)
                {
                    Fyt = NeMaliyetDty(sNo);
                }
                else
                {
                    Fyt = s.Fyt;
                }

                //if (dbg)
                Console.WriteLine($"{s.Ad}#{sNo} Maliyeti = {Fyt:n}");
            }
            else
            {
                Fyt = -1;
                //if (dbg)
                Console.WriteLine($"Ne:#{sNo} Bulunamadi");
            }
            return(Fyt);
        }
예제 #7
0
        public static DataTable DenemeDown()
        {
            DataTable table = new DataTable();

            table.Columns.Add("L", typeof(int));
            table.Columns.Add("P", typeof(ulong));
            table.Columns.Add("K", typeof(ulong));
            table.Columns.Add("A", typeof(string));
            table.Columns.Add("N", typeof(ulong));
            table.Columns.Add("M", typeof(double)); // Miktar
            table.Columns.Add("F", typeof(double)); // Fiyat
            table.Columns.Add("HasKid", typeof(bool));
            table.Columns.Add("Ureten", typeof(string));

            ulong P = 0;
            ulong K = 1;

            foreach (var n in Db.SQL <NNT>("SELECT r FROM NNT r WHERE r.HasPrn = ?", false))
            {
                table.Rows.Add(0, P, K, n.Ad, n.GetObjectNo(), 1, 0, n.HasKid);
                K++;
            }

            for (int L = 1; L < 10; L++)
            {
                DataRow[] dr = table.Select($"L = {L - 1}");
                foreach (var r in dr)
                {
                    P = (ulong)r["K"]; // (int)r.ItemArray[2];

                    foreach (var nr in Db.SQL <NNR>("SELECT r FROM NNR r WHERE r.NP.ObjectNo = ?", r["N"]))
                    {
                        table.Rows.Add(L, P, K, nr.KAd, nr.NC.GetObjectNo(), nr.Mik, nr.NC.Fyt, nr.NC.HasKid);
                        K++;
                    }
                }
            }
            foreach (DataRow t in table.Rows)
            {
                t["Ureten"] = NNT.NeUretenler((ulong)t["N"]);
            }
            return(table);
        }
예제 #8
0
        private static void UretenUrunTuketimleriDty(string ureten, NNT n, double mik, Dictionary <NNT, double> mD)
        {
            foreach (var nnr in Db.SQL <NNR>("SELECT n from NNR n WHERE n.NP = ?", n))
            {
                NNT kid = nnr.NC;
                var aaa = kid.Ad;

                if (!mD.ContainsKey(kid))
                {
                    mD[kid] = 0;
                }

                mD[kid] += mik * nnr.Mik;
                if (kid.HasKid) // && kid.GetObjectNo() != 275)
                {
                    UretenUrunTuketimleriDty(ureten, kid, mik * nnr.Mik, mD);
                }
            }
        }
예제 #9
0
        public static Dictionary <NNT, double> UretenUrunTuketimleri(string ureten, ulong urunNo, double uretimMik)
        {
            NNT urun = Db.FromId <NNT>(urunNo);
            // if(n.Ureten != ureten)
            // return null;  // Urunu Ureten imal etmiyorsa cik
            Dictionary <NNT, double> mD = new Dictionary <NNT, double>();

            UretenUrunTuketimleriDty(ureten, urun, uretimMik, mD);

            NNT u = Db.FromId <NNT>(urunNo);

            Console.WriteLine($"{urunNo} {u.Ad,10}:");
            foreach (var d in mD)
            {
                Console.WriteLine($"{d.Key.GetObjectNo()} {d.Key.Ad,10}: {d.Value}");
            }
            Console.WriteLine();

            return(mD);
        }
예제 #10
0
        public static void NodeMikInParents(ulong parent, DataTable table)
        {
            Dictionary <ulong, double> mikD = new Dictionary <ulong, double>(); // Gereken

            NodeMikInParent(parent, 1, mikD);                                   // Kid's Mik of parent.

            NNT p = Db.FromId <NNT>(parent);
            NNT n = null;

            Console.WriteLine($"Nodes @{p.Ad} ---------->");
            ulong  pNo = p.GetObjectNo();
            string nAd = "";
            string pAd = p.Ad;

            // ↑↓↕↔
            // ▲▼●
            if (!p.HasPrn)
            {
                pAd = "*" + pAd;  // root
            }
            else
            {
                pAd = "+" + pAd;
            }

            foreach (var r in mikD)
            {
                n   = Db.FromId <NNT>(r.Key);
                nAd = n.Ad;
                if (!n.HasKid)
                {
                    nAd = "-" + nAd;  // leaf
                }
                else
                {
                    nAd = "+" + nAd;
                }
                //Console.WriteLine($"{pAd}.{nAd} -> Mik: {r.Value}");
                table.Rows.Add(pNo, p.GetObjectNo(), pAd, nAd, r.Value);
            }
        }
예제 #11
0
        private static void UpToUsr(NNT node, NNT UsrYtk)    // Start from Ony=node, Upto Usr
        {
            //if (UsrYtk.GetObjectNo() == OnyYtk.GetObjectNo())
            //    return true;

            foreach (var r in Db.SQL <NNR>("select r from NNR r where r.NC = ?", node))
            {
                var aaa = r.NP.Ad;
                var bbb = r.NC.Ad;

                /*
                 * if (r.NP.GetObjectNo() == UsrYtk.GetObjectNo())
                 * {
                 *  //rv = true;
                 *  break;
                 * }
                 * else*/
                if (r.NP.HasPrn)
                {
                    UpToUsr(r.NP, UsrYtk);
                }
            }
            //return rv;
        }
예제 #12
0
        public static void initNNT()
        {
            if (Db.SQL <NNT>("select r from NNT r").FirstOrDefault() != null)
            {
                return; // Kayit var yapma
            }
            Db.Transact(() =>
            {
                Db.SQL("DELETE FROM NNR");
                Db.SQL("DELETE FROM NNT");

                var ahmet = new NNT
                {
                    Kd  = "40",
                    Ad  = "Ahmet",
                    Fyt = 100
                };
                var mehmet = new NNT
                {
                    Kd  = "50",
                    Ad  = "Mehmet",
                    Fyt = 110,
                };
                var suzan = new NNT
                {
                    Kd = "30",
                    Ad = "Suzan"
                };
                var senay = new NNT
                {
                    Kd = "30.10",
                    Ad = "Senay"
                };
                var umut = new NNT
                {
                    Kd  = "30.10.1",
                    Ad  = "Umut",
                    Fyt = 20
                };
                var nazli = new NNT
                {
                    Kd = "30.10.2",
                    Ad = "Nazli",
                };
                var sener = new NNT
                {
                    Kd = "30.20",
                    Ad = "Sener"
                };
                var can = new NNT
                {
                    Kd = "30.20.1",
                    Ad = "Can",
                };
                var ali = new NNT
                {
                    Kd  = "30.20.1.1",
                    Ad  = "Ali",
                    Fyt = 50
                };
                var ayse = new NNT
                {
                    Kd  = "30.20.1.2",
                    Ad  = "Ayse",
                    Fyt = 60
                };
                var veli = new NNT
                {
                    Kd  = "30.20.1.3",
                    Ad  = "Veli",
                    Fyt = 70
                };

                var kemal = new NNT
                {
                    Kd  = "kk",
                    Ad  = "Kemal",
                    Fyt = 30
                };

                new NNR
                {
                    NP  = suzan,
                    NC  = senay,
                    Mik = 2
                };
                new NNR
                {
                    NP  = senay,
                    NC  = umut,
                    Mik = 3
                };
                new NNR
                {
                    NP  = senay,
                    NC  = nazli,
                    Mik = 4
                };

                new NNR
                {
                    NP  = suzan,
                    NC  = sener,
                    Mik = 5
                };
                new NNR
                {
                    NP  = sener,
                    NC  = can,
                    Mik = 6
                };
                new NNR
                {
                    NP  = can,
                    NC  = ali,
                    Mik = 7
                };
                new NNR
                {
                    NP  = can,
                    NC  = ayse,
                    Mik = 8
                };
                new NNR
                {
                    NP  = can,
                    NC  = veli,
                    Mik = 9
                };
                new NNR
                {
                    NP = nazli,
                    NC = can,

                    Mik = 10
                };

                new NNR
                {
                    NP = sener,
                    NC = ahmet,

                    Mik = 11
                };
                new NNR
                {
                    NP = sener,
                    NC = mehmet,

                    Mik = 12
                };
                new NNR
                {
                    NP = sener,
                    NC = senay,

                    Mik = 13
                };
                new NNR
                {
                    NP = kemal,
                    NC = nazli,

                    Mik = 14
                };
                new NNR
                {
                    NP = kemal,
                    NC = sener,

                    Mik = 15
                };
                new NNR
                {
                    NP = suzan,
                    NC = ali,

                    Mik = 17
                };
                new NNR
                {
                    NP = sener,
                    NC = ali,

                    Mik = 18
                };
            });
        }