예제 #1
0
 /// <summary>
 /// 6位数字奇偶起卦,设置BOOL,动爻位置
 /// </summary>
 /// <param name="num"></param>
 /// <param name="ret"></param>
 /// <param name="yao"></param>
 public void NumToBool(int num, ref LiuYaoMod mod)
 {
     bool[] ret     = new bool[6];
     int[]  tempnum = new int[6];
     tempnum[5] = num % 10;
     tempnum[4] = (num / 10) % 10;
     tempnum[3] = (num / 100) % 10;
     tempnum[2] = (num / 1000) % 10;
     tempnum[1] = (num / 10000) % 10;
     tempnum[0] = (num / 100000) % 10;
     for (int i = 0; i <= 5; i++)
     {
         if (tempnum[i] >= 6)
         {
             mod.ZhuGua.Yaos[i + 1].Dong = true;
         }
         else
         {
             mod.ZhuGua.Yaos[i + 1].Dong = false;
         }
         if (tempnum[i] % 2 == 0)
         {
             ret[i] = false;
         }
         else
         {
             ret[i] = true;
         }
     }
     BitToYao(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ref mod);
 }
예제 #2
0
        /// <summary>
        /// 上卦数下卦数起卦,设置BOOL,动爻位置
        /// </summary>
        /// <param name="numa"></param>
        /// <param name="numb"></param>
        /// <param name="ret"></param>
        /// <param name="yao"></param>
        public void NumsToBool(string numa, string numb, ref LiuYaoMod mod)
        {
            int    temp  = 0;
            string temps = "";

            bool[] ret = new bool[6];
            for (int i = 0; i < numa.Length; i++)
            {
                temps = numa.Substring(i, 1);
                if (temps == "1" || temps == "2" || temps == "3" || temps == "4" || temps == "5" || temps == "6" || temps == "7" || temps == "8" || temps == "9" || temps == "0")
                {
                    temp = temp + Int16.Parse(temps);
                }
            }
            int numaa = temp % 8;
            int dong  = temp;

            NumsTogua(numaa, true, ref ret);
            temp = 0;
            for (int i = 0; i < numb.Length; i++)
            {
                temps = numb.Substring(i, 1);
                if (temps == "1" || temps == "2" || temps == "3" || temps == "4" || temps == "5" || temps == "6" || temps == "7" || temps == "8" || temps == "9" || temps == "0")
                {
                    temp = temp + Int16.Parse(temps);
                }
            }
            int numbb = temp % 8;

            NumsTogua(numbb, false, ref ret);
            dong = dong + temp;
            dong = dong % 6;
            if (dong == 0)
            {
                dong = 6;
            }
            for (int i = 1; i <= 6; i++)
            {
                if (i == dong)
                {
                    mod.ZhuGua.Yaos[i].Dong = true;
                }
                else
                {
                    mod.ZhuGua.Yaos[i].Dong = false;
                }
            }
            BitToYao(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ref mod);
        }
예제 #3
0
        public void XuanBaziToYao30(string[] bazi, string num, ref LiuYaoMod mod)
        {
            int upnum = 0; int downnum = 0;

            for (int i = 0; i <= 6; i = i + 2)
            {
                upnum   = upnum + XuanGZToNum(bazi[i].ToString());
                downnum = downnum + XuanGZToNum(bazi[i + 1].ToString());
            }
            int dong = upnum + downnum;

            if (num != "")
            {
                int tempnum = Int32.Parse(num.ToString());
                //tempnum = tempnum % 30;
                upnum   = upnum + XuanNumUp30(tempnum, bazi[6]);
                downnum = downnum + XuanNumDown30(tempnum);
                dong    = dong + XuanNumUp30(tempnum, bazi[6]) + XuanNumDown30(tempnum);
            }


            dong = dong % 6;
            if (dong == 0)
            {
                dong = 6;
            }
            upnum   = upnum % 8;
            downnum = downnum % 8;
            for (int i = 1; i <= 6; i++)
            {
                if (i == dong)
                {
                    mod.ZhuGua.Yaos[i].Dong = true;
                }
                else
                {
                    mod.ZhuGua.Yaos[i].Dong = false;
                }
            }
            bool[] tempbool = new bool[6];
            NumsTogua(upnum, true, ref tempbool);
            NumsTogua(downnum, false, ref tempbool);
            BitToYao(tempbool[0], tempbool[1], tempbool[2], tempbool[3], tempbool[4], tempbool[5], ref mod);
        }
