public Task Process(form form)
        {
            var syncContext = SynchronizationContext.Current;
            return Task.Run(() =>
            {
                var alignFormulasData = form.check_data_file.contents;
                using (var ms = new MemoryStream(alignFormulasData))
                {
                    var formulas = FormulaExpressionParser.ParseStream(ms);
                    foreach (var formula in formulas)
                    {
                        var sourceResult = formula.SourcePart.Calculate(spreadsheetControlCurrent.Document);
                        var targetResult = formula.TargetPart.Calculate(spreadsheetControlPrevious.Document);

                        foreach (var variable in formula.SourcePart.Variables)
                        {
                            var a1Ref = variable.Key;
                            var cell = spreadsheetControlCurrent.Document.Worksheets[a1Ref.Split('!').First().Trim('\'')].Cells[a1Ref.Split('!').Last()];
                            syncContext.Post(s => cell.Fill.BackgroundColor = sourceResult != targetResult ? Colors.SpreadsheetCellError : Colors.SpreadsheetCellOk, null);
                        }
                        foreach (var variable in formula.TargetPart.Variables)
                        {
                            var a1Ref = variable.Key;
                            var cell = spreadsheetControlPrevious.Document.Worksheets[a1Ref.Split('!').First().Trim('\'')].Cells[a1Ref.Split('!').Last()];
                            syncContext.Post(s => cell.Fill.BackgroundColor = sourceResult != targetResult ? Colors.SpreadsheetCellError : Colors.SpreadsheetCellOk, null);
                        }
                    }
                }
            });
        }
        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;
            }
        }
        public RegionFormulaPeekControl(Repository repo, form summaryForm, int year)
        {
            InitializeComponent();
            IsAvailable = false;

            if (Authentication.Credentials.IsRegion)
            {
                Initialize(repo, summaryForm, year);
            }

            this.buttonCancel.Click += CompleteHandler;
            this.buttonOk.Click += CompleteHandler;
        }
        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;
            }
        }
 private void gridViewForms_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     var form = ((GridView)sender).GetRow(e.FocusedRowHandle) as form;
     UncheckAllEdukindList();
     layoutControlGroupFormBlocking.Enabled = true;
     if (form != null)
     {
         _selectedForm = form;
         CheckEdukindList(form.edu_kind);
         SelectFormType(form.form_type);
         var edus = new List<edu>();
         form.edu_kind.ForEach(t => edus = edus.Union(t.edus).ToList());
         eduBindingSource.DataSource = edus;
         gridControlBlockedEdus.RefreshDataSource();
         SelectBlockedEdus(form.blocked_edus);
         SelectBlockedMunicipalities(form.blocked_municipalities);
         this.dateEditExpire.DateTime = form.submission_date.LocalDateTime;
     }
     else
     {
         layoutControlGroupFormBlocking.Enabled = false;
     }
 }
        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 LoadTemplateAsync(form form)
 {
     this.Enabled = false;
     try
     {
         if (form.template_file != null)
         {
             var fileData = form.template_file.contents;
             using (var ms = new MemoryStream(fileData, 0, fileData.Length))
             {
                 this.spreadsheetControl.LoadDocument(ms, DocumentFormat.OpenXml);
             }
         }
         else
         {
             this.ShowFlyoutMessageBox("Информация",
                 String.Format("У формы {0} отсутствует шаблон. Обратитесь к администратору.", form.name),
                 FlyoutCommand.OK);
         }
     }
     catch (Exception ex)
     {
         this.ShowFlyoutMessageBox("Информация", "Ошибка во время загрузки шаблона.\n" + ex.Message, FlyoutCommand.OK);
     }
     this.Enabled = true;
 }
 private IForm GetChangedFormData(form form, Status status)
 {
     var bytes = this.spreadsheetControl.Document.SaveDocument(DocumentFormat.OpenXml);
     var formData = this.FormData;
     formData.send_date = _selectedDate;
     formData.form = form;
     formData.status = (int)status;
     formData.file.contents = bytes;
     return formData;
 }
 protected QuerySummaryModel(form form, int year)
 {
     Form = form;
     Year = year;
     QueryList = new List<query>();
 }
 private void UpdateTemplate(form form)
 {
     if (!this.spreadsheetTemplate.Modified) 
         return;
     if (form == null) 
         return;
     form.template_file.contents = this.GetDocumentBytes();
     if (!_editedForms.Contains(form))
     {
         _editedForms.Add(form);
         this.RefreshTemplateList();
     }
 }
        private void InitializeEventHandlers()
        {
            this.formBindingSource.DataSourceChanged += (sender, args) =>
            {
                var forms = (ICollection<form>)formBindingSource.DataSource;
                this.comboBoxForm.DataSource = forms;
                this.comboBoxForm.DisplayMember = "name";
                if (forms.Any()) 
                    _selectedForm = forms.FirstOrDefault();
            };

            this.checkBoxOnlyPassport.CheckStateChanged += (s, e) =>
            {
                this.comboBoxForm.Enabled = !this.checkBoxOnlyPassport.Checked;
                this.comboBoxYear.Enabled = !this.checkBoxOnlyPassport.Checked;
            };
            ((RepositoryItemPopupContainerEdit) this.barEditQuerySummaryModel.Edit).QueryResultValue += (sender, args) =>
            {
                _isOnlyPassport = this.checkBoxOnlyPassport.Checked;
                _selectedForm = _isOnlyPassport
                    ? new form { form_id = 0, name = "Паспорт" }
                    : (form)this.comboBoxForm.SelectedItem;
                _selectedYear = _isOnlyPassport
                    ? DateTime.Now.Year
                    : (int)this.comboBoxYear.SelectedItem;
                OnIndexChangedSetDataSourceFor();

                View.ActiveContentContainer.Subtitle = _querySummaryModelCollection.Current.ToString();
            };

            buttonClosePopup.Click += (sender, args) => popupContainerQueryModel.OwnerEdit.ClosePopup();
            
            this.gridViewEdu.SelectionChanged += (sender, args) =>
            {
                if (!_isManualChecking) return;
                try
                {
                    if (args.ControllerRow == -1) 
                        return;
                    if (args.ControllerRow == GridControl.InvalidRowHandle)
                    {
                        _querySummaryModelCollection.Current.EduList.Clear();
                        if (this.gridViewEdu.SelectedRowsCount != 0)
                        {
                            var selectedRows = this.gridViewEdu.GetSelectedRows();
                            var selectedEdus = selectedRows
                                .Where(t => t != -1)
                                .Select(t => (edu) this.gridViewEdu.GetRow(t));
                            _querySummaryModelCollection.Current.EduList.AddRange(selectedEdus);
                        }
                    }
                    else
                    {
                        var edu = (edu) this.gridViewEdu.GetRow(args.ControllerRow);
                        if (edu == null) return;
                        switch (args.Action)
                        {
                            case CollectionChangeAction.Add:
                                _querySummaryModelCollection.Current.EduList.Add(edu);
                                break;
                            case CollectionChangeAction.Remove:
                                _querySummaryModelCollection.Current.EduList.Remove(edu);
                                break;

                        }
                    }
                    ResetGridViews();
                }
                catch
                {
                    // ignored
                }
            };

            this.queryControl.SelectionChanged += (sender, args) =>
            {
                if (!_isManualChecking) return;
                try
                {
                    var query = this.queryControl.Queries[args.ControllerRow];
                    switch (args.Action)
                    {
                        case CollectionChangeAction.Add:
                            _querySummaryModelCollection.Current.QueryList.Add(query);
                            break;
                        case CollectionChangeAction.Remove:
                            _querySummaryModelCollection.Current.QueryList.Remove(query);
                            break;
                    }
                    ResetGridViews();
                }
                catch { }
            };
        }
        private async void gridLookUpEdit1_EditValueChanged(object sender, EventArgs e)
        {
            var combo = (GridLookUpEdit)sender;
            var form = (form)combo.GetSelectedDataRow();
            if (form == null)
            {
                return;
            }
            var fileData = form.template_file.contents;
            using (var ms = new MemoryStream(fileData))
            {
                var format = DocumentFormat.OpenXml;
                this.spreadsheetControlQueries.LoadDocument(ms, format);
            }
            _selectedForm = form;

            this.Enabled = false;
            var queries = await Repo.GetQueries(form.form_id);
            queryBindingSource.DataSource = queries;
            this.Enabled = true;
        }
        private void InitializeEventHandlers()
        {
            this.formBindingSource.DataSourceChanged += (sender, args) =>
            {
                var forms = (ICollection<form>)formBindingSource.DataSource;
                this.comboBoxForm.DataSource = forms;
                this.comboBoxForm.DisplayMember = "name";
                if (forms.Any()) 
                    _selectedForm = forms.FirstOrDefault();
            };

            this.checkEditOnlyPassport.CheckStateChanged += (s, e) =>
            {
                this.comboBoxForm.Enabled = !this.checkEditOnlyPassport.Checked;
                this.comboBoxYear.Enabled = !this.checkEditOnlyPassport.Checked;
            };
            ((RepositoryItemPopupContainerEdit)this.barEditQuerySummaryModel.Edit).QueryResultValue += (sender, args) =>
            {
                _isOnlyPassport = this.checkEditOnlyPassport.Checked;
                _selectedForm = _isOnlyPassport
                    ? new form { form_id = 0, name = "Паспорт" }
                    : (form)this.comboBoxForm.SelectedItem;
                _selectedYear = _isOnlyPassport
                    ? 0
                    : (int)this.comboBoxYear.SelectedItem;
                OnIndexChangedSetDataSourceFor();
                View.ActiveContentContainer.Subtitle = _querySummaryModelCollection.Current.ToString();
            };

            this.buttonClosePopup.Click += (sender, args) => this.popupContainerQueryModel.OwnerEdit.ClosePopup();

            this.gridViewRegion.SelectionChanged += (sender, args) =>
            {
                if (!_isManualChecking) return;
                try
                {
                    if (args.ControllerRow < 0) 
                        return;
                    var region = (region) this.gridViewRegion.GetRow(args.ControllerRow);
                    if (region == null) 
                        return;
                    switch (args.Action)
                    {
                        case CollectionChangeAction.Add:
                            _querySummaryModelCollection.Current.RegionList.Add(region);
                            break;
                        case CollectionChangeAction.Remove:
                            _querySummaryModelCollection.Current.RegionList.Remove(region);
                            break;

                    }
                    ResetGridViews();
                }
                catch
                {
                    // ignored
                }
            };

            this.queryControl.SelectionChanged += (sender, args) =>
            {
                if (!_isManualChecking) return;
                try
                {
                    var query = this.queryControl.Queries[args.ControllerRow];
                    switch (args.Action)
                    {
                        case CollectionChangeAction.Add:
                            _querySummaryModelCollection.Current.QueryList.Add(query);
                            break;
                        case CollectionChangeAction.Remove:
                            _querySummaryModelCollection.Current.QueryList.Remove(query);
                            break;
                    }
                    ResetGridViews();
                }
                catch
                {
                    // ignored
                }
            };
        }
 private async Task<object> LoadTemplate(form form, ISpreadsheetControl spreadsheetControl)
 {
     if (form.template_file_id == null)
     {
         this.ShowFlyoutMessageBox("Информация", string.Format("У формы {0} отсутствует шаблон", form), FlyoutCommand.OK);
         spreadsheetControl.CreateNewDocument();
         return null;
     }
     var template = await Repo.GetFile(form.template_file_id.Value);
     var excelData = template != null ? template.contents : null;
     if (excelData == null)
     {
         this.ShowFlyoutMessageBox("Информация", "Не удалось загрузить шаблон", FlyoutCommand.OK);
         spreadsheetControl.CreateNewDocument();
         return null;
     }
     using (var ms = new MemoryStream(excelData))
     {
         var format = DocumentFormat.OpenXml;
         spreadsheetControl.LoadDocument(ms, format);
         spreadsheetControl.Document.History.IsEnabled = true;
         spreadsheetControl.Document.Worksheets.ActiveWorksheet = spreadsheetControl.Document.Worksheets.FirstOrDefault();
     }
     return null;
 }
 public QueryEduSummaryModel(form form, int year)
     : base (form, year)
 {
     EduList = new List<edu>();
 }
 public QueryRegionSummaryModel(form form, int year)
     : base (form, year)
 {
     RegionList = new List<region>();
 }
 private void UpdateFormula(form form)
 {
     if (!this.formulaEditControl1.TextModified) 
         return;
     if (form == null) 
         return;
     var encoding = Encoding.UTF8;
     var checkData = encoding.GetBytes(this.formulaEditControl1.Text);
     form.check_file_md5 = FileUtility.GetCRC32AsHexString(checkData);
     if (form.check_file == null)
     {
         form.check_file = Repo.Create<file>();
         Repo.Add(form.check_file);
     }
     form.check_file.contents = checkData;
     if (!_editedForms.Contains(form))
     {
         _editedForms.Add(form);
         this.RefreshTemplateList();
     }
 }
 private void CreateFormMenuStrip(ICollection<form> formList)
 {
     var group = formList.GroupBy(x => x.form_type).OrderBy(t => t.Key.form_type_id);
     foreach (var groupItem in group)
     {
         if (groupItem.Key == null)
             continue;
         var subItem = new BarSubItem(barManager, groupItem.Key.name)
         {
             Tag = groupItem.Key
         };
         this.popupMenuForm.AddItem(subItem);
         var sortedForms = groupItem.OrderBy(t =>
         {
             var span = t.TimeRemainingAsync().Result;
             return span == TimeSpan.Zero ? TimeSpan.MaxValue : span;
         }).ToList();
         foreach (var item in sortedForms)
         {
             var linkItem = new BarButtonItem(barManager, item.name)
             {
                 Tag = item
             };
             linkItem.ItemClick += async (s, e) =>
             {
                 try
                 {
                     _selectedForm = (form)e.Item.Tag;
                     this.dropDownForm.Text = _selectedForm.name;
                     if (Authentication.Credentials.IsMunicipality && 
                         (_selectedForm.form_type_id == (int) FormType.Edu || _selectedForm.form_type_id == (int) FormType.OtherEdu))
                         //муниципалитетам зачем-то понадобилось смотреть формы организаций без возможности загрузки...
                     {
                         SetEditEnabled(false);
                     }
                     else
                     {
                         var formIsBlocked  = await _selectedForm.IsBlockedAsync();
                         SetEditEnabled(!formIsBlocked);
                     }
                     var checkButton = windowsUIButtonPanelActions.Buttons.SingleOrDefault(t => ((WindowsUIButton)t).Tag.ToString() == "Check");
                     if (checkButton != null)
                         checkButton.Properties.Visible = _selectedForm.is_check_required;
                     spreadsheetControl.Tag = _selectedForm.is_check_required ? "Unchecked" : "Checked";
                     if (this.Mode == ControlMode.New && this.Source == FormSource.Template)
                         LoadTemplateAsync(_selectedForm);
                     this.View.ActiveContentContainer.Caption = _selectedForm.ToString();
                 }
                 catch (Exception ex)
                 {
                     this.ShowFlyoutMessageBox("Ошибка", ex.Message, FlyoutCommand.OK);
                 }
             };
             subItem.LinksPersistInfo.Add(new LinkPersistInfo(linkItem));
         }
     }
     if (_selectedForm == null)
         _selectedForm = formList.FirstOrDefault();
     if (_selectedForm != null)
         this.View.ActiveContentContainer.Caption = _selectedForm.name;
 }
 private void listBoxTemplatedForm_SelectedIndexChanged(object sender, EventArgs e)
 {
     var form = this.listBoxTemplatedForm.SelectedItem as form;
     if (form == null || (_lastSelectedForm != null && form == _lastSelectedForm))
     {
         return;
     }
     _lastSelectedForm = form;
     if (form.template_file == null)
     {
         return;
     }
     var excelData = form.template_file.contents;
     if (excelData == null)
     {
         return;
     }
     this.formulaEditControl1.Text = string.Empty;
     using (var ms = new MemoryStream(excelData))
     {
         var format = DocumentFormat.OpenXml;
         spreadsheetTemplate.LoadDocument(ms, format);
         spreadsheetTemplate.Document.History.IsEnabled = true;
     }
     this.layoutControl1.Enabled = false;
     if (form.check_file_id.HasValue)
     {
         var checkData = form.check_file.contents;
         if (checkData != null)
         {
             var crc = FileUtility.GetCRC32AsHexString(checkData);
             var encoding = Encoding.UTF8;
             var textContent = crc.Equals(form.check_file_md5) ? encoding.GetString(checkData) : null;
             if (textContent != null)
             {
                 this.formulaEditControl1.Text = textContent;
             }
             else
             {
                 this.formulaEditControl1.Text = string.Empty;
                 this.ShowFlyoutMessageBox("Ошибка загрузки формул", "Ошибка целостности данных", FlyoutCommand.OK);
             }
         }
     }
     try
     {
         this.layoutControl1.Enabled = true;
     }
     catch (NullReferenceException)
     {
         //похоже на баг в компонентах Devexpress
     }
 }
 private void ExecuteUpload(Document doc, form form, int year, Status status)
 {
     switch (doc.ControlName)
     {
         case "UploadSheetFromFile":
         case "UploadSheetFromTemplate":
             this.UploadNewFormData(form, year, status);
             break;
         case "FormData":
         case "FormData1":
         case "FormData2":
             this.UploadEduFormDataChanges(form, year, status);
             break;
         case "FormData3":
         case "FormData4":
             this.UploadMunitFormDataChanges(form, year, status);
             break;
         default:
             this.ShowFlyoutMessageBox("Информация", "Нечего отправлять.", FlyoutCommand.OK);
             break;
     }
 }
        private async void UploadNewFormData(form form, int year, Status status)
        {
            try
            {
                IForm formData = null;
                IForm possibleFormData = null;
                byte[] bytes;
                document_format documentFormat;
                var cred = Authentication.Credentials;
                using (new MarqueeProgressDialog(this.ParentForm, description: "Обработка"))
                {
                    if (cred.IsEdu)
                        possibleFormData = await Repo.FindEduFormData(form.form_id, cred.EduId, year);
                    else if (cred.IsMunicipality)
                        possibleFormData = await Repo.FindMunicipalityFormData(form.form_id, cred.MunitId, year);
                    else if (cred.IsRegion)
                        possibleFormData = await Repo.FindRegionFormData(form.form_id, cred.RegionId, year);

                    bytes = await Task.Run(() => this.spreadsheetControl.Document.SaveDocument(DocumentFormat.OpenXml));
                    documentFormat = await Repo.GetDocumentFormat_("xlsx");
                    
                }
                if (possibleFormData != null)
                {
                    Func<string> format = () =>
                    {
                        if (cred.IsEdu)
                            return string.Format("для организации {0}", cred.Name);
                        if (cred.IsMunicipality)
                            return string.Format("для муниципалитета {0}", cred.Name);
                        if (cred.IsRegion)
                            return string.Format("для организации {0}", cred.Name);
                        return string.Empty;
                    };
                    var message = string.Format("Форма {0} {1} уже загружена и датируется {2}. Форма будет заменена.\nПродолжить?",
                        possibleFormData.form.name, format.Invoke(), possibleFormData.send_date.ToString("d MMMM yyyy"));
                    var answer = this.ShowFlyoutMessageBox("Информация", message, FlyoutCommand.OK, FlyoutCommand.Cancel);
                    switch (answer)
                    {
                        case DialogResult.OK:
                            possibleFormData.document_format = documentFormat;
                            possibleFormData.send_date = _selectedDate;
                            possibleFormData.status = (int)status;
                            possibleFormData.file.contents = bytes;
                            formData = possibleFormData;
                            break;
                        default:
                            this.ShowFlyoutMessageBox("Информация", "Форма не загружена.", FlyoutCommand.OK);
                            return;
                    }
                }
                else
                {
                    if (cred.IsEdu)
                        formData = Repo.Create<edu_form_data>();
                    else if (cred.IsMunicipality)
                        formData = Repo.Create<municipality_form_data>();
                    else if (cred.IsRegion)
                        formData = Repo.Create<region_form_data>();

                    formData.document_format = documentFormat;
                    formData.file = new file
                    {
                        contents = bytes, 
                        code_page = Encoding.UTF8.CodePage
                    };
                    formData.form = form;
                    formData.send_date = _selectedDate;
                    formData.status = (int)status;
                }

                using (new MarqueeProgressDialog(this.ParentForm, description: "Отправка формы"))
                {
                    if (cred.IsEdu)
                    {
                        var data = (edu_form_data)formData;
                        data.edu = await Repo.GetEdu(cred.EduId);
                        if (data.id == 0)
                        {
                            formData = Repo.Add(data);
                        }
                    }
                    else if (Authentication.Credentials.IsMunicipality)
                    {
                        var data = (municipality_form_data)formData;
                        data.municipality = await Repo.GetMunicipality(cred.MunitId);
                        if (data.id == 0)
                        {
                            formData = Repo.Add(data);
                        }
                    }
                    else if (Authentication.Credentials.IsRegion)
                    {
                        var data = (region_form_data)formData;
                        data.region = await Repo.GetRegion(cred.RegionId);
                        if (data.id == 0)
                        {
                            formData = Repo.Add(data);
                        }
                    }
                    await Repo.SaveChangesAsync();
                }
                
                this.ShowFlyoutMessageBox("Информация",
                             String.Format("Загружена форма {0} за {1}.", formData.form.name, formData.send_date.ToString("d MMMM yyyy")),
                             FlyoutCommand.OK);
                IsSaved = true;
                var warn = Notifications.List.SingleOrDefault(t => ((Notifications.ExpireWarn) t).FormId == formData.form_id);
                if (warn != null)
                    Notifications.Remove(warn);
            }
            catch (Exception ex)
            {
                this.ShowFlyoutMessageBox("Ошибка", "Форма не загружена.\n" + ex.Message, FlyoutCommand.OK);
            }
        }
 private async void UploadMunitFormDataChanges(form form, int year, Status status)
 {
     var formData = (municipality_form_data) this.GetChangedFormData(form, status);
     try
     {
         if (_originalForm != formData.form)
         {
             municipality_form_data possibleFormData;
             using (new MarqueeProgressDialog(this.ParentForm, description: "Загрузка"))
             {
                 possibleFormData = await Repo.FindMunicipalityFormData(formData.form_id, formData.municipality_id, year);
             }
             if (possibleFormData != null)
             {
                 this.ShowFlyoutMessageBox("Информация",
                     String.Format("Форма {0} уже загружена {1}", possibleFormData.form.name,
                         possibleFormData.send_date.ToString("dd MMMM")), FlyoutCommand.OK);
                 return;
             }
         }
         using (new MarqueeProgressDialog(this.ParentForm, description: "Сохранение изменений"))
         {
             await Repo.SaveChangesAsync();
         }
     }
     catch (Exception ex)
     {
         this.ShowFlyoutMessageBox("Ошибка", "Форма не загружена.\n" + ex.Message, FlyoutCommand.OK);
     }
 }
 public QueryMunicipalitySummaryModel(form form, int year)
     : base (form, year)
 {
     MunicipalityList = new List<municipality>();
 }
        protected override void New(Document doc)
        {
            UncheckAllEdukindList();
            this.dateEditExpire.DateTime = DateTime.Now;
            var form = new form
            {
                form_type = (form_type) this.lookUpFormType.EditValue,
                name = "Новая форма",
                submission_date = this.dateEditExpire.DateTime,
                check_file_md5 = "0"
            };

            this.formBindingSource.Add(form);
            _selectedForm = form;
            var idx = this.formBindingSource.List.IndexOf(form);
            var rowHandle = this.gridViewForms.GetRowHandle(idx);
            if (!_editedList.Contains(form))
                _editedList.Add(form);
            this.gridViewForms.FocusedRowHandle = rowHandle;
            ExpandGroupRow(form.form_type.name);
        }