void GenerateData_Click(object sender, EventArgs e)
        {
            var rnd = new Random();

            var step        = 7;
            var visitsCount = 10;
            var baseDate    = DateTimeOffset.Now.AddDays(-1 * visitsCount * step);

            var promotions  = MainDatabase.GetItems <Promotion>();
            var drugSKUs    = MainDatabase.GetDrugSKUs();
            var pharmacies  = MainDatabase.GetItems <Pharmacy>();
            var transaction = MainDatabase.BeginTransaction();

            MainDatabase.DeleteAttendancies();
            MainDatabase.DeleteDistributions();
            MainDatabase.DeleteFinanceData();
            MainDatabase.DeleteSaleData();

            MainDatabase.DeleteItems <CoterieData>();
            MainDatabase.DeleteItems <PresentationData>();
            MainDatabase.DeleteItems <Employee>();
            MainDatabase.DeleteItems <PromotionData>();
            MainDatabase.DeleteItems <CompetitorData>();
            MainDatabase.DeleteItems <MessageData>();
            MainDatabase.DeleteItems <ResumeData>();
            MainDatabase.DeleteItems <PhotoData>();

            transaction.Commit();

            transaction = MainDatabase.BeginTransaction();

            //int count = 0;
            foreach (var pharmacy in pharmacies)
            {
                //count++;
                // Визиты
                if (true)
                {
                    for (int i = 0; i < visitsCount; i++)
                    {
                        var attendance = MainDatabase.Create <Attendance>();
                        attendance.Pharmacy = pharmacy.UUID;
                        attendance.When     = baseDate.AddDays(i * step);

                        foreach (var SKU in drugSKUs)
                        {
                            var distribution = MainDatabase.CreateData <DistributionData>(attendance.UUID);
                            distribution.DrugSKU     = SKU.uuid;
                            distribution.IsExistence = rnd.NextDouble() > 0.5;
                            distribution.Count       = rnd.Next(0, 10);
                            distribution.Price       = (int)(rnd.NextDouble() * 200);
                            distribution.IsPresence  = rnd.NextDouble() > 0.5;
                            distribution.HasPOS      = rnd.NextDouble() > 0.5;
                            distribution.Order       = @"Order " + SKU.uuid;
                            distribution.Comment     = @"Comment " + SKU.uuid;
                        }
                    }
                }

                // Продажи
                var financesCount = 5;
                baseDate = DateTimeOffset.Now.AddMonths(-3);
                for (int i = 0; i < financesCount; i++)
                {
                    foreach (var SKU in drugSKUs)
                    {
                        var financeData = MainDatabase.Create <FinanceData>();
                        financeData.Pharmacy = pharmacy.UUID;
                        financeData.Period   = baseDate.AddMonths(i);
                        financeData.DrugSKU  = SKU.uuid;
                        financeData.Sale     = rnd.NextDouble() > 0.3 ? null : (float?)(rnd.NextDouble() * 20);
                        financeData.Purchase = rnd.NextDouble() > 0.4 ? null : (float?)(rnd.NextDouble() * 20);
                        financeData.Remain   = rnd.NextDouble() > 0.5 ? null : (float?)(rnd.NextDouble() * 20);
                    }
                }

                // Содержание визите = Презентаци
                int employeesCount = 3;
                //int presentationsCount = 5;
                var attendanceLast = MainDatabase.GetAttendaces(pharmacy.UUID).OrderByDescending(i => i.When).FirstOrDefault();
                var positions      = MainDatabase.GetItems <Position>();
                var workTypes      = MainDatabase.GetItems <WorkType>();
                var brands         = MainDatabase.GetItems <DrugBrand>();
                var employees      = MainDatabase.GetEmployees(pharmacy.UUID);

                if (employees.Count == 0)
                {
                    for (int emp = 0; emp < employeesCount; emp++)
                    {
                        var employee = MainDatabase.CreateEmployee(pharmacy.UUID);
                        employee.SetSex(Sex.Male);
                        employee.Name = (rnd.NextDouble() > 0.5 ? @"Иванов" : @"Петров") + @" "
                                        + (rnd.NextDouble() > 0.5 ? @"Иван" : @"Петр") + @" "
                                        + (rnd.NextDouble() > 0.5 ? @"Иванович" : @"Петрович");
                        employee.Position  = positions[rnd.Next(positions.Count)].uuid;
                        employee.BirthDate = DateTimeOffset.Now.AddYears(-rnd.Next(25, 40)).AddDays((rnd.NextDouble() - 0.5) * 365);
                        employees.Add(employee);
                    }
                }

                foreach (var employee in employees)
                {
                    foreach (var brand in brands)
                    {
                        if (rnd.NextDouble() > 0.5)
                        {
                            continue;
                        }

                        for (int wt = 0; wt < workTypes.Count; wt++)
                        {
                            if (rnd.NextDouble() > 0.5)
                            {
                                continue;
                            }

                            var presentationData = MainDatabase.CreateData <PresentationData>(attendanceLast.UUID);
                            presentationData.Employee = employee.UUID;
                            presentationData.Brand    = brand.uuid;
                            presentationData.WorkType = workTypes[wt].uuid;
                        }
                    }
                }

                // Содержание визите = Фарм-кружок
                foreach (var employee in employees)
                {
                    if (rnd.NextDouble() > 0.5)
                    {
                        continue;
                    }

                    foreach (var brand in brands)
                    {
                        if (rnd.NextDouble() > 0.5)
                        {
                            continue;
                        }

                        var coterieData = MainDatabase.CreateData <CoterieData>(attendanceLast.UUID);
                        coterieData.Employee = employee.UUID;
                        coterieData.Brand    = brand.uuid;
                    }
                }

                // Акция
                var promotionData = MainDatabase.CreateData <PromotionData>(attendanceLast.UUID);
                promotionData.Promotion = promotions[rnd.Next(promotions.Count - 1)].uuid;
                promotionData.Text      = @"promotionData";

                // Активность конкурентов
                var competitorData = MainDatabase.CreateData <CompetitorData>(attendanceLast.UUID);
                competitorData.Text = @"competitorData";

                // Сообщения от аптеки
                var messageTypes = MainDatabase.GetItems <MessageType>();
                foreach (var item in messageTypes)
                {
                    if (rnd.NextDouble() > 0.5)
                    {
                        continue;
                    }

                    var messageData = MainDatabase.CreateData <MessageData>(attendanceLast.UUID);
                    messageData.Type = item.uuid;
                    messageData.Text = @"messageData " + item.uuid;
                }

                // Резюме визита;
                var resumeData = MainDatabase.CreateData <ResumeData>(attendanceLast.UUID);
                resumeData.Text = @"resumeData";
            }

            transaction.Commit();

            RefreshView();
        }