You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
183 lines
5.7 KiB
183 lines
5.7 KiB
3 months ago
|
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 BiskLog_Point_Of_Sale.Classes;
|
||
|
using BiskLog_Point_Of_Sale.Properties;
|
||
|
using Point_Of_Sale_Managment;
|
||
|
|
||
|
namespace Point_Of_Sale_Managment.CashierModule
|
||
|
{
|
||
|
public partial class Preference : Form
|
||
|
{
|
||
|
SystemSettings systemSettings;
|
||
|
public Preference(SystemSettings settings)
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
systemSettings = settings;
|
||
|
loadAll();
|
||
|
}
|
||
|
|
||
|
private void Button1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
systemSettings.MoveToTaxes();
|
||
|
}
|
||
|
|
||
|
private void Button2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
systemSettings.moveToMailer();
|
||
|
}
|
||
|
|
||
|
private void Button3_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
systemSettings.Close();
|
||
|
}
|
||
|
public void loadAll()
|
||
|
{
|
||
|
int i = 1;
|
||
|
for (i = 1; i < 2000; i++)
|
||
|
{
|
||
|
idleDuration.Items.Add(i);
|
||
|
}
|
||
|
if (idleDuration != null)
|
||
|
{
|
||
|
idleDuration.Text = Settings.Default.idleDuration.ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
idleDuration.Text = "5";
|
||
|
}
|
||
|
}
|
||
|
private void MetroToggle4_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (automaticallyLogout.Checked)
|
||
|
{
|
||
|
idleDuration.Enabled = true;
|
||
|
Settings.Default.logoutOnIdle = true;
|
||
|
Settings.Default.Save();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
idleDuration.Enabled = false;
|
||
|
Settings.Default.logoutOnIdle = false;
|
||
|
Settings.Default.Save();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void Preference_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
getCurrency();
|
||
|
idleDuration.Text = Settings.Default.idleDuration.ToString();
|
||
|
automaticallyLogout.Checked = Settings.Default.logoutOnIdle;
|
||
|
beepOnAdd.Checked = Settings.Default.BeepOnAdd;
|
||
|
promptPIN.Checked = Settings.Default.pinOnEveryTransaction;
|
||
|
cancellationConfirmation.Checked = Settings.Default.cancellationConfirmation;
|
||
|
treshold.Text = Settings.Default.lowStockTreshold.ToString();
|
||
|
}
|
||
|
public void getCurrency()
|
||
|
{
|
||
|
CurrencyProvider currencyProvider = new CurrencyProvider();
|
||
|
List<Currency> currencies = new List<Currency>();
|
||
|
currencies.AddRange(currencyProvider.GetAll());
|
||
|
foreach (var pg in currencies)
|
||
|
{
|
||
|
if (pg.Name != Settings.Default.Currency)
|
||
|
{
|
||
|
ComboboxItem combobox = new ComboboxItem();
|
||
|
combobox.Text = pg.Name;
|
||
|
combobox.Value = pg.Code;
|
||
|
currencyBox.Items.Add(combobox);
|
||
|
}
|
||
|
currencyBox.Sorted = true;
|
||
|
}
|
||
|
if (!String.IsNullOrEmpty(Settings.Default.Currency))
|
||
|
{
|
||
|
ComboboxItem combobox1 = new ComboboxItem();
|
||
|
combobox1.Text = Settings.Default.Currency;
|
||
|
combobox1.Value = Settings.Default.currrencyCode;
|
||
|
currencyBox.Items.Add(combobox1);
|
||
|
currencyBox.SelectedItem = combobox1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void BeepOnAdd_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (beepOnAdd.Checked)
|
||
|
{
|
||
|
Settings.Default.BeepOnAdd = true;
|
||
|
Settings.Default.Save();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Settings.Default.BeepOnAdd = false;
|
||
|
Settings.Default.Save();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void IdleDuration_TextChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
Settings.Default.idleDuration = int.Parse(idleDuration.Text);
|
||
|
Settings.Default.Save();
|
||
|
}
|
||
|
|
||
|
private void PromptPIN_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (promptPIN.Checked)
|
||
|
{
|
||
|
Settings.Default.pinOnEveryTransaction = true;
|
||
|
Settings.Default.Save();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Settings.Default.pinOnEveryTransaction = false;
|
||
|
Settings.Default.Save();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void CurrencyBox_TextChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
Settings.Default.currrencyCode = (currencyBox.SelectedItem as ComboboxItem).Value.ToString();
|
||
|
Settings.Default.Currency = (currencyBox.SelectedItem as ComboboxItem).Text.ToString();
|
||
|
Settings.Default.Save();
|
||
|
}
|
||
|
|
||
|
private void CancellationConfirmation_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (cancellationConfirmation.Checked)
|
||
|
{
|
||
|
Settings.Default.cancellationConfirmation = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Settings.Default.cancellationConfirmation = false;
|
||
|
}
|
||
|
Settings.Default.Save();
|
||
|
}
|
||
|
|
||
|
private void Treshold_TextChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (!String.IsNullOrEmpty(treshold.Text))
|
||
|
{
|
||
|
Settings.Default.lowStockTreshold = int.Parse(treshold.Text);
|
||
|
}
|
||
|
}
|
||
|
private void Treshold_KeyPress(object sender, KeyPressEventArgs e)
|
||
|
{
|
||
|
if (e.KeyChar == 8)
|
||
|
{
|
||
|
//accepts backspace
|
||
|
}
|
||
|
else if ((e.KeyChar < 48) || (e.KeyChar > 57)) //ascii code 48-57 between 0-9
|
||
|
{
|
||
|
e.Handled = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|