Esempio n. 1
0
        private void SetQiYun(ref BaZiMod bazi)
        {
            DateTime[]          jieqi     = new DateTime[2];
            PublicValue.JieQi[] jieqiname = new PublicValue.JieQi[2];
            if (bazi.BirthTime.Date < bazi.BirthTime.BeginMonth[0])
            {
                DateEntity tmpdate = new DateEntity(bazi.BirthTime.Date.AddMonths(-3));
                jieqi[0]     = tmpdate.BeginMonth[11];
                jieqi[1]     = bazi.BirthTime.BeginMonth[0];
                jieqiname[0] = (PublicValue.JieQi)(11);
                jieqiname[1] = (PublicValue.JieQi)(0);
            }
            else if (bazi.BirthTime.Date > bazi.BirthTime.BeginMonth[11])
            {
                DateEntity tmpdate = new DateEntity(bazi.BirthTime.Date.AddMonths(+3));
                jieqi[1]     = tmpdate.BeginMonth[0];
                jieqi[0]     = bazi.BirthTime.BeginMonth[11];
                jieqiname[0] = (PublicValue.JieQi)(11);
                jieqiname[1] = (PublicValue.JieQi)(0);
            }
            else
            {
                for (int i = 0; i <= 10; i++)
                {
                    if (bazi.BirthTime.Date >= bazi.BirthTime.BeginMonth[i] && bazi.BirthTime.Date <= bazi.BirthTime.BeginMonth[i + 1])
                    {
                        jieqi[0]     = bazi.BirthTime.BeginMonth[i];
                        jieqi[1]     = bazi.BirthTime.BeginMonth[i + 1];
                        jieqiname[0] = (PublicValue.JieQi)(i);
                        jieqiname[1] = (PublicValue.JieQi)(i + 1);
                        break;
                    }
                }
            }
            //DateTime[] zhongqi = new DateTime[2];
            //PublicValue.ZhongQi[] zhongqiname = new PublicValue.ZhongQi[2];
            //if (bazi.BirthTime.Date < bazi.BirthTime.BeginZodiac[0])
            //{
            //    DateEntity tmpdate = new DateEntity(bazi.BirthTime.Date.AddMonths(-3));
            //    zhongqi[0] = tmpdate.BeginZodiac[11];
            //    zhongqi[1] = bazi.BirthTime.BeginZodiac[0];
            //    zhongqiname[0] = (PublicValue.ZhongQi)(11);
            //    zhongqiname[1] = (PublicValue.ZhongQi)(0);
            //}
            //else if (bazi.BirthTime.Date > bazi.BirthTime.BeginZodiac[11])
            //{
            //    DateEntity tmpdate = new DateEntity(bazi.BirthTime.Date.AddMonths(+3));
            //    zhongqi[1] = tmpdate.BeginZodiac[0];
            //    zhongqi[0] = bazi.BirthTime.BeginZodiac[11];
            //    zhongqiname[0] = (PublicValue.ZhongQi)(11);
            //    zhongqiname[1] = (PublicValue.ZhongQi)(0);
            //}
            //else
            //{
            //    for (int i = 0; i < 10; i++)
            //    {
            //        if (bazi.BirthTime.Date >= bazi.BirthTime.BeginZodiac[i] && bazi.BirthTime.Date <= bazi.BirthTime.BeginZodiac[i + 1])
            //        {
            //            zhongqi[0] = bazi.BirthTime.BeginZodiac[i];
            //            zhongqi[1] = bazi.BirthTime.BeginZodiac[i + 1];
            //            zhongqiname[0] = (PublicValue.ZhongQi)(i);
            //            zhongqiname[1] = (PublicValue.ZhongQi)(i + 1);
            //            break;
            //        }
            //    }
            //}

            bazi.JieQi[0]     = jieqi[0];
            bazi.JieQiName[0] = (PublicValue.AllJieQi)((int)jieqiname[0] * 2);
            bazi.JieQi[1]     = jieqi[1];
            bazi.JieQiName[1] = (PublicValue.AllJieQi)((int)jieqiname[1] * 2);

            //if (jieqi[0] > zhongqi[0])
            //{
            //    bazi.JieQi[0] = jieqi[0];
            //    bazi.JieQiName[0] = (PublicValue.AllJieQi)((int)jieqiname[0] * 2);
            //}
            //else
            //{
            //    bazi.JieQi[0] = zhongqi[0];
            //    bazi.JieQiName[0] = (PublicValue.AllJieQi)((int)zhongqiname[0] * 2+1);
            //}
            //if (jieqi[1] < zhongqi[1])
            //{
            //    bazi.JieQi[1] = jieqi[1];
            //    bazi.JieQiName[1] = (PublicValue.AllJieQi)((int)jieqiname[1] * 2);
            //}
            //else
            //{
            //    bazi.JieQi[1] = zhongqi[1];
            //    bazi.JieQiName[1] = (PublicValue.AllJieQi)((int)zhongqiname[1] * 2 + 1);
            //}

            //TimeSpan tmp = bazi.JieQi[1] - bazi.JieQi[0];//两节气差

            if ((bazi.YinYang == PublicValue.ShuXing.yang && bazi.Gender == AppCmn.AppEnum.Gender.male) ||
                (bazi.YinYang == PublicValue.ShuXing.yin && bazi.Gender == AppCmn.AppEnum.Gender.female))
            {
                TimeSpan tmp1 = new TimeSpan();
                tmp1       = bazi.JieQi[1] - bazi.BirthTime.Date;
                bazi.QiYun = new TimeSpan(Convert.ToInt64(tmp1.Ticks / 3 * 365.25636));
            }
            else
            {
                TimeSpan tmp1 = new TimeSpan();
                tmp1       = bazi.BirthTime.Date - bazi.JieQi[0];
                bazi.QiYun = new TimeSpan(Convert.ToInt64(tmp1.Ticks / 3 * 365.25636));
            }
            bazi.JiaoYun = bazi.BirthTime.Date.Add(bazi.QiYun);
        }
