using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Counter = 1;
}
public int Counter { get; set; }
private void MainStack_MouseDown(object sender, MouseButtonEventArgs e)
{
MainStack.Children.Add(new Button()
{
Width = 800,
Height = 25,
Content = $"Button {Counter++}"
});
}
}
}
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<StackPanel Width="800" Height="450" Background="AliceBlue"
Name="MainStack" MouseDown="MainStack_MouseDown">
</StackPanel>
</Grid>
</Window>
Console.WriteLine(new DateTime(2023, 3, 1).GetSeason());
Console.WriteLine(new DateTime(2023, 6, 1).GetSeason());
Console.WriteLine(new DateTime(2023, 9, 1).GetSeason());
Console.WriteLine(new DateTime(2023, 12, 1).GetSeason());
Console.WriteLine(new DateTime(2023, 12, 2).GetSeasonDay());
public enum Season
{
Spring,
Summer,
Autumn,
Winter
}
public static class SeasonTools
{
public static Season GetSeason(this DateTime date)
{
int month = date.Month;
if (month >= 3 && month <= 5) return Season.Spring;
else if (month >= 6 && month <= 8) return Season.Summer;
else if (month >= 9 && month <= 11) return Season.Autumn;
else return Season.Winter;
}
public static int GetSeasonDay(this DateTime date)
{
int month = date.Month;
if (month >= 3 && month <= 5) return GetDay(date,Season.Spring);
else if (month >= 6 && month <= 8) return GetDay(date,Season.Summer);
else if (month >= 9 && month <= 11) return GetDay(date,Season.Autumn);
else return GetDay(date, Season.Winter);
}
private static int GetDay(DateTime date, Season season)
{
if (season == Season.Spring) return (int) (date - new DateTime(date.Year, 3, 1) ).TotalDays ;
else if (season == Season.Summer) return (int)(date - new DateTime(date.Year, 6, 1)).TotalDays;
else if (season == Season.Autumn) return (int)(date - new DateTime(date.Year, 9, 1)).TotalDays;
else return (int)(date - new DateTime(date.Year, 12, 1)).TotalDays;
}
}
private void Select(object sender, RoutedEventArgs e)
{
var ff = new FolderBrowserDialog();
if (ff.ShowDialog() == DialogResult.OK)
{
foreach (var file in Directory.EnumerateFiles(ff.SelectedPath, "*.dbf"))
{
var sqlFileName = file.Remove(file.IndexOf('.')) + "_asd_34.sql";
// тут вызываете конвертор
DbfToSql(file, sqlFileName);
}
}
}
switch (type)
{
case "Double":
return Type_.int_; // если пришел Double отправляем int
case "String":
// но как узнать длину строк? Возможно нужно пробежаться по всем данным и вычислить максимальную?
return "VARCHAR2(42)"; // если пришел String отправляем varchar(255)
case "DateTime":
return Type_.Datetime_; // если пришел DateTime, отправляем datetime
}
public interface ISqlGenerator
{
string Generate();
}
public class Parent
{
}
public class new_table : Parent, ISqlGenerator
{
public string Generate()
{
return "insert ....";
}
}
public class tb : Parent, ISqlGenerator
{
private string _id;
private string _name;
public string Id { get => _id; set => _id = value; }
public string Name { get => _name; set => _name = value; }
public tb(string id, string name)
{
Id = id;
Name = name;
}
public string Generate()
{
return "insert ....";
}
}
public class Crud {
public static bool Add(Parent instance, string tableName)
{
if (instance is tb)
{
var t = instance as tb;
}
else if (instance is new_table)
{
var t = instance as new_table;
}
return false;
}
public static bool AddInterface(ISqlGenerator instance, string tableName) {
var sql = instance.Generate();
return false;
}
}
var options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("mydefault.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
var imagefile = document.getElementById("upload_files") as HTMLInputElement;
if (imagefile == null) return;
if (imagefile.files == null) return;
const files = imagefile.files;
for (let i = 0; i < files.length; i++) {
formData.append("files", files[i]);
}