void InitPage(CrudAPI crudapi, UnicontaBaseEntity master)
        {
            RemoveMenuItem();
            dAddress.Header          = Uniconta.ClientTools.Localization.lookup("DeliveryAddr");
            layoutControl            = layoutItems;
            Employeelookupeditor.api = leAccount.api = lePayment.api = cmbDim1.api = cmbDim2.api = cmbDim3.api = cmbDim4.api = cmbDim5.api = leLayoutGroup.api = leInvoiceAccount.api = PriceListlookupeditior.api =
                leGroup.api          = leShipment.api = leDeliveryTerm.api = Projectlookupeditor.api = PrCategorylookupeditor.api = leDeliveryAddress.api = leVat.api = prTasklookupeditor.api = lePrWorkSpace.api = crudapi;

#if SILVERLIGHT
            leRelatedOrder.api = crudapi;
#else
            leRelatedOrder.CrudApi = crudapi;
#endif
            cbDeliveryCountry.ItemsSource = Enum.GetValues(typeof(Uniconta.Common.CountryCode));
            AdjustLayout();
            if (editrow == null)
            {
                frmRibbon.DisableButtons("Delete");
                liCreatedTime.Visibility = Visibility.Collapsed;
                editrow          = CreateNew() as DebtorOfferClient;
                editrow._Created = DateTime.MinValue;
                if (Debtor != null)
                {
                    editrow.SetMaster(Debtor);
                    if (editrow.RowId == 0)
                    {
                        SetValuesFromMaster(Debtor);
                    }
                    leAccount.IsEnabled = txtName.IsEnabled = false;
                }
                if (Contact != null)
                {
                    editrow.SetMaster(Contact);
                    editrow.ContactName      = Contact.Name;
                    cmbContactName.IsEnabled = false;
                }
                editrow.SetMaster(master); // cound be prospect or project
            }
            else
            {
                BindContact(editrow.Debtor);
            }

            if (Prospect != null)
            {
                BindContact(Prospect);
            }
            if (Contact != null)
            {
                BindContact(Contact.Prospect);
            }

            layoutItems.DataContext  = editrow;
            frmRibbon.OnItemClicked += frmRibbon_OnItemClicked;

            AcItem.ButtonClicked += AcItem_ButtonClicked;

#if !SILVERLIGHT
            editrow.PropertyChanged += Editrow_PropertyChanged;
#endif
            this.master = master;
            if (Prospect != null || Contact != null)
            {
                leAccount.IsEnabled = false;
                AcItem.IsEnabled    = false;
                txtName.IsEnabled   = false;
                txtName.Text        = editrow.Name;
            }

            if (master == null)
            {
                if (crudapi.CompanyEntity.CRM)
                {
                    LoadType(new Type[] { typeof(Uniconta.DataModel.Debtor), typeof(Uniconta.DataModel.CrmProspect) });
                }
                else
                {
                    LoadType(typeof(Uniconta.DataModel.Debtor));
                }
            }
            StartLoadCache();
        }
 public override void RowsPastedDone()
 {
     editrow.SetMaster(master);
     SetValuesFromMaster(Debtor);
 }
        void InitPage(CrudAPI crudapi, UnicontaBaseEntity master)
        {
            RemoveMenuItem();
            BusyIndicator                 = busyIndicator;
            dAddress.Header               = Uniconta.ClientTools.Localization.lookup("DeliveryAddr");
            layoutControl                 = layoutItems;
            Employeelookupeditor.api      = leAccount.api = lePayment.api = cmbDim1.api = cmbDim2.api = cmbDim3.api = cmbDim4.api = cmbDim5.api = leLayoutGroup.api = leInvoiceAccount.api = PriceListlookupeditior.api =
                leGroup.api               = leShipment.api = leDeliveryTerm.api = Projectlookupeditor.api = PrCategorylookupeditor.api = leDeliveryAddress.api = crudapi;
            cbDeliveryCountry.ItemsSource = Enum.GetValues(typeof(Uniconta.Common.CountryCode));
            AdjustLayout();
            if (editrow == null)
            {
                frmRibbon.DisableButtons("Delete");
                editrow = CreateNew() as DebtorOfferClient;
                liCreatedTime.Visibility = Visibility.Collapsed;
                if (master != null)
                {
                    editrow.SetMaster(master);
                    if (editrow.RowId == 0)
                    {
                        SetValuesFromMaster(master as Debtor);
                    }
                    leAccount.IsEnabled = txtName.IsEnabled = false;
                }
            }
            else
            {
                BindContact(editrow.Debtor);
            }

            layoutItems.DataContext  = editrow;
            frmRibbon.OnItemClicked += frmRibbon_OnItemClicked;

            AcItem.ButtonClicked += AcItem_ButtonClicked;

#if !SILVERLIGHT
            txtDelZipCode.EditValueChanged += TxtDelZipCode_EditValueChanged;
#endif

            this.master = master;
            if (master is CrmProspectClient)
            {
                leAccount.IsEnabled = false;
                AcItem.IsEnabled    = false;
                txtName.IsEnabled   = false;
                txtName.Text        = editrow.Name;
            }

            if (master == null)
            {
                if (crudapi.CompanyEntity.CRM)
                {
                    LoadType(new Type[] { typeof(Uniconta.DataModel.Debtor), typeof(Uniconta.DataModel.CrmProspect) });
                }
                else
                {
                    LoadType(typeof(Uniconta.DataModel.Debtor));
                }
            }
            StartLoadCache();
        }