Example #1
0
        //Numerator Builder
        //public static string PK(string Kode, int Count)
        //{
        //    return PK(Kode, 0, 0, Count);
        //}
        public static string PK(string Kode, int Tahun, int Bulan, int Count, string Project)
        {
            string x = "";

            var rs = Db.Rs("SELECT * FROM " + Mi.DbPrefix + "SECURITY..Numerator WHERE Kode = '" + Kode + "' AND Project = '" + Project + "'");

            if (rs.Rows.Count > 0)
            {
                var    r       = rs.Rows[0];
                string Pemisah = r["Pemisah"].ToString();

                x = r["Komposisi"].ToString();

                string Prefix = r["Prefix"].ToString();
                string Num    = Count.ToString().PadLeft(Convert.ToInt16(r["DigitNum"]), '0');

                string Thn = "";
                if (Tahun != 0)
                {
                    if (Convert.ToInt16(r["FormatTahun"]) == 0)
                    {
                        Thn = Tahun.ToString().Substring(2, 2);
                    }
                    if (Convert.ToInt16(r["FormatTahun"]) == 1)
                    {
                        Thn = Tahun.ToString();
                    }
                }

                string Bln = "";
                if (Bulan != 0)
                {
                    if (Convert.ToInt16(r["FormatBulan"]) == 0)
                    {
                        Bln = Bulan.ToString().PadLeft(2, '0');
                    }
                    if (Convert.ToInt16(r["FormatBulan"]) == 1)
                    {
                        Bln = Cf.TglNamaBln(Bulan, true);
                    }
                    if (Convert.ToInt16(r["FormatBulan"]) == 2)
                    {
                        Bln = Cf.TglNamaBln(Bulan, false).Substring(0, 3).ToUpper();
                    }
                }
                //khusus panahome
                string Pers = Db.SingleString("SELECT Pers FROM " + Mi.DbPrefix + "SECURITY..REF_PROJECT WHERE Project='" + Project + "'");

                x = x.Replace("{Prefix}", Prefix + Pemisah);
                x = x.Replace("{Project}", Pers + Pemisah);

                if (Tahun != 0)
                {
                    x = x.Replace("{Thn}", Thn + Pemisah);
                }
                else
                {
                    x = x.Replace("{Thn}", "");
                }
                if (Bulan != 0)
                {
                    x = x.Replace("{Bln}", Bln + Pemisah);
                }
                else
                {
                    x = x.Replace("{Bln}", "");
                }
                x = x.Replace("{Num}", Num + Pemisah);

                if (x.EndsWith(Pemisah))
                {
                    x = x.Remove(x.Length - 1);
                }
            }

            return(x);
        }