예제 #4
0
        /// <summary>
        /// 输入六位二进制,及动爻,排卦
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="c"></param>
        /// <param name="d"></param>
        /// <param name="e"></param>
        /// <param name="f"></param>
        /// <param name="yao"></param>
        public void BitToYao(bool a, bool b, bool c, bool d, bool e, bool f, ref LiuYaoMod mod)
        {
            string connectionString = AppConfig.ConnectionString;

            #region 设置主卦
            string cmdTexta = "SELECT * FROM Sign_64 WHERE firstbit = " + a + " AND secondbit = " + b + " AND thirdbit = " + c + " AND forthbit = " + d + " AND fifthbit = " + e + " AND sixthbit = " + f;

            using (SqlDataReader myreadera = SqlHelper.ExecuteReader(connectionString, CommandType.Text, cmdTexta))
            {
                myreadera.Read();

                mod.ZhuGua.Yaos[0].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[14].ToString());
                mod.ZhuGua.Yaos[1].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[15].ToString());
                mod.ZhuGua.Yaos[2].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[16].ToString());
                mod.ZhuGua.Yaos[3].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[17].ToString());
                mod.ZhuGua.Yaos[4].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[18].ToString());
                mod.ZhuGua.Yaos[5].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[19].ToString());

                mod.ZhuGua.Yaos[0].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[2].ToString());
                mod.ZhuGua.Yaos[1].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[3].ToString());
                mod.ZhuGua.Yaos[2].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[4].ToString());
                mod.ZhuGua.Yaos[3].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[5].ToString());
                mod.ZhuGua.Yaos[4].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[6].ToString());
                mod.ZhuGua.Yaos[5].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[7].ToString());

                mod.ZhuGua.Yaos[0].YaoType = (bool)myreadera[8];
                mod.ZhuGua.Yaos[1].YaoType = (bool)myreadera[9];
                mod.ZhuGua.Yaos[2].YaoType = (bool)myreadera[10];
                mod.ZhuGua.Yaos[3].YaoType = (bool)myreadera[11];
                mod.ZhuGua.Yaos[4].YaoType = (bool)myreadera[12];
                mod.ZhuGua.Yaos[5].YaoType = (bool)myreadera[13];

                mod.ZhuGua.ShiYao  = (int)myreadera[20];
                mod.ZhuGua.YingYao = (int)myreadera[21];
                mod.ZhuGua.GuaMing = myreadera[1].ToString();

                mod.ZhuGua.Yaos[0].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["firstlq"].ToString());
                mod.ZhuGua.Yaos[1].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["secondlq"].ToString());
                mod.ZhuGua.Yaos[2].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["thirdlq"].ToString());
                mod.ZhuGua.Yaos[3].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["forthlq"].ToString());
                mod.ZhuGua.Yaos[4].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["fifthlq"].ToString());
                mod.ZhuGua.Yaos[5].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["sixthlq"].ToString());

                //yao[9, 0] = myreadera["strong"].ToString();

                mod.ZhuGua.GuaHao = Int32.Parse(myreadera[0].ToString());
            }
            #endregion

            #region 设置伏卦
            int    temp     = mod.ZhuGua.GuaHao;
            string cmdTextb = "";
            if (temp % 10 == 1)
            {
                bool oa = opp(a);
                bool ob = opp(b);
                bool oc = opp(c);
                bool od = opp(d);
                bool oe = opp(e);
                bool of = opp(f);
                cmdTextb = "SELECT * FROM Sign_64 WHERE firstbit = " + oa + " AND secondbit = " + ob + " AND thirdbit = " + oc + " AND forthbit = " + od + " AND fifthbit = " + oe + " AND sixthbit = " + of;
            }
            else
            {
                temp     = (temp / 10) * 10 + 1;
                cmdTextb = @"SELECT * FROM Sign_64 WHERE guahao = " + temp.ToString();
            }

            using (SqlDataReader myreaderb = SqlHelper.ExecuteReader(connectionString, CommandType.Text, cmdTextb))
            {
                myreaderb.Read();

                mod.FuGua.Yaos[0].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[14].ToString());
                mod.FuGua.Yaos[1].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[15].ToString());
                mod.FuGua.Yaos[2].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[16].ToString());
                mod.FuGua.Yaos[3].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[17].ToString());
                mod.FuGua.Yaos[4].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[18].ToString());
                mod.FuGua.Yaos[5].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[19].ToString());

                mod.FuGua.Yaos[0].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[2].ToString());
                mod.FuGua.Yaos[1].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[3].ToString());
                mod.FuGua.Yaos[2].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[4].ToString());
                mod.FuGua.Yaos[3].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[5].ToString());
                mod.FuGua.Yaos[4].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[6].ToString());
                mod.FuGua.Yaos[5].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[7].ToString());
            }
            #endregion

            #region 设置变卦
            for (int i = 1; i <= 6; i++)
            {
                if (mod.ZhuGua.Yaos[i].Dong == true)
                {
                    switch (i)
                    {
                    case 1:
                        a = opp(a);
                        break;

                    case 2:
                        b = opp(b);
                        break;

                    case 3:
                        c = opp(c);
                        break;

                    case 4:
                        d = opp(d);
                        break;

                    case 5:
                        e = opp(e);
                        break;

                    case 6:
                        f = opp(f);
                        break;
                    }
                }
            }
            string cmdTextc = "SELECT * FROM Sign_64 WHERE firstbit = " + a + " AND secondbit = " + b + " AND thirdbit = " + c + " AND forthbit = " + d + " AND fifthbit = " + e + " AND sixthbit = " + f;

            using (SqlDataReader myreaderc = SqlHelper.ExecuteReader(connectionString, CommandType.Text, cmdTextc))
            {
                myreaderc.Read();

                mod.BianGua.Yaos[0].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[14].ToString());
                mod.BianGua.Yaos[1].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[15].ToString());
                mod.BianGua.Yaos[2].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[16].ToString());
                mod.BianGua.Yaos[3].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[17].ToString());
                mod.BianGua.Yaos[4].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[18].ToString());
                mod.BianGua.Yaos[5].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[19].ToString());

                mod.BianGua.Yaos[0].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[2].ToString());
                mod.BianGua.Yaos[1].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[3].ToString());
                mod.BianGua.Yaos[2].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[4].ToString());
                mod.BianGua.Yaos[3].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[5].ToString());
                mod.BianGua.Yaos[4].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[6].ToString());
                mod.BianGua.Yaos[5].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[7].ToString());

                mod.BianGua.Yaos[0].YaoType = (bool)myreaderc[8];
                mod.BianGua.Yaos[1].YaoType = (bool)myreaderc[9];
                mod.BianGua.Yaos[2].YaoType = (bool)myreaderc[10];
                mod.BianGua.Yaos[3].YaoType = (bool)myreaderc[11];
                mod.BianGua.Yaos[4].YaoType = (bool)myreaderc[12];
                mod.BianGua.Yaos[5].YaoType = (bool)myreaderc[13];

                mod.BianGua.ShiYao  = (int)myreaderc[20];
                mod.BianGua.YingYao = (int)myreaderc[21];
                mod.BianGua.GuaMing = myreaderc[1].ToString();

                mod.BianGua.GuaHao = Int32.Parse(myreaderc[0].ToString());
            }
            #endregion
        }
