예제 #1
0
        public bool InsertCycle(string date, int ndays)
        {
            try
            {
                NFPCycles cy = new NFPCycles()
                {
                    StartingDate = date,
                    NumDays      = ndays,
                    IsCurrent    = 1,
                    IsCurrentTxt = "Yes",
                    LastEdit     = 1
                };
                database.Insert(cy);
                DateTime dt1 = DateTime.Parse(date);
                for (int i = 1; i <= ndays; i++)
                {
                    DateTime      dt2 = dt1.AddDays(i - 1);
                    NFPData_1_1_0 dt  = new NFPData_1_1_0()
                    {
                        DayID       = i,
                        CycleID     = cy.CycleID,
                        Date        = dt2.ToString("yyyy-MM-dd"),
                        Menstrual   = 0,
                        Indicator_1 = 0,
                        Indicator_2 = 0,
                        Indicator_3 = 0,
                        Frequency   = 0,
                        Peak        = 0,
                        DayCount    = 0,
                        Intercourse = 0,
                        Notes       = "",
                        Color       = "White",
                        StSelect    = 0,
                        Image       = 0
                    };
                    database.Insert(dt);
                }

                SetCurrent(date);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
        public bool MigrateData(List <NFPCycles> cycles, List <NFPData> data)
        {
            try
            {
                for (var i = 0; i < cycles.Count; i++)
                {
                    NFPCycles cy = new NFPCycles()
                    {
                        StartingDate = cycles[i].StartingDate,
                        NumDays      = cycles[i].NumDays,
                        IsCurrent    = cycles[i].IsCurrent,
                        IsCurrentTxt = cycles[i].IsCurrentTxt,
                        LastEdit     = cycles[i].LastEdit
                    };
                    database.Insert(cy);
                }
                for (var i = 0; i < data.Count; i++)
                {
                    int Ind1;
                    int Ind2;
                    int Ind3;
                    switch (data[i].Indicator)
                    {
                    case 0:
                        Ind1 = 0;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;

                    case 1:
                        Ind1 = 1;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;

                    case 2:
                        Ind1 = 2;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;

                    case 3:
                        Ind1 = 3;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;

                    case 4:
                        Ind1 = 4;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;

                    case 5:
                        Ind1 = 5;
                        Ind2 = 1;
                        Ind3 = 0;
                        break;

                    case 6:
                        Ind1 = 5;
                        Ind2 = 2;
                        Ind3 = 0;
                        break;

                    case 7:
                        Ind1 = 5;
                        Ind2 = 3;
                        Ind3 = 0;
                        break;

                    case 8:
                        Ind1 = 5;
                        Ind2 = 0;
                        Ind3 = 2;
                        break;

                    case 9:
                        Ind1 = 5;
                        Ind2 = 4;
                        Ind3 = 0;
                        break;

                    case 10:
                        Ind1 = 5;
                        Ind2 = 0;
                        Ind3 = 1;
                        break;

                    case 11:
                        Ind1 = 5;
                        Ind2 = 0;
                        Ind3 = 3;
                        break;

                    case 12:
                        Ind1 = 5;
                        Ind2 = 5;
                        Ind3 = 0;
                        break;

                    case 13:
                        Ind1 = 6;
                        Ind2 = 1;
                        Ind3 = 0;
                        break;

                    case 14:
                        Ind1 = 6;
                        Ind2 = 2;
                        Ind3 = 0;
                        break;

                    case 15:
                        Ind1 = 6;
                        Ind2 = 3;
                        Ind3 = 0;
                        break;

                    case 16:
                        Ind1 = 6;
                        Ind2 = 0;
                        Ind3 = 2;
                        break;

                    case 17:
                        Ind1 = 6;
                        Ind2 = 4;
                        Ind3 = 0;
                        break;

                    case 18:
                        Ind1 = 6;
                        Ind2 = 0;
                        Ind3 = 1;
                        break;

                    case 19:
                        Ind1 = 6;
                        Ind2 = 0;
                        Ind3 = 3;
                        break;

                    case 20:
                        Ind1 = 6;
                        Ind2 = 5;
                        Ind3 = 0;
                        break;

                    case 21:
                        Ind1 = 7;
                        Ind2 = 1;
                        Ind3 = 0;
                        break;

                    case 22:
                        Ind1 = 7;
                        Ind2 = 2;
                        Ind3 = 0;
                        break;

                    case 23:
                        Ind1 = 7;
                        Ind2 = 3;
                        Ind3 = 0;
                        break;

                    case 24:
                        Ind1 = 7;
                        Ind2 = 0;
                        Ind3 = 2;
                        break;

                    case 25:
                        Ind1 = 7;
                        Ind2 = 4;
                        Ind3 = 0;
                        break;

                    case 26:
                        Ind1 = 7;
                        Ind2 = 0;
                        Ind3 = 1;
                        break;

                    case 27:
                        Ind1 = 7;
                        Ind2 = 0;
                        Ind3 = 3;
                        break;

                    case 28:
                        Ind1 = 7;
                        Ind2 = 5;
                        Ind3 = 0;
                        break;

                    case 29:
                        Ind1 = 8;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;

                    case 30:
                        Ind1 = 9;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;

                    case 31:
                        Ind1 = 10;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;

                    default:
                        Ind1 = 0;
                        Ind2 = 0;
                        Ind3 = 0;
                        break;
                    }
                    NFPData_1_1_0 dt = new NFPData_1_1_0()
                    {
                        DayID       = data[i].DayID,
                        CycleID     = data[i].CycleID,
                        Date        = data[i].Date,
                        Menstrual   = data[i].Menstrual,
                        Indicator_1 = Ind1,
                        Indicator_2 = Ind2,
                        Indicator_3 = Ind3,
                        Frequency   = data[i].Frequency,
                        Peak        = data[i].Peak,
                        DayCount    = data[i].DayCount,
                        Intercourse = data[i].Intercourse,
                        Notes       = data[i].Notes,
                        Color       = data[i].Color,
                        StSelect    = data[i].StSelect,
                        Image       = data[i].Image
                    };
                    database.Insert(dt);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }