private void FocusedRowChanged(object sender, FocusedRowObjectChangedEventArgs e) { var declaration = viewDeclaration.GetFocusedRow() as DeclarationView; if (declaration == null) { txtTrimestre.Text = string.Empty; txtDate.Text = string.Empty; btLSupprimer.Enabled = false; btGenererFichier.Enabled = false; btSupprimerLigne.Enabled = false; btArchiver.Enabled = false; btValider.Enabled = false; return; } viewLigne.OptionsView.ShowAutoFilterRow = !declaration.IsCloture; viewLigne.OptionsView.ShowGroupPanel = !declaration.IsCloture; viewLigne.OptionsCustomization.AllowSort = !declaration.IsCloture; viewLigne.OptionsBehavior.Editable = !declaration.IsCloture; viewLigne.OptionsCustomization.AllowGroup = !declaration.IsCloture; viewLigne.OptionsView.NewItemRowPosition = declaration.IsCloture ? NewItemRowPosition.None : NewItemRowPosition.Top; _colNumeroOrdre.Visible = declaration.IsCloture; btImporter.Enabled = !declaration.IsCloture; viewLigne.ExpandAllGroups(); btValider.Enabled = true; if (declaration.IsCloture) { btLSupprimer.Enabled = false; btGenererFichier.Enabled = true; btSupprimerLigne.Enabled = false; btArchiver.Enabled = true; } else { btLSupprimer.Enabled = true; btGenererFichier.Enabled = false; btSupprimerLigne.Enabled = true; btArchiver.Enabled = false; } if (declaration.IsArchive) { btArchiver.Enabled = false; btValider.Enabled = false; } foreach (object col in viewLigne.Columns) { var column = col as GridColumn; if (column == null) { continue; } column.OptionsColumn.AllowEdit = !declaration.IsCloture; } _currentDeclaration = declaration; btValider.Text = declaration.IsCloture ? "Editer" : "Valider"; var lignes = _controller.GetAllLigne(_currentDeclaration.Id); _listLignes = new BindingList <LigneView>(lignes); gridLigne.DataSource = null; gridLigne.DataSource = _listLignes; viewLigne.ExpandAllGroups(); if (declaration.IsCloture) { txtTotalPrixAchatHorsTaxe.Text = string.Format("{0:0.000}", _listLignes.Sum(x => x.PrixAchatHorsTaxe)); txtMontantTva.Text = string.Format("{0:0.000}", _listLignes.Sum(x => x.MontantTva)); } else { txtTotalPrixAchatHorsTaxe.Text = @"0.000"; txtMontantTva.Text = @"0.000"; } txtTrimestre.Text = string.Format("{0:0}", _currentDeclaration.Trimestre); txtDate.Text = string.Format("{0:dd/MM/yyyy}", _currentDeclaration.Date); }
private void FocusedRowChanged(object sender, FocusedRowObjectChangedEventArgs e) { txtMotif.Reset(); txtReference.Reset(); var declaration = viewDeclaration.GetFocusedRow() as DeclarationView; if (declaration == null) { txtDate.Text = string.Empty; btLSupprimer.Enabled = false; btGenererFichier.Enabled = false; btSupprimerLigne.Enabled = false; btArchiver.Enabled = false; btValider.Enabled = false; return; } viewLigne.OptionsView.ShowAutoFilterRow = !declaration.Cloturer; viewLigne.OptionsView.ShowGroupPanel = !declaration.Cloturer; viewLigne.OptionsCustomization.AllowSort = !declaration.Cloturer; viewLigne.OptionsBehavior.Editable = !declaration.Cloturer; viewLigne.OptionsCustomization.AllowGroup = !declaration.Cloturer; viewLigne.OptionsView.NewItemRowPosition = declaration.Cloturer ? NewItemRowPosition.None : NewItemRowPosition.Top; txtMotif.Properties.ReadOnly = declaration.Cloturer; txtReference.Properties.ReadOnly = declaration.Cloturer; //_colNumeroOrdre.Visible = declaration.Cloturer; btImportSage.Enabled = !declaration.Cloturer; btImporter.Enabled = !declaration.Cloturer; viewLigne.ExpandAllGroups(); btValider.Enabled = true; if (declaration.Cloturer) { btLSupprimer.Enabled = false; btGenererFichier.Enabled = true; btSupprimerLigne.Enabled = false; btArchiver.Enabled = true; } else { btLSupprimer.Enabled = true; btGenererFichier.Enabled = false; btSupprimerLigne.Enabled = true; btArchiver.Enabled = false; } if (declaration.Archiver) { btArchiver.Enabled = false; btValider.Enabled = false; } foreach (object col in viewLigne.Columns) { var column = col as GridColumn; if (column == null) { continue; } column.OptionsColumn.AllowEdit = !declaration.Cloturer; } _currentDeclaration = declaration; btValider.Text = declaration.Cloturer ? "Editer" : "Valider"; var lignes = _controller.GetAllLigne(_currentDeclaration.Id); _listLignes = new BindingList <LigneView>(lignes); gridLigne.DataSource = null; gridLigne.DataSource = _listLignes; viewLigne.ExpandAllGroups(); if (declaration.Cloturer) { txtTotal.Text = string.Format("{0:0.000}", _listLignes.Sum(x => x.NetAPaye)); } else { txtTotal.Text = @"0.000"; } txtDate.Text = string.Format("{0:dd/MM/yyyy}", _currentDeclaration.DateCreation); txtMotif.EditValue = declaration.MotifOperation; txtReference.EditValue = declaration.ReferenceEnvoi; }