async private Task Initialize(Repository repo, form summaryForm, int year)
        {
            var region = await repo.GetRegion(Authentication.Credentials.RegionId);
            _formula = await repo.GetFormulasBySummaryForm(summaryForm.form_id);
            this.IsAvailable = (_formula != null);
            if (this.IsAvailable)
            {
                _region = region;
                _summaryForm = summaryForm;
                _regularForm = _formula.regular_form;
                _year = year;

                var municipalityList = await repo.GetMunicipalities();
                var municipalitiesHaveFormData = await repo.GetMunicipalitiesHaveFormData(_regularForm.form_id, _year);
                var municipalitiesHaveFormDataIdList = municipalitiesHaveFormData
                    .Select(t => t.municipality_id)
                    .ToList();
                foreach (var munit in municipalityList)
                {
                    var hasForm = municipalitiesHaveFormDataIdList.Contains(munit.municipality_id);
                    munit.SetAttachedProperty("bHasForm", hasForm);
                }
                this.municipalityBindingSource.DataSource = municipalityList;
            }
        }
        async private Task InitializeAdmin(Repository repo, form summaryForm, int year)
        {
            _formula = await repo.GetFormulasBySummaryForm(summaryForm.form_id);
            this.IsAvailable = (_formula != null);
            if (this.IsAvailable)
            {
                _summaryForm = summaryForm;
                _regularForm = _formula.regular_form;
                _year = year;
                var eduList = await repo.GetEdusHaveFormData(_regularForm.form_id, _year);

                this.eduBindingSource.DataSource = eduList;
            }
        }
        async private Task InitializeMunicipality(Repository repo, form summaryForm, int year)
        {
            var munit = await repo.GetMunicipality(Authentication.Credentials.MunitId);
            _formula = await repo.GetFormulasBySummaryForm(summaryForm.form_id);
            this.IsAvailable = (_formula != null);
            if (this.IsAvailable)
            {
                _municipality = munit;
                _summaryForm = summaryForm;
                _regularForm = _formula.regular_form;
                _year = year;

                var eduList = await repo.GetEdus(munit.municipality_id);
                var eduHasFormIdList = (await repo.GetEdusHaveFormData(_regularForm.form_id, _year))
                    .Select(t => t.edu_id);
                foreach (var edu in eduList)
                {
                    var hasForm = eduHasFormIdList.Contains(edu.edu_id);
                    edu.SetAttachedProperty("bHasForm", hasForm);
                }
                this.eduBindingSource.DataSource = eduList;
            }
        }
        private void InitializeEventHandlers()
        {
            lookUpSummaryFormType.Properties.ValueMember = "Value";
            lookUpSummaryFormType.Properties.DisplayMember = "Key";
            this.lookUpSummaryFormType.Properties.DataSource = new List<KeyValuePair<String, FormType>>
            {
                new KeyValuePair<string, FormType>("Регион", FormType.Region),
                new KeyValuePair<string, FormType>("Муниципалитет", FormType.Municipality)
            };

            this.lookUpSummaryFormType.EditValueChanged += async (sender, args) =>
            {
                var formType = (FormType) this.lookUpSummaryFormType.EditValue;
                switch (formType)
                {
                    case FormType.Region:
                        this.SummaryFormDataSource = await Repo.GetFormsByType(true, FormType.Region, FormType.OtherRegion);
                        this.RegularFormDataSource = await Repo.GetFormsByType(true, FormType.Municipality, FormType.OtherMunicipality);
                        this.labelRegularForm.Text = FormType.Municipality.GetDescription();
                        break;
                    case FormType.Municipality:
                        this.SummaryFormDataSource = await Repo.GetFormsByType(true, FormType.Municipality, FormType.OtherMunicipality);
                        this.RegularFormDataSource = await Repo.GetFormsByType(true, FormType.Edu, FormType.OtherEdu);
                        this.labelRegularForm.Text = FormType.Edu.GetDescription();
                        break;
                }
            };

            this.lookUpSummaryForm.EditValueChanged += (sender, args) =>
            {
                this.allformBindingSourceSummary.Position = this.allformBindingSourceSummary.List.IndexOf(lookUpSummaryForm.EditValue);
            };
            this.lookUpRegularForm.EditValueChanged += (sender, args) =>
            {
                this.allformBindingSourceRegular.Position = this.allformBindingSourceRegular.List.IndexOf(lookUpRegularForm.EditValue);
            };

            this.allformBindingSourceRegular.CurrentItemChanged += (sender, args) =>
            {
                if (lookUpRegularForm.EditValue == null)
                    return;
                var form = this.allformBindingSourceRegular.Current as form;
                if (form == null) return;
                LoadTemplate(form, spreadsheetRegular);
            };

            this.allformBindingSourceSummary.CurrentItemChanged += async (sender, args) =>
            {
                if (lookUpSummaryForm.EditValue == null)
                    return;
                var summaryForm = this.allformBindingSourceSummary.Current as form;
                var regularForm = this.allformBindingSourceRegular.Current as form;
                if (summaryForm == null || regularForm == null) return;
                lookUpRegularForm.EditValue = regularForm;
                this.layoutControl1.Enabled = false;

                var formula = await Repo.GetFormulasBySummaryForm(summaryForm.form_id);
                if (formula != null)
                {
                    if (formula.regular_form != regularForm)
                    {
                        regularForm = formula.regular_form;
                        this.lookUpRegularForm.EditValue = formula.regular_form;
                    }
                    _currentFormula = formula;
                    this.formulaEditControl.Text = await Task.Run(() => Encoding.UTF8.GetString(formula.file_data));
                }
                else
                {
                    _currentFormula = new mm_regular__summary_form();
                    this.formulaEditControl.Text = string.Empty;
                }
                await this.LoadTemplate(summaryForm, this.spreadsheetSummary);
                await this.LoadTemplate(regularForm, this.spreadsheetRegular);

                this.layoutControl1.Enabled = true;
            };
        }