70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace WpfApp2
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
public static int stock = 0;
|
|
public static List<int> days = new List<int>();
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
for (int i = 1; i <= 40; i++)
|
|
{
|
|
dropdown.Items.Add(i);
|
|
}
|
|
|
|
}
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
int made = Convert.ToInt32(elkeszitett.Text);
|
|
int sold = Convert.ToInt32(eladott.Text);
|
|
int day = dropdown.SelectedIndex + 1;
|
|
|
|
|
|
if (made < 0 || sold < 0)
|
|
{
|
|
MessageBox.Show("Negatív számot nem adhat meg!");
|
|
}
|
|
else
|
|
{
|
|
stock += made;
|
|
|
|
if (sold <= stock && !days.Contains(day))
|
|
{
|
|
stock -= sold;
|
|
string newline = $"{day}.nap +{made} -{sold} ={stock}";
|
|
days.Add(day);
|
|
lista.Items.Add(newline);
|
|
}
|
|
else
|
|
{
|
|
if (sold > stock)
|
|
{
|
|
MessageBox.Show("Túl sok az eladott angyalka!");
|
|
stock -= made; //reset the stock amount
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Ezt a napot már hozzáadtad!");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |