private Control CreateDateControl(DokuField dokuField) { // Create a new DateTimePicker control and initialize it. var dateCtrl = new DateTimePicker(); dateCtrl.Format = DateTimePickerFormat.Short; dateCtrl.MinDate = new DateTime(1970, 1, 1); dateCtrl.Tag = dokuField; if (dokuField.mandatory == 1) { dateCtrl.BackColor = Color.LightYellow; } if (dokuField.value != null && !string.IsNullOrWhiteSpace(dokuField.value.ToString())) { var longDate = long.Parse(dokuField.value.ToString()); dateCtrl.Value = DateTimeHelper.FromUnixEpoch(longDate); } else { dateCtrl.Value = DateTime.Now; } return(dateCtrl); }
private Control CreateTimeControl(DokuField dokuField) { // Create a new DateTimePicker control and initialize it. var timeCtrl = new DateTimePicker(); timeCtrl.Tag = dokuField; // Set the MinDate and MaxDate. timeCtrl.MinDate = new DateTime(1970, 1, 1); // Set the CustomFormat string timeCtrl.Format = DateTimePickerFormat.Time; // Show the CheckBox and display the control as an up-down control. timeCtrl.ShowUpDown = true; if (dokuField.mandatory == 1) { timeCtrl.BackColor = Color.LightYellow; } if (dokuField.value != null && !string.IsNullOrWhiteSpace(dokuField.value.ToString())) { var unixDate = long.Parse(dokuField.value.ToString()); timeCtrl.Value = unixDate.FromUnixEpoch(); //timeCtrl.Value = DateTime.Parse(dokuField.value.ToString(), new CultureInfo("es-ES")); } else { timeCtrl.Value = DateTime.Now; } return(timeCtrl); }
private Control CreateRichTextControl(DokuField dokuField) { var richTextCtrl = new RichTextBox(); richTextCtrl.Height = 60; richTextCtrl.Tag = dokuField; richTextCtrl.Text = dokuField.value == null ? String.Empty : dokuField.value.ToString(); if (dokuField.mandatory == 1) { richTextCtrl.BackColor = Color.LightYellow; } return(richTextCtrl); }
private Control CreateListControl(DokuField dokuField) { var listCtrl = new ListBox(); listCtrl.MultiColumn = false; listCtrl.SelectionMode = SelectionMode.One; listCtrl.SelectedItem = dokuField.value; listCtrl.Tag = dokuField; if (dokuField.mandatory == 1) { listCtrl.BackColor = Color.LightYellow; } return(listCtrl); }
public static DokuField CreateNew(DokuField dkField) { var dkf = new DokuField() { id = dkField.id, text = dkField.text, type = dkField.type, dokuField = dkField.dokuField, order = dkField.order, mandatory = dkField.mandatory, description = dkField.description, options = dkField.options, value = dkField.value, key = dkField.key }; return(dkf); }
private Control CreateTextControl(DokuField dokuField) { var textCtrl = new TextBox(); textCtrl.AcceptsReturn = true; textCtrl.AcceptsTab = true; textCtrl.Dock = DockStyle.Fill; textCtrl.Multiline = false; textCtrl.ScrollBars = ScrollBars.None; textCtrl.Tag = dokuField; textCtrl.Text = dokuField.value == null ? String.Empty : dokuField.value.ToString(); if (dokuField.mandatory == 1) { textCtrl.BackColor = Color.LightYellow; } return(textCtrl); }
public Control CreateCurrencyControl(DokuField dokuField) { //Create and initialize a NumericUpDown control. var currencyCtrl = new NumericUpDown(); currencyCtrl.Dock = DockStyle.Fill; currencyCtrl.DecimalPlaces = 5; currencyCtrl.Maximum = int.MaxValue; currencyCtrl.Minimum = 0; currencyCtrl.Value = string.IsNullOrWhiteSpace(dokuField.value as string) ? 0 : decimal.Parse(dokuField.value.ToString()); currencyCtrl.Tag = dokuField; if (dokuField.mandatory == 1) { currencyCtrl.BackColor = Color.LightYellow; } return(currencyCtrl); }
private Control CreateMemoControl(DokuField dokuField) { var memoCtrl = new TextBox(); memoCtrl.AcceptsReturn = true; memoCtrl.AcceptsTab = true; memoCtrl.Dock = DockStyle.Fill; memoCtrl.Multiline = true; memoCtrl.ScrollBars = ScrollBars.Vertical; memoCtrl.Tag = dokuField; memoCtrl.Height = 60; memoCtrl.Text = dokuField.value == null ? String.Empty : dokuField.value.ToString(); if (dokuField.mandatory == 1) { memoCtrl.BackColor = Color.LightYellow; } return(memoCtrl); }
public static List <DokuField> GetDokuFieldList(this ImportFolderModel folderConfig, string fileName) { var list = new List <DokuField>(); var fieldValues = fileName.Split(folderConfig.FieldDelimiter); for (int i = 0; i < fieldValues.Length; i++) { var dokuField = CreateDokuFieldFromFieldIndex(i); if (dokuField != null) { dokuField.value = fieldValues[i]; list.Add(dokuField); } } DokuField CreateDokuFieldFromFieldIndex(int fieldIndex) { var metadata = folderConfig.MetadataCollection.FirstOrDefault(f => f.FieldNameIndex.Equals(fieldIndex)); if (metadata == null) { return(null); } var newDkField = new DokuField { id = metadata.DokufieldId, key = metadata.DokufieldName, type = metadata.DokufieldType, }; return(newDkField); } return(list); }
private Control CreateComboControl(DokuField dokuField) { var comboCtrl = new ComboBox(); comboCtrl.Dock = DockStyle.Fill; comboCtrl.DropDownWidth = 280; comboCtrl.DropDownStyle = ComboBoxStyle.DropDownList; comboCtrl.Tag = dokuField; if (dokuField.mandatory == 1) { comboCtrl.BackColor = Color.LightYellow; } if (!String.IsNullOrWhiteSpace(dokuField.options)) { var options = dokuField.options.Split('#'); comboCtrl.Items.AddRange(options); } comboCtrl.SelectedItem = dokuField.value; return(comboCtrl); }
private async void scanToolStripMenuItem_Click(object sender, EventArgs e) { var scannedImages = new List <ScannedImage>(); try { using (var form = new NewScanForm()) { if (form.ShowDialog() == DialogResult.OK) { scannedImages.AddRange(form.ScannedImages); } else { return; } } } catch (Exception ex) { LogFactory.CreateLog().LogError(ex); MessageBox.Show(ex.Message, "Doku4Invoices", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Cursor = Cursors.WaitCursor; var ticket = String.Empty; try { ticket = await Session.GetTikectAsync(); if (_documentaryTypes.Count == 0) { _documentaryTypes.AddRange(await DokuFlexService.GetDocumentaryTypesAsync(ticket)); } } finally { this.Cursor = Cursors.Default; } if (string.IsNullOrWhiteSpace(ticket)) { return; } using (var form = new ProgressForm()) { if (!form.UploadFiles(ticket, scannedImages)) { return; } } try { foreach (var scannedImage in scannedImages) { if (!string.IsNullOrWhiteSpace(scannedImage.Routing.Documentary)) { await DokuFlexService.UpdateDocumentMetadataAsync(ticket, scannedImage.Routing.Documentary, scannedImage.Routing.FileId, new DokuField[] { }); var documentary = _documentaryTypes.FirstOrDefault(d => d.id.Equals(scannedImage.Routing.Documentary)); if (documentary != null) { foreach (var element in documentary.elements) { scannedImage.Metadata.Add(DokuField.CreateNew(element)); } } } AddToListView(scannedImage); } } catch (Exception ex) { LogFactory.CreateLog().LogError(ex); MessageBox.Show(ex.Message, "Doku4Invoices", MessageBoxButtons.OK, MessageBoxIcon.Error); } }