Esempio n. 2
0
        private void SetQiYun(ref BaZiMod bazi)
        {
            DateTime[] jieqi = new DateTime[2];
            PublicValue.JieQi[] jieqiname = new PublicValue.JieQi[2];
            if (bazi.BirthTime.Date < bazi.BirthTime.BeginMonth[0])
            {
                DateEntity tmpdate = new DateEntity(bazi.BirthTime.Date.AddMonths(-3));
                jieqi[0] = tmpdate.BeginMonth[11];
                jieqi[1] = bazi.BirthTime.BeginMonth[0];
                jieqiname[0] = (PublicValue.JieQi)(11);
                jieqiname[1] = (PublicValue.JieQi)(0);
            }
            else if (bazi.BirthTime.Date > bazi.BirthTime.BeginMonth[11])
            {
                DateEntity tmpdate = new DateEntity(bazi.BirthTime.Date.AddMonths(+3));
                jieqi[1] = tmpdate.BeginMonth[0];
                jieqi[0] = bazi.BirthTime.BeginMonth[11];
                jieqiname[0] = (PublicValue.JieQi)(11);
                jieqiname[1] = (PublicValue.JieQi)(0);
            }
            else
            {
                for (int i = 0; i <= 10; i++)
                {
                    if (bazi.BirthTime.Date >= bazi.BirthTime.BeginMonth[i] && bazi.BirthTime.Date <= bazi.BirthTime.BeginMonth[i + 1])
                    {
                        jieqi[0] = bazi.BirthTime.BeginMonth[i];
                        jieqi[1] = bazi.BirthTime.BeginMonth[i + 1];
                        jieqiname[0] = (PublicValue.JieQi)(i);
                        jieqiname[1] = (PublicValue.JieQi)(i + 1);
                        break;
                    }
                }
            }
            //DateTime[] zhongqi = new DateTime[2];
            //PublicValue.ZhongQi[] zhongqiname = new PublicValue.ZhongQi[2];
            //if (bazi.BirthTime.Date < bazi.BirthTime.BeginZodiac[0])
            //{
            //    DateEntity tmpdate = new DateEntity(bazi.BirthTime.Date.AddMonths(-3));
            //    zhongqi[0] = tmpdate.BeginZodiac[11];
            //    zhongqi[1] = bazi.BirthTime.BeginZodiac[0];
            //    zhongqiname[0] = (PublicValue.ZhongQi)(11);
            //    zhongqiname[1] = (PublicValue.ZhongQi)(0);
            //}
            //else if (bazi.BirthTime.Date > bazi.BirthTime.BeginZodiac[11])
            //{
            //    DateEntity tmpdate = new DateEntity(bazi.BirthTime.Date.AddMonths(+3));
            //    zhongqi[1] = tmpdate.BeginZodiac[0];
            //    zhongqi[0] = bazi.BirthTime.BeginZodiac[11];
            //    zhongqiname[0] = (PublicValue.ZhongQi)(11);
            //    zhongqiname[1] = (PublicValue.ZhongQi)(0);
            //}
            //else
            //{
            //    for (int i = 0; i < 10; i++)
            //    {
            //        if (bazi.BirthTime.Date >= bazi.BirthTime.BeginZodiac[i] && bazi.BirthTime.Date <= bazi.BirthTime.BeginZodiac[i + 1])
            //        {
            //            zhongqi[0] = bazi.BirthTime.BeginZodiac[i];
            //            zhongqi[1] = bazi.BirthTime.BeginZodiac[i + 1];
            //            zhongqiname[0] = (PublicValue.ZhongQi)(i);
            //            zhongqiname[1] = (PublicValue.ZhongQi)(i + 1);
            //            break;
            //        }
            //    }
            //}

            bazi.JieQi[0] = jieqi[0];
            bazi.JieQiName[0] = (PublicValue.AllJieQi)((int)jieqiname[0] * 2);
            bazi.JieQi[1] = jieqi[1];
            bazi.JieQiName[1] = (PublicValue.AllJieQi)((int)jieqiname[1] * 2);

            //if (jieqi[0] > zhongqi[0])
            //{
            //    bazi.JieQi[0] = jieqi[0];
            //    bazi.JieQiName[0] = (PublicValue.AllJieQi)((int)jieqiname[0] * 2);
            //}
            //else
            //{
            //    bazi.JieQi[0] = zhongqi[0];
            //    bazi.JieQiName[0] = (PublicValue.AllJieQi)((int)zhongqiname[0] * 2+1);
            //}
            //if (jieqi[1] < zhongqi[1])
            //{
            //    bazi.JieQi[1] = jieqi[1];
            //    bazi.JieQiName[1] = (PublicValue.AllJieQi)((int)jieqiname[1] * 2);
            //}
            //else
            //{
            //    bazi.JieQi[1] = zhongqi[1];
            //    bazi.JieQiName[1] = (PublicValue.AllJieQi)((int)zhongqiname[1] * 2 + 1);
            //}

            //TimeSpan tmp = bazi.JieQi[1] - bazi.JieQi[0];//两节气差

            if ((bazi.YinYang == PublicValue.ShuXing.yang && bazi.Gender == AppCmn.AppEnum.Gender.male) ||
                (bazi.YinYang == PublicValue.ShuXing.yin && bazi.Gender == AppCmn.AppEnum.Gender.female))
            {
                TimeSpan tmp1 = new TimeSpan();
                tmp1 = bazi.JieQi[1] - bazi.BirthTime.Date;
                bazi.QiYun = new TimeSpan(Convert.ToInt64(tmp1.Ticks / 3 * 365.25636));
            }
            else
            {
                TimeSpan tmp1 = new TimeSpan();
                tmp1 = bazi.BirthTime.Date - bazi.JieQi[0];
                bazi.QiYun = new TimeSpan(Convert.ToInt64(tmp1.Ticks / 3 * 365.25636));
            }
            bazi.JiaoYun = bazi.BirthTime.Date.Add(bazi.QiYun);
        }