示例#1
0
文件: Hlp.cs 项目: SenerDemiral/MM0
        public static void SablondanEkle(ulong ppId, string sablon)
        {
            PP dpp = Db.FromId((ulong)ppId) as PP;

            if (dpp == null)
            {
                return;
            }

            using (StreamReader sr = new StreamReader($@"C:\Starcounter\MM0Data\{sablon}.txt", System.Text.Encoding.UTF8))
            {
                string line;
                HH[]   dhh = new HH[9];
                dhh[0] = dpp.HHroot;

                int not = 0;
                Db.Transact(() =>
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
                        {
                            not = 1;
                            foreach (var c in line)
                            {
                                if (c == '\t')
                                {
                                    not++;
                                }
                            }
                            dhh[not] = new HH
                            {
                                PP  = dpp,
                                Prn = dhh[not - 1],
                                Ad  = line.TrimStart('\t'),
                            };
                            HH.PostIns(dhh[not]);
                        }
                    }
                });
            }
        }
示例#2
0
        public static string InsertRec(long ppId, long prnId, string Ad, decimal ThmGdr, decimal ThmGlr, string Info)
        {
            // Hareketi/FF olan bir hesabin altina kayit acilack ise
            // Mevcut Parent'dan Yeni Parent yarat. Eskisi ve AltHesap buna baglanacak
            // Mevcut Parent'in adina "Eski" ekle, YeniParent'e bagla
            // AltHesapAc Yeniye bagla
            // AAA nin FF hareketleri var altina BBB acilacak
            // Sonunda Boyle olacak:
            // AAA
            //  EskiAAA
            //  BBB

            Ad = Ad.Trim();
            string msj = "";

            Db.Transact(() =>
            {
                if (Db.FromId((ulong)prnId) is HH phh)
                {
                    if (phh.HasHrk)
                    {
                        //msj = "Hesabın hareketleri var, Bu hesabın altına hesap ekleyemezsiniz.";
                        // Parent kaydi duplicate et, Yeni Parent bu olacak. Eskisi ve AltHesap buna baglanacak
                        HH newPHH = new HH
                        {
                            Prn    = phh.Prn,
                            PP     = phh.PP,
                            Lvl    = phh.Lvl,
                            Skl    = phh.Skl,
                            Ad     = phh.Ad,
                            Info   = phh.Info,
                            ThmGdr = phh.ThmGdr,
                            ThmGlr = phh.ThmGlr
                        };

                        // Mevcut prn'in adine Eski ekleyip Parintini newPHH yap
                        phh.Ad  = $"Eski {phh.Ad}";
                        phh.Prn = newPHH;
                        HH.PostIns(phh);

                        // AltHesabi Ac
                        HH newHH = new HH
                        {
                            Prn    = newPHH,
                            PP     = Db.FromId <PP>((ulong)ppId),
                            Ad     = Ad,
                            Info   = Info,
                            ThmGdr = ThmGdr,
                            ThmGlr = ThmGlr
                        };
                        HH.PostIns(newHH);
                    }
                    else
                    {
                        HH hh = new HH
                        {
                            Prn    = phh,
                            PP     = Db.FromId <PP>((ulong)ppId),
                            Ad     = Ad,
                            Info   = Info,
                            ThmGdr = ThmGdr,
                            ThmGlr = ThmGlr
                        };
                        HH.PostIns(hh);
                    }
                }
            });
            return(msj);
        }