Exemplo n.º 1
0
        private void btnRipartoClick(object sender, EventArgs e)
        {
            if (modelloRipartizione.Value != null && modelloRipartizione.Value != DBNull.Value)
            {
                CommonMessages.DisplayWarning("Se è presente un modello non è possibile modificare il riparto del movimento.");
                return;
            }

            if (ripartizioneDettaglio.ActiveRow != null)
            {
                var ripartizione = setRipartizioneUnita(ripartizioneDettaglio.ActiveRow);

                var conto = getConto(ripartizioneDettaglio.ActiveRow.Cells["IdConto"], true);
                if (conto != null)
                {
                    var movimento = (MovimentoContabileDTO) ripartizioneDettaglio.ActiveRow.ListObject; 

                    decimal? importo = null;
                    if (ripartizioneDettaglio.ActiveRow.Cells["Importo"].Value != null)
                        importo = (decimal)ripartizioneDettaglio.ActiveRow.Cells["Importo"].Value;

                    var readOnly = false;
                    var updatableStandardForm = ParentForm as UpdatableStandardForm;
                    if (updatableStandardForm != null)
                        readOnly = !updatableStandardForm.IsEditingMode;

                    var ripartizioneSave = ObjectCopier.CloneWcf(ripartizione);
                    if(ripartizioneSave != null)
                    {
                        var form = new RipartizioneMovimentoUI(ripartizioneSave, getMovimentoContabileService().GetKey(movimento), movimento, _esercizio, importo.GetValueOrDefault(), readOnly);
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            _ripartizione[(DettaglioSpesaDTO)dettagliSpesa.SelectedTab.Tag] = form.GetRipartizione();
                            if (form.IsDirty)
                            {
                                _spesa.Stato = "U";
                                Dirty = true;
                                modelloRipartizione.Value = null;
                            }
                        }
                        form.Dispose();
                    }
                    else
                    {
                        _log.WarnFormat("ATTENZIONE: Ripartizione a NULL - {0}", Utility.GetMethodDescription());
                    }
                }
            }
        }
 public Form GetRegistrazioneMovimento(RipartizioneSpeseDTO ripartizione, string key, MovimentoContabileDTO movimentoContabileDTO, EsercizioDTO esercizioDTO, decimal importo, bool readOnly)
 {
     _form = new RipartizioneMovimentoUI(ripartizione, key, movimentoContabileDTO, esercizioDTO, importo, readOnly);
     return _form;
 }