예제 #5
0
        /// <summary>
        /// 输入六位二进制,及动爻,排卦
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="c"></param>
        /// <param name="d"></param>
        /// <param name="e"></param>
        /// <param name="f"></param>
        /// <param name="yao"></param>
        public void BitToYao(bool a, bool b, bool c, bool d, bool e, bool f, ref LiuYaoMod mod)
        {
            string connectionString = AppConfig.ConnectionString;

            #region 设置主卦
            string cmdTexta = "SELECT * FROM Sign_64 WHERE firstbit = " + a + " AND secondbit = " + b + " AND thirdbit = " + c + " AND forthbit = " + d + " AND fifthbit = " + e + " AND sixthbit = " + f;

            using (SqlDataReader myreadera = SqlHelper.ExecuteReader(connectionString, CommandType.Text, cmdTexta))
            {
                myreadera.Read();

                mod.ZhuGua.Yaos[0].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[14].ToString());
                mod.ZhuGua.Yaos[1].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[15].ToString());
                mod.ZhuGua.Yaos[2].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[16].ToString());
                mod.ZhuGua.Yaos[3].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[17].ToString());
                mod.ZhuGua.Yaos[4].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[18].ToString());
                mod.ZhuGua.Yaos[5].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreadera[19].ToString());

                mod.ZhuGua.Yaos[0].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[2].ToString());
                mod.ZhuGua.Yaos[1].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[3].ToString());
                mod.ZhuGua.Yaos[2].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[4].ToString());
                mod.ZhuGua.Yaos[3].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[5].ToString());
                mod.ZhuGua.Yaos[4].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[6].ToString());
                mod.ZhuGua.Yaos[5].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreadera[7].ToString());

                mod.ZhuGua.Yaos[0].YaoType = (bool)myreadera[8];
                mod.ZhuGua.Yaos[1].YaoType = (bool)myreadera[9];
                mod.ZhuGua.Yaos[2].YaoType = (bool)myreadera[10];
                mod.ZhuGua.Yaos[3].YaoType = (bool)myreadera[11];
                mod.ZhuGua.Yaos[4].YaoType = (bool)myreadera[12];
                mod.ZhuGua.Yaos[5].YaoType = (bool)myreadera[13];

                mod.ZhuGua.ShiYao = (int)myreadera[20];
                mod.ZhuGua.YingYao = (int)myreadera[21];
                mod.ZhuGua.GuaMing = myreadera[1].ToString();

                mod.ZhuGua.Yaos[0].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["firstlq"].ToString());
                mod.ZhuGua.Yaos[1].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["secondlq"].ToString());
                mod.ZhuGua.Yaos[2].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["thirdlq"].ToString());
                mod.ZhuGua.Yaos[3].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["forthlq"].ToString());
                mod.ZhuGua.Yaos[4].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["fifthlq"].ToString());
                mod.ZhuGua.Yaos[5].LiuQin = (PublicValue.LYLiuQin)Enum.Parse(typeof(PublicValue.LYLiuQin), myreadera["sixthlq"].ToString());

                //yao[9, 0] = myreadera["strong"].ToString();

                mod.ZhuGua.GuaHao = Int32.Parse(myreadera[0].ToString());
            }
            #endregion

            #region 设置伏卦
            int temp = mod.ZhuGua.GuaHao;
            string cmdTextb = "";
            if (temp % 10 == 1)
            {
                bool oa = opp(a);
                bool ob = opp(b);
                bool oc = opp(c);
                bool od = opp(d);
                bool oe = opp(e);
                bool of = opp(f);
                cmdTextb = "SELECT * FROM Sign_64 WHERE firstbit = " + oa + " AND secondbit = " + ob + " AND thirdbit = " + oc + " AND forthbit = " + od + " AND fifthbit = " + oe + " AND sixthbit = " + of;
            }
            else
            {
                temp = (temp / 10) * 10 + 1;
                cmdTextb = @"SELECT * FROM Sign_64 WHERE guahao = " + temp.ToString();
            }

            using (SqlDataReader myreaderb = SqlHelper.ExecuteReader(connectionString, CommandType.Text, cmdTextb))
            {
                myreaderb.Read();

                mod.FuGua.Yaos[0].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[14].ToString());
                mod.FuGua.Yaos[1].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[15].ToString());
                mod.FuGua.Yaos[2].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[16].ToString());
                mod.FuGua.Yaos[3].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[17].ToString());
                mod.FuGua.Yaos[4].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[18].ToString());
                mod.FuGua.Yaos[5].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderb[19].ToString());

                mod.FuGua.Yaos[0].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[2].ToString());
                mod.FuGua.Yaos[1].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[3].ToString());
                mod.FuGua.Yaos[2].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[4].ToString());
                mod.FuGua.Yaos[3].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[5].ToString());
                mod.FuGua.Yaos[4].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[6].ToString());
                mod.FuGua.Yaos[5].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderb[7].ToString());
            }
            #endregion

            #region 设置变卦
            for (int i = 1; i <= 6; i++)
            {
                if (mod.ZhuGua.Yaos[i].Dong == true)
                {
                    switch (i)
                    {
                        case 1:
                            a = opp(a);
                            break;
                        case 2:
                            b = opp(b);
                            break;
                        case 3:
                            c = opp(c);
                            break;
                        case 4:
                            d = opp(d);
                            break;
                        case 5:
                            e = opp(e);
                            break;
                        case 6:
                            f = opp(f);
                            break;
                    }
                }
            }
            string cmdTextc = "SELECT * FROM Sign_64 WHERE firstbit = " + a + " AND secondbit = " + b + " AND thirdbit = " + c + " AND forthbit = " + d + " AND fifthbit = " + e + " AND sixthbit = " + f;

            using (SqlDataReader myreaderc = SqlHelper.ExecuteReader(connectionString, CommandType.Text, cmdTextc))
            {
                myreaderc.Read();

                mod.BianGua.Yaos[0].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[14].ToString());
                mod.BianGua.Yaos[1].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[15].ToString());
                mod.BianGua.Yaos[2].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[16].ToString());
                mod.BianGua.Yaos[3].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[17].ToString());
                mod.BianGua.Yaos[4].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[18].ToString());
                mod.BianGua.Yaos[5].YaoTG = (PublicValue.TianGan)Enum.Parse(typeof(PublicValue.TianGan), myreaderc[19].ToString());

                mod.BianGua.Yaos[0].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[2].ToString());
                mod.BianGua.Yaos[1].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[3].ToString());
                mod.BianGua.Yaos[2].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[4].ToString());
                mod.BianGua.Yaos[3].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[5].ToString());
                mod.BianGua.Yaos[4].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[6].ToString());
                mod.BianGua.Yaos[5].YaoDZ = (PublicValue.DiZhi)Enum.Parse(typeof(PublicValue.DiZhi), myreaderc[7].ToString());

                mod.BianGua.Yaos[0].YaoType = (bool)myreaderc[8];
                mod.BianGua.Yaos[1].YaoType = (bool)myreaderc[9];
                mod.BianGua.Yaos[2].YaoType = (bool)myreaderc[10];
                mod.BianGua.Yaos[3].YaoType = (bool)myreaderc[11];
                mod.BianGua.Yaos[4].YaoType = (bool)myreaderc[12];
                mod.BianGua.Yaos[5].YaoType = (bool)myreaderc[13];

                mod.BianGua.ShiYao = (int)myreaderc[20];
                mod.BianGua.YingYao = (int)myreaderc[21];
                mod.BianGua.GuaMing = myreaderc[1].ToString();

                mod.BianGua.GuaHao = Int32.Parse(myreaderc[0].ToString());
            }
            #endregion
        }
