Exemplo n.º 1
0
        private void InitializeEntries()
        {
            txtNumber.Text = document.NumberString;

            List <KeyValuePair <long, string> > paymentPairs = PaymentType.GetAll().Select(p => new KeyValuePair <long, string> (p.Id, p.Name)).ToList();

            if (IsEditable)
            {
                cboPaymentType.Load(paymentPairs, "Key", "Value", BusinessDomain.AppConfiguration.LastDocumentPaymentMethodId);
                Operation operation = operations.Last();
                cbeRecipient.Load(DocumentBase.GetRecipientSuggestions(operation.PartnerId), null, null);
                cbeEGN.Load(DocumentBase.GetEGNSuggestions(operation.PartnerId), null, null);
                cbeProvider.Load(DocumentBase.GetProviderSuggestions(), null, null);
                cbeReason.Load(DocumentBase.GetReasonSuggestions(), null, null);
                cbeDescription.Load(DocumentBase.GetDescriptionSuggestions(), null, null);
                cbeLocation.Load(DocumentBase.GetLocationSuggestions(), null, null);

                txtDate.Text    = BusinessDomain.GetFormattedDate(BusinessDomain.Today);
                txtTaxDate.Text = BusinessDomain.GetFormattedDate(operation.Date);
                Partner partner = Partner.GetById(partnerId);
                if (partner != null)
                {
                    lblPartnerValue.SetText(partner.Name);
                }
                txtNumber.GrabFocus();
            }
            else
            {
                txtRefNumber.Text = document.ReferenceNumberString;
                txtRefDate.Text   = document.ReferenceDateString;
                cboPaymentType.Load(paymentPairs, "Key", "Value", document.PaymentMethod);
                cbeRecipient.Entry.Text   = document.Recipient;
                cbeEGN.Entry.Text         = document.RecipientEGN;
                cbeProvider.Entry.Text    = document.Provider;
                cbeReason.Entry.Text      = document.Reason;
                cbeDescription.Entry.Text = document.Description;
                lblPartnerValue.SetText(document.RecipientName);
                cbeLocation.Entry.Text = document.Location;

                txtDate.Text            = document.DateString;
                txtTaxDate.Text         = document.TaxDateString;
                hboPartner.Sensitive    = false;
                fraMain.Sensitive       = false;
                fraAdditional.Sensitive = false;
            }
        }
Exemplo n.º 2
0
        private void InitializeEntries()
        {
            LazyListModel <MesUnit> units = MesUnit.GetAll();

            if (item == null)
            {
                item = new Item();

                if (defaultGroupId.HasValue)
                {
                    gEditPanel.SelectGroupId((int)defaultGroupId);
                }

                if (BusinessDomain.AppConfiguration.AutoGenerateItemCodes)
                {
                    item.AutoGenerateCode();
                }
            }
            else
            {
                gEditPanel.SelectGroupId(item.GroupId);
            }

            txtCode.Text               = item.Code;
            txtName.Text               = item.Name;
            txtDisplayName.Text        = item.Name2;
            txtCatalogNumber1.Text     = item.Catalog;
            txtCatalogNumber2.Text     = item.Catalog2;
            txtCatalogNumber3.Text     = item.Catalog3;
            txvDescription.Buffer.Text = item.Description;

            txtBarCode1.Text = item.BarCode;
            txtBarCode2.Text = item.BarCode2;

            barcodes.Clear();
            if (!string.IsNullOrWhiteSpace(item.BarCode3))
            {
                foreach (string barcode in item.BarCode3.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    barcodes.Add(barcode);
                }
            }

            if (barcodes.Count == 0)
            {
                barcodes.Add(string.Empty);
            }

            List <KeyValuePair <object, string> > barCodeTypes = Enum.GetValues(typeof(GeneratedBarcodeType))
                                                                 .Cast <object> ()
                                                                 .Select(value => new KeyValuePair <object, string> (value, value.ToString()))
                                                                 .OrderBy(p => p.Value).ToList();

            cboBarcodeType.Load(barCodeTypes, "Key", "Value", BusinessDomain.AppConfiguration.CustomGeneratedBarcodeType);
            txtBarcodeFormat.Text = BusinessDomain.AppConfiguration.CustomGeneratedBarcodeFormat;

            List <MesUnit> validUnits = units.Where(u => !string.IsNullOrWhiteSpace(u.Name)).ToList();

            cbeMesUnit.Load(validUnits, "Name", "Name");
            if (!string.IsNullOrWhiteSpace(item.MUnit))
            {
                cbeMesUnit.Entry.Text = item.MUnit;
            }
            txtMesRatio.Text = Number.ToEditString(item.MUnitRatio);
            cbeMesUnit2.Load(validUnits, "Name", "Name");
            if (!string.IsNullOrWhiteSpace(item.MUnit))
            {
                cbeMesUnit2.Entry.Text = item.MUnit2;
            }
            txtMinimalQty.Text = Quantity.ToEditString(item.MinimalQuantity);
            txtNominalQty.Text = Quantity.ToEditString(item.NominalQuantity);

            LazyListModel <VATGroup>            allGroups = VATGroup.GetAll();
            List <KeyValuePair <long, string> > vatList   = new List <KeyValuePair <long, string> > (allGroups
                                                                                                     .Select(vatGroup => new KeyValuePair <long, string> (vatGroup.Id,
                                                                                                                                                          string.Format("{0} ({1})", vatGroup.Name, Percent.ToString(vatGroup.VatValue)))));

            cboVATGroup.Load(vatList, "Key", "Value", item.VatGroupId);

            SetPrices(item);
        }