public static void RunNotificationsAlgorithm(string ConnectionString, string Language) { HrUnitOfWork unitofwork = new HrUnitOfWork(new HrContextFactory(ConnectionString)); try { DateTime Today = DateTime.Now.Date; List <EmploymentPaper_ToNotify> EmpPapers_ToNotify = unitofwork.CompanyDocsViewsRepository.EmploymentPapersForNotifications(); string EmpIDs = (EmpPapers_ToNotify.Any()) ? EmpPapers_ToNotify.Select(a => a.EmpID.ToString()).Aggregate <string>((x1, x2) => x1 + "," + x2).ToString() : ""; List <FormDropDown> EmpsLangs = unitofwork.MeetingRepository.GetUsersLang(EmpIDs); List <NotifyLetter> NotifyLettersList = new List <NotifyLetter>(); EmpPapers_ToNotify.ForEach(e => { FormDropDown EmpLang = EmpsLangs.Where(a => a.id == e.EmpID).FirstOrDefault(); string Lang = ""; if (EmpLang != null) { Lang = EmpLang.name; } NotifyLetter NL = new NotifyLetter() { CompanyId = e.CompanyId.Value, EmpId = e.EmpID, NotifyDate = Today, NotifySource = MsgUtils.Instance.Trls(Lang, e.DocTypeName), SourceId = e.Stream_Id.ToString(), Sent = true, EventDate = e.ExpiryDate.Value, Description = MsgUtils.Instance.Trls(Lang, "you must renew") + " " + e.PaperFileName + " " + MsgUtils.Instance.Trls(Lang, "Before") + " " + e.ExpiryDate.Value.ToMyDateString(Lang, "yyyy-MM-dd") }; //unitofwork.NotifyLetterRepository.Add(NL); NotifyLettersList.Add(NL); }); string ErrorMessage; AddNotifyLetters AddNotifyLetters = new AddNotifyLetters(unitofwork, NotifyLettersList, Language); bool Result = AddNotifyLetters.Run(out ErrorMessage); //unitofwork.SaveChanges(); } catch (Exception ex) { unitofwork.HandleDbExceptions(ex); } finally { } }
private List <AbstractFormElement> MapDocumentConstructingExpressions(List <string> constructingExpressions) { if (constructingExpressions != null && constructingExpressions.Count > 0) { List <AbstractFormElement> constructingElements = new List <AbstractFormElement>(); foreach (string item in constructingExpressions) { string[] splitedExpression = item.Replace("{{options:", string.Empty).Replace("#}}", string.Empty).Split('#'); string name = splitedExpression[0]; if (splitedExpression.Length < 3) { FormCheckBox checkBox = new FormCheckBox(); checkBox.Name = name; checkBox.Expression = item; checkBox.Text = splitedExpression[1]; checkBox.IsChecked = false; constructingElements.Add(checkBox); } else if (splitedExpression.Where((x, index) => index > 0).Where(s => s.Length > 50).Count() > 0) { FormRadioButton comboBox = new FormRadioButton(); comboBox.Name = name; comboBox.Expression = item; for (int i = 1; i < splitedExpression.Length; i++) { comboBox.Options.Add(splitedExpression[i]); } comboBox.SelectedIndex = 0; constructingElements.Add(comboBox); } else { FormDropDown dropDown = new FormDropDown(); dropDown.Name = name; dropDown.Expression = item; for (int i = 1; i < splitedExpression.Length; i++) { dropDown.Options.Add(splitedExpression[i]); } dropDown.SelectedIndex = 0; constructingElements.Add(dropDown); } } return(constructingElements); } return(null); }
private void formDropDownToolStripMenuItem_Click(object sender, EventArgs e) { // create a new FormDropDown field and add it to TextControl FormDropDown fddField = new FormDropDown(); fddField.ApplicationField.Deleteable = false; fddField.ApplicationField.Editable = false; fddField.ApplicationField.DoubledInputPosition = true; // open the dialog to allow user to add some items fddField.ShowDialog(); fddField.Text = fddField.ListEntries.ElementAt(0); textControl1.ApplicationFields.Add(fddField.ApplicationField); }
private void ApplicationFieldActivate(TXTextControl.ApplicationField ApplicationField) { // remove all child controls textControl1.Controls.Clear(); // check the field type in order to display the proper control switch (ApplicationField.TypeName) { case "FORMDROPDOWN": // create a FormDropDown field FormDropDown fddField = new FormDropDown(ApplicationField); // create a new System.Windows.Forms.ComboBox and add the // FormDropDown's items ComboBox cb = new ComboBox(); cb.Items.AddRange(fddField.ListEntries.ToArray <string>()); Point cbLocation = new Point((fddField.ApplicationField.Bounds.Location.X - textControl1.ScrollLocation.X) / dpiX, (fddField.ApplicationField.Bounds.Location.Y - textControl1.ScrollLocation.Y) / dpiX); cb.Location = cbLocation; cb.Tag = fddField; cb.SelectedText = fddField.ApplicationField.Text; cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged); cb.LostFocus += new EventHandler(cb_LostFocus); // show the ComboBox on top of TextControl textControl1.Controls.Add(cb); cb.Focus(); break; case "FORMCHECKBOX": // create a FormCheckBox field FormCheckBox fcbField = new FormCheckBox(ApplicationField); fcbField.Checked = !fcbField.Checked; // change the text according to the current state fcbField.Text = fcbField.Checked == true ? CHECKED : UNCHECKED; break; case "DATE": // create a DateField field DateField dField = new DateField(ApplicationField); // create a new System.Windows.Forms.DateTimePicker and set the // date to the current DateField date DateTimePicker dtPicker = new DateTimePicker(); dtPicker.Tag = dField; dtPicker.Value = DateTime.Parse(dField.Text); Point dtpLocation = new Point((dField.ApplicationField.Bounds.Location.X - textControl1.ScrollLocation.X) / dpiX, (dField.ApplicationField.Bounds.Location.Y - textControl1.ScrollLocation.Y) / dpiX); dtPicker.Location = dtpLocation; dtPicker.ValueChanged += new EventHandler(dtPicker_ValueChanged); dtPicker.LostFocus += new EventHandler(dtPicker_LostFocus); // show the DateTimePicker on top of TextControl textControl1.Controls.Add(dtPicker); dtPicker.Focus(); break; case "FORMTEXT": // create a FormText field FormText ftField = new FormText(ApplicationField); // create a new System.Windows.Forms.TextBox and set the // text to the current FormText text TextBox tb = new TextBox(); tb.Text = ftField.Text; ftField.Text = ""; Point tbLocation = new Point((ftField.ApplicationField.Bounds.Location.X - textControl1.ScrollLocation.X) / dpiX, (ftField.ApplicationField.Bounds.Location.Y - textControl1.ScrollLocation.Y) / dpiX); tb.Location = tbLocation; tb.Tag = ftField; tb.LostFocus += new EventHandler(tb_LostFocus); tb.KeyPress += new KeyPressEventHandler(tb_KeyPress); tb.SelectAll(); // show the TextBox on top of TextControl textControl1.Controls.Add(tb); tb.Focus(); break; } }
public List <UIElement> BuildUIElements(List <AbstractFormElement> list) { Thickness defaultMargin = new Thickness(20, 5, 20, 5); List <UIElement> uiList = new List <UIElement>(); foreach (var item in list) { if (item is FormCheckBox) { FormCheckBox formCheckBox = item as FormCheckBox; Grid grid = new Grid(); ColumnDefinition columnDefinition1 = new ColumnDefinition(); columnDefinition1.Width = new GridLength(1.0, GridUnitType.Star); ColumnDefinition columnDefinition2 = new ColumnDefinition(); columnDefinition2.Width = new GridLength(1.0, GridUnitType.Star); grid.ColumnDefinitions.Add(columnDefinition1); grid.ColumnDefinitions.Add(columnDefinition2); CheckBox checkBox = new CheckBox(); checkBox.Margin = defaultMargin; Binding isChecked = new Binding("IsChecked"); isChecked.Source = formCheckBox; isChecked.Mode = BindingMode.TwoWay; checkBox.SetBinding(CheckBox.IsCheckedProperty, isChecked); TextBlock textBlock = new TextBlock(); textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Text = formCheckBox.Text; checkBox.Content = textBlock; Grid.SetColumnSpan(checkBox, 2); grid.Children.Add(checkBox); uiList.Add(grid); } if (item is FormDropDown) { FormDropDown formDropDown = item as FormDropDown; Grid grid = new Grid(); ColumnDefinition columnDefinition1 = new ColumnDefinition(); columnDefinition1.Width = new GridLength(1.0, GridUnitType.Star); ColumnDefinition columnDefinition2 = new ColumnDefinition(); columnDefinition2.Width = new GridLength(2.0, GridUnitType.Star); grid.ColumnDefinitions.Add(columnDefinition1); grid.ColumnDefinitions.Add(columnDefinition2); grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; TextBlock textBlock = new TextBlock(); textBlock.Margin = defaultMargin; textBlock.FontWeight = FontWeights.Bold; Binding text = new Binding("Name"); text.Source = formDropDown; text.Mode = BindingMode.OneWay; textBlock.SetBinding(TextBlock.TextProperty, text); ComboBox comboBox = new ComboBox(); comboBox.Margin = defaultMargin; Binding options = new Binding("Options"); options.Source = formDropDown; options.Mode = BindingMode.TwoWay; comboBox.SetBinding(ComboBox.ItemsSourceProperty, options); Binding selectedIndex = new Binding("SelectedIndex"); selectedIndex.Source = formDropDown; selectedIndex.Mode = BindingMode.TwoWay; comboBox.SetBinding(ComboBox.SelectedIndexProperty, selectedIndex); Binding selectedValue = new Binding("SelectedValue"); selectedValue.Source = formDropDown; selectedValue.Mode = BindingMode.OneWay; comboBox.SetBinding(ComboBox.SelectedValueProperty, selectedValue); Grid.SetColumn(textBlock, 0); Grid.SetColumn(comboBox, 1); grid.Children.Add(textBlock); grid.Children.Add(comboBox); uiList.Add(grid); } if (item is FormRadioButton) { FormRadioButton formRadioButton = item as FormRadioButton; StackPanel stackPanel = new StackPanel(); stackPanel.HorizontalAlignment = HorizontalAlignment.Stretch; stackPanel.VerticalAlignment = VerticalAlignment.Stretch; for (int i = 0; i < formRadioButton.Options.Count; i++) { TextBlock textBlock = new TextBlock(); textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Text = formRadioButton.Options[i]; RadioButton radioButton = new RadioButton(); radioButton.Margin = defaultMargin; radioButton.Content = textBlock; radioButton.GroupName = item.Name; radioButton.Checked += (sender, args) => { formRadioButton.SelectedIndex = formRadioButton.Options.IndexOf(textBlock.Text); }; if (i == formRadioButton.SelectedIndex) { radioButton.IsChecked = true; } RowDefinition rowDefinition = new RowDefinition(); stackPanel.Children.Add(radioButton); } GroupBox groupBox = new GroupBox(); groupBox.Header = item.Name; groupBox.Content = stackPanel; groupBox.Margin = defaultMargin; uiList.Add(groupBox); } if (item is FormTextBox) { FormTextBox formTextBox = item as FormTextBox; Grid grid = new Grid(); ColumnDefinition columnDefinition1 = new ColumnDefinition(); columnDefinition1.Width = new GridLength(1.0, GridUnitType.Star); ColumnDefinition columnDefinition2 = new ColumnDefinition(); columnDefinition2.Width = new GridLength(2.0, GridUnitType.Star); grid.ColumnDefinitions.Add(columnDefinition1); grid.ColumnDefinitions.Add(columnDefinition2); grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.Bold; textBlock.Margin = defaultMargin; Binding label = new Binding("Name"); label.Source = formTextBox; label.Mode = BindingMode.OneWay; textBlock.SetBinding(TextBlock.TextProperty, label); TextBox textBox = new TextBox(); textBox.Margin = defaultMargin; Binding text = new Binding("Text"); text.Source = formTextBox; text.Mode = BindingMode.TwoWay; text.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; textBox.SetBinding(TextBox.TextProperty, text); textBox.Text = item.Name; Grid.SetColumn(textBlock, 0); Grid.SetColumn(textBox, 1); grid.Children.Add(textBlock); grid.Children.Add(textBox); uiList.Add(grid); } if (item is FormTextBlock) { FormTextBlock formTextBlock = item as FormTextBlock; StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Vertical; stackPanel.HorizontalAlignment = HorizontalAlignment.Stretch; stackPanel.VerticalAlignment = VerticalAlignment.Stretch; stackPanel.Margin = defaultMargin; TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.Bold; textBlock.TextWrapping = TextWrapping.Wrap; Binding label = new Binding("Name"); label.Source = formTextBlock; label.Mode = BindingMode.OneWay; textBlock.SetBinding(TextBlock.TextProperty, label); TextBox textBox = new TextBox(); textBox.MinLines = 5; textBox.AcceptsReturn = true; textBox.AcceptsTab = true; textBox.TextWrapping = TextWrapping.Wrap; Binding text = new Binding("Text"); text.Source = formTextBlock; text.Mode = BindingMode.TwoWay; text.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; textBox.SetBinding(TextBox.TextProperty, text); textBox.Text = item.Name; stackPanel.Children.Add(textBlock); stackPanel.Children.Add(textBox); uiList.Add(stackPanel); } if (item is FormDate) { FormDate formDate = item as FormDate; Grid grid = new Grid(); ColumnDefinition columnDefinition1 = new ColumnDefinition(); columnDefinition1.Width = new GridLength(1.0, GridUnitType.Star); ColumnDefinition columnDefinition2 = new ColumnDefinition(); columnDefinition2.Width = new GridLength(2.0, GridUnitType.Star); grid.ColumnDefinitions.Add(columnDefinition1); grid.ColumnDefinitions.Add(columnDefinition2); grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.Bold; textBlock.Margin = defaultMargin; textBlock.TextWrapping = TextWrapping.Wrap; Binding label = new Binding("Name"); label.Source = formDate; label.Mode = BindingMode.OneWay; textBlock.SetBinding(TextBlock.TextProperty, label); DatePicker datePicker = new DatePicker(); datePicker.Margin = defaultMargin; Binding date = new Binding("Date"); date.Source = formDate; date.Mode = BindingMode.TwoWay; date.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; datePicker.SetBinding(DatePicker.SelectedDateProperty, date); Grid.SetColumn(textBlock, 0); Grid.SetColumn(datePicker, 1); grid.Children.Add(textBlock); grid.Children.Add(datePicker); uiList.Add(grid); } } return(uiList); }