예제 #6
0
        public void XuanBaziToYao30(string[] bazi, string num, ref LiuYaoMod mod)
        {
            int upnum = 0; int downnum = 0;
            for (int i = 0; i <= 6; i = i + 2)
            {
                upnum = upnum + XuanGZToNum(bazi[i].ToString());
                downnum = downnum + XuanGZToNum(bazi[i + 1].ToString());
            }
            int dong = upnum + downnum;
            if (num != "")
            {
                int tempnum = Int32.Parse(num.ToString());
                //tempnum = tempnum % 30;
                upnum = upnum + XuanNumUp30(tempnum, bazi[6]);
                downnum = downnum + XuanNumDown30(tempnum);
                dong = dong + XuanNumUp30(tempnum, bazi[6]) + XuanNumDown30(tempnum);
            }

            dong = dong % 6;
            if (dong == 0)
                dong = 6;
            upnum = upnum % 8;
            downnum = downnum % 8;
            for (int i = 1; i <= 6; i++)
            {
                if (i == dong)
                    mod.ZhuGua.Yaos[i].Dong = true;
                else
                    mod.ZhuGua.Yaos[i].Dong = false;
            }
            bool[] tempbool = new bool[6];
            NumsTogua(upnum, true, ref tempbool);
            NumsTogua(downnum, false, ref tempbool);
            BitToYao(tempbool[0], tempbool[1], tempbool[2], tempbool[3], tempbool[4], tempbool[5], ref mod);
        }
