using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using OnDoc.Klassen; using Syncfusion.WinForms.Controls; using Windows.UI.Xaml.Controls; namespace OnDoc.Diverses { public partial class valueselector : SfForm { public string partnernr { get; set; } = ""; public string datenherkunft { get; set; } = ""; public string selected_value { get; set; } public DateTime selected_datetime { get; set; } = DateTime.Now; public valueselector() { InitializeComponent(); this.panel1.Visible = false; this.GridData.Visible = true; } public valueselector(Boolean Showcalendar) { InitializeComponent(); this.panel1.Visible = true; this.GridData.Visible = false; label2.Text = DateTime.Now.ToString("dd.MM.yyyy"); } private void valueselector_Load(object sender, EventArgs e) { this.SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y); this.sfCalendar1.SelectedDate = DateTime.Now; } public void load_data() { if (datenherkunft == "" || datenherkunft == "&Freitext&") { return; } Database.DB dB = new Database.DB(AppParams.connectionstring); dB.clear_parameter(); dB.add_parameter("@nrpar00",partnernr); dB.add_parameter("@regel", datenherkunft); dB.Get_Tabledata("dbo.SP_Dokumentbearbeitung_DokWertList", true, false); this.GridData.DataSource = dB.dsdaten.Tables[0]; GridData.AutoSizeColumnsMode = Syncfusion.WinForms.DataGrid.Enums.AutoSizeColumnsMode.AllCells; } private void GridData_CellClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e) { string value = ""; try { var selectedItem = e.DataRow; var dataRow = (e.DataRow.RowData as DataRowView).Row; value = dataRow[0].ToString(); selected_value = value; } catch { selected_value = ""; } } private void GridData_CellDoubleClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e) { string value = ""; try { var selectedItem = e.DataRow; var dataRow = (e.DataRow.RowData as DataRowView).Row; value = dataRow[0].ToString(); selected_value = value; } catch { selected_value = ""; } DialogResult = DialogResult.OK; this.Close(); } private void sfCalendar1_Click(object sender, EventArgs e) { this.selected_datetime = (DateTime)sfCalendar1.SelectedDate; } private void sfCalendar1_DoubleClick(object sender, EventArgs e) { sfCalendar1_Click(sender, e); DialogResult = DialogResult.OK; this.Close(); } private void panel2_Click(object sender, EventArgs e) { sfCalendar1.SelectedDate = DateTime.Now; sfCalendar1_DoubleClick(sender, e); } private void button1_Click(object sender, EventArgs e) { sfCalendar1_DoubleClick(sender, e); } } }