예제 #7
0
 /// <summary>
 /// 6位数字奇偶起卦,设置BOOL,动爻位置
 /// </summary>
 /// <param name="num"></param>
 /// <param name="ret"></param>
 /// <param name="yao"></param>
 public void NumToBool(int num, ref LiuYaoMod mod)
 {
     bool[] ret = new bool[6];
     int[] tempnum = new int[6];
     tempnum[5] = num % 10;
     tempnum[4] = (num / 10) % 10;
     tempnum[3] = (num / 100) % 10;
     tempnum[2] = (num / 1000) % 10;
     tempnum[1] = (num / 10000) % 10;
     tempnum[0] = (num / 100000) % 10;
     for (int i = 0; i <= 5; i++)
     {
         if (tempnum[i] >= 6)
             mod.ZhuGua.Yaos[i+1].Dong = true;
         else
             mod.ZhuGua.Yaos[i + 1].Dong = false;
         if (tempnum[i] % 2 == 0)
             ret[i] = false;
         else
             ret[i] = true;
     }
     BitToYao(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ref mod);
 }
예제 #8
0
 /// <summary>
 /// 上卦数下卦数起卦,设置BOOL,动爻位置
 /// </summary>
 /// <param name="numa"></param>
 /// <param name="numb"></param>
 /// <param name="ret"></param>
 /// <param name="yao"></param>
 public void NumsToBool(string numa, string numb, ref LiuYaoMod mod)
 {
     int temp = 0;
     string temps = "";
     bool[] ret = new bool[6];
     for (int i = 0; i < numa.Length; i++)
     {
         temps = numa.Substring(i, 1);
         if (temps == "1" || temps == "2" || temps == "3" || temps == "4" || temps == "5" || temps == "6" || temps == "7" || temps == "8" || temps == "9" || temps == "0")
             temp = temp + Int16.Parse(temps);
     }
     int numaa = temp % 8;
     int dong = temp;
     NumsTogua(numaa, true, ref ret);
     temp = 0;
     for (int i = 0; i < numb.Length; i++)
     {
         temps = numb.Substring(i, 1);
         if (temps == "1" || temps == "2" || temps == "3" || temps == "4" || temps == "5" || temps == "6" || temps == "7" || temps == "8" || temps == "9" || temps == "0")
             temp = temp + Int16.Parse(temps);
     }
     int numbb = temp % 8;
     NumsTogua(numbb, false, ref ret);
     dong = dong + temp;
     dong = dong % 6;
     if (dong == 0)
         dong = 6;
     for (int i = 1; i <= 6; i++)
     {
         if (i == dong)
             mod.ZhuGua.Yaos[i].Dong = true;
         else
             mod.ZhuGua.Yaos[i].Dong = false;
     }
     BitToYao(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ref mod);
 }